Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
148670 | Oct 29,2019 09:20 PM UTC | Oct 31,2019 06:30 AM UTC | ASP.NET MVC | 3 |
![]() |
Tags: Chart |
Hi,
How can I add a trendline by selecting a series and clicking a button?
The code I want is something like this:
function AdicionarTendencia(ch) { var chart = document.getElementById(ch).ej2_instances[0]; var series = chart.selectionModule.selectedDataIndexes; if (series.length > 0) { var i = series[0].series; chart.series[i].trendlines.add(); } else { alert("Nenhuma Série Selecionada! Por Favor selecione primeiro uma série.") } }
Is there a way to do this? Thank you!
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.")
}
}; |
Hi Kalai,
Worked perfectly.
Thank you!
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.