Hi Pops, Is this all JavaScript?
Firstly, you're declaring that $points is an argument to drawChart, but are never actually passing it in. You'll have better luck just using your global variable directly and figuring out how to generalize later. Secondly, you can't just interpolate a string and turn it into code. You'll need to take some explicit action, like calling JSON.parse (to parse the JSON that you specified). Third, you're not going to be able to get anywhere with your "points" string as is. Currently, it is not a valid object expression, and the comments will simply cause the last thing to be executed (or maybe just cause an error). You need to surround your entire points string in brackets to make it an array, like so: var points = "*[*['Mon', 20, 28, 38, 45],['Tue', 31, 38, 55, 66],['Wed', 50, 55, 77, 80],['Thu', 77, 77, 66, 50],['Fri', 68, 66, 22, 15]*]*"; Which would also mean that you don't need the extra brackets around arrayToDataTable's argument. So putting it all together, you would get: var data = google.visualization.arrayToDataTable(JSON.parse(points), true); On Sun, Feb 14, 2016 at 11:36 AM Pops Vlogs <[email protected]> wrote: > I need a way to pass in a string that is formatted as you'll see in the > code below into the chart. if anybody could help out that will be > amazing!!!! > > > > > > > > > var points = "['Mon', 20, 28, 38, 45],['Tue', 31, 38, 55, 66],['Wed', 50, > 55, 77, 80],['Thu', 77, 77, 66, 50],['Fri', 68, 66, 22, 15]" > > google.setOnLoadCallback(drawChart); > > function drawChart($points) { > var data = google.visualization.arrayToDataTable([ > $points > // Treat first row as data as well. > ], true); > > var options = { > legend:'none' > }; > > var chart = new > google.visualization.CandlestickChart(document.getElementById('chart_div')); > > chart.draw(data, options); > } > > > the highlighted bit is the string I cant get to work... > > -- > You received this message because you are subscribed to the Google Groups > "Google Visualization API" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to > [email protected]. > Visit this group at > https://groups.google.com/group/google-visualization-api. > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-visualization-api/3233955b-580a-4f4e-b333-56c61c960339%40googlegroups.com > <https://groups.google.com/d/msgid/google-visualization-api/3233955b-580a-4f4e-b333-56c61c960339%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- *[image: unnamed.gif]• Sergey Grabkovsky• Software Engineer• Google, Inc• [email protected] <[email protected]>* -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/google-visualization-api. To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/CAEwwup5kG62a4dBSr4NGXx1N--F%2BaPNZxyQuAm2__fG501J_hw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
