Skip to content

Commit 643b4d4

Browse files
committed
before calling update() method, check if last options were same as current ones
1 parent a71cc82 commit 643b4d4

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/apexcharts.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export default class ApexCharts {
3838
const initCtx = new InitCtxVariables(this)
3939
initCtx.initModules()
4040

41+
this.lastUpdateOptions = null
42+
4143
this.create = Utils.bind(this.create, this)
4244
this.windowResizeHandler = this._windowResizeHandler.bind(this)
4345
this.parentResizeHandler = this._parentResizeCallback.bind(this)
@@ -429,6 +431,16 @@ export default class ApexCharts {
429431
// fixes apexcharts.js#1488
430432
w.globals.selection = undefined
431433

434+
if (
435+
this.lastUpdateOptions &&
436+
JSON.stringify(this.lastUpdateOptions) === JSON.stringify(options)
437+
) {
438+
// Options are identical, skip the update
439+
return resolve(this)
440+
}
441+
442+
this.lastUpdateOptions = Utils.clone(options)
443+
432444
if (options.series) {
433445
this.series.resetSeries(false, true, false)
434446
if (options.series.length && options.series[0].data) {
@@ -527,6 +539,16 @@ export default class ApexCharts {
527539

528540
update(options) {
529541
return new Promise((resolve, reject) => {
542+
if (
543+
this.lastUpdateOptions &&
544+
JSON.stringify(this.lastUpdateOptions) === JSON.stringify(options)
545+
) {
546+
// Options are identical, skip the update
547+
return resolve(this)
548+
}
549+
550+
this.lastUpdateOptions = Utils.clone(options)
551+
530552
new Destroy(this.ctx).clear({ isUpdating: true })
531553

532554
const graphData = this.create(this.w.config.series, options)

0 commit comments

Comments
 (0)