data is an array of dataSeries Objects. dataSeries is explained in detail below.
Each element in the data array is a dataSeries object. dataSeries is the object where user can define all the dataPoints to be plotted and also control various properties related to rendering – like chart type, color, labels, events, etc.
Certain properties like tooltipText, color, etc can be set at both dataSeries and dataPoint level. In those cases, the value set at dataPoint overrides the one provided at the dataSeries level.
You can add more than one dataSeries element to data Array in order to create Multi-Series/Combination charts. Using “type” property of dataSeries, you can define how it should be rendered – column, line, pie, etc.
Whenever you have more than one dataSeries, they all can have same or different chart types, making it a Multi-Series or a Combinational Chart.
var chart = new CanvasJS.Chart("container", { . . data:[ {// dataSeries 1 }, {// dataSeries 2 }, . ], . }); chart.render();
Applies To | Attribute | Type | Default | Options/Examples | Remarks |
---|---|---|---|---|---|
dataSeries | name | String | auto. named | “series1”, “data1”.. | |
dataSeries | type | String | “column” | “line”,”pie”,”area”..etc. | |
dataSeries | axisXType | String | “primary” | “primary”,”secondary” | |
dataSeries | axisYType | String | “primary” | “primary”,”secondary” | |
dataSeries | axisXIndex | Number | 0 | 1,2,3… | |
dataSeries | axisYIndex | Number | 0 | 1,2,3… | |
dataSeries | xValueType | String | auto | “number”,”dateTime” | |
dataSeries | bevelEnabled | Boolean | false | true,false | |
dataSeries | color | String | From theme | “red”,”#1E90FF”.. | |
dataSeries | lineColor | String | From color | “red”,”#1E90FF”.. | |
dataSeries | connectNullData | Boolean | false | true, false | |
dataSeries | nullDataLineDashType | String | “dash” | “solid”,”dot”.. | |
dataSeries | visible | Boolean | true | true, false | |
dataSeries | fillOpacity | Number | .7 for Area Charts and 1 for all other chart types | 1, .5 etc | |
dataSeries | xValueFormatString | String | null | “##.0#”, “DD-MMM-YYYY” etc | |
dataSeries | yValueFormatString | String | null | “##.0#” etc | |
dataSeries | zValueFormatString | String | null | “##.0#” etc | |
dataSeries | percentFormatString | String | null | “##.0#” etc | |
dataSeries | startAngle | Number | 0 | 25,-45,180.. | |
dataSeries | indexLabel | String | “” | “{label}”, “Win”, “x: {x}, y: {y}” | |
dataSeries | indexLabelMaxWidth | Number | Automatically calculated based on the length of indexLabel | 2, 10, 40 etc | |
dataSeries | indexLabelWrap | Boolean | true | true, false | |
dataSeries | indexLabelTextAlign | String | “left” | “left”,”center”, “right” | |
dataSeries | indexLabelPlacement | String | Automatically handled based on chart types | “inside”,”outside” | |
dataSeries | indexLabelOrientation | String | “horizontal” | “horizontal”,”vertical” | |
dataSeries | indexLabelBackgroundColor | String | null | “red”,”#1E90FF”.. | |
dataSeries | indexLabelBorderColor | String | null | “red”,”#FABD76″.. | |
dataSeries | indexLabelBorderThickness | Number | 0 | 1, 3 | |
dataSeries | indexLabelFontStyle | String | “normal” | “normal”, “italic”, “oblique” | |
dataSeries | indexLabelFontColor | String | “grey” | “red”,”#1E90FF”.. | |
dataSeries | indexLabelFontSize | Number | 18 | 16,20,24.. | |
dataSeries | indexLabelFontFamily | String | “Calibri, Optima, Candara, Verdana, Geneva, sans-serif” | “arial”, “calibri”, “tahoma”.. | |
dataSeries | indexLabelFontWeight | String | “normal” | “lighter”, “normal” ,”bold” , “bolder” | |
dataSeries | indexLabelLineColor | String | “lightgrey” | “red”, “#1E90FF”.. | |
dataSeries | indexlabelLineThickness | Number | 2 | 2,4 | |
dataSeries | toolTipContent | String | auto. | “{y} units” | |
dataSeries | lineThickness | Number | 2 | 3,4 | |
dataSeries | markerType | String | “circle” | “circle”, “square”, “cross”, “triangle”, “line” | |
dataSeries | markerColor | String | auto. takes dataSeries/dataPoint color | “red”, “#1E90FF”.. | |
dataSeries | markerSize | Number | auto. Zero for area chart | 5, 10.. | |
dataSeries | markerBorderColor | String | marker Color | “red”, “#1E90FF”.. | |
dataSeries | markerBorderThickness | Number | 1 | 4,6.. | |
dataSeries | showInLegend | Boolean | false | true,false | |
dataSeries | legendText | String | “dataSeries1”, “dataSeries2” .. | “apples”, “oranges” .. | |
dataSeries | legendMarkerType | String | “circle” | “circle”, “square”, “cross”, “triangle” | |
dataSeries | legendMarkerColor | String | marker Color | “red”,”#1E90FF”.. | |
dataSeries | explodeOnClick | Boolean | true | true, false | |
dataSeries | legendMarkerBorderColor | String | dataSeries Color | “red”,”#1E90FF”.. | |
dataSeries | legendMarkerBorderThickness | Number | 0 | 2, 4 etc | |
dataSeries | risingColor | String | “white” | “red”, “#DD7E86” etc | |
dataSeries | click | Function | null | function(e) { }, | |
dataSeries | mouseover | Function | null | function(e) { }, | |
dataSeries | mouseout | Function | null | function(e) { }, | |
dataSeries | mousemove | Function | null | function(e) { }, | |
dataSeries | cursor | String | “default” | “pointer”, “crosshair”, etc | Sets cursor type for the dataSeries |
dataSeries | highlightEnabled | Boolean | true | false, true | |
dataSeries | lineDashType | String | “solid” | “dot”, “dash” | Sets the Line Dash Type for all Line and Area Charts. |
dataSeries | indexLabelLineDashType | String | “solid” | “dot”, “dash” | Sets the Dash Type for indexLabel’s line. |
dataSeries | indexLabelFormatter | Function | null | function(e) { } |
Object | Attributes | Type | Default | Options | Remarks |
---|---|---|---|---|---|
dataSeries | datapoints | Object |
var chart = new CanvasJS.Chart("container", { data:[{ dataPoints: [ { x: 10, y: 5} ] }] }); chart.render();
6 Comments
Pingback: Version 1.2 supports Localizing Charts - CanvasJS
how can in create a chart with data in sharepoint list.
how to change type{pie,bar…} dynamically?
Sindhu,
You chart-type dynamically from drop-down. Here is an example.
like suppose in a dropdown if i have pie,bar,spline and when i select any one from dropdown list say,bar the type should be changed to bar and display bar chart.is it possible?if so please help me
Sindhu,
Yes, it’s possible to change chart-type dynamically from drop-down. Here is an example.