Heatmap
Reusable Heatmap API module that renders a simple and configurable heatmap chart.
Example
import { select } from 'd3-selection';
import { heatmap } from '@britecharts/core';
// dataset: [{ day, hour, value }], day 0-6 and hour 0-23, or indexes into
// yAxisLabels and xAxisLabels
const heatmapChart = heatmap();
heatmapChart
.width(500);
select('.css-selector')
.datum(dataset)
.call(heatmapChart);
- Heatmap
- exports(_selection) ⏏
- static
- .a11yTitle(_x) ⇒
String|null|module - .a11yDescription(_x) ⇒
String|null|module - .a11yDataTable(_x) ⇒
Boolean|module - .a11yKeyboardNavigation(_x) ⇒
Boolean|module - .animationDuration(_x) ⇒
duration|module - .boxSize(_x) ⇒
Number|module - .colorSchema(_x) ⇒
Array.<String>|module - .exportChart(filename, title)
- .isLoading(_flag) ⇒
boolean|module - .height(_x) ⇒
Number|module - .isAnimated(_x) ⇒
Boolean|module - .margin(_x) ⇒
margin|module - .on() ⇒
module - .yAxisLabels(_x) ⇒
yAxisLabels|module - .xAxisLabels(_x) ⇒
xAxisLabels|module - .width(_x) ⇒
Number|module
- .a11yTitle(_x) ⇒
- inner
- ~HeatmapData :
Array.<Object>
- ~HeatmapData :
- static
- exports(_selection) ⏏
exports(_selection) ⏏
This function creates the graph using the selection as container
Kind: Exported function
| Param | Type | Description |
|---|---|---|
| _selection | D3Selection | A d3 selection that represents the container(s) where the chart(s) will be rendered |
a11yTitle(_x) ⇒ String | null | module
Gets or Sets the name screen readers announce for the chart. It is
set as the svg's aria-label. Unset, the chart is announced as
"Heatmap".
Kind: static method of exports
Returns: String | null | module - Current a11yTitle or Chart module to chain calls
Access: public
| Param | Type | Description |
|---|---|---|
| _x | String | null | Desired accessible title for the chart |
a11yDescription(_x) ⇒ String | null | module
Gets or Sets a longer description screen readers announce after the
chart's name, such as what the data shows. It is rendered as the svg's
<desc>. Unset, the chart has no description.
Kind: static method of exports
Returns: String | null | module - Current a11yDescription or Chart module to chain calls
Access: public
| Param | Type | Description |
|---|---|---|
| _x | String | null | Desired accessible description for the chart |
a11yDataTable(_x) ⇒ Boolean | module
Gets or Sets whether the chart renders its data as a visually hidden table after its svg, which screen readers can read cell by cell. On by default; set it to false when the app gives the data its own accessible form.
Kind: static method of exports
Returns: Boolean | module - Current a11yDataTable or Chart module to chain calls
Access: public
| Param | Type | Description |
|---|---|---|
| _x | Boolean | Whether to render the data table |
a11yKeyboardNavigation(_x) ⇒ Boolean | module
Gets or Sets whether a keyboard can move through the chart's data points: the chart takes one tab stop, the arrow keys move between points, Home and End go to the first and last, and Escape lets go. The tooltip and highlights follow focus as they follow the pointer. On by default.
Kind: static method of exports
Returns: Boolean | module - Current a11yKeyboardNavigation or Chart module to chain calls
Access: public
| Param | Type | Description |
|---|---|---|
| _x | Boolean | Whether the keyboard can move through the data |
animationDuration(_x) ⇒ duration | module
Gets or Sets the duration of the animation
Kind: static method of exports
Returns: duration | module - Current animation duration or Chart module to chain calls
Access: public
| Param | Type | Default | Description |
|---|---|---|---|
| _x | Number | 1200 | Desired animation duration for the graph |
boxSize(_x) ⇒ Number | module
Gets or Sets the boxSize of the chart
Kind: static method of exports
Returns: Number | module - Current boxSize or Chart module to chain calls
Access: public
| Param | Type | Default | Description |
|---|---|---|---|
| _x | Number | 30 | Desired boxSize for the heatmap boxes |
colorSchema(_x) ⇒ Array.<String> | module
Gets or Sets the colorSchema of the chart
Kind: static method of exports
Returns: Array.<String> | module - Current colorSchema or Chart module to chain calls
Access: public
| Param | Type | Default | Description |
|---|---|---|---|
| _x | Array.<String> | britecharts-red | Desired colorSchema for the heatma boxes |
exportChart(filename, title)
Exports the chart and fires a download: an svg file when the filename
ends in .svg, and a png otherwise
Kind: static method of exports
Access: public
| Param | Type | Description |
|---|---|---|
| filename | String | Name of the downloaded file, whose extension picks the format |
| title | String | Title to add at the top of the exported picture |
isLoading(_flag) ⇒ boolean | module
Gets or Sets the loading state of the chart
Kind: static method of exports
Returns: boolean | module - Current loading state flag or Chart module to chain calls
Access: public
| Param | Type | Description |
|---|---|---|
| _flag | boolean | Desired value for the loading state |
Example
chart.isLoading(true)
height(_x) ⇒ Number | module
Gets or Sets the height of the chart
Kind: static method of exports
Returns: Number | module - Current height or Chart module to chain calls
Access: public
| Param | Type | Default | Description |
|---|---|---|---|
| _x | Number | 270 | Desired height for the chart |
isAnimated(_x) ⇒ Boolean | module
Gets or Sets the isAnimated value of the chart
The chart draws without animation when the reader's system asks for
reduced motion (prefers-reduced-motion), whatever this is set to.
Kind: static method of exports
Returns: Boolean | module - Current isAnimated value or Chart module to chain calls
Access: public
| Param | Type | Default | Description |
|---|---|---|---|
| _x | Boolean | false | Decide whether to show chart animation |
margin(_x) ⇒ margin | module
Gets or Sets the margin of the chart
Kind: static method of exports
Returns: margin | module - Current margin or Chart module to chain calls
Access: public
| Param | Type | Description |
|---|---|---|
| _x | Object | Margin object to get/set |
on() ⇒ module
Exposes an 'on' method that acts as a bridge with the event dispatcher We are going to expose this events: customMouseOver, customMouseMove, customMouseOut, and customClick
Kind: static method of exports
Returns: module - Bar Chart
Access: public
yAxisLabels(_x) ⇒ yAxisLabels | module
Gets or Sets the y-axis labels of the chart
Kind: static method of exports
Returns: yAxisLabels | module - Current yAxisLabels array or Chart module to chain calls
Access: public
| Param | Type | Default | Description |
|---|---|---|---|
| _x | Array.<String> | ['Mo', | 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'] An array of string labels across the y-axis |
xAxisLabels(_x) ⇒ xAxisLabels | module
Gets or Sets the x-axis labels of the chart. With them, hour indexes
these labels rather than the hours of the day, so together with
yAxisLabels the heatmap can show any two sets of categories.
Kind: static method of exports
Returns: xAxisLabels | module - Current xAxisLabels array or Chart module to chain calls
Access: public
| Param | Type | Default | Description |
|---|---|---|---|
| _x | Array.<String> | ['00h','01h',...,'23h' | An array of string labels across the x-axis |
width(_x) ⇒ Number | module
Gets or Sets the width of the chart
Kind: static method of exports
Returns: Number | module - Current width or Chart module to chain calls
Access: public
| Param | Type | Default | Description |
|---|---|---|---|
| _x | Number | 780 | Desired width for the chart |
exports~HeatmapData : Array.<Object>
The data a heatmap takes: one entry per box.
Kind: inner typedef of exports
Properties
| Name | Type |
|---|---|
| day | Number |
| hour | Number |
| value | Number |
Example
[
{
day: 0,
hour: 0,
value: 7
},
{
day: 0,
hour: 1,
value: 10
}
]