Thanks a lot for your ardent help, Sergey.

Now, somebody please see how best to handle the following situation.

I need to do something like this:
http://jsfiddle.net/dlaliberte/4w0bxLx0/

I.e., change data when the pulldown select option changes. But instead of
pulling data from external source each time, I'm going to pre-define all my
data in the html page, like this:

        var data0 = [
          ['G1 - Ursa Major II Dwarf', 30000, 14.3, 30000, 14.3],
          ['G2 - Lg. Magellanic Cloud', 50000, 0.9, 50000, 0.9],
          ['G2 - Bootes I', 60000, 13.1, 60000, 13.1],
          ['G2 - Canis Major Dwarf', 8000, 23.3, 8000, 23.3],
          ['G3 - Sagittarius Dwarf', 24000, 4.5, 24000, 4.5]
        ];

Then use the pulldown select with options of "G1", "G2", and "G3". When it
changed I'm going to use data0.filter() to pick the correct group, be
it  "G1", "G2", or "G3", then chart them.

However, as I just learned, my above plan does not play well with how
DataTable works. The  main problem is getting the data0.filter() result
into DataTable, as I do need each value having its own tooltip.

Is there any way to make my above plan still work?

I've even tried to pre-define a header of

       [
          ['Galaxy', 'V1', {label: 'T1', role: 'tooltip'}, 'V2', {label:
'T2', role: 'tooltip'}]
        ]

then call

        var data = new google.visualization.arrayToDataTable(
          header1.concat(data0));

But that doesn't work either.

Please help.
Thanks


On Thu, Feb 5, 2015 at 6:46 PM, 'Sergey Grabkovsky' via Google
Visualization API <[email protected]> wrote:

> Hi Tong,
>
> The reason for this is because arrayToDataTable attempts to infer the
> types of your data. So when you attempt to use it with just the header row,
> it infers the types of all the columns to be string (the default type). You
> can fix your first example by creating the DataTable via the DataTable
> constructor and using addColumn to add all the columns and specify their
> types. It's generally not advised to mix usage of arrayToDataTable and
> addRows.
>
> You can "set/reset chart data" simply by calling chart.draw with a
> different DataTable and/or options, or even the same DataTable with
> modified data.
>
> On Thu Feb 05 2015 at 6:09:33 PM Tong Sun <[email protected]> wrote:
>
>> Hi,
>>
>> Please take a look at the following jsfiddle:
>>
>> http://jsfiddle.net/12r0ztoa/1/
>> http://jsfiddle.net/849tL2k8/1/
>>
>> The only difference between the two is whether "var data" was initially
>> empty or not. Yet, one is working while the other one isn't. Why is that?
>>
>> How to set/reset chart data using another data array?
>>
>> Thanks
>>
>> --
>> 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
>> http://groups.google.com/group/google-visualization-api.
>> For more options, visit https://groups.google.com/d/optout.
>>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Google Visualization API" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/google-visualization-api/qVIsp_uhNNY/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to
> [email protected].
> Visit this group at
> http://groups.google.com/group/google-visualization-api.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to