fix: adjust line type as well as weight for time series (#30949)
This commit is contained in:
parent
79f21b09d2
commit
550123882c
|
|
@ -45,7 +45,6 @@ import {
|
|||
extractExtraMetrics,
|
||||
getOriginalSeries,
|
||||
isDerivedSeries,
|
||||
getTimeOffset,
|
||||
} from '@superset-ui/chart-controls';
|
||||
import type { EChartsCoreOption } from 'echarts/core';
|
||||
import type { LineStyleOption } from 'echarts/types/src/util/types';
|
||||
|
|
@ -281,21 +280,15 @@ export default function transformProps(
|
|||
const array = ensureIsArray(chartProps.rawFormData?.time_compare);
|
||||
const inverted = invert(verboseMap);
|
||||
|
||||
const offsetLineWidths: { [key: string]: number } = {};
|
||||
let patternIncrement = 0;
|
||||
|
||||
rawSeries.forEach(entry => {
|
||||
const derivedSeries = isDerivedSeries(entry, chartProps.rawFormData);
|
||||
const lineStyle: LineStyleOption = {};
|
||||
if (derivedSeries) {
|
||||
const offset = getTimeOffset(
|
||||
entry,
|
||||
ensureIsArray(chartProps.rawFormData?.time_compare),
|
||||
)!;
|
||||
if (!offsetLineWidths[offset]) {
|
||||
offsetLineWidths[offset] = Object.keys(offsetLineWidths).length + 1;
|
||||
}
|
||||
lineStyle.type = 'dashed';
|
||||
lineStyle.width = offsetLineWidths[offset];
|
||||
patternIncrement += 1;
|
||||
// use a combination of dash and dot for the line style
|
||||
lineStyle.type = [(patternIncrement % 5) + 1, (patternIncrement % 3) + 1];
|
||||
lineStyle.opacity = OpacityEnum.DerivedSeries;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -315,15 +315,7 @@ export function transformSeries(
|
|||
opacity: opacity * areaOpacity,
|
||||
}
|
||||
: undefined,
|
||||
emphasis: {
|
||||
// bold on hover as required since 5.3.0 to retain backwards feature parity:
|
||||
// https://apache.github.io/echarts-handbook/en/basics/release-note/5-3-0/#removing-the-default-bolding-emphasis-effect-in-the-line-chart
|
||||
// TODO: should consider only adding emphasis to currently hovered series
|
||||
lineStyle: {
|
||||
width: 'bolder',
|
||||
},
|
||||
...emphasis,
|
||||
},
|
||||
emphasis,
|
||||
showSymbol,
|
||||
symbolSize: markerSize,
|
||||
label: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue