Skip to content

Commit dd0788d

Browse files
msyavuzclaude
andcommitted
fix(echarts): fix time shift color matching functionality
The "Match time shift color with original series" checkbox was not working because time-shifted series names (e.g., "28 days ago") could not be properly mapped back to their original series for color matching. This fix adds logic to detect when a series name exactly matches a time comparison value and finds the corresponding original series to use its color key, ensuring time-shifted series use the same colors as their original series when the checkbox is enabled. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 93cb60b commit dd0788d

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ export default function transformProps(
200200
zoomable,
201201
stackDimension,
202202
}: EchartsTimeseriesFormData = { ...DEFAULT_FORM_DATA, ...formData };
203+
203204
const refs: Refs = {};
204205
const groupBy = ensureIsArray(groupby);
205206
const labelMap: { [key: string]: string[] } = Object.entries(
@@ -301,7 +302,24 @@ export default function transformProps(
301302

302303
const entryName = String(entry.name || '');
303304
const seriesName = inverted[entryName] || entryName;
304-
const colorScaleKey = getOriginalSeries(seriesName, array);
305+
306+
let colorScaleKey = getOriginalSeries(seriesName, array);
307+
308+
// If this series name exactly matches a time compare value, it's a time-shifted series
309+
// and we need to find the corresponding original series for color matching
310+
if (array && array.includes(seriesName)) {
311+
// Find the original series (first non-time-compare series)
312+
const originalSeries = rawSeries.find(s => {
313+
const sName = inverted[String(s.name || '')] || String(s.name || '');
314+
return !array.includes(sName);
315+
});
316+
if (originalSeries) {
317+
const originalSeriesName =
318+
inverted[String(originalSeries.name || '')] ||
319+
String(originalSeries.name || '');
320+
colorScaleKey = getOriginalSeries(originalSeriesName, array);
321+
}
322+
}
305323

306324
const transformedSeries = transformSeries(
307325
entry,

0 commit comments

Comments
 (0)