@record-evolution/widget-gauge 1.7.17 → 1.7.19
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/dist/src/widget-gauge.d.ts +4 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/widget-gauge.js +4542 -2962
- package/dist/widget-gauge.js.map +1 -1
- package/package.json +4 -4
- package/src/default-data.json +1 -5
- package/src/widget-gauge.ts +32 -43
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "REWidget widget-gauge",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "widget-gauge",
|
|
6
|
-
"version": "1.7.
|
|
6
|
+
"version": "1.7.19",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/widget-gauge.js",
|
|
9
9
|
"types": "dist/src/widget-gauge.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"release": "npm run build && npm run types && npm version patch --tag-version-prefix='' && git push && git push --tag && npm run build"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"echarts": "
|
|
26
|
+
"echarts": "6.0.0",
|
|
27
27
|
"lit": "^3.3.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"eslint": "^9.29.0",
|
|
41
41
|
"eslint-config-prettier": "^10.1.5",
|
|
42
42
|
"json-schema-to-typescript": "^15.0.4",
|
|
43
|
-
"prettier": "^3.
|
|
44
|
-
"rollup": "^4.
|
|
43
|
+
"prettier": "^3.6.2",
|
|
44
|
+
"rollup": "^4.52.4",
|
|
45
45
|
"typescript": "5.8.3"
|
|
46
46
|
},
|
|
47
47
|
"repository": {
|
package/src/default-data.json
CHANGED
package/src/widget-gauge.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { html, css, LitElement, PropertyValueMap } from 'lit'
|
|
2
|
-
import { customElement, property, state } from 'lit/decorators.js'
|
|
1
|
+
import { html, css, LitElement, PropertyValueMap, PropertyValues } from 'lit'
|
|
2
|
+
import { customElement, property, query, state } from 'lit/decorators.js'
|
|
3
3
|
import { GaugeChartConfiguration, SectionBackgroundColors } from './definition-schema.js'
|
|
4
4
|
|
|
5
5
|
import * as echarts from 'echarts/core'
|
|
@@ -37,15 +37,17 @@ export class WidgetGauge extends LitElement {
|
|
|
37
37
|
@state() private themeTitleColor?: string
|
|
38
38
|
@state() private themeSubtitleColor?: string
|
|
39
39
|
|
|
40
|
+
@query('.gauge-container') private gaugeContainer?: HTMLDivElement
|
|
41
|
+
@query('.wrapper') private wrapper?: HTMLDivElement
|
|
42
|
+
|
|
40
43
|
private resizeObserver: ResizeObserver
|
|
41
44
|
|
|
42
45
|
boxes?: HTMLDivElement[]
|
|
43
|
-
origWidth: number =
|
|
44
|
-
origHeight: number =
|
|
46
|
+
origWidth: number = 600
|
|
47
|
+
origHeight: number = 350
|
|
45
48
|
template: EChartsOption
|
|
46
49
|
modifier: number = 1
|
|
47
50
|
version: string = 'versionplaceholder'
|
|
48
|
-
gaugeContainer: HTMLDivElement | null | undefined
|
|
49
51
|
|
|
50
52
|
constructor() {
|
|
51
53
|
super()
|
|
@@ -160,9 +162,6 @@ export class WidgetGauge extends LitElement {
|
|
|
160
162
|
if (changedProperties.has('inputData') && this.gaugeContainer) {
|
|
161
163
|
this.transformData()
|
|
162
164
|
this.setupCharts()
|
|
163
|
-
this.sizingSetup()
|
|
164
|
-
this.adjustSizes()
|
|
165
|
-
this.applyData()
|
|
166
165
|
}
|
|
167
166
|
|
|
168
167
|
if (changedProperties.has('theme')) {
|
|
@@ -170,20 +169,24 @@ export class WidgetGauge extends LitElement {
|
|
|
170
169
|
this.deleteCharts()
|
|
171
170
|
this.transformData()
|
|
172
171
|
this.setupCharts()
|
|
173
|
-
this.sizingSetup()
|
|
174
172
|
this.adjustSizes()
|
|
175
173
|
this.applyData()
|
|
176
174
|
}
|
|
177
175
|
super.update(changedProperties)
|
|
178
176
|
}
|
|
179
177
|
|
|
178
|
+
protected updated(changedProperties: PropertyValues): void {
|
|
179
|
+
if (changedProperties.has('inputData') && this.gaugeContainer) {
|
|
180
|
+
this.adjustSizes()
|
|
181
|
+
this.applyData()
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
180
185
|
protected firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void {
|
|
181
|
-
this.resizeObserver.observe(this.
|
|
182
|
-
this.gaugeContainer = this.shadowRoot?.querySelector('.gauge-container')
|
|
186
|
+
if (this.wrapper) this.resizeObserver.observe(this.wrapper)
|
|
183
187
|
this.registerTheme(this.theme)
|
|
184
188
|
this.transformData()
|
|
185
189
|
this.setupCharts()
|
|
186
|
-
this.sizingSetup()
|
|
187
190
|
this.adjustSizes()
|
|
188
191
|
this.applyData()
|
|
189
192
|
}
|
|
@@ -197,23 +200,9 @@ export class WidgetGauge extends LitElement {
|
|
|
197
200
|
cssTextColor || this.theme?.theme_object?.title?.subtextStyle?.color || this.themeTitleColor
|
|
198
201
|
|
|
199
202
|
if (!theme || !theme.theme_object || !theme.theme_name) return
|
|
200
|
-
|
|
201
203
|
echarts.registerTheme(theme.theme_name, theme.theme_object)
|
|
202
204
|
}
|
|
203
205
|
|
|
204
|
-
sizingSetup() {
|
|
205
|
-
if (this.origWidth !== 0 && this.origHeight !== 0) return
|
|
206
|
-
|
|
207
|
-
this.boxes =
|
|
208
|
-
Array.from(this?.shadowRoot?.querySelectorAll('.chart-wrapper') as NodeListOf<HTMLDivElement>) ??
|
|
209
|
-
[]
|
|
210
|
-
if (!this.boxes.length) return
|
|
211
|
-
this.origWidth = 600
|
|
212
|
-
// this.boxes?.map((b) => b.getBoundingClientRect().width).reduce((p, c) => (c > p ? c : p), 0) ?? 0
|
|
213
|
-
this.origHeight = 230
|
|
214
|
-
// this.boxes?.map((b) => b.getBoundingClientRect().height).reduce((p, c) => (c > p ? c : p), 0) ?? 0
|
|
215
|
-
}
|
|
216
|
-
|
|
217
206
|
adjustSizes() {
|
|
218
207
|
// if (!this.origHeight) return
|
|
219
208
|
if (!this.gaugeContainer) return
|
|
@@ -245,7 +234,8 @@ export class WidgetGauge extends LitElement {
|
|
|
245
234
|
|
|
246
235
|
const maxSize = fits.reduce((p, c) => (c.size < p ? p : c.size), 0)
|
|
247
236
|
const fit = fits.find((f) => f.size === maxSize)
|
|
248
|
-
|
|
237
|
+
if (!fit) return
|
|
238
|
+
const modifier = fit.m ?? 0
|
|
249
239
|
|
|
250
240
|
// console.log(
|
|
251
241
|
// 'FITS count',
|
|
@@ -259,7 +249,9 @@ export class WidgetGauge extends LitElement {
|
|
|
259
249
|
// (userWidth * userHeight).toFixed(0),
|
|
260
250
|
// this.boxes
|
|
261
251
|
// )
|
|
262
|
-
this.boxes = Array.from(this?.
|
|
252
|
+
this.boxes = Array.from(this.gaugeContainer?.querySelectorAll('.chart') as NodeListOf<HTMLDivElement>)
|
|
253
|
+
|
|
254
|
+
this.gaugeContainer.style.gridTemplateColumns = `repeat(${fit.c}, 1fr)`
|
|
263
255
|
|
|
264
256
|
this.boxes?.forEach((box) =>
|
|
265
257
|
box.setAttribute('style', `width:${modifier * chartW}px; height:${modifier * (chartH - 27)}px`)
|
|
@@ -278,15 +270,18 @@ export class WidgetGauge extends LitElement {
|
|
|
278
270
|
if (!this?.inputData) return
|
|
279
271
|
this.inputData.dataseries
|
|
280
272
|
?.sort((a, b) => ((a.label ?? '') > (b.label ?? '') ? 1 : -1))
|
|
281
|
-
.forEach((ds) => {
|
|
273
|
+
.forEach((ds, idx) => {
|
|
282
274
|
// pivot data
|
|
283
|
-
const distincts =
|
|
284
|
-
|
|
275
|
+
const distincts = ds.multiChart
|
|
276
|
+
? ([...new Set(ds.data?.map((d: Data) => d.pivot))].sort() as string[])
|
|
277
|
+
: ['']
|
|
285
278
|
distincts.forEach((piv) => {
|
|
286
279
|
const prefix = piv ?? ''
|
|
287
|
-
|
|
280
|
+
let label = ds.label?.trim() ?? ''
|
|
281
|
+
label = prefix + (!!prefix && !!label ? ' - ' : '') + label
|
|
282
|
+
if (this.dataSets.some((ds) => ds.label === label)) label += ' ' + idx
|
|
288
283
|
const pds: any = {
|
|
289
|
-
label:
|
|
284
|
+
label: label,
|
|
290
285
|
unit: ds.unit,
|
|
291
286
|
precision: ds.precision,
|
|
292
287
|
advanced: ds.advanced,
|
|
@@ -309,7 +304,6 @@ export class WidgetGauge extends LitElement {
|
|
|
309
304
|
})
|
|
310
305
|
|
|
311
306
|
this.dataSets.sort((a, b) => ((a.label as string) > (b.label as string) ? 1 : -1))
|
|
312
|
-
this.requestUpdate()
|
|
313
307
|
|
|
314
308
|
for (const ds of this.dataSets) {
|
|
315
309
|
// compute derivative values
|
|
@@ -354,10 +348,10 @@ export class WidgetGauge extends LitElement {
|
|
|
354
348
|
ga.data[0].name = ds.unit
|
|
355
349
|
// unit style
|
|
356
350
|
ga.title.fontSize = 20 * modifier
|
|
357
|
-
ga.title.color = ds.valueColor
|
|
351
|
+
ga.title.color = ds.valueColor || this.themeTitleColor
|
|
358
352
|
ga.title.opacity = 1
|
|
359
353
|
// value style
|
|
360
|
-
ga.detail.color = ds.valueColor
|
|
354
|
+
ga.detail.color = ds.valueColor || this.themeTitleColor
|
|
361
355
|
ga.detail.opacity = 1
|
|
362
356
|
ga.detail.fontSize = 40 * modifier
|
|
363
357
|
|
|
@@ -454,7 +448,7 @@ export class WidgetGauge extends LitElement {
|
|
|
454
448
|
newCanvas.setAttribute('class', 'chart')
|
|
455
449
|
newCanvas.setAttribute(
|
|
456
450
|
'style',
|
|
457
|
-
`min-width:
|
|
451
|
+
`min-width: ${this.origWidth}; min-height: ${this.origHeight}; width: ${this.origWidth}; height: ${this.origHeight};`
|
|
458
452
|
)
|
|
459
453
|
|
|
460
454
|
newWrapper!.appendChild(newTitle)
|
|
@@ -495,7 +489,7 @@ export class WidgetGauge extends LitElement {
|
|
|
495
489
|
align-items: center;
|
|
496
490
|
}
|
|
497
491
|
.gauge-container {
|
|
498
|
-
display:
|
|
492
|
+
display: grid;
|
|
499
493
|
flex: 1;
|
|
500
494
|
justify-content: center;
|
|
501
495
|
align-items: center;
|
|
@@ -526,11 +520,6 @@ export class WidgetGauge extends LitElement {
|
|
|
526
520
|
white-space: nowrap;
|
|
527
521
|
}
|
|
528
522
|
|
|
529
|
-
.chart {
|
|
530
|
-
width: 600px; /* will be overriden by adjustSizes */
|
|
531
|
-
height: 230px;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
523
|
.no-data {
|
|
535
524
|
font-size: 20px;
|
|
536
525
|
display: flex;
|