Skip to content

Commit

Permalink
fix(Explore): Force different color for same metrics in Mixed Time-Se…
Browse files Browse the repository at this point in the history
…ries (#18603)

* Force different color for same metrics

* Conform to chart labels suffix

* Simplify
  • Loading branch information
geido committed Feb 10, 2022
1 parent bd0b9f2 commit f565230
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,11 @@ export default function transformProps(
stack,
yAxisIndex,
filterState,
seriesKey: entry.name,
});
if (transformedSeries) series.push(transformedSeries);
});

rawSeriesB.forEach(entry => {
const transformedSeries = transformSeries(entry, colorScale, {
area: areaB,
Expand All @@ -189,6 +191,9 @@ export default function transformProps(
stack: stackB,
yAxisIndex: yAxisIndexB,
filterState,
seriesKey: primarySeries.has(entry.name as string)
? `${entry.name} (1)`
: entry.name,
});
if (transformedSeries) series.push(transformedSeries);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export function transformSeries(
showValueIndexes?: number[];
thresholdValues?: number[];
richTooltip?: boolean;
seriesKey?: OptionName;
},
): SeriesOption | undefined {
const { name } = series;
Expand All @@ -103,6 +104,7 @@ export function transformSeries(
showValueIndexes = [],
thresholdValues = [],
richTooltip,
seriesKey,
} = opts;
const contexts = seriesContexts[name || ''] || [];
const hasForecast =
Expand Down Expand Up @@ -147,8 +149,9 @@ export function transformSeries(
} else {
plotType = seriesType === 'bar' ? 'bar' : 'line';
}
// forcing the colorScale to return a different color for same metrics across different queries
const itemStyle = {
color: colorScale(forecastSeries.name),
color: colorScale(seriesKey || forecastSeries.name),
opacity,
};
let emphasis = {};
Expand Down

0 comments on commit f565230

Please sign in to comment.