You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2020/09/29 07:04:48 UTC

[incubator-echarts] branch next updated: fix(line): fix default formatter not apply value animation in endLabel

This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch next
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git


The following commit(s) were added to refs/heads/next by this push:
     new a499570  fix(line): fix default formatter not apply value animation in endLabel
a499570 is described below

commit a499570c861606f9831871b7aa8b5323ca078242
Author: pissang <bm...@gmail.com>
AuthorDate: Tue Sep 29 15:04:18 2020 +0800

    fix(line): fix default formatter not apply value animation in endLabel
---
 src/chart/line/LineView.ts | 11 +++++++----
 src/label/labelStyle.ts    |  6 ++++--
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/chart/line/LineView.ts b/src/chart/line/LineView.ts
index 245c230..9c6c91e 100644
--- a/src/chart/line/LineView.ts
+++ b/src/chart/line/LineView.ts
@@ -52,11 +52,10 @@ import { setStatesStylesFromModel, setStatesFlag, enableHoverEmphasis } from '..
 import Displayable from 'zrender/src/graphic/Displayable';
 import Model from '../../model/Model';
 import {setLabelStyle, getLabelStatesModels, labelInner} from '../../label/labelStyle';
-import {getDefaultLabel} from '../helper/labelHelper';
+import {getDefaultLabel, getDefaultInterpolatedLabel} from '../helper/labelHelper';
 
 import { getECData } from '../../util/innerStore';
 import { createFloat32Array } from '../../util/vendor';
-import Cartesian from '../../coord/cartesian/Cartesian';
 
 type PolarArea = ReturnType<Polar['getArea']>;
 type Cartesian2DArea = ReturnType<Cartesian2D['getArea']>;
@@ -983,6 +982,7 @@ class LineView extends ChartView {
         const endLabelModel = seriesModel.getModel('endLabel');
 
         if (endLabelModel.get('show')) {
+            const data = seriesModel.getData();
             const polyline = this._polyline;
             let endLabel = this._endLabel;
             if (!endLabel) {
@@ -1003,7 +1003,10 @@ class LineView extends ChartView {
                     {
                         labelFetcher: seriesModel,
                         labelDataIndex: dataIndex,
-                        defaultText: getDefaultLabel(seriesModel.getData(), dataIndex),
+                        defaultText(dataIndex, opt, overrideValue) {
+                            return overrideValue ? getDefaultInterpolatedLabel(data, overrideValue)
+                                : getDefaultLabel(data, dataIndex);
+                        },
                         enableTextSetter: true
                     },
                     getEndLabelStateSpecified(endLabelModel, coordSys)
@@ -1083,7 +1086,7 @@ class LineView extends ChartView {
                 endLabel.attr({ x: pt[0], y: pt[1] });
             }
             if (valueAnimation) {
-                labelInner(endLabel).setLabelText(value);
+                labelInner(endLabel).setLabelText(value, );
             }
         }
     }
diff --git a/src/label/labelStyle.ts b/src/label/labelStyle.ts
index c8ddd71..6a584c7 100644
--- a/src/label/labelStyle.ts
+++ b/src/label/labelStyle.ts
@@ -42,7 +42,9 @@ type TextCommonParams = {
 const EMPTY_OBJ = {};
 
 interface SetLabelStyleOpt<LDI> extends TextCommonParams {
-    defaultText?: string | ((labelDataIndex: LDI, opt: SetLabelStyleOpt<LDI>) => string);
+    defaultText?: string | ((
+        labelDataIndex: LDI, opt: SetLabelStyleOpt<LDI>, overrideValue?: ParsedValue | ParsedValue[]
+    ) => string);
     // Fetch text by:
     // opt.labelFetcher.getFormattedLabel(
     //     opt.labelDataIndex, 'normal'/'emphasis', null, opt.labelDimIndex, opt.labelProp
@@ -115,7 +117,7 @@ export function getLabelText<LDI>(
         );
     }
     if (baseText == null) {
-        baseText = isFunction(opt.defaultText) ? opt.defaultText(labelDataIndex, opt) : opt.defaultText;
+        baseText = isFunction(opt.defaultText) ? opt.defaultText(labelDataIndex, opt, overrideValue) : opt.defaultText;
     }
 
     const statesText = {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org