Is there an Dygraph has loaded event?

醉酒当歌 提交于 2021-01-27 15:51:27

问题


I want to show checkboxes for every column in my dygraph. But I can't figure out when to get the names of my columns from dygraph using

g.getLabels().

It works when I call it manually after I know the graph has loaded. But how can I automate this? I couldn't find an event like "Dygraph.loaded" or a property like "Dygraph.hasLoaded". Is there some way to easily do this?


回答1:


This is what the .ready() method is designed to do:

g = new Dygraph(div, "/path/to/data.csv");
g.ready(function() {
  var labels = g.labels();
  ...
});

The function you pass to ready() will be called after the chart has been drawn for the first time.

If you pass CSV data or an array to the Dygraphs constructor, it will be called synchronously. If you pass a URL, it will be called asynchronously.



来源:https://stackoverflow.com/questions/26316435/is-there-an-dygraph-has-loaded-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!