apexcharts.js icon indicating copy to clipboard operation
apexcharts.js copied to clipboard

Series hide and show methods

Open Jzueh opened this issue 6 years ago • 21 comments
trafficstars

Hi,

I would love to have a hide and show method for series, so I can always be sure in what state my series is. I have multiple legends who all toggle some series. Sometimes more than one. An I had to build a workaround to know which of the series is hidden and which is not. It would also be great to hide a series on render. Like an additional option in the series configuration. I have large charts in which the user can filter what he would like to see in the chart. Per default only one option (series) is visible and the user can show more options if he wishes to.

Greetings

Jzueh avatar Apr 02 '19 10:04 Jzueh

Have you tried the toggleSeries() method? https://apexcharts.com/docs/methods/#toggleSeries

var chart = new ApexCharts(el, {
  series: [{
    name: 'Football'
    data: [33, 23, 76, 33]
  }, {
    name: 'Cricket'
    data: [23, 33, 16, 23]
  }]
});

chart.toggleSeries('Football')

junedchhipa avatar Apr 02 '19 11:04 junedchhipa

Yes, I've tried the toggle Method.

The problem is, I never know where the user is and what state the series is in (toggled or not). So it is a big Bug trap. Show and hide would solve this problem. Or a "hidden" value which I can adress.

Also initial hiding a Series is pretty complicated to acomplish.

Jzueh avatar Apr 02 '19 11:04 Jzueh

Ok, I will note down as a feature enhancement.

junedchhipa avatar Apr 02 '19 12:04 junedchhipa

+1 for this.

We need showSeries() and hideSeries()

In addition can we get highlightSeries() as a method?

Hyperblaster avatar May 20 '19 02:05 Hyperblaster

+1

Could toggleSeries() return true or false depending on the visible state of the series?

harshanaravindakshan avatar Jun 12 '19 18:06 harshanaravindakshan

+1

I need to hide all series except the first one by default.

koenrad avatar Oct 21 '19 23:10 koenrad

Added new methods showSeries and hideSeries. Also, toggleSeries will return a boolean value whether the series is hidden or not. The change will be reflected in the next patch/minor release.

junedchhipa avatar Oct 23 '19 08:10 junedchhipa

I can't seem to get these methods to work. I made an issue with codepen here #1192

ThinkSalat avatar Jan 07 '20 18:01 ThinkSalat

Is showSeries() and hideSeries() available for apexcharts react implementation as well?

sebastianpikand avatar Oct 05 '20 09:10 sebastianpikand

I am having a weird issue with showSeries(). Every time I call it the page will automatically scroll up to the top. Can we avoid this?

sonphnt avatar Feb 25 '21 11:02 sonphnt

Added new methods showSeries and hideSeries. Also, toggleSeries will return a boolean value whether the series is hidden or not. The change will be reflected in the next patch/minor release.

Thank you for the feature!

It can be an array of string ? Would be nice to have.

gyurielf avatar Nov 02 '21 15:11 gyurielf

Added new methods showSeries and hideSeries. Also, toggleSeries will return a boolean value whether the series is hidden or not. The change will be reflected in the next patch/minor release.

@junedchhipa Thanks for adding the showSeries and hideSeries functions and it works great functionally. But the performance is too slow when the charts has many data series. Would love to have a showAllSeries and hideAllSeries, that would actually shows/hides all the data series in one go rather than the developer showing/hiding one by one in loop.

arunsabtharishi avatar Nov 05 '21 03:11 arunsabtharishi

Added new methods showSeries and hideSeries. Also, toggleSeries will return a boolean value whether the series is hidden or not. The change will be reflected in the next patch/minor release.

@junedchhipa Thanks for adding the showSeries and hideSeries functions and it works great functionally. But the performance is too slow when the charts has many data series. Would love to have a showAllSeries and hideAllSeries, that would actually shows/hides all the data series in one go rather than the developer showing/hiding one by one in loop.

+1 I also had performance issues while using these methods.

gyurielf avatar Nov 05 '21 13:11 gyurielf

Added new methods showSeries and hideSeries. Also, toggleSeries will return a boolean value whether the series is hidden or not. The change will be reflected in the next patch/minor release.

@junedchhipa Thanks for adding the showSeries and hideSeries functions and it works great functionally. But the performance is too slow when the charts has many data series. Would love to have a showAllSeries and hideAllSeries, that would actually shows/hides all the data series in one go rather than the developer showing/hiding one by one in loop.

