Skip to main content

LegendLite

This plugin generates a basic legend

Compared to Legend, this plugin generates a more basic legend, with a UI more similar to github contribution calendar.

Install

Add the legend plugin in your page's <head>, after cal-heatmap library <script>

<script src="https://unpkg.com/cal-heatmap/dist/plugins/LegendLite.min.js"></script>
caution

This plugin only support the quantize, ordinal, and threshold scale's type


Usage

const cal = new CalHeatmap();
cal.paint({}, [[LegendLite, LEGEND_OPTIONS]]);

See LegendOptions for the full list of available options.

LegendOptions

interface LegendOptions {
enabled: boolean;
itemSelector: string | null;
width: number;
height: number;
gutter: number;
radius: number;
includeBlank: boolean;
}

enabled

Whether to enable the legend

Default: true

itemSelector

Specify where the legend should be rendered

If not specified, the legend will be inserted just after the calendar, in the same DOM node defined by itemSelector.

const cal = new CalHeatmap();
cal.paint({}, [[Legend, { itemSelector: '#my-legend-container' }]]);

width

Set the legend cell's width

Default: 10

http://localhost:3000
Live Editor
Result
Loading...

height

Set the legend cell's height

Default: 10

http://localhost:3000
Live Editor
Result
Loading...

gutter

Set the legend cell's gutter

Default: 2

http://localhost:3000
Live Editor
Result
Loading...

radius

Set the legend cell's radius

Default: 0

http://localhost:3000
Live Editor
Result
Loading...

includeBlank

Whether to include a cell for data with no values

Default: false

http://localhost:3000
Live Editor
Result
Loading...