Skip to content

Commit

Permalink
fix(plugin-chart-echarts): fix Time-series line x-filtering not worki…
Browse files Browse the repository at this point in the history
…ng when not rich tooltip (#1302)

* fix(plugin-chart-echarts): fix Time-series line x-filtering not working

* fix: fix emphasis

* fix: size
  • Loading branch information
stephenLYZ authored and zhaoyongjie committed Nov 26, 2021
1 parent 4d29bd4 commit c31892e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export default function transformProps(
showValue,
totalStackedValues,
showValueIndexes,
richTooltip,
});
if (transformedSeries) series.push(transformedSeries);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export function transformSeries(
formatter?: NumberFormatter;
totalStackedValues?: number[];
showValueIndexes?: number[];
richTooltip?: boolean;
},
): SeriesOption | undefined {
const { name } = series;
Expand All @@ -95,6 +96,7 @@ export function transformSeries(
formatter,
totalStackedValues = [],
showValueIndexes = [],
richTooltip,
} = opts;

const forecastSeries = extractForecastSeriesContext(name || '');
Expand Down Expand Up @@ -128,6 +130,11 @@ export function transformSeries(
} else {
plotType = seriesType === 'bar' ? 'bar' : 'line';
}
const itemStyle = {
color: colorScale(forecastSeries.name),
opacity,
};
let emphasis = {};
let showSymbol = false;
if (!isConfidenceBand) {
if (plotType === 'scatter') {
Expand All @@ -136,6 +143,16 @@ export function transformSeries(
showSymbol = true;
} else if (plotType === 'line' && showValue) {
showSymbol = true;
} else if (plotType === 'line' && !richTooltip && !markerEnabled) {
// this is hack to make timeseries line chart clickable when tooltip trigger is 'item'
// so that the chart can emit cross-filtering
showSymbol = true;
itemStyle.opacity = 0;
emphasis = {
itemStyle: {
opacity: 1,
},
};
} else if (markerEnabled) {
showSymbol = true;
}
Expand All @@ -145,10 +162,7 @@ export function transformSeries(
...series,
yAxisIndex,
name: forecastSeries.name,
itemStyle: {
color: colorScale(forecastSeries.name),
opacity,
},
itemStyle,
// @ts-ignore
type: plotType,
smooth: seriesType === 'smooth',
Expand All @@ -162,6 +176,7 @@ export function transformSeries(
? opacity * areaOpacity
: 0,
},
emphasis,
showSymbol,
symbolSize: markerSize,
label: {
Expand Down

0 comments on commit c31892e

Please sign in to comment.