@record-evolution/widget-linechart 1.6.16 → 1.6.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Webcomponent widget-linechart following open-wc recommendations",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "widget-linechart",
|
|
6
|
-
"version": "1.6.
|
|
6
|
+
"version": "1.6.17",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/widget-linechart.js",
|
|
9
9
|
"types": "dist/src/widget-linechart.d.ts",
|
package/src/widget-linechart.ts
CHANGED
|
@@ -50,7 +50,13 @@ export class WidgetLinechart extends LitElement {
|
|
|
50
50
|
@state()
|
|
51
51
|
private canvasList: Map<
|
|
52
52
|
string,
|
|
53
|
-
{
|
|
53
|
+
{
|
|
54
|
+
echart?: echarts.ECharts
|
|
55
|
+
series: SeriesOptionX[]
|
|
56
|
+
doomed?: boolean
|
|
57
|
+
element?: HTMLDivElement
|
|
58
|
+
drawing: boolean
|
|
59
|
+
}
|
|
54
60
|
> = new Map()
|
|
55
61
|
|
|
56
62
|
@state() private themeBgColor?: string
|
|
@@ -171,8 +177,13 @@ export class WidgetLinechart extends LitElement {
|
|
|
171
177
|
|
|
172
178
|
update(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void {
|
|
173
179
|
if (changedProperties.has('inputData') && this.chartContainer) {
|
|
174
|
-
this.
|
|
175
|
-
|
|
180
|
+
const drawingStates = Array.from(this.canvasList).map(([key, chart]) => chart.drawing)
|
|
181
|
+
if (drawingStates.every((d) => !d)) {
|
|
182
|
+
this.transformData()
|
|
183
|
+
this.applyData()
|
|
184
|
+
} else {
|
|
185
|
+
console.log('skipping linechart draw')
|
|
186
|
+
}
|
|
176
187
|
}
|
|
177
188
|
|
|
178
189
|
if (changedProperties.has('theme')) {
|
|
@@ -317,7 +328,6 @@ export class WidgetLinechart extends LitElement {
|
|
|
317
328
|
if (orderA !== orderB) {
|
|
318
329
|
return orderA - orderB
|
|
319
330
|
}
|
|
320
|
-
console.log('Sorting by label', labelA, labelB, labelA.localeCompare(labelB))
|
|
321
331
|
return labelA.localeCompare(labelB)
|
|
322
332
|
})
|
|
323
333
|
)
|
|
@@ -381,14 +391,15 @@ export class WidgetLinechart extends LitElement {
|
|
|
381
391
|
option.series = chart.series
|
|
382
392
|
// console.log('Applying data to chart', label, option)
|
|
383
393
|
if (chart.series.length <= 1) option.legend.show = false
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
394
|
+
const now = Date.now()
|
|
395
|
+
const timeSinceLastUpdate = now - this.lastUpdateTime
|
|
396
|
+
this.lastUpdateTime = now
|
|
397
|
+
|
|
398
|
+
const tooFast = timeSinceLastUpdate < this.updateThresholdMs
|
|
399
|
+
option.animation = !tooFast
|
|
400
|
+
option.animationDuration = tooFast ? 0 : this.updateThresholdMs
|
|
401
|
+
chart.echart?.on('finished', () => (chart.drawing = false))
|
|
402
|
+
chart.drawing = true
|
|
392
403
|
chart.echart?.setOption(option, { notMerge })
|
|
393
404
|
// chart.echart?.resize()
|
|
394
405
|
})
|
|
@@ -418,10 +429,14 @@ export class WidgetLinechart extends LitElement {
|
|
|
418
429
|
newContainer.setAttribute('name', label)
|
|
419
430
|
newContainer.setAttribute('class', 'sizer')
|
|
420
431
|
this.chartContainer.appendChild(newContainer)
|
|
421
|
-
console.log('Setting up chart for label:', label)
|
|
422
432
|
|
|
423
433
|
const newChart = echarts.init(newContainer, this.theme?.theme_name)
|
|
424
|
-
const chart = {
|
|
434
|
+
const chart = {
|
|
435
|
+
echart: newChart,
|
|
436
|
+
series: [] as SeriesOptionX[],
|
|
437
|
+
element: newContainer,
|
|
438
|
+
drawing: false
|
|
439
|
+
}
|
|
425
440
|
this.canvasList.set(label, chart)
|
|
426
441
|
|
|
427
442
|
return chart
|