@record-evolution/widget-gauge 1.7.18 → 1.7.20
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 +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/widget-gauge.js +4539 -2970
- package/dist/widget-gauge.js.map +1 -1
- package/package.json +4 -4
- package/src/default-data.json +13 -0
- package/src/widget-gauge.ts +22 -11
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.20",
|
|
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
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dataseries": [
|
|
3
|
+
{
|
|
4
|
+
"label": "Temperature",
|
|
5
|
+
"unit": "°C",
|
|
6
|
+
"precision": 1,
|
|
7
|
+
"value": 83,
|
|
8
|
+
"sections": {
|
|
9
|
+
"sectionLimits": [],
|
|
10
|
+
"backgroundColors": []
|
|
11
|
+
},
|
|
12
|
+
"advanced": {
|
|
13
|
+
"averageLatest": 1
|
|
14
|
+
}
|
|
15
|
+
},
|
|
3
16
|
{
|
|
4
17
|
"label": "Temperature",
|
|
5
18
|
"unit": "°C",
|
package/src/widget-gauge.ts
CHANGED
|
@@ -45,6 +45,7 @@ export class WidgetGauge extends LitElement {
|
|
|
45
45
|
boxes?: HTMLDivElement[]
|
|
46
46
|
origWidth: number = 600
|
|
47
47
|
origHeight: number = 350
|
|
48
|
+
textContainerHeight: number = 36
|
|
48
49
|
template: EChartsOption
|
|
49
50
|
modifier: number = 1
|
|
50
51
|
version: string = 'versionplaceholder'
|
|
@@ -234,7 +235,8 @@ export class WidgetGauge extends LitElement {
|
|
|
234
235
|
|
|
235
236
|
const maxSize = fits.reduce((p, c) => (c.size < p ? p : c.size), 0)
|
|
236
237
|
const fit = fits.find((f) => f.size === maxSize)
|
|
237
|
-
|
|
238
|
+
if (!fit) return
|
|
239
|
+
const modifier = fit.m ?? 0
|
|
238
240
|
|
|
239
241
|
// console.log(
|
|
240
242
|
// 'FITS count',
|
|
@@ -250,8 +252,13 @@ export class WidgetGauge extends LitElement {
|
|
|
250
252
|
// )
|
|
251
253
|
this.boxes = Array.from(this.gaugeContainer?.querySelectorAll('.chart') as NodeListOf<HTMLDivElement>)
|
|
252
254
|
|
|
255
|
+
this.gaugeContainer.style.gridTemplateColumns = `repeat(${fit.c}, 1fr)`
|
|
256
|
+
|
|
253
257
|
this.boxes?.forEach((box) =>
|
|
254
|
-
box.setAttribute(
|
|
258
|
+
box.setAttribute(
|
|
259
|
+
'style',
|
|
260
|
+
`width:${modifier * chartW}px; height:${modifier * (chartH - this.textContainerHeight)}px`
|
|
261
|
+
)
|
|
255
262
|
)
|
|
256
263
|
|
|
257
264
|
this.modifier = modifier
|
|
@@ -267,16 +274,18 @@ export class WidgetGauge extends LitElement {
|
|
|
267
274
|
if (!this?.inputData) return
|
|
268
275
|
this.inputData.dataseries
|
|
269
276
|
?.sort((a, b) => ((a.label ?? '') > (b.label ?? '') ? 1 : -1))
|
|
270
|
-
.forEach((ds) => {
|
|
277
|
+
.forEach((ds, idx) => {
|
|
271
278
|
// pivot data
|
|
272
279
|
const distincts = ds.multiChart
|
|
273
280
|
? ([...new Set(ds.data?.map((d: Data) => d.pivot))].sort() as string[])
|
|
274
281
|
: ['']
|
|
275
282
|
distincts.forEach((piv) => {
|
|
276
283
|
const prefix = piv ?? ''
|
|
277
|
-
|
|
284
|
+
let label = ds.label?.trim() ?? ''
|
|
285
|
+
label = prefix + (!!prefix && !!label ? ' - ' : '') + label
|
|
286
|
+
if (this.dataSets.some((ds) => ds.label === label)) label += ' ' + idx
|
|
278
287
|
const pds: any = {
|
|
279
|
-
label:
|
|
288
|
+
label: label,
|
|
280
289
|
unit: ds.unit,
|
|
281
290
|
precision: ds.precision,
|
|
282
291
|
advanced: ds.advanced,
|
|
@@ -342,13 +351,14 @@ export class WidgetGauge extends LitElement {
|
|
|
342
351
|
ga.data[0].value = ds.needleValue
|
|
343
352
|
ga.data[0].name = ds.unit
|
|
344
353
|
// unit style
|
|
345
|
-
|
|
354
|
+
|
|
355
|
+
ga.title.fontSize = 32 * modifier
|
|
346
356
|
ga.title.color = ds.valueColor || this.themeTitleColor
|
|
347
357
|
ga.title.opacity = 1
|
|
348
358
|
// value style
|
|
349
359
|
ga.detail.color = ds.valueColor || this.themeTitleColor
|
|
350
360
|
ga.detail.opacity = 1
|
|
351
|
-
ga.detail.fontSize =
|
|
361
|
+
ga.detail.fontSize = 60 * modifier
|
|
352
362
|
|
|
353
363
|
ga.detail.formatter = (val: number) =>
|
|
354
364
|
isNaN(val) ? '-' : val.toFixed(Math.floor(ds.precision ?? 0))
|
|
@@ -383,7 +393,7 @@ export class WidgetGauge extends LitElement {
|
|
|
383
393
|
ga2.axisLine.lineStyle.color = colorSections?.length
|
|
384
394
|
? colorSections
|
|
385
395
|
: ga2.axisLine.lineStyle.color
|
|
386
|
-
ga2.axisLabel.fontSize =
|
|
396
|
+
ga2.axisLabel.fontSize = 24 * modifier
|
|
387
397
|
// ga2.axisLabel.color = ds.valueColor
|
|
388
398
|
ga2.axisLabel.distance = -24 * modifier
|
|
389
399
|
ga2.splitLine.length = 16 * modifier
|
|
@@ -402,9 +412,9 @@ export class WidgetGauge extends LitElement {
|
|
|
402
412
|
|
|
403
413
|
const titleElement = this.canvasList.get(ds.label)?.title
|
|
404
414
|
if (titleElement) {
|
|
405
|
-
titleElement.style.fontSize = String(
|
|
415
|
+
titleElement.style.fontSize = String(36 * modifier) + 'px'
|
|
406
416
|
titleElement.style.maxWidth = String(300 * modifier) + 'px'
|
|
407
|
-
titleElement.style.height = String(
|
|
417
|
+
titleElement.style.height = String(this.textContainerHeight * modifier) + 'px'
|
|
408
418
|
titleElement.textContent = ds.label ?? ''
|
|
409
419
|
}
|
|
410
420
|
|
|
@@ -484,7 +494,7 @@ export class WidgetGauge extends LitElement {
|
|
|
484
494
|
align-items: center;
|
|
485
495
|
}
|
|
486
496
|
.gauge-container {
|
|
487
|
-
display:
|
|
497
|
+
display: grid;
|
|
488
498
|
flex: 1;
|
|
489
499
|
justify-content: center;
|
|
490
500
|
align-items: center;
|
|
@@ -504,6 +514,7 @@ export class WidgetGauge extends LitElement {
|
|
|
504
514
|
overflow: hidden;
|
|
505
515
|
text-overflow: ellipsis;
|
|
506
516
|
white-space: nowrap;
|
|
517
|
+
line-height: 1;
|
|
507
518
|
}
|
|
508
519
|
p {
|
|
509
520
|
margin: 10px 0 0 0;
|