You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/02/08 03:40:11 UTC
[GitHub] [superset] zhaoyongjie commented on a change in pull request #18603: fix(Explore): Force different color for same metrics in Mixed Time-Series
zhaoyongjie commented on a change in pull request #18603:
URL: https://github.com/apache/superset/pull/18603#discussion_r801240112
##########
File path: superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts
##########
@@ -147,8 +148,14 @@ export function transformSeries(
} else {
plotType = seriesType === 'bar' ? 'bar' : 'line';
}
+ const rawSeriesBHasMetric = !!(rawSeriesB || []).find(
+ (serie: SeriesOption) => serie.name === forecastSeries.name,
+ );
+ // forcing the colorScale to return a different color for same metrics across different queries
const itemStyle = {
- color: colorScale(forecastSeries.name),
+ color: colorScale(
+ rawSeriesBHasMetric ? `${forecastSeries.name}-A` : forecastSeries.name,
+ ),
Review comment:
```suggestion
color: colorScale(seriesHash || forecastSeries.name),
```
##########
File path: superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
##########
@@ -165,19 +165,25 @@ export default function transformProps(
);
rawSeriesA.forEach(entry => {
- const transformedSeries = transformSeries(entry, colorScale, {
- area,
- markerEnabled,
- markerSize,
- areaOpacity: opacity,
- seriesType,
- showValue,
- stack,
- yAxisIndex,
- filterState,
- });
+ const transformedSeries = transformSeries(
+ entry,
+ colorScale,
+ {
+ area,
+ markerEnabled,
+ markerSize,
+ areaOpacity: opacity,
+ seriesType,
+ showValue,
+ stack,
+ yAxisIndex,
+ filterState,
+ },
+ rawSeriesB,
Review comment:
```suggestion
filterState,
seriesHash: `query A ${metric name} ${series name}` <---- make a hash key for different series
},
```
##########
File path: superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts
##########
@@ -84,6 +84,7 @@ export function transformSeries(
thresholdValues?: number[];
richTooltip?: boolean;
},
+ rawSeriesB?: SeriesOption[],
Review comment:
transformSeries means how to generate echart SeriesOption from form_data. we can set different attributes on the different series to resolve this issue.
```suggestion
richTooltip?: boolean;
seriesHash?: string;
},
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org