为 Jquery 库方法赋值
<script type="text/javascript">
$(function () {
var lines = <?php echo $dataLines ?>;
var d0 = lines[0];
var d1 = lines[1];
var plot = $.plot($("#placeholder"), [
{data: d0},{data: d1}],options);
});
上面的代码是正确的代码,但是行数是硬编码的。为了使其灵活,我使用“For Loop”来自动获取行数。但是,当我进行更改时它不起作用(请参阅以下代码)。
我猜想 For 循环内部的 plot.data = di
有问题。
谁能帮助我吗?谢谢!
<script type="text/javascript">
$(function () {
var lines = <?php echo $dataLines ?>;
var plot = $.plot($("#placeholder"),options);
for (var i = 0; i < lines.length; i++){
plot.data = di; //somthing wrong here
}
});
<script type="text/javascript">
$(function () {
var lines = <?php echo $dataLines ?>;
var d0 = lines[0];
var d1 = lines[1];
var plot = $.plot($("#placeholder"), [
{data: d0},{data: d1}],options);
});
The above code is the correct code, but the number of the lines are hard-coded. In order to make it flexiable, I used "For Loop" to get the amount of lines automatically. However, it doesn't work when I did changes(see the following code).
I guess there is something wrong on plot.data = di
inside of For Loop.
Can anyone help me? Thanks!
<script type="text/javascript">
$(function () {
var lines = <?php echo $dataLines ?>;
var plot = $.plot($("#placeholder"),options);
for (var i = 0; i < lines.length; i++){
plot.data = di; //somthing wrong here
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你应该这样做:
以这种方式将一个对象添加到数组
plot.data
I think you should do:
in this way you add an object to the array
plot.data