@record-evolution/widget-gauge 1.7.8 → 1.7.10
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/tsconfig.tsbuildinfo +1 -1
- package/dist/widget-gauge.js +12 -7
- package/dist/widget-gauge.js.map +1 -1
- package/package.json +1 -1
- package/src/default-data.json +17 -0
- package/src/widget-gauge.ts +13 -7
package/package.json
CHANGED
package/src/default-data.json
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dataseries": [
|
|
3
|
+
{
|
|
4
|
+
"label": "Demo Gauge Temperature",
|
|
5
|
+
"unit": "°C",
|
|
6
|
+
"precision": 1,
|
|
7
|
+
"data": [
|
|
8
|
+
{
|
|
9
|
+
"value": 83
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"sections": {
|
|
13
|
+
"sectionLimits": [],
|
|
14
|
+
"backgroundColors": []
|
|
15
|
+
},
|
|
16
|
+
"advanced": {
|
|
17
|
+
"averageLatest": 1
|
|
18
|
+
}
|
|
19
|
+
},
|
|
3
20
|
{
|
|
4
21
|
"label": "Demo Gauge Pascal",
|
|
5
22
|
"unit": "Pa",
|
package/src/widget-gauge.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { html, css, LitElement, PropertyValueMap } from 'lit'
|
|
2
2
|
import { customElement, property, state } from 'lit/decorators.js'
|
|
3
|
-
import { GaugeChartConfiguration } from './definition-schema.js'
|
|
3
|
+
import { GaugeChartConfiguration, SectionBackgroundColors } from './definition-schema.js'
|
|
4
4
|
|
|
5
5
|
import * as echarts from 'echarts/core'
|
|
6
6
|
import { TooltipComponent } from 'echarts/components'
|
|
@@ -263,7 +263,7 @@ export class WidgetGauge extends LitElement {
|
|
|
263
263
|
this.boxes = Array.from(this?.shadowRoot?.querySelectorAll('.chart') as NodeListOf<HTMLDivElement>)
|
|
264
264
|
|
|
265
265
|
this.boxes?.forEach((box) =>
|
|
266
|
-
box.setAttribute('style', `width:${modifier * chartW}px; height:${modifier * (chartH -
|
|
266
|
+
box.setAttribute('style', `width:${modifier * chartW}px; height:${modifier * (chartH - 27)}px`)
|
|
267
267
|
)
|
|
268
268
|
|
|
269
269
|
this.modifier = modifier
|
|
@@ -346,7 +346,7 @@ export class WidgetGauge extends LitElement {
|
|
|
346
346
|
|
|
347
347
|
ga.data[0].value = ds.needleValue
|
|
348
348
|
ga.data[0].name = ds.unit
|
|
349
|
-
ga.title.fontSize =
|
|
349
|
+
ga.title.fontSize = 20 * modifier
|
|
350
350
|
ga.title.color = ds.valueColor ?? this.themeTitleColor
|
|
351
351
|
ga.detail.color = ds.valueColor ?? this.themeTitleColor
|
|
352
352
|
ga.detail.fontSize = 40 * modifier
|
|
@@ -356,14 +356,20 @@ export class WidgetGauge extends LitElement {
|
|
|
356
356
|
// ga.pointer.itemStyle.color = ds.valueColor
|
|
357
357
|
|
|
358
358
|
// Axis
|
|
359
|
-
const sectionLimits = ds.sections?.sectionLimits
|
|
359
|
+
const sectionLimits = !ds.sections?.sectionLimits?.length
|
|
360
|
+
? [0, 40, 80, 100]
|
|
361
|
+
: ds.sections?.sectionLimits
|
|
360
362
|
ga2.min = sectionLimits?.length ? Math.min(...sectionLimits) : 0
|
|
361
363
|
ga2.max = sectionLimits?.length ? Math.max(...sectionLimits) : 100
|
|
362
364
|
ga.min = ga2.min
|
|
363
365
|
ga.max = ga2.max
|
|
364
366
|
|
|
365
|
-
const tcolors = this.theme?.theme_object?.color
|
|
366
|
-
const
|
|
367
|
+
const tcolors: SectionBackgroundColors = this.theme?.theme_object?.color
|
|
368
|
+
const bcolors: SectionBackgroundColors = !ds.sections?.backgroundColors?.length
|
|
369
|
+
? (tcolors?.slice(0, 3) ?? ['#bf444c', '#d88273', '#f6efa6'])
|
|
370
|
+
: ds.sections?.backgroundColors
|
|
371
|
+
|
|
372
|
+
const colors: SectionBackgroundColors = bcolors?.map(
|
|
367
373
|
(b, i) => b || tcolors[i % (tcolors?.length ?? 0)]
|
|
368
374
|
) ??
|
|
369
375
|
tcolors?.slice(0, 3) ?? ['#bf444c', '#d88273', '#f6efa6']
|
|
@@ -399,7 +405,7 @@ export class WidgetGauge extends LitElement {
|
|
|
399
405
|
if (titleElement) {
|
|
400
406
|
titleElement.style.fontSize = String(20 * modifier) + 'px'
|
|
401
407
|
titleElement.style.maxWidth = String(300 * modifier) + 'px'
|
|
402
|
-
titleElement.style.height = String(
|
|
408
|
+
titleElement.style.height = String(27 * modifier) + 'px'
|
|
403
409
|
titleElement.textContent = ds.label ?? ''
|
|
404
410
|
}
|
|
405
411
|
|