@record-evolution/widget-linechart 1.6.1 → 1.6.3

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": "Webcomponent widget-linechart following open-wc recommendations",
4
4
  "license": "MIT",
5
5
  "author": "widget-linechart",
6
- "version": "1.6.1",
6
+ "version": "1.6.3",
7
7
  "type": "module",
8
8
  "main": "dist/widget-linechart.js",
9
9
  "types": "dist/src/widget-linechart.d.ts",
@@ -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",
@@ -101,17 +101,12 @@ export class WidgetLinechart extends LitElement {
101
101
  // start: 30,
102
102
  // end: 70,
103
103
  xAxisIndex: [0, 1]
104
- },
105
- {
106
- show: false,
107
- realtime: true,
108
- // start: 30,
109
- // end: 70,
110
- yAxisIndex: [0, 1]
111
104
  }
112
105
  ],
113
106
  xAxis: {
114
107
  type: 'value', // value, time, log, category
108
+ name: 'Time',
109
+ nameGap: 25,
115
110
  nameLocation: 'middle',
116
111
  axisLine: {
117
112
  lineStyle: {
@@ -125,6 +120,8 @@ export class WidgetLinechart extends LitElement {
125
120
  yAxis: {
126
121
  type: 'value',
127
122
  nameLocation: 'middle',
123
+ name: 'Temperature (°C)',
124
+ nameGap: 25,
128
125
  axisLabel: {
129
126
  fontSize: 14
130
127
  },
@@ -142,7 +139,8 @@ export class WidgetLinechart extends LitElement {
142
139
  symbolSize: 8,
143
140
  lineStyle: {
144
141
  width: 2,
145
- type: 'solid'
142
+ type: 'solid',
143
+ color: 'green'
146
144
  },
147
145
  data: [10, 11, 13, 11, 12, 12, 9]
148
146
  } as SeriesOption,
@@ -228,12 +226,16 @@ export class WidgetLinechart extends LitElement {
228
226
  const prefix = piv ?? ''
229
227
  const label = ds.label ?? ''
230
228
  const name = prefix + (!!prefix && !!label ? ' - ' : '') + label
231
- const lineColor = ds.advanced?.chartName?.includes('#split#')
232
- ? ds.borderColor
233
- : derivedBdColors[i]
234
- const fillColor = ds.advanced?.chartName?.includes('#split#')
235
- ? ds.backgroundColor
236
- : derivedBgColors[i]
229
+ const lineColor = ds.borderColor
230
+ ? ds.advanced?.chartName?.includes('#split#')
231
+ ? ds.borderColor
232
+ : derivedBdColors[i]
233
+ : undefined
234
+ const fillColor = ds.backgroundColor
235
+ ? ds.advanced?.chartName?.includes('#split#')
236
+ ? ds.backgroundColor
237
+ : derivedBgColors[i]
238
+ : undefined
237
239
  const data = distincts.length === 1 ? ds.data : ds.data?.filter((d) => d.pivot === piv)
238
240
  const data2 = this.inputData?.axis?.timeseries
239
241
  ? data?.map((d) =>
@@ -250,6 +252,13 @@ export class WidgetLinechart extends LitElement {
250
252
  // @ts-ignore
251
253
  type: ds.styling?.borderDash ?? 'solid'
252
254
  },
255
+ itemStyle: {
256
+ color: fillColor,
257
+ borderColor: lineColor,
258
+ borderWidth: ds.styling?.borderWidth ?? 2,
259
+ // @ts-ignore
260
+ type: ds.styling?.borderDash ?? 'solid'
261
+ },
253
262
  areaStyle: { color: ds.styling?.fill ? fillColor : 'transparent' },
254
263
  symbol: ds.styling?.pointStyle ?? 'circle',
255
264
  symbolSize: (data) => data[2] ?? 4,
@@ -298,7 +307,6 @@ export class WidgetLinechart extends LitElement {
298
307
 
299
308
  // Axis
300
309
  option.xAxis.name = this.inputData?.axis?.xAxisLabel ?? ''
301
- option.xAxis.nameGap = 30 * modifier
302
310
  option.dataZoom[0].show = this.inputData?.axis?.xAxisZoom ?? false
303
311
  option.toolbox.show = this.inputData?.axis?.xAxisZoom ?? false
304
312
  // option.xAxis.axisLine.lineStyle.width = 2 * modifier
@@ -306,15 +314,14 @@ export class WidgetLinechart extends LitElement {
306
314
  option.xAxis.type = this.xAxisType()
307
315
 
308
316
  option.yAxis.name = this.inputData?.axis?.yAxisLabel ?? ''
309
- option.yAxis.nameGap = 30 * modifier
310
317
  // option.yAxis.axisLine.lineStyle.width = 2 * modifier
311
318
  // option.yAxis.axisLabel.fontSize = 20 * modifier
312
319
  option.yAxis.scale = this.inputData?.axis?.yAxisScaling ?? false
313
320
 
314
- option.series = []
315
- for (const ds of chart.series) {
316
- option.series.push(ds)
317
- }
321
+ option.series = chart.series
322
+
323
+ if (chart.series.length <= 1) option.legend.show = false
324
+
318
325
  chart.echart?.setOption(option)
319
326
  })
320
327
  }