Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding and removing regions dynamically #1527

Open
AbeHandler opened this issue Jan 4, 2016 · 1 comment
Open

Adding and removing regions dynamically #1527

AbeHandler opened this issue Jan 4, 2016 · 1 comment

Comments

@AbeHandler
Copy link

Hi,

Would it be possible to add functionality to add/remove regions dynamically? I see that this is not supported from http://c3js.org/reference.html#api-load

I know that it's possible to add regions this this... chart.regions.add({axis: 'x', start: 1 end: 3, class: "X"});

and them remove them like this: $(".c3-regions .X").remove()

But this is unsuitable because if you go to add a new region, c3js still "remembers" the removed ones. This will show both region X (which has been removed with CSS) and region Y ...

chart.regions.add({axis: 'x', start: '4', end: '7', class: 'regionY'})

Thanks!

@dmauer
Copy link

dmauer commented Jul 8, 2016

You can do this, actually, using the .regions(arrayOfRegions) method, which replaces the current set of regions with the provided set:

chart.regions([{axis:'x', start:4, end:12, class:'active-region'}]); // clears all regions, adds a region on x-axis from 4 to 12
chart.regions([]); // clears all regions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants