开发者

Google Visualization - Annotated timeline legend

开发者 https://www.devze.com 2023-01-07 12:13 出处:网络
I have an annotated timeline chart that gets new data over ajax. It\'s working fine, new points come in and I redraw the graph. My graph has two lines, so there are two labels in the legend on top. Fo

I have an annotated timeline chart that gets new data over ajax. It's working fine, new points come in and I redraw the graph. My graph has two lines, so there are two labels in the legend on top. For whatever stupid reason, every single time the graph is redrawn, the legend labels swap places! So it will say

• Foo 5.2 • Bar 3.6

And then I'll refresh (and there will be no new data, so the call to redraw is 100% identical to开发者_Go百科 the previous one) and now it says

• Bar 3.6 • Foo 5.2

In the respective red and blue, of course. What on earth would possess the applet to do this? Is there any way I can control the order of legend labels? I couldn't find anything about it in the official documentation.


Try using google.visualization.DataTable. For example:

dataTable = new google.visualization.DataTable({cols:graphColumns, rows:graphRows});
chart = new google.visualization.AnnotatedTimeLine($('#chart_div')[0]);
chart.draw(dataTable)

I use it this way and don't have any problems with my legend values.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号