Ric*_*cky 3 html javascript jquery d3.js c3.js
我想使用某种回调函数,该函数将在C3 Graph完成加载后运行一些代码,以便可以更改某些点的填充颜色。
不要在初始化中加载任何数据。而是显式调用load事件并传递数据。然后,您可以访问done回调。
var chart = c3.generate({ /*...*/ });
chart.load({
columns: [['data1, 100, 200, 150, ...],
...
],
done: function() { /* whatever you need done here... */}
});
Run Code Online (Sandbox Code Playgroud)
id尝试在图形容器(通常是svg)上使用 声明.attr("id", "GraphContainer")。之后,您可以将 an 绑定.onload到它。像这样的东西:
var SVGCont = document.getElementById("GraphContainer");
SVGCont.onload = function() {
// your code for when it's done loading
};
Run Code Online (Sandbox Code Playgroud)
您还可以在 SVG 元素添加到 DOM 时使用该事件:
$(document).bind("DOMNodeInserted", function(e) {
// your code
});
Run Code Online (Sandbox Code Playgroud)