C3 plots on load callback

I want to use some kind of callback function that will run some code that will finish loading the C3 graph ...

The purpose of this is so that I can change some of the fill colors of the points.

Any ideas?

+3


source to share


2 answers


Don't load data into initialization. Rather, explicitly call the load event and pass the data. Then you have access to the postback done

.



var chart = c3.generate({ /*...*/ });

chart.load({
  columns: [['data1, 100, 200, 150, ...],
    ...
  ],
  done: function() { /* whatever you need done here... */}
});

      

+4


source


Try to declare the id

graph container (usually svg

) with .attr("id", "GraphContainer")

. After that, you can bind to it .onload

. Something like that:

var SVGCont = document.getElementById("GraphContainer");
SVGCont.onload = function() {
    // your code for when it done loading
};

      



You can also use an event when SVG elements are added to the DOM:

$(document).bind("DOMNodeInserted", function(e) {
    // your code 
});

      

0


source







All Articles