Not able to use toggleSeries with next js application
See original GitHub issueI want to toggleSeries data of a chart in my next js application. I am trying to use that method in 2 different ways, but none of them is working. I will show you the error i am getting with both these methods differently. Please help me with a solution.
Method 1:
import ApexCharts from 'apexcharts';
toggleSeries = (seriesName) => {
ApexCharts.exec('myChartId', 'toggleSeries', 'seriesName');
}
In method 1 there are 2 problems
- Most of the time i get window is not defined for ApexCharts
- Second, sometimes i get:
apexcharts__WEBPACK_IMPORTED_MODULE_9___default.a.exec is not a function
/
In order to resolve error: window is not defined
I use dynamic import as i use dynamic import for react-apexcharts see below
Method 2:
const ApexCharts = dynamic(() => import('apexcharts'), { ssr: false });
toggleSeries = (seriesName) => {
ApexCharts.exec('myChartId', 'toggleSeries', 'seriesName');
}
In method 2 it says ApexCharts.exec is not a function.
Please help me with the solution for this
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:12
Top Results From Across the Web
Getting Started | Next.js
Get started with Next.js in the official documentation, and learn more about all our features!
Read more >Advanced Features: Custom `App` - Next.js
Note: Next.js 13 introduces the app/ directory (beta). This new directory has support for layouts, nested routes, and uses Server Components by default....
Read more >Basic Features: Handling Scripts - Next.js
Offloading Scripts To A Web Worker (experimental) ... Note: The worker strategy is not yet stable and does not yet work with the...
Read more >next.config.js: Introduction
js module, not a JSON file. It gets used by the Next.js server and build phases, and it's not included in the browser...
Read more >Advanced Features: Custom Server - Next.js
Start a Next.js app programmatically using a custom server. ... have an existing backend, you can still use it with Next.js (this is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@hbole
Use
react-apexcharts apexcharts
package and solve with dynamic import in next.jsand call component
<ChartSample />
Hi,
Apologies, I know this is closed but no solution here works in terms of toggling a series with an external button for me.
I have tried the method by @MisaelMa , but I get the error
ApexCharts.exec is not a function
after importing the chart component and clicking the button.