Ah I see the issue now! Here is what happens:
1. A chart is drawn in an invisible div where text measurement is wonky,
and things get laid out poorly.
2. Some time after the chart is drawn, the visibility of the div is changed
and the chart is asked to redraw.
3. Our charts try to be smart and not redraw things unnecessarily, and
since nothing has changed between the options and the data, the chart does
minimal amount of work needed to draw, which does not include layout out
the legend again.

This is most definitely a bug, and I filed an internal bug to track this
issue; but it's not entirely obvious how it should be fixed, since we do
want to continue doing minimal work whenever possible.

It was pointed out in another thread that this issue can be avoided if you
call .clearChart() before you draw.
Another workaround you could do is to simply not draw the chart in
invisible divs. It's not simply a matter of redrawing the chart when the
div becomes available, but actively disabling the drawing if the div is not
visible.

Here's a jsfiddle where this issue can be easily reproduced (along with a
checkbox to enable the clearChart fix to verify that it does fix the
issue): http://jsfiddle.net/4a2unfnu/1/


On Wed, Apr 8, 2015 at 10:19 AM Alan Sparkes <[email protected]> wrote:

> Thanks Sergey,
>>
>> I tried it a few different ways delaying with SetTimeout even waiting 9
> seconds at one point. The result is the same legend squash :)
> eg
> $('dl.tabs dd a').on('click', function (event) {
>  activateTab($(this));
>  delayRedraw();
> });
>
> function delayRedraw(){
> mydelay = setTimeout(redraw, 3000);
>
> }
> function redraw(){
>  chart.draw(data, options);
>  }
>
> I guess this is an edge case ?
>
> --
> 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 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