我一定错过了一些简单的东西,但是......:在 API 方法的 ZingChart 文档中,函数都引用 myid
,但我无法弄清楚 ZingChart 的 id 是什么。例如,方法 getseriesvalues
:
zingchart.exec('myid', 'getseriesvalues', {});
此示例代码中的'myid'
指的是什么?
这是我的简单 ZingChart 示例代码:
$(function(){
var myChart = {
type : "line",
title : {text: "Hello ZingChart World!"},
series : [
{values:[5, 10, 15, 5, 10, 5]},
{values:[2, 4, 6, 8, 10, 12]}
]
};
zingchart.render({
id : "myChartDiv",
height : 450,
width : 600,
data : myChart
});
})
现在假设我想调用此图表上的 getseriesvalues
方法 - myid 是什么? myChart
? myChartDiv
?它们都不起作用...
最佳答案
id
属性引用 <div>
元素的id
注入(inject)图表的属性。请参阅ZingChart "Getting Started" guide .
示例:
<html>
<body>
<script>
var myChart = {
type : "line",
title : {text: "Hello ZingChart World!"},
series : [
{values:[5, 10, 15, 5, 10, 5]},
{values:[2, 4, 6, 8, 10, 12]}
]
};
window.onload=function(){
zingchart.render({
id : "myChartDiv",
height : 450,
width : 600,
data : myChart
});
};
</script>
<div id="myChartDiv"></div>
</body>
</html>
它还用于其他 ZingChart 方法(例如 to subsequently bind events to your chart )。例如,要获取此图表启动后的值:
zingchart.exec("myChartDiv", "getseriesvalues", {});
你可以想到id
作为全局变量 - 始终按名称引用相同的图表,无论其在代码中的位置如何。
关于jquery - ZingChart 文档中的 "myid"是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20855983/