feat(plugin-chart-echarts): [feature-parity] support extra control for the area chart V2 (#16493)

* feat(echarts): [feature-parity] support extra control

* add extra control for plugin

* refactor: extract ExtraControl

* fix: lint

* fix some problems
This commit is contained in:
Stephen Liu
2022-06-09 00:59:10 +08:00
committed by GitHub
parent 0238492df7
commit eab0009101
19 changed files with 349 additions and 70 deletions

View File

@@ -52,7 +52,7 @@ import {
import { MarkLine1DDataItemOption } from 'echarts/types/src/component/marker/MarkLineModel';
import { extractForecastSeriesContext } from '../utils/forecast';
import { ForecastSeriesEnum, LegendOrientation } from '../types';
import { ForecastSeriesEnum, LegendOrientation, StackType } from '../types';
import { EchartsTimeseriesSeriesType } from './types';
import {
@@ -62,7 +62,11 @@ import {
parseAnnotationOpacity,
} from '../utils/annotation';
import { currentSeries, getChartPadding } from '../utils/series';
import { OpacityEnum, TIMESERIES_CONSTANTS } from '../constants';
import {
AreaChartExtraControlsValue,
OpacityEnum,
TIMESERIES_CONSTANTS,
} from '../constants';
export function transformSeries(
series: SeriesOption,
@@ -75,7 +79,7 @@ export function transformSeries(
markerSize?: number;
areaOpacity?: number;
seriesType?: EchartsTimeseriesSeriesType;
stack?: boolean;
stack?: StackType;
yAxisIndex?: number;
showValue?: boolean;
onlyTotal?: boolean;
@@ -225,6 +229,7 @@ export function transformSeries(
const { value, dataIndex, seriesIndex, seriesName } = params;
const numericValue = isHorizontal ? value[0] : value[1];
const isSelectedLegend = currentSeries.legend === seriesName;
const isAreaExpand = stack === AreaChartExtraControlsValue.Expand;
if (!formatter) return numericValue;
if (!stack || isSelectedLegend) return formatter(numericValue);
if (!onlyTotal) {
@@ -234,7 +239,7 @@ export function transformSeries(
return '';
}
if (seriesIndex === showValueIndexes[dataIndex]) {
return formatter(totalStackedValues[dataIndex]);
return formatter(isAreaExpand ? 1 : totalStackedValues[dataIndex]);
}
return '';
},