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/04/03 14:09:10 UTC

[incubator-echarts] branch next updated: fix: fix manually brush action not work bug. fix effect polyline.

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 7ed1ed1  fix: fix manually brush action not work bug. fix effect polyline.
7ed1ed1 is described below

commit 7ed1ed1de7dfe1b4948267e92c2938369e068044
Author: pissang <bm...@gmail.com>
AuthorDate: Fri Apr 3 22:08:32 2020 +0800

    fix: fix manually brush action not work bug. fix effect polyline.
---
 src/chart/helper/EffectLine.ts        | 62 ++++++++++++++++++-----------------
 src/chart/helper/EffectPolyline.ts    |  7 ++--
 src/component/brush/BrushView.ts      |  4 +++
 src/component/brush/visualEncoding.ts | 21 +++++-------
 4 files changed, 49 insertions(+), 45 deletions(-)

diff --git a/src/chart/helper/EffectLine.ts b/src/chart/helper/EffectLine.ts
index 66503f0..d269faa 100644
--- a/src/chart/helper/EffectLine.ts
+++ b/src/chart/helper/EffectLine.ts
@@ -60,7 +60,7 @@ class EffectLine extends graphic.Group {
         return new Line(lineData, idx, seriesScope);
     }
 
-    _updateEffectSymbol(lineData: List, idx: number) {
+    private _updateEffectSymbol(lineData: List, idx: number) {
         const itemModel = lineData.getItemModel<LineDrawModelOption>(idx);
         const effectModel = itemModel.getModel('effect');
         let size = effectModel.get('symbolSize');
@@ -106,7 +106,7 @@ class EffectLine extends graphic.Group {
         this._updateEffectAnimation(lineData, effectModel, idx);
     }
 
-    _updateEffectAnimation(
+    private _updateEffectAnimation(
         lineData: List,
         effectModel: Model<LineDrawModelOption['effect']>,
         idx: number
@@ -131,7 +131,7 @@ class EffectLine extends graphic.Group {
         // Ignore when updating
         symbol.ignore = true;
 
-        this.updateAnimationPoints(symbol, points);
+        this._updateAnimationPoints(symbol, points);
 
         if (constantSpeed > 0) {
             period = this._getLineLength(symbol) / constantSpeed * 1000;
@@ -141,44 +141,46 @@ class EffectLine extends graphic.Group {
 
             symbol.stopAnimation();
 
-            let delayNum: number;
-            if (typeof delayExpr === 'function') {
-                delayNum = delayExpr(idx);
-            }
-            else {
-                delayNum = delayExpr;
-            }
-            if (symbol.__t > 0) {
-                delayNum = -period * symbol.__t;
-            }
-            symbol.__t = 0;
-            const animator = symbol.animate('', loop)
-                .when(period, {
-                    __t: 1
-                })
-                .delay(delayNum)
-                .during(function () {
-                    self.updateSymbolPosition(symbol);
-                });
-            if (!loop) {
-                animator.done(function () {
-                    self.remove(symbol);
-                });
+            if (period > 0) {
+                let delayNum: number;
+                if (typeof delayExpr === 'function') {
+                    delayNum = delayExpr(idx);
+                }
+                else {
+                    delayNum = delayExpr;
+                }
+                if (symbol.__t > 0) {
+                    delayNum = -period * symbol.__t;
+                }
+                symbol.__t = 0;
+                const animator = symbol.animate('', loop)
+                    .when(period, {
+                        __t: 1
+                    })
+                    .delay(delayNum)
+                    .during(function () {
+                        self._updateSymbolPosition(symbol);
+                    });
+                if (!loop) {
+                    animator.done(function () {
+                        self.remove(symbol);
+                    });
+                }
+                animator.start();
             }
-            animator.start();
         }
 
         this._period = period;
         this._loop = loop;
     }
 
-    private _getLineLength(symbol: ECSymbolOnEffectLine) {
+    protected _getLineLength(symbol: ECSymbolOnEffectLine) {
         // Not so accurate
         return (vec2.dist(symbol.__p1, symbol.__cp1)
             + vec2.dist(symbol.__cp1, symbol.__p2));
     }
 
-    protected updateAnimationPoints(symbol: ECSymbolOnEffectLine, points: number[][]) {
+    protected _updateAnimationPoints(symbol: ECSymbolOnEffectLine, points: number[][]) {
         symbol.__p1 = points[0];
         symbol.__p2 = points[1];
         symbol.__cp1 = points[2] || [
@@ -192,7 +194,7 @@ class EffectLine extends graphic.Group {
         this._updateEffectSymbol(lineData, idx);
     }
 
-    updateSymbolPosition(symbol: ECSymbolOnEffectLine) {
+    protected _updateSymbolPosition(symbol: ECSymbolOnEffectLine) {
         const p1 = symbol.__p1;
         const p2 = symbol.__p2;
         const cp1 = symbol.__cp1;
diff --git a/src/chart/helper/EffectPolyline.ts b/src/chart/helper/EffectPolyline.ts
index 2211b59..8049975 100644
--- a/src/chart/helper/EffectPolyline.ts
+++ b/src/chart/helper/EffectPolyline.ts
@@ -38,7 +38,7 @@ class EffectPolyline extends EffectLine {
     };
 
     // Override
-    protected updateAnimationPoints(symbol: ECSymbolOnEffectLine, points: number[][]) {
+    protected _updateAnimationPoints(symbol: ECSymbolOnEffectLine, points: number[][]) {
         this._points = points;
         const accLenArr = [0];
         let len = 0;
@@ -49,6 +49,7 @@ class EffectPolyline extends EffectLine {
             accLenArr.push(len);
         }
         if (len === 0) {
+            this._length = 0;
             return;
         }
 
@@ -60,12 +61,12 @@ class EffectPolyline extends EffectLine {
     };
 
     // Override
-    getLineLength() {
+    protected _getLineLength() {
         return this._length;
     };
 
     // Override
-    updateSymbolPosition(symbol: ECSymbolOnEffectLine) {
+    protected _updateSymbolPosition(symbol: ECSymbolOnEffectLine) {
         const t = symbol.__t;
         const points = this._points;
         const offsets = this._offsets;
diff --git a/src/component/brush/BrushView.ts b/src/component/brush/BrushView.ts
index 6b7e090..06563a1 100644
--- a/src/component/brush/BrushView.ts
+++ b/src/component/brush/BrushView.ts
@@ -61,6 +61,10 @@ class BrushView extends ComponentView {
         this._updateController(brushModel, ecModel, api, payload);
     }
 
+    updateVisual(brushModel: BrushModel, ecModel: GlobalModel, api: ExtensionAPI, payload: Payload) {
+        this.updateTransform(brushModel, ecModel, api, payload);
+    }
+
     updateView(brushModel: BrushModel, ecModel: GlobalModel, api: ExtensionAPI, payload: Payload) {
         this._updateController(brushModel, ecModel, api, payload);
     }
diff --git a/src/component/brush/visualEncoding.ts b/src/component/brush/visualEncoding.ts
index 97509c9..87a9ea1 100644
--- a/src/component/brush/visualEncoding.ts
+++ b/src/component/brush/visualEncoding.ts
@@ -59,18 +59,6 @@ interface BrushSelectedItem {
     }[]
 };
 
-/**
- * Layout for visual, the priority higher than other layout, and before brush visual.
- */
-echarts.registerLayout(PRIORITY_BRUSH, function (ecModel: GlobalModel, api: ExtensionAPI, payload: Payload) {
-    ecModel.eachComponent({mainType: 'brush'}, function (brushModel: BrushModel) {
-        payload && payload.type === 'takeGlobalCursor' && brushModel.setBrushOption(
-            payload.key === 'brush' ? payload.brushOption : {brushType: false}
-        );
-    });
-    layoutCovers(ecModel);
-});
-
 export function layoutCovers(ecModel: GlobalModel): void {
     ecModel.eachComponent({mainType: 'brush'}, function (brushModel: BrushModel) {
         const brushTargetManager = brushModel.brushTargetManager = new BrushTargetManager(brushModel.option, ecModel);
@@ -87,6 +75,15 @@ echarts.registerVisual(PRIORITY_BRUSH, function (ecModel: GlobalModel, api: Exte
     let throttleType;
     let throttleDelay;
 
+    ecModel.eachComponent({mainType: 'brush'}, function (brushModel: BrushModel) {
+        payload && payload.type === 'takeGlobalCursor' && brushModel.setBrushOption(
+            payload.key === 'brush' ? payload.brushOption : {brushType: false}
+        );
+    });
+
+    layoutCovers(ecModel);
+
+
     ecModel.eachComponent({mainType: 'brush'}, function (brushModel: BrushModel, brushIndex) {
 
         const thisBrushSelected: BrushSelectedItem = {


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