Apexcharts.js: Possibility to set specific series as unselected in legend container

Created on 18 Sep 2018  路  7Comments  路  Source: apexcharts/apexcharts.js

Hi again,

I've encountered a scenario where I would like to specify specific series as unselected in the legend container. I've tried looking at the documentation and can't seem to find anything related to that, except that it is only possible to hide the legend container.

Thanks!

feature-request

Most helpful comment

A new public method toggleSeries('seriesName') is added since 2.1.4 which will allow you to toggle series visibility programmatically.

You can also create a custom legend and call this method to control the series visibility.

Codepen Demo
Docs

All 7 comments

You mean, if you have a multiple series chart, you want to initialize the chart by having certain series "deselected" like this?

screen shot 2018-09-18 at 7 42 16 pm

Or you want that series not to show in the legend at all?

Exactly, I would like to have certain series "deselected" when initialised but keep the series in the legend container, so the user can "select" it again. :)

Well, currently ApexCharts doesn't have this option directly, but you can try a hacky solution.

const legendItem = document.querySelector(".apexcharts-legend-text.apexcharts-legend-series:nth-child(1)")

legendItem.dispatchEvent(new Event('click'))

Will think of adding an option in config in future releases.

@junedchhipa Such an option would be great! We have too many items in legend and then in the tooltip and limit to e.g. 10 items by initially disabling the rest would be very useful.

A new public method toggleSeries('seriesName') is added since 2.1.4 which will allow you to toggle series visibility programmatically.

You can also create a custom legend and call this method to control the series visibility.

Codepen Demo
Docs

what about in a REACT apex chart?

@junedchhipa How do we utilize this w/ React? It would be great if there was a prop on legend component that would made all the series untoggled by default. Is there a way I can accomplish this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maasha picture maasha  路  3Comments

rcoundon picture rcoundon  路  3Comments

ismaildervisoglu picture ismaildervisoglu  路  3Comments

drummad picture drummad  路  3Comments

drew-dulgar picture drew-dulgar  路  3Comments