@record-evolution/widget-linechart 1.6.3 → 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 +35 -24
- package/dist/widget-linechart.js.map +1 -1
- package/package.json +5 -3
- package/src/default-data.json +1 -1
- package/src/definition-schema.d.ts +5 -5
- package/src/definition-schema.json +14 -14
- package/src/widget-linechart.ts +31 -24
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
|
@@ -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,
|
|
@@ -106,7 +114,7 @@ export class WidgetLinechart extends LitElement {
|
|
|
106
114
|
xAxis: {
|
|
107
115
|
type: 'value', // value, time, log, category
|
|
108
116
|
name: 'Time',
|
|
109
|
-
nameGap:
|
|
117
|
+
nameGap: 27,
|
|
110
118
|
nameLocation: 'middle',
|
|
111
119
|
axisLine: {
|
|
112
120
|
lineStyle: {
|
|
@@ -121,7 +129,7 @@ export class WidgetLinechart extends LitElement {
|
|
|
121
129
|
type: 'value',
|
|
122
130
|
nameLocation: 'middle',
|
|
123
131
|
name: 'Temperature (°C)',
|
|
124
|
-
nameGap:
|
|
132
|
+
nameGap: 30,
|
|
125
133
|
axisLabel: {
|
|
126
134
|
fontSize: 14
|
|
127
135
|
},
|
|
@@ -238,35 +246,29 @@ export class WidgetLinechart extends LitElement {
|
|
|
238
246
|
: undefined
|
|
239
247
|
const data = distincts.length === 1 ? ds.data : ds.data?.filter((d) => d.pivot === piv)
|
|
240
248
|
const data2 = this.inputData?.axis?.timeseries
|
|
241
|
-
? data?.map((d) =>
|
|
242
|
-
|
|
243
|
-
)
|
|
244
|
-
: 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])
|
|
245
251
|
|
|
252
|
+
// preparing the echarts series option for later application
|
|
246
253
|
const pds: SeriesOption = {
|
|
247
254
|
name: name,
|
|
248
255
|
type: ds.type ?? 'line',
|
|
249
256
|
lineStyle: {
|
|
250
257
|
color: lineColor,
|
|
251
258
|
width: ds.styling?.borderWidth ?? 2,
|
|
252
|
-
// @ts-ignore
|
|
253
259
|
type: ds.styling?.borderDash ?? 'solid'
|
|
254
260
|
},
|
|
255
261
|
itemStyle: {
|
|
256
262
|
color: fillColor,
|
|
257
263
|
borderColor: lineColor,
|
|
258
|
-
borderWidth: ds.styling?.borderWidth ?? 2
|
|
259
|
-
// @ts-ignore
|
|
260
|
-
type: ds.styling?.borderDash ?? 'solid'
|
|
264
|
+
borderWidth: ds.styling?.borderWidth ?? 2
|
|
261
265
|
},
|
|
262
|
-
areaStyle:
|
|
266
|
+
areaStyle: ds.styling?.fill ? { color: fillColor } : undefined,
|
|
263
267
|
symbol: ds.styling?.pointStyle ?? 'circle',
|
|
264
268
|
symbolSize: (data) => data[2] ?? 4,
|
|
265
269
|
showSymbol: ds.styling?.pointStyle === 'none' ? false : true,
|
|
266
270
|
data: data2 ?? []
|
|
267
271
|
}
|
|
268
|
-
// if (ds.type === 'scatter') (pds as ScatterSeriesOption).symbolSize = (data) => data[2]
|
|
269
|
-
|
|
270
272
|
let chartName = ds.advanced?.chartName ?? ''
|
|
271
273
|
if (chartName.includes('#split#')) {
|
|
272
274
|
chartName = prefix + '-' + chartName
|
|
@@ -277,13 +279,16 @@ export class WidgetLinechart extends LitElement {
|
|
|
277
279
|
})
|
|
278
280
|
})
|
|
279
281
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
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))
|
|
287
292
|
}
|
|
288
293
|
|
|
289
294
|
xAxisType(): 'value' | 'log' | 'category' | 'time' | undefined {
|
|
@@ -321,8 +326,10 @@ export class WidgetLinechart extends LitElement {
|
|
|
321
326
|
option.series = chart.series
|
|
322
327
|
|
|
323
328
|
if (chart.series.length <= 1) option.legend.show = false
|
|
324
|
-
|
|
325
|
-
chart.
|
|
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()
|
|
326
333
|
})
|
|
327
334
|
}
|
|
328
335
|
|