@record-evolution/widget-gauge 1.7.15 → 1.7.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": "REWidget widget-gauge",
4
4
  "license": "MIT",
5
5
  "author": "widget-gauge",
6
- "version": "1.7.15",
6
+ "version": "1.7.17",
7
7
  "type": "module",
8
8
  "main": "dist/widget-gauge.js",
9
9
  "types": "dist/src/widget-gauge.d.ts",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "echarts": "5.6.0",
27
- "lit": "^3.3.0"
27
+ "lit": "^3.3.1"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@custom-elements-manifest/analyzer": "^0.10.4",
@@ -15,12 +15,20 @@ export type Unit = string;
15
15
  /**
16
16
  * The number of decimal places to show in the value. If not specified, precision is 0.
17
17
  */
18
- export type Precision = number;
18
+ export type Decimals = number;
19
+ /**
20
+ * Draw multiple Charts based on the split column of a data table.
21
+ */
22
+ export type MultiChart = boolean;
23
+ /**
24
+ * The value of the gauge
25
+ */
26
+ export type Value = number;
19
27
  /**
20
28
  * This should be an ISO String date like 2023-11-04T22:47:52.351152+00:00. Will only be used to detect data age of data.
21
29
  */
22
30
  export type Timestamp = string;
23
- export type Value = number;
31
+ export type Value1 = number;
24
32
  /**
25
33
  * You can specify a table column to autogenerate dataseries for each distinct entry in this column. E.g. if you have a table with columns [city, timestamp, temperature] and specify ''city'' as split column, then you will get a gauge for each city.
26
34
  */
@@ -30,7 +38,7 @@ export type SplitDataBy = string;
30
38
  */
31
39
  export type Data = {
32
40
  tsp?: Timestamp;
33
- value?: Value;
41
+ value?: Value1;
34
42
  pivot?: SplitDataBy;
35
43
  [k: string]: unknown;
36
44
  }[];
@@ -56,7 +64,9 @@ export type Gauges = {
56
64
  label?: Label;
57
65
  valueColor?: ValueColor;
58
66
  unit?: Unit;
59
- precision?: Precision;
67
+ precision?: Decimals;
68
+ multiChart?: MultiChart;
69
+ value?: Value;
60
70
  data?: Data;
61
71
  sections?: GaugeColorSections;
62
72
  advanced?: AdvancedConfiguration;
@@ -39,17 +39,38 @@
39
39
  "order": 3
40
40
  },
41
41
  "precision": {
42
- "title": "Precision",
42
+ "title": "Decimals",
43
43
  "description": "The number of decimal places to show in the value. If not specified, precision is 0.",
44
44
  "type": "number",
45
- "dataDrivenDisabled": false,
45
+ "dataDrivenDisabled": true,
46
46
  "order": 4
47
47
  },
48
+ "multiChart": {
49
+ "title": "Multi Chart",
50
+ "description": "Draw multiple Charts based on the split column of a data table.",
51
+ "type": "boolean",
52
+ "dataDrivenDisabled": true,
53
+ "order": 6
54
+ },
55
+ "value": {
56
+ "title": "Value",
57
+ "description": "The value of the gauge",
58
+ "type": "number",
59
+ "condition": {
60
+ "relativePath": "../multiChart",
61
+ "showIfValueIn": [false]
62
+ },
63
+ "order": 5
64
+ },
48
65
  "data": {
49
66
  "title": "Data",
50
67
  "description": "Provide a list of values. Only the latest value is shown in the gauge unless you configure \"Advanced Settings\" below or use split data.",
51
68
  "type": "array",
52
- "order": 4,
69
+ "condition": {
70
+ "relativePath": "../multiChart",
71
+ "showIfValueIn": [true]
72
+ },
73
+ "order": 7,
53
74
  "items": {
54
75
  "type": "object",
55
76
  "properties": {
@@ -78,7 +99,7 @@
78
99
  "title": "Gauge Color Sections",
79
100
  "description": "",
80
101
  "type": "object",
81
- "order": 5,
102
+ "order": 8,
82
103
  "properties": {
83
104
  "sectionLimits": {
84
105
  "title": "Section Limits",
@@ -108,7 +129,7 @@
108
129
  "title": "Advanced Configuration",
109
130
  "description": "",
110
131
  "type": "object",
111
- "order": 6,
132
+ "order": 9,
112
133
  "properties": {
113
134
  "averageLatest": {
114
135
  "title": "Average Latest Values",
@@ -292,6 +292,8 @@ export class WidgetGauge extends LitElement {
292
292
  advanced: ds.advanced,
293
293
  valueColor: ds.valueColor,
294
294
  sections: ds.sections,
295
+ multiChart: ds.multiChart,
296
+ value: ds.value,
295
297
  data: distincts.length === 1 ? ds.data : ds?.data?.filter((d) => d.pivot === piv)
296
298
  }
297
299
  this.dataSets.push(pds)
@@ -317,10 +319,15 @@ export class WidgetGauge extends LitElement {
317
319
  if (typeof ds.advanced?.averageLatest !== 'number' || isNaN(ds.advanced?.averageLatest))
318
320
  ds.advanced.averageLatest = 1
319
321
  const data = ds?.data?.slice(-ds.advanced?.averageLatest || -1) ?? []
320
- const values = (data?.map((d) => d.value)?.filter((p) => p !== undefined) ?? []) as number[]
321
- const average = values.reduce((p, c) => p + c, 0) / values.length
322
-
323
- ds.needleValue = isNaN(average) ? ds.sections?.sectionLimits?.[0] : average
322
+ if (!ds.multiChart) {
323
+ ds.needleValue = ds.value as number
324
+ } else {
325
+ const values = (data?.map((d) => d.value)?.filter((p) => p !== undefined) ?? []) as number[]
326
+ ds.needleValue = (values.reduce((p, c) => p + c, 0) / values.length) as number
327
+ }
328
+ ds.needleValue = isNaN(ds.needleValue as number)
329
+ ? ds.sections?.sectionLimits?.[0]
330
+ : ds.needleValue
324
331
 
325
332
  // The full range of the gauge
326
333
  ds.range =