c3js / c3

:bar_chart: A D3-based reusable chart library
http://c3js.org
MIT License
9.34k stars 1.39k forks source link

Zooming after flow stops does not work #1640

Open petogriac opened 8 years ago

petogriac commented 8 years ago

Hi,

I am having this problem , that after starting and stopping the flow I am not able to zoom the graph. But if I click on some data in the legend the zoom enables back. I tried to focus and defocus via API , but that didnt work.

Thanks for help

Peter

$("#liveStream").change(function() { if ($(this).is(":checked")) { liveStream = setInterval(function() { chartRX.flow({ columns: data.rx, length: 0 }); }, 1000); } else { clearInterval(liveStream); } });

aendra-rininsland commented 8 years ago

Hi @petogriac — could you please produce a JSFiddle depicting the behaviour you're observing? Thanks!

petogriac commented 8 years ago

Hi @aendrew ,

sure, here is the JSFiddle: https://jsfiddle.net/4yuckL99/1/

At the beginning it is possible to zoom fine in the chart, but if I turn ON and after a while OFF the Live Stream (flow function), it is not possible to zoom no more. Only if I click on the legend it enables again.

Thanks a lot!

Peto

lifecoderua commented 8 years ago

Hi, @petogriac, you may fix this to some extent by enabling zoom via c3's API on flow #done method.

petogriac commented 8 years ago

thanks @lifecoderua I tried adding that, it works now, but only after waiting a while. Probably it is takes a while for triggering the.done function. Please check : https://jsfiddle.net/4yuckL99/2/

Thanks!

lifecoderua commented 8 years ago

Hi, @petogriac. It doesn't work reliably because your done callback don't actually do anything. You only declare object and don't use it anywhere.

Here is an example of how it may be done: https://jsfiddle.net/bgfLw4cc/

It would still be resized to the initial zoom on data addition, so you should consider to have longer delays between data updates, or pause data updates on #zoomstart event.