Skip to content

Commit

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

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

* Fix bug on initialization

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
stratoula and kibanamachine committed Apr 26, 2021
1 parent 01774c6 commit 391241a
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 @@ -331,12 +331,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 @@ -430,7 +435,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 391241a

Please sign in to comment.