@junedchhipa , there has been already a thread regarding this which has been tagged to high priority feature request, but has been automatically closed by bot because of no activity.

arunsabtharishi avatar Nov 05 '21 15:11 arunsabtharishi

Hi, how can we please use methods on Chart component in ReactJs please? Thank you

Caecilius21 avatar Dec 08 '21 10:12 Caecilius21

Hi, how can we please use methods on Chart component in ReactJs please? Thank you

as a workaround you can

window.ApexCharts.exec('my.options.chart.id', 'resetSeries',{})

karschdn avatar Jan 19 '22 12:01 karschdn

Same performance issues here, calling the show/hide/toggle brings web page to it's knees

jjxtra avatar May 21 '22 21:05 jjxtra

+1

I need to hide all series except the first one by default.

The ability to have series disabled by default would be a great plus

brodrigz avatar Oct 13 '22 15:10 brodrigz

+10 To have an option to set a series invisible while creating, so they won't render initially would be the great (and I believe must have option). The hideSeries method is ok, but useless when you need to hide series initially.

g3gant avatar Nov 16 '22 18:11 g3gant

Added new methods showSeries and hideSeries. Also, toggleSeries will return a boolean value whether the series is hidden or not. The change will be reflected in the next patch/minor release.

@junedchhipa Thanks for adding the showSeries and hideSeries functions and it works great functionally. But the performance is too slow when the charts has many data series. Would love to have a showAllSeries and hideAllSeries, that would actually shows/hides all the data series in one go rather than the developer showing/hiding one by one in loop.

@junedchhipa now i am getting the same performance issue.. for now is there any soluation for any method for hide many at at time

veerababuyarramalla avatar Dec 05 '22 11:12 veerababuyarramalla

Performance is really an issue. Example: 35 series chart where each series have only 14 points calling hideSeries in loop to hide all but one series takes just under 4 seconds.

emailnikola avatar Dec 26 '22 13:12 emailnikola

Can we hide two series out of five series and can we show that hidden series values in tooltip?

namrata-smarttrak avatar Jul 08 '24 15:07 namrata-smarttrak

bump the last comment

RafaelCENG avatar Jul 23 '24 13:07 RafaelCENG

A new property hidden added into series. The configuration for it will look like this

series = [
  {
    name: 'series1',
    data: [31, 40, 28, 51, 42, 109, 100],
  },
  {
    name: 'series2',
    data: [11, 32, 45, 32, 34, 52, 41],
    hidden: true,
  },
],

The new property will be available from v3.53.0

junedchhipa avatar Aug 13 '24 10:08 junedchhipa

A new property hidden added into series. The configuration for it will look like this

series = [
  {
    name: 'series1',
    data: [31, 40, 28, 51, 42, 109, 100],
  },
  {
    name: 'series2',
    data: [11, 32, 45, 32, 34, 52, 41],
    hidden: true,
  },
],

The new property will be available from v3.53.0

W Dev

RafaelCENG avatar Aug 13 '24 14:08 RafaelCENG

use hideSeries if check chart two id

becouse check data Y sum 0 hide series

error log

// Hide series with all zero data after rendering

seriesData.forEach((series, index) => {
       let totalSum = series.data.reduce((sum, dataPoint) => sum + parseFloat(dataPoint.y), 0);
       if (totalSum == 0) {
           chart[chartId].hideSeries(series.name);
       }
   });

Uncaught TypeError: Cannot read properties of null (reading 'getAttribute') at y.value (apexcharts-CNFkXbcq.js:13:26744) at y.value (apexcharts-CNFkXbcq.js:13:27453) at y.value (apexcharts-CNFkXbcq.js:703:7654) at :73:32 at Array.forEach () at :70:20 value @ apexcharts-CNFkXbcq.js:13 value @ apexcharts-CNFkXbcq.js:13 value @ apexcharts-CNFkXbcq.js:703 (anonymous) @ VM9558:73 (anonymous) @ VM9558:70

bahyusanciko avatar Aug 16 '24 09:08 bahyusanciko

@junedchhipa When can we expect the 3.53.0 version release?

litera avatar Aug 29 '24 09:08 litera

@litera Release notes for v3.53.0

junedchhipa avatar Aug 30 '24 18:08 junedchhipa

@litera Release notes for v3.53.0

Thx alot 🙏

itsantini avatar Aug 31 '24 00:08 itsantini

hey @junedchhipa any chance to implement same feature on https://www.npmjs.com/package/react-apexcharts/v/1.4.1 ???

victorbiasibetti avatar Sep 11 '24 01:09 victorbiasibetti