@@ -2,9 +2,7 @@ import { PureComponent } from 'react';
22import { inject } from 'mobx-react' ;
33
44import { DomainRange , Position , Rendering , Rotation } from '../chart_types/xy_chart/utils/specs' ;
5- import { LIGHT_THEME } from '../utils/themes/light_theme' ;
6- import { DARK_THEME } from '../utils/themes/dark_theme' ;
7- import { BaseThemeType , mergeWithDefaultTheme , PartialTheme , Theme , BaseThemeTypes } from '../utils/themes/theme' ;
5+ import { mergeWithDefaultTheme , PartialTheme , Theme } from '../utils/themes/theme' ;
86import { Domain } from '../utils/domain' ;
97import { TooltipType , TooltipValueFormatter } from '../chart_types/xy_chart/utils/interactions' ;
108import {
@@ -16,6 +14,7 @@ import {
1614 CursorUpdateListener ,
1715} from '../chart_types/xy_chart/store/chart_state' ;
1816import { ScaleTypes } from '../utils/scales/scales' ;
17+ import { LIGHT_THEME } from '../utils/themes/light_theme' ;
1918
2019export const DEFAULT_TOOLTIP_TYPE = TooltipType . VerticalCursor ;
2120export const DEFAULT_TOOLTIP_SNAP = true ;
@@ -52,8 +51,16 @@ function isTooltipType(config: TooltipType | TooltipProps): config is TooltipTyp
5251
5352export interface SettingSpecProps {
5453 chartStore ?: ChartStore ;
54+ /**
55+ * Full or partial theme to be merged with base
56+ */
5557 theme ?: Theme | PartialTheme ;
56- baseThemeType ?: BaseThemeType ;
58+ /**
59+ * Full default theme to use as base
60+ *
61+ * @default `LIGHT_THEME`
62+ */
63+ baseTheme ?: Theme ;
5764 rendering : Rendering ;
5865 rotation : Rotation ;
5966 animateData : boolean ;
@@ -76,20 +83,16 @@ export interface SettingSpecProps {
7683 xDomain ?: Domain | DomainRange ;
7784}
7885
79- function getTheme ( theme ?: Theme | PartialTheme , baseThemeType : BaseThemeType = BaseThemeTypes . Light ) : Theme {
80- if ( theme ) {
81- const baseTheme = baseThemeType === BaseThemeTypes . Light ? LIGHT_THEME : DARK_THEME ;
82- return mergeWithDefaultTheme ( theme , baseTheme ) ;
83- }
84-
85- return LIGHT_THEME ;
86+ function getTheme ( baseTheme ?: Theme , theme ?: Theme | PartialTheme ) : Theme {
87+ const base = baseTheme ? baseTheme : LIGHT_THEME ;
88+ return theme ? mergeWithDefaultTheme ( theme , base ) : base ;
8689}
8790
8891function updateChartStore ( props : SettingSpecProps ) {
8992 const {
9093 chartStore,
9194 theme,
92- baseThemeType ,
95+ baseTheme ,
9396 rotation,
9497 rendering,
9598 animateData,
@@ -110,11 +113,12 @@ function updateChartStore(props: SettingSpecProps) {
110113 debug,
111114 xDomain,
112115 } = props ;
116+
113117 if ( ! chartStore ) {
114118 return ;
115119 }
116120
117- chartStore . chartTheme = getTheme ( theme , baseThemeType ) ;
121+ chartStore . chartTheme = getTheme ( baseTheme , theme ) ;
118122 chartStore . chartRotation = rotation ;
119123 chartStore . chartRendering = rendering ;
120124 chartStore . animateData = animateData ;
@@ -176,7 +180,6 @@ export class SettingsComponent extends PureComponent<SettingSpecProps> {
176180 animateData : true ,
177181 showLegend : false ,
178182 debug : false ,
179- baseThemeType : BaseThemeTypes . Light ,
180183 tooltip : {
181184 type : DEFAULT_TOOLTIP_TYPE ,
182185 snap : DEFAULT_TOOLTIP_SNAP ,
0 commit comments