You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ms...@apache.org on 2025/10/24 08:06:26 UTC
(superset) 01/01: fix(echarts): fix time shift color matching functionality
This is an automated email from the ASF dual-hosted git repository.
msyavuz pushed a commit to branch msyavuz/fix/match-timeshift-color
in repository https://gitbox.apache.org/repos/asf/superset.git
commit dd0788d9bca9bc25c5d8e4a9fcd8ae51438e8ca2
Author: Mehmet Salih Yavuz <sa...@proton.me>
AuthorDate: Fri Oct 24 11:05:56 2025 +0300
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 <no...@anthropic.com>
---
.../src/Timeseries/transformProps.ts | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
index dac90937e3..9e897e2952 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
@@ -200,6 +200,7 @@ export default function transformProps(
zoomable,
stackDimension,
}: EchartsTimeseriesFormData = { ...DEFAULT_FORM_DATA, ...formData };
+
const refs: Refs = {};
const groupBy = ensureIsArray(groupby);
const labelMap: { [key: string]: string[] } = Object.entries(
@@ -301,7 +302,24 @@ export default function transformProps(
const entryName = String(entry.name || '');
const seriesName = inverted[entryName] || entryName;
- const colorScaleKey = getOriginalSeries(seriesName, array);
+
+ let colorScaleKey = getOriginalSeries(seriesName, array);
+
+ // If this series name exactly matches a time compare value, it's a time-shifted series
+ // and we need to find the corresponding original series for color matching
+ if (array && array.includes(seriesName)) {
+ // Find the original series (first non-time-compare series)
+ const originalSeries = rawSeries.find(s => {
+ const sName = inverted[String(s.name || '')] || String(s.name || '');
+ return !array.includes(sName);
+ });
+ if (originalSeries) {
+ const originalSeriesName =
+ inverted[String(originalSeries.name || '')] ||
+ String(originalSeries.name || '');
+ colorScaleKey = getOriginalSeries(originalSeriesName, array);
+ }
+ }
const transformedSeries = transformSeries(
entry,