Apexcharts.js: Toggle state gets lost after updateSeries

Created on 9 Jul 2019  路  1Comment  路  Source: apexcharts/apexcharts.js

Codepen

https://codesandbox.io/embed/react-basic-example-sbosu

Explanation

  • What is the behavior you expect?
    After a series has been toggled the state should persist after an update.
  • What is happening instead?
    When a series is not visible it turns visible after I make an update.

Most helpful comment

updateSeries forcefully makes all series visible intentionally as leaving them hidden causes a lot of bugs.
I suggest you keep track of which series you toggled in a separate state. Then, after calling updateSeries, you again toggle those series manually.

   ApexCharts.exec("basic-bar", "updateSeries", [
      {
        data: [30, 40, 45, 50, 49, 60, 70, 91]
      },
      {
        data: [33, 43, 43, 53, 43, 63, 73, 93]
      }
    ]).then((chart) => {
      ApexCharts.exec("basic-bar", "toggleSeries", "series-1");

      // or you can also do this as you have got chart's context in this function param
      chart.toggleSeries('series-1')
    });

>All comments

updateSeries forcefully makes all series visible intentionally as leaving them hidden causes a lot of bugs.
I suggest you keep track of which series you toggled in a separate state. Then, after calling updateSeries, you again toggle those series manually.

   ApexCharts.exec("basic-bar", "updateSeries", [
      {
        data: [30, 40, 45, 50, 49, 60, 70, 91]
      },
      {
        data: [33, 43, 43, 53, 43, 63, 73, 93]
      }
    ]).then((chart) => {
      ApexCharts.exec("basic-bar", "toggleSeries", "series-1");

      // or you can also do this as you have got chart's context in this function param
      chart.toggleSeries('series-1')
    });
Was this page helpful?
0 / 5 - 0 ratings

Related issues

maasha picture maasha  路  3Comments

tcarlsen picture tcarlsen  路  3Comments

jlil picture jlil  路  3Comments

pribilinskiy picture pribilinskiy  路  3Comments

frlinw picture frlinw  路  3Comments