1

i want to create a diagram with a jquery Plugin (tufteGraph).

I have to give some data information for the Plugin:

  jQuery('#awesome-graph').tufteBar({

            data: [[5, {label: "Bar1"}],[6,{label: "Bar2"}]]
            },
            [...]

How can i put data into that, i build with a JS loop?

var datas;
for(var i = 0; i < zi; i++)
                {
                    if (i < zi - 1)
                    {                        
                        datas+="["+timefield[i]+", {label: "+SelectObjects1[pX][i][1]+"}],";                   
                    }
                    else
                    {
                        datas+="["+timefield[i]+", {label: "+SelectObjects1[pX][i][1]+"}]]";                
                    }
                }  

How can i use the "datas" data inside the JQuery function?

Thank you :)

1 Answer 1

1

Do not build it as a string, but as an array directly

var datas = [];
for(var i = 0; i < zi; i++)
    {                      
      datas.push( [timefield[i], {label: SelectObjects1[pX][i][1]}] );      
    }  

and use it

jQuery('#awesome-graph').tufteBar({
            data: datas
            },
            [...]
Sign up to request clarification or add additional context in comments.

Comments

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.