Skip to content

Commit ebe1484

Browse files
committed
reset parsing flags during update when data is parsed
1 parent 4a57f5c commit ebe1484

File tree

4 files changed

+33
-38
lines changed

4 files changed

+33
-38
lines changed

src/apexcharts.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ export default class ApexCharts {
440440
}
441441

442442
if (options.series) {
443-
this.updateHelpers.resetParsingFlags()
443+
this.data.resetParsingFlags()
444444

445445
this.series.resetSeries(false, true, false)
446446
if (options.series.length && options.series[0].data) {
@@ -482,7 +482,7 @@ export default class ApexCharts {
482482
* @param {array} series - New series which will override the existing
483483
*/
484484
updateSeries(newSeries = [], animate = true, overwriteInitialSeries = true) {
485-
this.updateHelpers.resetParsingFlags()
485+
this.data.resetParsingFlags()
486486

487487
this.series.resetSeries(false)
488488
this.updateHelpers.revertDefaultAxisMinMax()
@@ -499,6 +499,8 @@ export default class ApexCharts {
499499
* @param {array} newSerie - New serie which will be appended to the existing series
500500
*/
501501
appendSeries(newSerie, animate = true, overwriteInitialSeries = true) {
502+
this.data.resetParsingFlags()
503+
502504
const newSeries = this.w.config.series.slice()
503505
newSeries.push(newSerie)
504506
this.series.resetSeries(false)
@@ -518,8 +520,8 @@ export default class ApexCharts {
518520
appendData(newData, overwriteInitialSeries = true) {
519521
let me = this
520522

523+
me.data.resetParsingFlags()
521524
me.w.globals.dataChanged = true
522-
523525
me.series.getPreviousPaths()
524526

525527
let newSeries = me.w.config.series.slice()

src/modules/CoreUtils.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,15 @@ class CoreUtils {
279279
axisSeries.forEach((si) => {
280280
// series may be bare until loaded in realtime
281281
if (cnf.series[si] && cnf.series[si].group === undefined) {
282-
// A series with no group defined will be named after the axis that
283-
// referenced it and thus form a group automatically.
284-
cnf.series[si].group = 'apexcharts-axis-'.concat(ai.toString())
282+
if (cnf.series[si].__apexParsed) {
283+
// For parsed series, use sequential counter to avoid duplicates
284+
cnf.series[si].group = 'apexcharts-axis-'.concat(si.toString())
285+
} else {
286+
// For non-parsed series,
287+
// A series with no group defined will be named after the axis that
288+
// referenced it and thus form a group automatically.
289+
cnf.series[si].group = 'apexcharts-axis-'.concat(ai.toString())
290+
}
285291
}
286292
})
287293
})

src/modules/Data.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,23 @@ export default class Data {
600600
return this.w
601601
}
602602

603+
/**
604+
* Reset parsing flags to allow re-parsing of data during updates
605+
*/
606+
resetParsingFlags() {
607+
const w = this.w
608+
w.globals.dataWasParsed = false
609+
w.globals.originalSeries = null
610+
611+
if (w.config.series) {
612+
w.config.series.forEach((serie) => {
613+
if (serie.__apexParsed) {
614+
delete serie.__apexParsed
615+
}
616+
})
617+
}
618+
}
619+
603620
extractPieDataFromSeries(ser) {
604621
const values = []
605622
const labels = []

src/modules/helpers/UpdateHelpers.js

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -134,22 +134,8 @@ export default class UpdateHelpers {
134134
this.ctx.series.getPreviousPaths()
135135
}
136136

137-
let existingSeries
138-
139-
// axis charts
140-
if (w.globals.axisCharts) {
141-
existingSeries = newSeries.map((s, i) => {
142-
return this._extendSeries(s, i)
143-
})
144-
145-
if (existingSeries.length === 0) {
146-
existingSeries = [{ data: [] }]
147-
}
148-
w.config.series = existingSeries
149-
} else {
150-
// non-axis chart (pie/radialbar)
151-
w.config.series = newSeries.slice()
152-
}
137+
this.ctx.data.resetParsingFlags()
138+
this.ctx.data.parseData(newSeries)
153139

154140
if (overwriteInitialSeries) {
155141
w.globals.initialConfig.series = Utils.clone(w.config.series)
@@ -255,22 +241,6 @@ export default class UpdateHelpers {
255241
return options
256242
}
257243

258-
resetParsingFlags() {
259-
const gl = this.w.globals
260-
261-
// Reset parsing flags
262-
gl.dataWasParsed = false
263-
gl.originalSeries = null
264-
265-
if (this.w.config.series) {
266-
this.w.config.series.forEach((serie) => {
267-
if (serie.__apexParsed) {
268-
delete serie.__apexParsed
269-
}
270-
})
271-
}
272-
}
273-
274244
/**
275245
* This function reverts the yaxis and xaxis min/max values to what it was when the chart was defined.
276246
* This function fixes an important bug where a user might load a new series after zooming in/out of previous series which resulted in wrong min/max

0 commit comments

Comments
 (0)