Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
geido committed Feb 8, 2022
1 parent 754c334 commit 6b0f3c7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,27 +175,26 @@ 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,
markerEnabled: markerEnabledB,
markerSize: markerSizeB,
areaOpacity: opacityB,
seriesType: seriesTypeB,
showValue: showValueB,
stack: stackB,
yAxisIndex: yAxisIndexB,
filterState,
},
rawSeriesA,
);
const transformedSeries = transformSeries(entry, colorScale, {
area: areaB,
markerEnabled: markerEnabledB,
markerSize: markerSizeB,
areaOpacity: opacityB,
seriesType: seriesTypeB,
showValue: showValueB,
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,8 +83,8 @@ export function transformSeries(
showValueIndexes?: number[];
thresholdValues?: number[];
richTooltip?: boolean;
seriesKey?: OptionName;
},
additionalSeriesGroup?: SeriesOption[],
): SeriesOption | undefined {
const { name } = series;
const {
Expand All @@ -104,6 +104,7 @@ export function transformSeries(
showValueIndexes = [],
thresholdValues = [],
richTooltip,
seriesKey,
} = opts;
const contexts = seriesContexts[name || ''] || [];
const hasForecast =
Expand Down Expand Up @@ -148,20 +149,9 @@ export function transformSeries(
} else {
plotType = seriesType === 'bar' ? 'bar' : 'line';
}
// checking if the same metric name is available in the previous query
const metricExists = !!(additionalSeriesGroup || []).find(
(serie: SeriesOption) => {
const otherForecastedSeries = extractForecastSeriesContext(
serie.name || '',
);
return otherForecastedSeries.name === forecastSeries.name;
},
);
// forcing the colorScale to return a different color for same metrics across different queries
const itemStyle = {
color: colorScale(
metricExists ? `${forecastSeries.name} (1)` : forecastSeries.name,
),
color: colorScale(seriesKey || forecastSeries.name),
opacity,
};
let emphasis = {};
Expand Down

0 comments on commit 6b0f3c7

Please sign in to comment.