I have a graph who can have one set of data or multiples set of data. I need to check every stateChange and triggered the callback (he make actions that I need to make at every changes).
here is my graph :
scope.options = {
chart: {
type: 'lineChart',
height: 450,
margin : {
top: 20,
right: 20,
bottom: 40,
left: 55
},
useInteractiveGuideline: false,
dispatch: {
stateChange: function(){ console.log("stateChange"); },
changeState: function(){ console.log("changeState"); },
tooltipShow: function(){ console.log("tooltipShow"); },
tooltipHide: function(){ console.log("tooltipHide"); },
},
xAxis: {
axisLabel: 'Temperature (Celcius)'
},
yAxis: {
axisLabel: 'Fluorescence',
tickFormat: function(d){
return d3.format('0f')(d);
},
axisLabelDistance: -10
},
callback: function(chart){
console.log("!!! lineChart callback !!!");
// If there is a tm point we show it
if (data.length === 1 && angular.isObject(tmPoints[data[0].key])){
console.log("SHOW TM");
data[0].values.forEach(function(element){
if (parseInt(element.x) === parseInt(tmPoints[data[0].key].tm)){
// Recuperer l'objet point et non ses valeurs
highlightPoint(chart, {'point' : element}, 10, true);
}
});
}
console.log(data.length);
if (data.length === 1) {
chart.lines.dispatch.on("elementClick", function(e) {
// Faire ça uniquement si il y a UN graph
if (clickedPoints.length >= 2){
// Remove the first point of the array
var pointToDelete = clickedPoints.shift(0,1);
// And remove his highlight
removeHighlightPoint(pointToDelete, pointToDelete.element.attributes[1].nodeValue);
}
clickedPoints.push(e);
highlightPoint(chart, e, 7, false);
});
}
},
},
title: {
enable: true,
text: 'Title for Line Chart'
},
};
I need to make actions when only one set of data is show, I have my condition for the if but the callback is called only one time at the beggining, how can I call at every stateChange ?
I also need to call the callback when my options change, currently when I change the scope.options, no one of the event (stateChange) are triggered, and the callback is not triggered too.
Anyone have an idea ?