0

I'm new to google charts and can't seem to figure out how i would do something of the following:

I want to make a data table that has my xcord,ycord,legendlabel. I'm trying the following:

var data = google.visualization.arrayToDataTable([]);   

            data.addColumn("number","reps");
            data.addColumn("number","weight");
            data.addColumn("string","legendlabel")

            //data.addColumn("string","workoutname");

            data.addRows([[150, 10,"workoutA"],
                          [300, 2,"workoutB"],

                        ]);

However, it isn't working obviously because we have two different types, number and string.

Is there a way i can specify the xcord, ycord then have a label for this point, then if there are multiple labels that are the same it forms a line graph?

Thanks in advance guys!

Lilluda 5
  • 1,111
  • 3
  • 18
  • 38

1 Answers1

0

I there some reason you're initializing the empty data variable and then adding to it?

Why not do this:

var data = google.visualization.arrayToDataTable([
  ['legendlabel', 'Reps', 'Weight'],
  ['workoutA', 150, 10],
  ['workoutB', 300, 2]
]);

…which works in my test at the Google Code Playground.

Though, it probably doesn't display what you want, since you're comparing two scalars values of different scales (one is 2-10, one is 150-300). What sort of graph are you hoping to see?

This question may help you with dual y-axes: Can Google Charts support dual y-axis (v-axis)?

Community
  • 1
  • 1
msanford
  • 11,803
  • 11
  • 66
  • 93
  • Yes it doesn't really display what i want. What i really want to do is have a data datable something like [[xcord,ycord],legendlabel] is that possible any way – Lilluda 5 Aug 07 '12 at 02:25
  • I'm hoping to see the weight value on the y axis, rep value on the x axis, then lines according to a legend label i.e. workoutA would connect all the dots with workoutA label, then another legendlabel called workoutB connecting all of those dots etc. – Lilluda 5 Aug 07 '12 at 02:28