Google Charts: How to pass a parameter into a callback (JavaScript)?

一世执手 提交于 2020-01-30 08:45:39

问题


I have a following code:

google.charts.setOnLoadCallback( drawChart );
function drawChart() { ... }

I need to pass a parameter called chartID into a drawChart() function. How can I do it? Seems google chart doesn't want to get any params :) Any ideas?


回答1:


one way is to add another function...

google.charts.setOnLoadCallback(function () {
  drawChart(chartID);
});

function drawChart(chartID) { ... }


来源:https://stackoverflow.com/questions/45255690/google-charts-how-to-pass-a-parameter-into-a-callback-javascript

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