You're on the right track. Assuming what you copied here is a straight
copy-paste from your HTML, then the problem is likely in the onclick event:
onclick="initialize_charts("year2.json")
The double-quotes at the beginning of year2.json are closing the string
holding the event, so what your browser is seeing is
onclick="initialize_charts(" which will not work. Try using single quotes
instead:
onclick="initialize_charts('year2.json');"
On Saturday, January 5, 2013 1:03:49 AM UTC-5, [email protected] wrote:
>
> Hi,
>
> *Overall Problem:* I have year-wise data in different JSON files. For
> each JSON file, I generate 3 charts that are displayed on the webpage. Now
> the user should be able to select a different year, and the charts should
> update based on that particular year's data.
>
> *What I have Done:* I wrote a function called initialize_charts() which
> parses the given JSON, prepares data as per google chart requirements and
> draws those charts. I am calling this function from
> google.setOnLoadCallback. (as of now I have hardcoded the json file name).
>
> *Main Issue:* Now, I am not sure how do I re-render the charts when the
> user selects some other year's JSON file? Somehow, I should be able to
> pass-on filename parameter to google.setOnLoadCallback or google.load, such
> that my initialize_chart reads this new data and re-renders the charts. But
> I am not sure how.
>
> *What I tried:* I tried writing a wrapper function called initialize like
> this:
>
> google.setOnLoadCallback(initialize);
>
> function initialize()
> {
> initialize_charts("year1.json");
> }
>
> So, when it loads first, it loads year1.json data. Then for onclick event
> i called onclick="initialize_charts("year2.json"). But that doesn't work. I
> suppose that the placeholders for the charts (div elements) are replaced by
> the charts itself. So, it can't find those placeholders.
>
> I would greatly appreciate any sort of help with this. If you need more
> information or my code, I would be happy to provide. I am stuck on this
> from the last 2 days :-(
>
> Regards
> P
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-visualization-api/-/t64jYIw915sJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.