1.5.5 • Published 5 months ago
proportions-chart v1.5.5
Proportions Chart
An interactive one-dimensional proportions chart for representing categorical data.
Quick start
import ProportionsChart from 'proportions-chart';
or using a script tag
<script src="//unpkg.com/proportions-chart"></script>
then
const myChart = ProportionsChart();
myChart(<myDOMElement>)
.data(<myData>);
API reference
Method | Description | Default |
---|---|---|
data(array) | Getter/setter for the chart data, as an array of series objects, each representing a chart segment. | [] |
width(number) | Getter/setter for the chart width in px. | <window width> |
height(number) | Getter/setter for the chart height in px. | <window height> |
label(string or fn) | Getter/setter for a series object label accessor, used to display labels on the segments and their tooltips. | name |
size(string or fn) | Getter/setter for a series object size accessor, used to compute the length of the segments. | value |
color(string or fn) | Getter/setter for a series object color accessor, used to color the segments. | grey |
sort(fn) | Getter/setter for the compare method used to sort the series. A value of null (default) maintains the existing order found in the input data structure. This method receives two arguments representing two series objects and expects a numeric return value (-1 , 0 or 1 ) indicating the order. For example, to order segments by size, use: (a, b) => b.size - a.size . | <existing order> |
showLabels(boolean) | Getter/setter for whether to show labels in the segments. Regardless of this setting, labels too large to fit within a segment's boundaries are automatically hidden. | true |
tooltipContent(fn) | Getter/setter for a series object tooltip content accessor function. Use this to specify extra content in each of the segment's tooltips in addition to the series name that's included by default. | <value (%)> |
onHover(fn) | Callback function for mouse hover events. The series object (or null if hovering outside the chart area) and the event object are included as arguments onHover(series, event) . | |
onClick(fn) | Callback function for click events. The series object and the event object are included as arguments onClick(series, event) . | |
onRightClick(fn) | Callback function for right-click events. The series object and the event object are included as arguments onRightClick(series, event) . A falsy value (default) will fallback to the default browser behaviour, which is to open the context menu. |
1.5.5
5 months ago
1.5.4
6 months ago
1.5.3
6 months ago
1.5.2
6 months ago
1.5.1
7 months ago
1.5.0
7 months ago
1.4.0
10 months ago
1.3.1
2 years ago
1.3.0
2 years ago
1.2.2
3 years ago
1.2.0
4 years ago
1.2.1
4 years ago
1.1.2
5 years ago
1.1.1
5 years ago
1.1.0
6 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago
0.0.1
6 years ago