c3 icon indicating copy to clipboard operation
c3 copied to clipboard

Chart does not render properly when it was generated in not active tab in chrome

Open norecces opened this issue 11 years ago • 7 comments

I opened http://c3js.org/samples/chart_combination.html from http://c3js.org/examples.html by clicking at link and opening it in new tab. Then I waited few seconds and went to combination example. It was not rendered (Actually it was but wrong). 10 To get chart visible I had to resize window. If it is only one tab in chrome, this bug does not seem to appear.

Google Chrome 39.0.2171.99 m

norecces avatar Jan 21 '15 06:01 norecces

I saw the same bug in Chrome when rendering bar charts. I was able to fix this by changing this line in c3.js:

$$.redrawBar(drawBar, false), // changed from true to false to fix bug (line 626)

tw3 avatar Jan 22 '15 02:01 tw3

Hi, tw3

As I understand with this change in code you will loose smooth transitions.

Compare transition behaviour in http://c3js.org/samples/chart_bar_stacked.html and http://jsfiddle.net/norecces/sq5Lq7br/1/

norecces avatar Jan 22 '15 07:01 norecces

Marking this as a bug. #774 might allow @tw3's fix to be added to core while still enabling transitions.

aendra-rininsland avatar Jan 22 '15 11:01 aendra-rininsland

I've noticed this quite a lot recently working with C3, seems like if a chart is rendered and not painted, it will paint only upon being told to resize or flush or whatever. According to #936, charts also fail to render properly if they're not visible and are then made as such.

aendra-rininsland avatar Jan 24 '15 20:01 aendra-rininsland

See this SO answer. It's a broader problem with D3, due to requestAnimationFrame.

IMO, the answer is 100% to drop all D3 transition() calls altogether in favour of CSS transitions/animations. See #774. Another solution would be to call a redraw when the visibilitychange event fires; see: https://developer.mozilla.org/en-US/docs/Web/Guide/User_experience/Using_the_Page_Visibility_API

aendra-rininsland avatar Jan 24 '15 21:01 aendra-rininsland

I'm facing this problem with version 0.6.7. Its happening with examples too.

To reproduce, open an example chart in a new tab with Chrome. Wait a few seconds and switch to the new tab, the chart isn't rendered correctly.

Chrome version: 69.0.3497.81 (linux)

fmluizao avatar Sep 05 '18 19:09 fmluizao

Seems like its already reported:

https://github.com/c3js/c3/issues/2458

fmluizao avatar Sep 05 '18 19:09 fmluizao