Skip to content

Commit 0fd0910

Browse files
committed
Remove use of global ApexCharts class
The `setupBrushHandler` method of the `Core` class relies on the `ApexCharts` class' static `getChartByID` method. It calls this static method on the `ApexCharts` class directly without importing it currently. This is fine if consuming `apexcharts` via CDN / script tag as that places the exported `ApexCharts` class in the global scope, but it becomes an issue when users want to consume `apexcharts` via a package manager. Update the `setupBrushHandler` method to call `ApexCharts.getChartByID` the `Core` class' `ctx` field instead.
1 parent 97ed0dc commit 0fd0910

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/modules/Core.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ export default class Core {
561561
}
562562

563563
setupBrushHandler() {
564-
const { w } = this
564+
const { ctx, w } = this
565565

566566
if (!w.config.chart.brush.enabled) return
567567

@@ -570,7 +570,7 @@ export default class Core {
570570
? w.config.chart.brush.targets
571571
: [w.config.chart.brush.target]
572572
targets.forEach((target) => {
573-
const targetChart = ApexCharts.getChartByID(target)
573+
const targetChart = ctx.constructor.getChartByID(target)
574574
targetChart.w.globals.brushSource = this.ctx
575575

576576
if (typeof targetChart.w.config.chart.events.zoomed !== 'function') {
@@ -585,7 +585,7 @@ export default class Core {
585585

586586
w.config.chart.events.selection = (chart, e) => {
587587
targets.forEach((target) => {
588-
const targetChart = ApexCharts.getChartByID(target)
588+
const targetChart = ctx.constructor.getChartByID(target)
589589
targetChart.ctx.updateHelpers._updateOptions(
590590
{
591591
xaxis: {

0 commit comments

Comments
 (0)