@@ -33,16 +33,17 @@ import { InputData } from './definition-schema'
3333import { EChartsOption , ScatterSeriesOption , SeriesOption } from 'echarts'
3434import { TitleOption } from 'echarts/types/dist/shared'
3535
36+ type Theme = {
37+ theme_name : string
38+ theme_object : any
39+ }
3640@customElement ( 'widget-linechart-versionplaceholder' )
3741export class WidgetLinechart extends LitElement {
3842 @property ( { type : Object } )
3943 inputData ?: InputData
4044
4145 @property ( { type : Object } )
42- themeObject ?: any
43-
44- @property ( { type : String } )
45- themeName ?: string
46+ theme ?: Theme
4647
4748 @state ( )
4849 private canvasList : Map <
@@ -172,12 +173,8 @@ export class WidgetLinechart extends LitElement {
172173 this . applyData ( )
173174 }
174175
175- if ( changedProperties . has ( 'themeObject' ) ) {
176- this . registerTheme ( this . themeName , this . themeObject )
177- }
178-
179- if ( changedProperties . has ( 'themeName' ) ) {
180- this . registerTheme ( this . themeName , this . themeObject )
176+ if ( changedProperties . has ( 'theme' ) ) {
177+ this . registerTheme ( this . theme )
181178 this . deleteCharts ( )
182179 this . transformData ( )
183180 this . applyData ( )
@@ -200,10 +197,11 @@ export class WidgetLinechart extends LitElement {
200197 }
201198 }
202199
203- registerTheme ( themeName ?: string , themeObject ?: any ) {
204- if ( ! themeObject || ! themeName ) return
200+ registerTheme ( theme ?: Theme ) {
201+ if ( ! theme || ! theme . theme_object || ! theme . theme_name ) return
205202
206- echarts . registerTheme ( themeName , this . themeObject )
203+ console . log ( 'Registering theme' , theme )
204+ echarts . registerTheme ( theme . theme_name , theme . theme_object )
207205 }
208206
209207 transformData ( ) {
@@ -363,7 +361,7 @@ export class WidgetLinechart extends LitElement {
363361 newContainer . setAttribute ( 'class' , 'sizer' )
364362 this . chartContainer . appendChild ( newContainer )
365363
366- const newChart = echarts . init ( newContainer , this . themeName )
364+ const newChart = echarts . init ( newContainer , this . theme ?. theme_name )
367365 const chart = { echart : newChart , series : [ ] as SeriesOption [ ] , element : newContainer }
368366 this . canvasList . set ( label , chart )
369367 //@ts -ignore
0 commit comments