1

This is my data..

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);

When I use hardcode like

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

Jqchart is working fine, but I want to send the array data(rname and rqi) .. Is there any way to send javascript array data to jqplot dynamically?? Thanks in advance...

1 Answer 1

2

try this

    <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>
Sign up to request clarification or add additional context in comments.

3 Comments

I have another question.. I want to change the back ground color of that plot.. I am using the jquery.jqplot.css css file. `<link type="text/css" href="js/jquery.jqplot.css" rel="stylesheet" />' Where I have to change to get the white background for jqplot?
marvelous.. Than q,Than q,Than q,Than q,Than q very much.. :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.