Constructor
new Piechart(element, paramsopt)
Constructs a Piechart
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
element |
string | css query selector of the container dom element into which the chart is placed. | ||
params |
Object |
<optional> |
options. | |
data |
Array.<Object> |
<optional> |
the data to be displayed. | |
data[].value |
number |
<optional> |
value of the part. | |
data[].label |
number |
<optional> |
label of the part. | |
data[].color |
number |
<optional> |
color of the part. | |
padding |
Object |
<optional> |
padding in all directions of the chart. | |
padding.top |
number | string |
<optional> |
top padding for the chart. | |
padding.right |
number | string |
<optional> |
right padding for the chart. | |
padding.bottom |
number | string |
<optional> |
bottom padding for the chart. | |
padding.left |
number | string |
<optional> |
left padding for the chart. | |
colors |
Array |
<optional> |
custom colors | |
font |
string |
<optional> |
'Roboto' | the font for all writing. Font must be imported separately. |
hover |
Object |
<optional> |
options for the hover effect. | |
hover.visible |
boolean |
<optional> |
true | whether the titles should be shown on hover or not. |
hover.callback |
function |
<optional> |
function that returns html that is displayed in the hover effect. Receives (title, start, end). |
Will throw an error if the container element is not found.
Methods
setData()
Replaces the existing data with new data.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
params.data |
array |
<optional> |
the data to be displayed. |
params.data |
Array.<Object> |
<optional> |
the data to be displayed. |
value |
number |
<optional> |
value of the part. |
label |
number |
<optional> |
label of the part. |
color |
number |
<optional> |
color of the part. |