With all the customizable features of Frappe Charts, this section is dedicated to enabling / disabling existing functionality.
The first parameter required by the Chart
constructor is the container element. You can pass in a CSS Selector or a DOM Object.
const chart = new Chart('#chart', options);
// or
const container = document.querySelector('#chart');
const chart = new Chart(container, options);
The second parameter required by the Chart
constructor is the options object. The minimum required configuration is to pass data
values, which itself requires an array of labels
and an array of datasets
.
const options = {
data: {
labels: ["12am-3am", "3am-6am", "6am-9am", "9am-12pm", "12pm-3pm"],
datasets: [
{
name: "Some Data", values: [25, 40, 30, 35, 8]
},
{
name: "Another Set", values: [25, 50, -10, 15, 18]
}
]
}
}
const chart = new Chart(container, options);
Object
labels
, datasets
yMarkers
, yRegions
Contains an array of labels
and an array of datasets
, each a value for the 2-dimensional data points.
May also have annotation parameters, for example those for yMarkers
and yRegions
. This is because all properties defined inside data are meant to be animatable.
data: {
labels: ["12am-3am", "3am-6am", "6am-9am", "9am-12pm", "12pm-3pm"],
datasets: [
{ name: "Some Data", values: [25, 40, 30, 35, 8] },
{ name: "Another Set", values: [25, 50, -10, 15, 18] }
],
yMarkers: [{ label: "Marker", value: 70 }],
yRegions: [{ label: "Region", start: -10, end: 50 }]
}
Other configurable options are listed as follows:
String
''
Add a title to the Chart.
String
line | bar | axis-mixed | pie | percentage | heatmap
line
Let the chart know what type to render.
Mixed axis chart. For this to work, you must pass the chartType
value for each dataset.
const data = {
labels: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
datasets: [
{
name: "Some Data",
values: [18, 40, 30, 35, 8, 52, 17],
chartType: 'bar'
},
{
name: "Yet Another",
values: [15, 20, -3, -15, 58, 12, -17],
chartType: 'line'
}
]
}
const chart = new Chart('#chart', {
data: data
});
Array
['light-blue', 'blue', 'violet', 'red', 'orange', 'yellow', 'green', 'light-green', 'purple', 'magenta', 'light-grey', 'dark-grey']
Set the colors to be used for each individual unit type, depending on the chart type.
Number
240
Set the height of the chart in pixels.
Object
{}
String
span | tick
span
Foo
Boolean
0
Foo
Object
{}
Object
{}
This option controls how width of each column
is calculated in the chart.
Number
0
2
0.5
Boolean
0
Object
{}
Foo
Boolean
0
Foo Example
{
dropdownButton: '<span class="fa fa-chevron-down"></span>'
}
Boolean
0
Foo