Skip to content

Commit

Permalink
[9.0] [Charts] Fix borealis theme overrides (#209595) (#209631)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `9.0`:
- [[Charts] Fix borealis theme overrides
(#209595)](#209595)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Nick
Partridge","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-02-04T18:54:19Z","message":"[Charts]
Fix borealis theme overrides (#209595)\n\n## Summary\r\n\r\nThis removes
an override that was applied to the charts theme prior to\r\nupdating
the `Theme` in `@elastic/charts`. This is no longer needed and\r\nis now
using the wrong color.\r\n\r\n## Release note\r\n\r\nFixes issue with
`Amsterdam` theme where charts render with the\r\nincorrect background
color.","sha":"595406176fd82b3e0c1ce967d8a801e428e0e94a","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Visualizations","Feature:Lens","backport:prev-minor","backport:current-major","v9.1.0"],"title":"[Charts]
Fix borealis theme
overrides","number":209595,"url":"https://github.com/elastic/kibana/pull/209595","mergeCommit":{"message":"[Charts]
Fix borealis theme overrides (#209595)\n\n## Summary\r\n\r\nThis removes
an override that was applied to the charts theme prior to\r\nupdating
the `Theme` in `@elastic/charts`. This is no longer needed and\r\nis now
using the wrong color.\r\n\r\n## Release note\r\n\r\nFixes issue with
`Amsterdam` theme where charts render with the\r\nincorrect background
color.","sha":"595406176fd82b3e0c1ce967d8a801e428e0e94a"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/209595","number":209595,"mergeCommit":{"message":"[Charts]
Fix borealis theme overrides (#209595)\n\n## Summary\r\n\r\nThis removes
an override that was applied to the charts theme prior to\r\nupdating
the `Theme` in `@elastic/charts`. This is no longer needed and\r\nis now
using the wrong color.\r\n\r\n## Release note\r\n\r\nFixes issue with
`Amsterdam` theme where charts render with the\r\nincorrect background
color.","sha":"595406176fd82b3e0c1ce967d8a801e428e0e94a"}}]}]
BACKPORT-->

Co-authored-by: Nick Partridge <[email protected]>
  • Loading branch information
kibanamachine and nickofthyme authored Feb 4, 2025
1 parent d8a104b commit 0b552c2
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/platform/plugins/shared/charts/public/services/theme/theme.ts
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;
}

0 comments on commit 0b552c2

Please sign in to comment.