Hi,
I am trying to implement a line chart creating series dinamically, but all examples I found are using static series. I have already try to use addSeries but no success!
I receive data from an ajax function:
let grafDados;
let ajax = new ej.base.Ajax(URL, "GET");
ajax.send();
ajax.onSuccess = function (data) {
let grade = JSON.parse(data);
grid.dataSource = grade.grid;
showGraphs(grade);
};
And then I create the chart:
function showGraphs (chartData) {
var chart = new ej.charts.Chart({
title: chartData.campos.titulo ,// tituloGrafico,
legendSettings: {
visible: true
},
tooltip: {
enable: true
},
primaryXAxis: {
valueType: 'Category',
title: 'Datas das Medições',
labelFormat: 'y',
intervalType: 'Years'
},
primaryYAxis: {
labelFormat: '{value}',
title: chartData.campos.label_vertical
},
series: [{
// dataSource for chart series
dataSource: chartData.chart,
name:'Sales',
xName: 'month',
yName: 'sales',
type: 'Line',
emptyPointSettings: {
mode: 'Average',
fill: 'pink'
}
}]
}, '#element');
}
My need is to create series dynamically and change the method series in showGraphs function.
Do you mind help me with that?