About using the same Line options to different chart instances

42 views
Skip to first unread message

Jayme Jeffman

unread,
Jun 14, 2017, 10:10:11 AM6/14/17
to Google Visualization API
Hello,

I have five different charts with the same structure, the differences are the vertical axis title and perhaps the axis labels and limits .

Initially, for testing purposes, I am using the same line options JavaScript object, but I am getting different behaviours, the columns legend is being overwritten in the second chart.

Should I have different line options for each chart? Or can I reutilize the same line options code?

Thank you very much.

Best regards.

Jayme Jeffman
chart_options_thesame.png

Daniel LaLiberte

unread,
Jun 14, 2017, 10:24:08 AM6/14/17
to Google Visualization API
If you are changing the options from one chart to the next, then you should use different options objects.  If they are sharing the same object, it is certainly possible, due to the internal asynchrony involved in chart drawing, that when you change the options for one chart, you are also affecting another chart that is using the same options object.

In other words, the chart doesn't copy the options object when you draw the chart.  There are some situations in which it is copied, but this is not something you can rely on.

The column header labels are used in the legend, by the way, and so if you share the same datatable across charts, but vary the data each time, it's the same kind of problem as for sharing the options object.

But perhaps I am missing what you are asking about.  Can you point me to your web page with the multiple charts?

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
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/0687883f-2bd6-491d-bd50-9763fc978c43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Jayme Jeffman

unread,
Jun 14, 2017, 10:33:22 AM6/14/17
to Google Visualization API
The png image I have attached to the initial post are screenshots of two Line charts using the same line options, all html tags are clones and have the same structure, but axis labels and the legend are being painted differently.

The page is on my localhost, I have not any link to it.

Daniel LaLiberte

unread,
Jun 14, 2017, 10:47:22 AM6/14/17
to Google Visualization API
In the screenshot, the legend in the second chart appears to be overwriting the lines and the labels, which suggests you are drawing the chart when it is not yet visible (so it appears to the chart that the text doesn't take any space).  The solution (workaround) is to only draw the chart when it is visible.

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.

For more options, visit https://groups.google.com/d/optout.

Jayme Jeffman

unread,
Jun 14, 2017, 10:56:38 AM6/14/17
to Google Visualization API
That makes sense. The html div might be set with display="none" while drawing, I will change that.

Thank you very much.

Jayme Jeffman

unread,
Jun 16, 2017, 10:19:53 AM6/16/17
to Google Visualization API
Thank you very much Daniel.

Your suspicion was right. I have changed code to ensure the chart container be visible while chart is being drawn and everything is now working fine.

Best regards,

Jayme Jeffman

Daniel LaLiberte

unread,
Jun 16, 2017, 11:12:14 AM6/16/17
to Google Visualization API
Good to hear you got it working.

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages