You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose I have a data on 5 stocks in amStockChart. The first stock data is in dataSets[0] and the remaining 4 stocks to be compared are in dataSets[1]
I want to allow the users to remove any of the 4 comparing stocks. Based on users choice of stock to be removed, a script re-runs the data and removes a particular stock of user's choice from the 4-stock data and then passes this new data of 3 stocks (called NewData) and the graph ID of the graph to be removed to a JavaScript function.
JavaScript Function does the following:
chart.dataSets[1].dataProvider= NewData;
chart.validateData();
for (i = 0; i < chart.panels[0].graphs.length; i++) {
if (chart.panels[0].graphs[i].id == GraphID) {
chart.panels[0].graphs.splice(i, 1);
chart.panels[0].graphs.splice(i+1, 1);
}
}
//var graph = chart.panels[0].getGraphById(GraphID);
//chart.panels[0].removeGraph(graph);
//graph1 = chart.panels[0].getGraphById('comparedGraph_'+GraphID+'_ds2');
//chart.panels[0].removeGraph(graph1);
The problem with the above is that the graph gets removed but the legend remains. Please see screenshot below:
Please let me know where am I going wrong
The text was updated successfully, but these errors were encountered:
In general yes, your suggestion is apt and very useful. In my particular case, the project requires the different approach. I am using the below now and it is working fine
var graphcnt = chart.panels[0].graphs.length;
for (i = 0; i < graphcnt; i++) {
if (chart.panels[0].graphs[i].id == params[3]) {
var graph = chart.panels[0].graphs[i];
chart.panels[0].removeStockGraph(graph);
var graph = chart.panels[0].graphs[i+1]; //this is to remove the compare graph
chart.panels[0].removeStockGraph(graph);
}
chart.dataSets[1].dataProvider= NewData;
chart.validateData();
Please let me know in case I am not following the best practices.
Hi,
Suppose I have a data on 5 stocks in amStockChart. The first stock data is in dataSets[0] and the remaining 4 stocks to be compared are in dataSets[1]
I want to allow the users to remove any of the 4 comparing stocks. Based on users choice of stock to be removed, a script re-runs the data and removes a particular stock of user's choice from the 4-stock data and then passes this new data of 3 stocks (called NewData) and the graph ID of the graph to be removed to a JavaScript function.
JavaScript Function does the following:
The problem with the above is that the graph gets removed but the legend remains. Please see screenshot below:
Please let me know where am I going wrong
The text was updated successfully, but these errors were encountered: