c3js / c3

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

Calling chart.regions([...]) does not update chart #2789

Open queimadus opened 4 years ago

queimadus commented 4 years ago

Quick consecutive calls to chart.regions(newRegions) do not update the chart. Even calls spaced by 1 second do not work as expected.

In this example (https://jsfiddle.net/La5mfg67/) we do the following sequence:

I was expecting:


ebencollins commented 3 years ago

I ran into the same issue on v0.7.20, except it wasn't just quick consecutive calls that didn't work; even after many seconds had passed, a call to update with a new set of regions wouldn't cause any changes.

It seems that regions must be removed before updating (otherwise nothing changes). I had to use with chart.regions.remove() instead of chart.regions([]) to accomplish this.

Additionally, because .remove() animates by default, I had to use chart.regions.remove({'duration' : 0})

Modified example fiddle w/ workaround: https://jsfiddle.net/z7f8b9La/