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
- CDN
- NPM
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>
The plugin is built-in in the core CalHeatmap, just import the module with
import LegendLite from 'cal-heatmap/plugins/LegendLite';
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
height
Set the legend cell's height
Default: 10
gutter
Set the legend cell's gutter
Default: 2
radius
Set the legend cell's radius
Default: 0
includeBlank
Whether to include a cell for data with no values
Default: false