mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix(timeshiftcolor): Time shift color to match the original color (#38473)
This commit is contained in:
@@ -336,6 +336,7 @@ export default function transformProps(
|
||||
chartProps.rawFormData,
|
||||
seriesName,
|
||||
);
|
||||
|
||||
const lineStyle: LineStyleOption = {};
|
||||
if (derivedSeries) {
|
||||
// Get the time offset for this series to assign different dash patterns
|
||||
@@ -370,7 +371,21 @@ export default function transformProps(
|
||||
|
||||
let colorScaleKey = getOriginalSeries(seriesName, array);
|
||||
|
||||
// If series name exactly matches a time offset (single metric case),
|
||||
// When there's a single metric with dimensions, the backend replaces the metric
|
||||
// with the time offset in derived series (e.g., "28 days ago, Medium" instead of
|
||||
// "SUM(sales), 28 days ago, Medium"). To match colors, strip the metric label
|
||||
// from original series so both produce the same key (e.g., "Medium").
|
||||
if (
|
||||
groupby &&
|
||||
groupby.length > 0 &&
|
||||
array.length > 0 &&
|
||||
metrics?.length === 1
|
||||
) {
|
||||
const metricLabel = getMetricLabel(metrics[0]);
|
||||
colorScaleKey = colorScaleKey.replace(`${metricLabel}, `, '');
|
||||
}
|
||||
|
||||
// If series name exactly matches a time offset (single metric case, no dimensions),
|
||||
// find the original series for color matching
|
||||
if (derivedSeries && array.includes(seriesName)) {
|
||||
const originalSeries = rawSeries.find(
|
||||
|
||||
Reference in New Issue
Block a user