This is an automated email from the ASF dual-hosted git repository. sushuang pushed a commit to branch fix/label-valueAnimation in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git
commit a40a3ebc4320e2d4b9eb1a96e51fe941ccca216a Author: 100pah <sushuang0...@gmail.com> AuthorDate: Wed Dec 9 17:50:51 2020 +0800 ts: remove some any. --- src/chart/helper/labelHelper.ts | 3 ++- src/chart/sankey/SankeySeries.ts | 6 +++--- src/data/helper/dataProvider.ts | 8 +++++--- src/model/mixin/dataFormat.ts | 3 ++- src/util/types.ts | 4 ++-- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/chart/helper/labelHelper.ts b/src/chart/helper/labelHelper.ts index 5e45f21..d74451f 100644 --- a/src/chart/helper/labelHelper.ts +++ b/src/chart/helper/labelHelper.ts @@ -35,7 +35,8 @@ export function getDefaultLabel( // Simple optimization (in lots of cases, label dims length is 1) if (len === 1) { - return retrieveRawValue(data, dataIndex, labelDims[0]); + const rawVal = retrieveRawValue(data, dataIndex, labelDims[0]); + return rawVal != null ? rawVal + '' : void 0; } else if (len) { const vals = []; diff --git a/src/chart/sankey/SankeySeries.ts b/src/chart/sankey/SankeySeries.ts index 8914aa6..ff94fc7 100644 --- a/src/chart/sankey/SankeySeries.ts +++ b/src/chart/sankey/SankeySeries.ts @@ -237,7 +237,7 @@ class SankeySeriesModel extends SeriesModel<SankeySeriesOption> { // dataType === 'node' or empty do not show tooltip by default if (dataType === 'edge') { const params = this.getDataParams(dataIndex, dataType); - const rawDataOpt = params.data; + const rawDataOpt = params.data as SankeyEdgeItemOption; const edgeValue = params.value; const edgeName = rawDataOpt.source + ' -- ' + rawDataOpt.target; return createTooltipMarkup('nameValue', { @@ -250,9 +250,9 @@ class SankeySeriesModel extends SeriesModel<SankeySeriesOption> { else { const node = this.getGraph().getNodeByIndex(dataIndex); const value = node.getLayout().value; - const name = this.getDataParams(dataIndex, dataType).data.name; + const name = (this.getDataParams(dataIndex, dataType).data as SankeyNodeItemOption).name; return createTooltipMarkup('nameValue', { - name: name, + name: name != null ? name + '' : void 0, value: value, noValue: noValue(value) }); diff --git a/src/data/helper/dataProvider.ts b/src/data/helper/dataProvider.ts index cd378c3..412f69e 100644 --- a/src/data/helper/dataProvider.ts +++ b/src/data/helper/dataProvider.ts @@ -408,8 +408,8 @@ type RawSourceValueGetter = ( dataItem: OptionDataItem, dimIndex: DimensionIndex, dimName: DimensionName - // If dimIndex not provided, return OptionDataItem. - // If dimIndex provided, return OptionDataPrimitive. + // If dimIndex is null/undefined, return OptionDataItem. + // Otherwise, return OptionDataValue. ) => OptionDataValue | OptionDataItem; const getRawValueSimply = function ( @@ -469,7 +469,9 @@ function getMethodMapKey(sourceFormat: SourceFormat, seriesLayoutBy: SeriesLayou // TODO: consider how to treat null/undefined/NaN when display? export function retrieveRawValue( data: List, dataIndex: number, dim?: DimensionName | DimensionIndexLoose -): any { + // If dimIndex is null/undefined, return OptionDataItem. + // Otherwise, return OptionDataValue. +): OptionDataValue | OptionDataItem { if (!data) { return; } diff --git a/src/model/mixin/dataFormat.ts b/src/model/mixin/dataFormat.ts index 83b492f..8a28b01 100644 --- a/src/model/mixin/dataFormat.ts +++ b/src/model/mixin/dataFormat.ts @@ -146,7 +146,8 @@ export class DataFormatMixin { if (dim.charAt(0) === '[' && dim.charAt(len - 1) === ']') { dim = +dim.slice(1, len - 1); // Also: '[]' => 0 } - return retrieveRawValue(data, dataIndex, dim); + const val = retrieveRawValue(data, dataIndex, dim) as OptionDataValue; + return val != null ? val + '' : ''; }); } } diff --git a/src/util/types.ts b/src/util/types.ts index 94e53a4..ba3785b 100644 --- a/src/util/types.ts +++ b/src/util/types.ts @@ -631,9 +631,9 @@ export interface CallbackDataParams { seriesName?: string; name: string; dataIndex: number; - data: any; + data: OptionDataItem; dataType?: SeriesDataType; - value: any; + value: OptionDataItem | OptionDataValue; color?: ZRColor; borderColor?: string; dimensionNames?: DimensionName[]; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@echarts.apache.org For additional commands, e-mail: commits-h...@echarts.apache.org