@@ -8,16 +8,45 @@ import type {
88 TooltipComponentOption ,
99} from 'echarts/components' ;
1010import type { ComposeOption , EChartsType } from 'echarts/core' ;
11- import type { LineSeriesOption , SeriesOption } from 'echarts/types/dist/shared' ;
11+ import {
12+ BarSeriesOption ,
13+ LineSeriesOption ,
14+ SeriesOption ,
15+ } from 'echarts/types/dist/shared' ;
1216
13- import { Theme } from '@leafygreen-ui/lib' ;
17+ import { Theme , ValuesOf } from '@leafygreen-ui/lib' ;
1418
1519// Type not exported by echarts.
1620// reference: https://github.com/apache/echarts/blob/master/src/coord/axisCommonTypes.ts#L193
1721export type AxisLabelValueFormatter = ( value : number , index ?: number ) => string ;
1822
19- export type EChartLineSeriesOption = LineSeriesOption ;
20- export type EChartSeriesOption = { name : string } & SeriesOption ;
23+ export interface StylingContext {
24+ seriesColor ?: string ;
25+ }
26+
27+ // to convert an SeriesOption type of echarts into a more structured form aligned with LeafyGreen design standards,
28+ // where the 'type', 'name', and 'data' fields are explicitly required and typed,
29+ // and all additional properties related to series styling are encapsulated within the 'stylingOptions' object
30+ interface DisciplinedSeriesOption < EChartType extends SeriesOption > {
31+ type : NonNullable < EChartType [ 'type' ] > ;
32+ name : string ;
33+ data : NonNullable < EChartType [ 'data' ] > ;
34+ stylingOptions : Omit < EChartType , 'type' | 'name' | 'data' > ;
35+ }
36+
37+ // all supported series options types disciplined and grouped into a single interface
38+ export interface EChartSeriesOptions {
39+ line : DisciplinedSeriesOption < LineSeriesOption > ;
40+ // TODO: to be leveraged in a follow-up PR that adds Bar chart support
41+ bar : DisciplinedSeriesOption < BarSeriesOption > ;
42+ }
43+
44+ // a disciplined substitute for SeriesOption type of echarts limited to the ones supported here
45+ export type EChartSeriesOption = Omit <
46+ ValuesOf < EChartSeriesOptions > ,
47+ 'stylingOptions'
48+ > &
49+ ValuesOf < EChartSeriesOptions > [ 'stylingOptions' ] ;
2150
2251/**
2352 * TODO: This might need to be improved. `ComposeOption` appears to make most base option
@@ -107,6 +136,7 @@ interface EChartsEventHandlerType {
107136 callback : ( params : any ) => void ,
108137 options ?: Partial < { useCanvasAsTrigger : boolean } > ,
109138 ) : void ;
139+
110140 (
111141 event : 'zoomselect' ,
112142 callback : ( params : EChartZoomSelectionEvent ) => void ,
0 commit comments