Skip to content

Commit

Permalink
fix: default theme (#336)
Browse files Browse the repository at this point in the history
Fixes default theme from chart_state
  • Loading branch information
nickofthyme authored Aug 21, 2019
1 parent b756116 commit 2edadb2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/chart_types/xy_chart/store/chart_state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -68,7 +67,6 @@ describe('Chart Store', () => {
};
beforeEach(() => {
store = new ChartStore();
store.chartTheme = LIGHT_THEME;
store.updateParentDimensions(600, 600, 0, 0);
store.computeChart();
});
Expand Down
6 changes: 2 additions & 4 deletions src/chart_types/xy_chart/store/chart_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ import {
Transform,
updateDeselectedDataSeries,
} from './utils';
import { LIGHT_THEME } from '../../../utils/themes/light_theme';

export interface Point {
x: number;
Expand Down Expand Up @@ -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<AxisId, AxisSpec> = new Map(); // readed from jsx
axesTicksDimensions: Map<AxisId, AxisTicksDimensions> = new Map(); // computed
axesPositions: Map<AxisId, Dimensions> = new Map(); // computed
Expand Down
5 changes: 3 additions & 2 deletions src/specs/settings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -162,7 +163,7 @@ describe('Settings spec component', () => {
},
};

expect(chartStore.chartTheme).toBeUndefined();
expect(chartStore.chartTheme).toEqual(LIGHT_THEME);

const updatedProps: SettingSpecProps = {
theme: partialTheme,
Expand Down

0 comments on commit 2edadb2

Please sign in to comment.