@record-evolution/widget-linechart 1.6.5 → 1.6.7
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.
|
|
6
|
+
"version": "1.6.7",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/widget-linechart.js",
|
|
9
9
|
"types": "dist/src/widget-linechart.d.ts",
|
package/src/widget-linechart.ts
CHANGED
|
@@ -30,19 +30,20 @@ echarts.use([
|
|
|
30
30
|
])
|
|
31
31
|
|
|
32
32
|
import { InputData } from './definition-schema'
|
|
33
|
-
import { EChartsOption,
|
|
33
|
+
import { EChartsOption, SeriesOption } from 'echarts'
|
|
34
34
|
import { TitleOption } from 'echarts/types/dist/shared'
|
|
35
35
|
|
|
36
|
+
type Theme = {
|
|
37
|
+
theme_name: string
|
|
38
|
+
theme_object: any
|
|
39
|
+
}
|
|
36
40
|
@customElement('widget-linechart-versionplaceholder')
|
|
37
41
|
export class WidgetLinechart extends LitElement {
|
|
38
42
|
@property({ type: Object })
|
|
39
43
|
inputData?: InputData
|
|
40
44
|
|
|
41
45
|
@property({ type: Object })
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
@property({ type: String })
|
|
45
|
-
themeName?: string
|
|
46
|
+
theme?: Theme
|
|
46
47
|
|
|
47
48
|
@state()
|
|
48
49
|
private canvasList: Map<
|
|
@@ -50,11 +51,9 @@ export class WidgetLinechart extends LitElement {
|
|
|
50
51
|
{ echart?: echarts.ECharts; series: SeriesOption[]; doomed?: boolean; element?: HTMLDivElement }
|
|
51
52
|
> = new Map()
|
|
52
53
|
|
|
53
|
-
@state()
|
|
54
|
-
private
|
|
55
|
-
|
|
56
|
-
@state()
|
|
57
|
-
private themeColor?: string
|
|
54
|
+
@state() private themeBgColor?: string
|
|
55
|
+
@state() private themeTitleColor?: string
|
|
56
|
+
@state() private themeSubtitleColor?: string
|
|
58
57
|
|
|
59
58
|
boxes?: HTMLDivElement[]
|
|
60
59
|
origWidth: number = 0
|
|
@@ -172,12 +171,8 @@ export class WidgetLinechart extends LitElement {
|
|
|
172
171
|
this.applyData()
|
|
173
172
|
}
|
|
174
173
|
|
|
175
|
-
if (changedProperties.has('
|
|
176
|
-
this.registerTheme(this.
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (changedProperties.has('themeName')) {
|
|
180
|
-
this.registerTheme(this.themeName, this.themeObject)
|
|
174
|
+
if (changedProperties.has('theme')) {
|
|
175
|
+
this.registerTheme(this.theme)
|
|
181
176
|
this.deleteCharts()
|
|
182
177
|
this.transformData()
|
|
183
178
|
this.applyData()
|
|
@@ -200,10 +195,17 @@ export class WidgetLinechart extends LitElement {
|
|
|
200
195
|
}
|
|
201
196
|
}
|
|
202
197
|
|
|
203
|
-
registerTheme(
|
|
204
|
-
if (!
|
|
205
|
-
|
|
206
|
-
|
|
198
|
+
registerTheme(theme?: Theme) {
|
|
199
|
+
if (!theme || !theme.theme_object || !theme.theme_name) return
|
|
200
|
+
|
|
201
|
+
console.log('Registering theme', theme)
|
|
202
|
+
echarts.registerTheme(theme.theme_name, theme.theme_object)
|
|
203
|
+
const cssTextColor = getComputedStyle(this).getPropertyValue('--re-text-color').trim()
|
|
204
|
+
const cssBgColor = getComputedStyle(this).getPropertyValue('--re-background-color').trim()
|
|
205
|
+
this.themeBgColor = cssBgColor || this.theme?.theme_object?.backgroundColor
|
|
206
|
+
this.themeTitleColor = cssTextColor || this.theme?.theme_object?.title?.textStyle?.color
|
|
207
|
+
this.themeSubtitleColor =
|
|
208
|
+
cssTextColor || this.theme?.theme_object?.title?.subtextStyle?.color || this.themeTitleColor
|
|
207
209
|
}
|
|
208
210
|
|
|
209
211
|
transformData() {
|
|
@@ -334,7 +336,7 @@ export class WidgetLinechart extends LitElement {
|
|
|
334
336
|
const oldOption: any = chart.echart?.getOption() ?? {}
|
|
335
337
|
const notMerge = oldOption.series?.length !== chart.series.length
|
|
336
338
|
chart.echart?.setOption(option, { notMerge })
|
|
337
|
-
chart.echart?.resize()
|
|
339
|
+
// chart.echart?.resize()
|
|
338
340
|
})
|
|
339
341
|
}
|
|
340
342
|
|
|
@@ -363,13 +365,10 @@ export class WidgetLinechart extends LitElement {
|
|
|
363
365
|
newContainer.setAttribute('class', 'sizer')
|
|
364
366
|
this.chartContainer.appendChild(newContainer)
|
|
365
367
|
|
|
366
|
-
const newChart = echarts.init(newContainer, this.
|
|
368
|
+
const newChart = echarts.init(newContainer, this.theme?.theme_name)
|
|
367
369
|
const chart = { echart: newChart, series: [] as SeriesOption[], element: newContainer }
|
|
368
370
|
this.canvasList.set(label, chart)
|
|
369
|
-
|
|
370
|
-
this.themeBgColor = newChart._theme?.backgroundColor
|
|
371
|
-
//@ts-ignore
|
|
372
|
-
this.themeColor = newChart._theme?.title?.textStyle?.color
|
|
371
|
+
|
|
373
372
|
return chart
|
|
374
373
|
}
|
|
375
374
|
|
|
@@ -384,7 +383,6 @@ export class WidgetLinechart extends LitElement {
|
|
|
384
383
|
static styles = css`
|
|
385
384
|
:host {
|
|
386
385
|
display: block;
|
|
387
|
-
color: var(--re-text-color, #000);
|
|
388
386
|
font-family: sans-serif;
|
|
389
387
|
box-sizing: border-box;
|
|
390
388
|
position: relative;
|
|
@@ -402,7 +400,6 @@ export class WidgetLinechart extends LitElement {
|
|
|
402
400
|
width: 100%;
|
|
403
401
|
padding: 16px;
|
|
404
402
|
box-sizing: border-box;
|
|
405
|
-
color: var(--re-text-color, #000);
|
|
406
403
|
gap: 12px;
|
|
407
404
|
}
|
|
408
405
|
|
|
@@ -451,7 +448,6 @@ export class WidgetLinechart extends LitElement {
|
|
|
451
448
|
|
|
452
449
|
.no-data {
|
|
453
450
|
font-size: 20px;
|
|
454
|
-
color: var(--re-text-color, #000);
|
|
455
451
|
display: flex;
|
|
456
452
|
height: 100%;
|
|
457
453
|
width: 100%;
|
|
@@ -463,10 +459,19 @@ export class WidgetLinechart extends LitElement {
|
|
|
463
459
|
|
|
464
460
|
render() {
|
|
465
461
|
return html`
|
|
466
|
-
<div
|
|
462
|
+
<div
|
|
463
|
+
class="wrapper"
|
|
464
|
+
style="background-color: ${this.themeBgColor}; color: ${this.themeTitleColor}"
|
|
465
|
+
>
|
|
467
466
|
<header class="paging" ?active=${this.inputData?.title || this.inputData?.subTitle}>
|
|
468
467
|
<h3 class="paging" ?active=${this.inputData?.title}>${this.inputData?.title}</h3>
|
|
469
|
-
<p
|
|
468
|
+
<p
|
|
469
|
+
class="paging"
|
|
470
|
+
?active=${this.inputData?.subTitle}
|
|
471
|
+
style="color: ${this.themeSubtitleColor}"
|
|
472
|
+
>
|
|
473
|
+
${this.inputData?.subTitle}
|
|
474
|
+
</p>
|
|
470
475
|
</header>
|
|
471
476
|
<div class="paging no-data" ?active=${this.canvasList.size === 0}>No Data</div>
|
|
472
477
|
<div
|