Hi Maico,
Greetings from Syncfusion.
We have analysed your query. Based on that we have prepared a sample. In that, we are adding trendlines after selecting a series and clicking the button. Please find below sample and code snippet,
Code Snippet:
document.getElementById('togglebtn').onclick = () => {
var chart = document.getElementById('container').ej2_instances[0];
var series = chart.selectionModule.selectedDataIndexes;
if (series.length > 0) {
var i = series[0].series;
if (i == 0) {
chart.series[i].trendlines = [{ type: 'Linear', animation: { enable: false }, fill: 'red', width: 3, dashArray: '5,5' }];
//To maintain the selected data index
chart.selectedDataIndexes = [{ series: i }];
chart.refresh();
}
//other code here
} else {
alert("Nenhuma Série Selecionada! Por Favor selecione primeiro uma série.")
}
}; |
Screenshot:
Kindly check the above sample and revert us, if you need further assistance.
Regards,
Kalai.