1

这是我的数据。。

var rname=new Array();
rname.push('India');
rname.push('Pakistan');
rname.push('Australia');
rname.push('America');
rname.push('Sri Lanka');

var rnqi=new Array();
rnqi.push(4);
rnqi.push(6);
rnqi.push(50);
rnqi.push(40);
rnqi.push(5);

当我使用硬编码时

var line1=[['India',4], ['Pakistan',6], ['Australia',50], ['America',40], ['Sri Lanka',5]]

Jqchart 工作正常,但我想发送数组数据(rname 和 rqi).. 有没有办法将 javascript 数组数据动态发送到 jqplot?提前致谢...

4

1 回答 1

2

尝试这个

    <script type="text/javascript">
    var rname = new Array();
    rname.push('India');
    rname.push('Pakistan');
    rname.push('Australia');
    rname.push('America');
    rname.push('Sri Lanka');

    var rnqi = new Array();
    rnqi.push(4);
    rnqi.push(6);
    rnqi.push(50);
    rnqi.push(40);
    rnqi.push(5);

    var result = new Array();
    for (var i = 0, j = 0; i < rname.length, j < rnqi.length; i++, j++) {
        var temp = new Array();
        temp.push(rname[i].toString());
        temp.push(parseInt(rnqi[j]));
        result.push(temp);
    }
    var line1 = [['India', 4], ['Pakistan', 6], ['Australia', 50], ['America', 40], ['Sri Lanka', 5]]
    //now result array is similar to line1
</script>
于 2013-06-13T07:21:49.073 回答