Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.0] [Charts] Fix borealis theme overrides (#209595) #209631

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { useEffect, useRef, useState } from 'react';
import { Observable, BehaviorSubject } from 'rxjs';

import { CoreSetup, CoreTheme } from '@kbn/core/public';
import { DARK_THEME, LIGHT_THEME, PartialTheme, Theme } from '@elastic/charts';
import { euiThemeVars } from '@kbn/ui-theme';
import { LIGHT_THEME, PartialTheme, Theme, getChartsTheme } from '@elastic/charts';

export class ThemeService {
/** Returns default charts theme */
Expand Down Expand Up @@ -104,20 +103,7 @@ export class ThemeService {
public init(theme: CoreSetup['theme']) {
this.theme$ = theme.theme$;
this.theme$.subscribe((newTheme) => {
this._chartsBaseTheme$.next(getChartTheme(newTheme));
this._chartsBaseTheme$.next(getChartsTheme(newTheme));
});
}
}

// TODO: define these overrides in elastic/charts when Borealis becomes default
function getChartTheme(theme: CoreTheme): Theme {
const chartTheme = theme.darkMode ? DARK_THEME : LIGHT_THEME;

if (theme.name !== 'amsterdam') {
const backgroundColor = euiThemeVars.euiColorEmptyShade;
chartTheme.background.color = backgroundColor;
chartTheme.background.fallbackColor = backgroundColor;
}

return chartTheme;
}