@record-evolution/widget-linechart 1.6.2 → 1.6.4
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-linechart.js +56 -40
- package/dist/widget-linechart.js.map +1 -1
- package/package.json +5 -3
- package/src/default-data.json +2 -5
- package/src/definition-schema.d.ts +5 -5
- package/src/definition-schema.json +14 -14
- package/src/widget-linechart.ts +52 -38
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.4",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/widget-linechart.js",
|
|
9
9
|
"types": "dist/src/widget-linechart.d.ts",
|
|
@@ -14,12 +14,14 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"analyze": "cem analyze --litelement",
|
|
16
16
|
"start": "concurrently -k -r \"npm run watch\" \"wds\"",
|
|
17
|
-
"link": "
|
|
17
|
+
"link": "npm run build && npm link && cd ../RESWARM/frontend && npm link @record-evolution/widget-linechart",
|
|
18
18
|
"unlink": "npm unlink --global && cd ../RESWARM/frontend && npm unlink @record-evolution/widget-linechart && npm i @record-evolution/widget-linechart",
|
|
19
19
|
"build": "rollup -c rollup.config.js",
|
|
20
20
|
"watch": "rollup -w -c rollup.config.js",
|
|
21
21
|
"types": "cat src/definition-schema.json | json2ts --style.tabWidth=4 > src/definition-schema.d.ts",
|
|
22
|
-
"
|
|
22
|
+
"patch": "npm version patch --tag-version-prefix=''",
|
|
23
|
+
"minor": "npm version minor --tag-version-prefix=''",
|
|
24
|
+
"release": "npm run build && npm run types && git push && git push --tag"
|
|
23
25
|
},
|
|
24
26
|
"dependencies": {
|
|
25
27
|
"echarts": "5.6.0",
|
package/src/default-data.json
CHANGED
|
@@ -13,14 +13,12 @@
|
|
|
13
13
|
{
|
|
14
14
|
"label": "Demo Bubble",
|
|
15
15
|
"type": "scatter",
|
|
16
|
-
|
|
17
16
|
"styling": {
|
|
18
17
|
"borderWidth": 2,
|
|
19
18
|
"fill": false
|
|
20
19
|
},
|
|
21
20
|
"advanced": {
|
|
22
|
-
"drawOrder": 1
|
|
23
|
-
"chartName": "Demo Bubble Chart"
|
|
21
|
+
"drawOrder": 1
|
|
24
22
|
},
|
|
25
23
|
"data": [
|
|
26
24
|
{
|
|
@@ -43,7 +41,6 @@
|
|
|
43
41
|
{
|
|
44
42
|
"label": "Demo Bar",
|
|
45
43
|
"type": "bar",
|
|
46
|
-
|
|
47
44
|
"styling": {
|
|
48
45
|
"borderWidth": 2,
|
|
49
46
|
"pointStyle": "circle",
|
|
@@ -77,7 +74,7 @@
|
|
|
77
74
|
"styling": {
|
|
78
75
|
"fill": false,
|
|
79
76
|
"borderWidth": 2,
|
|
80
|
-
"borderDash": "
|
|
77
|
+
"borderDash": "dashed",
|
|
81
78
|
"pointStyle": "circle"
|
|
82
79
|
},
|
|
83
80
|
|
|
@@ -7,16 +7,16 @@
|
|
|
7
7
|
|
|
8
8
|
export type Title = string;
|
|
9
9
|
export type Subtitle = string;
|
|
10
|
+
export type XAxisLabel = string;
|
|
11
|
+
export type YAxisLabel = string;
|
|
10
12
|
/**
|
|
11
13
|
* This will apply a proper time series x-Axis. Check if your x-values are timestamps.
|
|
12
14
|
*/
|
|
13
15
|
export type TimeseriesChart = boolean;
|
|
14
|
-
export type XAxisLabel = string;
|
|
15
16
|
/**
|
|
16
17
|
* If checked, a zoom tool will be shown on the x-axis to zoom into the chart.
|
|
17
18
|
*/
|
|
18
19
|
export type XAxisZoomTool = boolean;
|
|
19
|
-
export type YAxisLabel = string;
|
|
20
20
|
/**
|
|
21
21
|
* If checked, the Y-Axis will be scaled to the data range. If not checked, the Y-Axis will always start at 0.
|
|
22
22
|
*/
|
|
@@ -54,7 +54,7 @@ export type ChartName = string;
|
|
|
54
54
|
export type XValue = string;
|
|
55
55
|
export type YValue = number;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* Controls the symbol size for line and scatter charts.
|
|
58
58
|
*/
|
|
59
59
|
export type BubbleSize = number;
|
|
60
60
|
/**
|
|
@@ -90,10 +90,10 @@ export interface InputData {
|
|
|
90
90
|
[k: string]: unknown;
|
|
91
91
|
}
|
|
92
92
|
export interface AxisSettings {
|
|
93
|
-
timeseries?: TimeseriesChart;
|
|
94
93
|
xAxisLabel?: XAxisLabel;
|
|
95
|
-
xAxisZoom?: XAxisZoomTool;
|
|
96
94
|
yAxisLabel?: YAxisLabel;
|
|
95
|
+
timeseries?: TimeseriesChart;
|
|
96
|
+
xAxisZoom?: XAxisZoomTool;
|
|
97
97
|
yAxisScaling?: YAxisScaling;
|
|
98
98
|
columnLayout?: VerticalLayout;
|
|
99
99
|
[k: string]: unknown;
|
|
@@ -17,30 +17,30 @@
|
|
|
17
17
|
"type": "object",
|
|
18
18
|
"order": 3,
|
|
19
19
|
"properties": {
|
|
20
|
-
"timeseries": {
|
|
21
|
-
"title": "Timeseries Chart",
|
|
22
|
-
"description": "This will apply a proper time series x-Axis. Check if your x-values are timestamps.",
|
|
23
|
-
"type": "boolean",
|
|
24
|
-
"dataDrivenDisabled": true,
|
|
25
|
-
"order": 3
|
|
26
|
-
},
|
|
27
20
|
"xAxisLabel": {
|
|
28
21
|
"title": "X-Axis Label",
|
|
29
22
|
"type": "string",
|
|
30
23
|
"dataDrivenDisabled": false,
|
|
24
|
+
"order": 3
|
|
25
|
+
},
|
|
26
|
+
"yAxisLabel": {
|
|
27
|
+
"title": "Y-Axis Label",
|
|
28
|
+
"type": "string",
|
|
29
|
+
"dataDrivenDisabled": false,
|
|
31
30
|
"order": 4
|
|
32
31
|
},
|
|
32
|
+
"timeseries": {
|
|
33
|
+
"title": "Timeseries Chart",
|
|
34
|
+
"description": "This will apply a proper time series x-Axis. Check if your x-values are timestamps.",
|
|
35
|
+
"type": "boolean",
|
|
36
|
+
"dataDrivenDisabled": true,
|
|
37
|
+
"order": 5
|
|
38
|
+
},
|
|
33
39
|
"xAxisZoom": {
|
|
34
40
|
"title": "X-Axis Zoom Tool",
|
|
35
41
|
"type": "boolean",
|
|
36
42
|
"description": "If checked, a zoom tool will be shown on the x-axis to zoom into the chart.",
|
|
37
43
|
"dataDrivenDisabled": true,
|
|
38
|
-
"order": 5
|
|
39
|
-
},
|
|
40
|
-
"yAxisLabel": {
|
|
41
|
-
"title": "Y-Axis Label",
|
|
42
|
-
"type": "string",
|
|
43
|
-
"dataDrivenDisabled": false,
|
|
44
44
|
"order": 6
|
|
45
45
|
},
|
|
46
46
|
"yAxisScaling": {
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
},
|
|
186
186
|
"r": {
|
|
187
187
|
"title": "Bubble Size",
|
|
188
|
-
"description": "
|
|
188
|
+
"description": "Controls the symbol size for line and scatter charts.",
|
|
189
189
|
"order": 3,
|
|
190
190
|
"type": "number"
|
|
191
191
|
},
|
package/src/widget-linechart.ts
CHANGED
|
@@ -71,7 +71,7 @@ export class WidgetLinechart extends LitElement {
|
|
|
71
71
|
this.template = {
|
|
72
72
|
title: {
|
|
73
73
|
text: 'Temperature Change in the Coming Week',
|
|
74
|
-
left:
|
|
74
|
+
left: 20,
|
|
75
75
|
textStyle: {
|
|
76
76
|
fontSize: 14
|
|
77
77
|
}
|
|
@@ -81,7 +81,15 @@ export class WidgetLinechart extends LitElement {
|
|
|
81
81
|
},
|
|
82
82
|
legend: {
|
|
83
83
|
right: '10%',
|
|
84
|
-
top:
|
|
84
|
+
top: 0
|
|
85
|
+
},
|
|
86
|
+
grid: {
|
|
87
|
+
backgroundColor: 'rgba(0, 255, 0, 0.1)',
|
|
88
|
+
top: 30,
|
|
89
|
+
bottom: 20,
|
|
90
|
+
left: 20,
|
|
91
|
+
right: 10,
|
|
92
|
+
containLabel: true // ensures labels are not cut off
|
|
85
93
|
},
|
|
86
94
|
toolbox: {
|
|
87
95
|
show: true,
|
|
@@ -101,17 +109,12 @@ export class WidgetLinechart extends LitElement {
|
|
|
101
109
|
// start: 30,
|
|
102
110
|
// end: 70,
|
|
103
111
|
xAxisIndex: [0, 1]
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
show: false,
|
|
107
|
-
realtime: true,
|
|
108
|
-
// start: 30,
|
|
109
|
-
// end: 70,
|
|
110
|
-
yAxisIndex: [0, 1]
|
|
111
112
|
}
|
|
112
113
|
],
|
|
113
114
|
xAxis: {
|
|
114
115
|
type: 'value', // value, time, log, category
|
|
116
|
+
name: 'Time',
|
|
117
|
+
nameGap: 27,
|
|
115
118
|
nameLocation: 'middle',
|
|
116
119
|
axisLine: {
|
|
117
120
|
lineStyle: {
|
|
@@ -125,6 +128,8 @@ export class WidgetLinechart extends LitElement {
|
|
|
125
128
|
yAxis: {
|
|
126
129
|
type: 'value',
|
|
127
130
|
nameLocation: 'middle',
|
|
131
|
+
name: 'Temperature (°C)',
|
|
132
|
+
nameGap: 30,
|
|
128
133
|
axisLabel: {
|
|
129
134
|
fontSize: 14
|
|
130
135
|
},
|
|
@@ -142,7 +147,8 @@ export class WidgetLinechart extends LitElement {
|
|
|
142
147
|
symbolSize: 8,
|
|
143
148
|
lineStyle: {
|
|
144
149
|
width: 2,
|
|
145
|
-
type: 'solid'
|
|
150
|
+
type: 'solid',
|
|
151
|
+
color: 'green'
|
|
146
152
|
},
|
|
147
153
|
data: [10, 11, 13, 11, 12, 12, 9]
|
|
148
154
|
} as SeriesOption,
|
|
@@ -228,36 +234,41 @@ export class WidgetLinechart extends LitElement {
|
|
|
228
234
|
const prefix = piv ?? ''
|
|
229
235
|
const label = ds.label ?? ''
|
|
230
236
|
const name = prefix + (!!prefix && !!label ? ' - ' : '') + label
|
|
231
|
-
const lineColor = ds.
|
|
232
|
-
? ds.
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
+
const lineColor = ds.borderColor
|
|
238
|
+
? ds.advanced?.chartName?.includes('#split#')
|
|
239
|
+
? ds.borderColor
|
|
240
|
+
: derivedBdColors[i]
|
|
241
|
+
: undefined
|
|
242
|
+
const fillColor = ds.backgroundColor
|
|
243
|
+
? ds.advanced?.chartName?.includes('#split#')
|
|
244
|
+
? ds.backgroundColor
|
|
245
|
+
: derivedBgColors[i]
|
|
246
|
+
: undefined
|
|
237
247
|
const data = distincts.length === 1 ? ds.data : ds.data?.filter((d) => d.pivot === piv)
|
|
238
248
|
const data2 = this.inputData?.axis?.timeseries
|
|
239
|
-
? data?.map((d) =>
|
|
240
|
-
|
|
241
|
-
)
|
|
242
|
-
: data?.map((d) => (d?.r !== undefined ? [d.x, d.y, d.r] : [d.x, d.y]))
|
|
249
|
+
? data?.map((d) => [new Date(d.x ?? ''), d.y, d.r])
|
|
250
|
+
: data?.map((d) => [d.x, d.y, d.r])
|
|
243
251
|
|
|
252
|
+
// preparing the echarts series option for later application
|
|
244
253
|
const pds: SeriesOption = {
|
|
245
254
|
name: name,
|
|
246
255
|
type: ds.type ?? 'line',
|
|
247
256
|
lineStyle: {
|
|
248
257
|
color: lineColor,
|
|
249
258
|
width: ds.styling?.borderWidth ?? 2,
|
|
250
|
-
// @ts-ignore
|
|
251
259
|
type: ds.styling?.borderDash ?? 'solid'
|
|
252
260
|
},
|
|
253
|
-
|
|
261
|
+
itemStyle: {
|
|
262
|
+
color: fillColor,
|
|
263
|
+
borderColor: lineColor,
|
|
264
|
+
borderWidth: ds.styling?.borderWidth ?? 2
|
|
265
|
+
},
|
|
266
|
+
areaStyle: ds.styling?.fill ? { color: fillColor } : undefined,
|
|
254
267
|
symbol: ds.styling?.pointStyle ?? 'circle',
|
|
255
268
|
symbolSize: (data) => data[2] ?? 4,
|
|
256
269
|
showSymbol: ds.styling?.pointStyle === 'none' ? false : true,
|
|
257
270
|
data: data2 ?? []
|
|
258
271
|
}
|
|
259
|
-
// if (ds.type === 'scatter') (pds as ScatterSeriesOption).symbolSize = (data) => data[2]
|
|
260
|
-
|
|
261
272
|
let chartName = ds.advanced?.chartName ?? ''
|
|
262
273
|
if (chartName.includes('#split#')) {
|
|
263
274
|
chartName = prefix + '-' + chartName
|
|
@@ -268,13 +279,16 @@ export class WidgetLinechart extends LitElement {
|
|
|
268
279
|
})
|
|
269
280
|
})
|
|
270
281
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
282
|
+
const doomedCharts: string[] = []
|
|
283
|
+
// remove all doomed charts
|
|
284
|
+
this.canvasList.forEach((chart, label) => {
|
|
285
|
+
if (!chart.doomed) return
|
|
286
|
+
chart.echart?.dispose()
|
|
287
|
+
chart.element?.remove()
|
|
288
|
+
doomedCharts.push(label)
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
doomedCharts.forEach((label) => this.canvasList.delete(label))
|
|
278
292
|
}
|
|
279
293
|
|
|
280
294
|
xAxisType(): 'value' | 'log' | 'category' | 'time' | undefined {
|
|
@@ -298,7 +312,6 @@ export class WidgetLinechart extends LitElement {
|
|
|
298
312
|
|
|
299
313
|
// Axis
|
|
300
314
|
option.xAxis.name = this.inputData?.axis?.xAxisLabel ?? ''
|
|
301
|
-
option.xAxis.nameGap = 30 * modifier
|
|
302
315
|
option.dataZoom[0].show = this.inputData?.axis?.xAxisZoom ?? false
|
|
303
316
|
option.toolbox.show = this.inputData?.axis?.xAxisZoom ?? false
|
|
304
317
|
// option.xAxis.axisLine.lineStyle.width = 2 * modifier
|
|
@@ -306,16 +319,17 @@ export class WidgetLinechart extends LitElement {
|
|
|
306
319
|
option.xAxis.type = this.xAxisType()
|
|
307
320
|
|
|
308
321
|
option.yAxis.name = this.inputData?.axis?.yAxisLabel ?? ''
|
|
309
|
-
option.yAxis.nameGap = 30 * modifier
|
|
310
322
|
// option.yAxis.axisLine.lineStyle.width = 2 * modifier
|
|
311
323
|
// option.yAxis.axisLabel.fontSize = 20 * modifier
|
|
312
324
|
option.yAxis.scale = this.inputData?.axis?.yAxisScaling ?? false
|
|
313
325
|
|
|
314
|
-
option.series =
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
chart.
|
|
326
|
+
option.series = chart.series
|
|
327
|
+
|
|
328
|
+
if (chart.series.length <= 1) option.legend.show = false
|
|
329
|
+
const oldOption: any = chart.echart?.getOption() ?? {}
|
|
330
|
+
const notMerge = oldOption.series?.length !== chart.series.length
|
|
331
|
+
chart.echart?.setOption(option, { notMerge })
|
|
332
|
+
chart.echart?.resize()
|
|
319
333
|
})
|
|
320
334
|
}
|
|
321
335
|
|