From 2edadb27e56fa51a009ba3a4a7d97c257d8ded3e Mon Sep 17 00:00:00 2001 From: Nick Partridge Date: Wed, 21 Aug 2019 15:49:58 -0500 Subject: [PATCH] fix: default theme (#336) Fixes default theme from chart_state --- src/chart_types/xy_chart/store/chart_state.test.ts | 2 -- src/chart_types/xy_chart/store/chart_state.ts | 6 ++---- src/specs/settings.test.tsx | 5 +++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/chart_types/xy_chart/store/chart_state.test.ts b/src/chart_types/xy_chart/store/chart_state.test.ts index f4fa3c0eb4..d9217023aa 100644 --- a/src/chart_types/xy_chart/store/chart_state.test.ts +++ b/src/chart_types/xy_chart/store/chart_state.test.ts @@ -20,7 +20,6 @@ import { ChartStore } from './chart_state'; describe('Chart Store', () => { let store = new ChartStore(); - store.chartTheme = LIGHT_THEME; const SPEC_ID = getSpecId('spec_1'); const AXIS_ID = getAxisId('axis_1'); @@ -68,7 +67,6 @@ describe('Chart Store', () => { }; beforeEach(() => { store = new ChartStore(); - store.chartTheme = LIGHT_THEME; store.updateParentDimensions(600, 600, 0, 0); store.computeChart(); }); diff --git a/src/chart_types/xy_chart/store/chart_state.ts b/src/chart_types/xy_chart/store/chart_state.ts index 7e8bc14e59..d11a9f19a5 100644 --- a/src/chart_types/xy_chart/store/chart_state.ts +++ b/src/chart_types/xy_chart/store/chart_state.ts @@ -92,6 +92,7 @@ import { Transform, updateDeselectedDataSeries, } from './utils'; +import { LIGHT_THEME } from '../../../utils/themes/light_theme'; export interface Point { x: number; @@ -149,10 +150,7 @@ export class ChartStore { chartRotation: Rotation = 0; // updated from jsx chartRendering: Rendering = 'canvas'; // updated from jsx - /** - * Chart theme to be set from Settings.tsx - */ - chartTheme!: Theme; + chartTheme: Theme = LIGHT_THEME; axesSpecs: Map = new Map(); // readed from jsx axesTicksDimensions: Map = new Map(); // computed axesPositions: Map = new Map(); // computed diff --git a/src/specs/settings.test.tsx b/src/specs/settings.test.tsx index 0e1f3e7125..2e6e6e3955 100644 --- a/src/specs/settings.test.tsx +++ b/src/specs/settings.test.tsx @@ -6,6 +6,7 @@ import { TooltipType } from '../chart_types/xy_chart/utils/interactions'; import { ChartStore } from '../chart_types/xy_chart/store/chart_state'; import { DEFAULT_TOOLTIP_SNAP, DEFAULT_TOOLTIP_TYPE, SettingsComponent, SettingSpecProps } from './settings'; import { PartialTheme } from '../utils/themes/theme'; +import { LIGHT_THEME } from '../utils/themes/light_theme'; describe('Settings spec component', () => { test('should update store on mount if spec has a chart store', () => { @@ -55,7 +56,7 @@ describe('Settings spec component', () => { test('should set chart properties on chart store', () => { const chartStore = new ChartStore(); - expect(chartStore.chartTheme).toBeUndefined(); + expect(chartStore.chartTheme).toEqual(LIGHT_THEME); expect(chartStore.chartRotation).toBe(0); expect(chartStore.chartRendering).toBe('canvas'); expect(chartStore.animateData).toBe(false); @@ -162,7 +163,7 @@ describe('Settings spec component', () => { }, }; - expect(chartStore.chartTheme).toBeUndefined(); + expect(chartStore.chartTheme).toEqual(LIGHT_THEME); const updatedProps: SettingSpecProps = { theme: partialTheme,