I am working with dimple js and I want to set an event that when ever user clicked on plot(circle) on chart the Value of chart got updated but here is the problem when I set event handler for that It just worked one time and If user clicked for the second time nothing happened what is the problem here what should I do to solve this problem Here is my js code
data = [
{ "Value" : 10, "Year" : 2009},
{ "Value" : 11, "Year" : 2011},
{ "Value" : 12, "Year" : 2007},
{ "Value" : 13, "Year" : 2006},
{ "Value" : 14, "Year" : 2014},
{ "Value" : 15, "Year" : 2012},
{ "Value" : 16, "Year" : 2011},
{ "Value" : 17, "Year" : 2013},
{ "Value" : 18, "Year" : 2015}
];
var svg = dimple.newSvg(#chartContainer", 600, 400);
var chart = new dimple.chart(svg, data);
var x = chart.addCategoryAxis("x", "Year");
x.addOrderRule("Year");
var y = chart.addMeasureAxis("y", "Value");
chart.addColorAxis(Value", ["green", "yellow", "red"]);
var lines = chart.addSeries(null, dimple.plot.line);
lines.lineWeight = 4;
lines.lineMarkers = true;
chart.ease = "bounce";
chart.staggerDraw = true;
chart.draw(1000);
And here is event code
d3.selectAll("circle").on("click", function (e) {
chart.data = [
{ "Value" : (Math.random() * 100), "Year" : 2009},
{ "Value" : (Math.random() * 100), "Year" : 2011},
{ "Value" : (Math.random() * 100), "Year" : 2007},
{ "Value" : (Math.random() * 100), "Year" : 2006},
{ "Value" : (Math.random() * 100), "Year" : 2014},
{ "Value" : (Math.random() * 100), "Year" : 2012},
{ "Value" : (Math.random() * 100), "Year" : 2011},
{ "Value" : (Math.random() * 100), "Year" : 2013},
{ "Value" : (Math.random() * 100), "Year" : 2015}
];
chart.draw(1000);
});
This is working for me.
Fiddle Link