Skip to content

Commit

Permalink
[TSVB] Visualization crashes when it is opened from Metrics Ui (#98120)…
Browse files Browse the repository at this point in the history
… (#98279)

* [TSVB] Metrics UI crashes when it is opened from Metrics Ui

* Fix bug on initialization

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
stratoula and kibanamachine authored Apr 26, 2021
1 parent b4db266 commit 49ed9f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,17 @@ export const TimeseriesConfig = injectI18n(function (props) {
? props.model.series_index_pattern
: props.indexPatternForQuery;

const initialPalette = {
...model.palette,
const initialPalette = model.palette ?? {
type: 'palette',
name: 'default',
};

const palette = {
...initialPalette,
name:
model.split_color_mode === 'kibana'
? 'kibana_palette'
: model.split_color_mode || model.palette.name,
: model.split_color_mode || initialPalette.name,
};

return (
Expand Down Expand Up @@ -427,7 +432,7 @@ export const TimeseriesConfig = injectI18n(function (props) {
>
<PalettePicker
palettes={palettesRegistry}
activePalette={initialPalette}
activePalette={palette}
setPalette={handlePaletteChange}
color={model.color}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const getSplitByTermsColor = ({
}
: seriesPalette.params;

const outputColor = palettesRegistry?.get(paletteName).getColor(
const outputColor = palettesRegistry?.get(paletteName || 'default').getColor(
[
{
name: seriesName || emptyLabel,
Expand Down

0 comments on commit 49ed9f7

Please sign in to comment.