You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by wa...@apache.org on 2021/04/21 17:21:37 UTC

[echarts] branch fix-marker created (now ad05359)

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

wangzx pushed a change to branch fix-marker
in repository https://gitbox.apache.org/repos/asf/echarts.git.


      at ad05359  fix(MarkerLine): add missing value type `string | number` to `symbolOffset` and add missing return type `string | number` to `SymbolOffsetCallback`.

This branch includes the following new commits:

     new 03fd554  fix(markPoint): symbolOffset & symbolKeepAspect doesn't work in MarkPoint.
     new ad05359  fix(MarkerLine): add missing value type `string | number` to `symbolOffset` and add missing return type `string | number` to `SymbolOffsetCallback`.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


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


[echarts] 01/02: fix(markPoint): symbolOffset & symbolKeepAspect doesn't work in MarkPoint.

Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wangzx pushed a commit to branch fix-marker
in repository https://gitbox.apache.org/repos/asf/echarts.git

commit 03fd5546367812d063c6550ddb098ff4482de0a7
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Thu Apr 22 00:55:25 2021 +0800

    fix(markPoint): symbolOffset & symbolKeepAspect doesn't work in MarkPoint.
    
    - current callback function logic seems inappropriate, data item should not support callback. refactor needed.
---
 src/component/marker/MarkPointView.ts | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/component/marker/MarkPointView.ts b/src/component/marker/MarkPointView.ts
index 82f1d69..b7cf0a2 100644
--- a/src/component/marker/MarkPointView.ts
+++ b/src/component/marker/MarkPointView.ts
@@ -120,8 +120,11 @@ class MarkPointView extends MarkerView {
             let symbol = itemModel.getShallow('symbol');
             let symbolSize = itemModel.getShallow('symbolSize');
             let symbolRotate = itemModel.getShallow('symbolRotate');
+            let symbolOffset = itemModel.getShallow('symbolOffset');
+            const symbolKeepAspect = itemModel.getShallow('symbolKeepAspect');
 
-            if (isFunction(symbol) || isFunction(symbolSize) || isFunction(symbolRotate)) {
+            // TODO: refactor needed: single data item should not support callback function
+            if (isFunction(symbol) || isFunction(symbolSize) || isFunction(symbolRotate) || isFunction(symbolOffset)) {
                 const rawIdx = mpModel.getRawValue(idx);
                 const dataParams = mpModel.getDataParams(idx);
                 if (isFunction(symbol)) {
@@ -134,6 +137,9 @@ class MarkPointView extends MarkerView {
                 if (isFunction(symbolRotate)) {
                     symbolRotate = symbolRotate(rawIdx, dataParams);
                 }
+                if (isFunction(symbolOffset)) {
+                    symbolOffset = symbolOffset(rawIdx, dataParams);
+                }
             }
 
             const style = itemModel.getModel('itemStyle').getItemStyle();
@@ -146,6 +152,8 @@ class MarkPointView extends MarkerView {
                 symbol: symbol,
                 symbolSize: symbolSize,
                 symbolRotate: symbolRotate,
+                symbolOffset: symbolOffset,
+                symbolKeepAspect: symbolKeepAspect,
                 style
             });
         });
@@ -209,4 +217,4 @@ function createList(
     return mpData;
 }
 
-export default MarkPointView;
\ No newline at end of file
+export default MarkPointView;

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


[echarts] 02/02: fix(MarkerLine): add missing value type `string | number` to `symbolOffset` and add missing return type `string | number` to `SymbolOffsetCallback`.

Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wangzx pushed a commit to branch fix-marker
in repository https://gitbox.apache.org/repos/asf/echarts.git

commit ad053597fe9dfaa163fadf1cfcdd2db4fb86699f
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Thu Apr 22 01:15:10 2021 +0800

    fix(MarkerLine): add missing value type `string | number` to `symbolOffset` and add missing return type `string | number` to `SymbolOffsetCallback`.
---
 src/chart/helper/Line.ts             |  2 +-
 src/component/marker/MarkLineView.ts | 25 +++++++++++++++++++++----
 src/util/types.ts                    |  4 ++--
 src/visual/symbol.ts                 |  2 +-
 4 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/src/chart/helper/Line.ts b/src/chart/helper/Line.ts
index b2edb27..4ec9df8 100644
--- a/src/chart/helper/Line.ts
+++ b/src/chart/helper/Line.ts
@@ -81,7 +81,7 @@ function createSymbol(name: 'fromSymbol' | 'toSymbol', lineData: LineList, idx:
         ? symbolOffset : [symbolOffset, symbolOffset];
 
     symbolOffsetArr[0] = parsePercent(symbolOffsetArr[0], symbolSizeArr[0]);
-    symbolOffsetArr[1] = parsePercent(retrieve2(symbolOffsetArr[1], symbolOffsetArr[0]),symbolSizeArr[1]);
+    symbolOffsetArr[1] = parsePercent(retrieve2(symbolOffsetArr[1], symbolOffsetArr[0]), symbolSizeArr[1]);
 
     const symbolPath = symbolUtil.createSymbol(
         symbolType,
diff --git a/src/component/marker/MarkLineView.ts b/src/component/marker/MarkLineView.ts
index 902a574..1495cac 100644
--- a/src/component/marker/MarkLineView.ts
+++ b/src/component/marker/MarkLineView.ts
@@ -318,10 +318,15 @@ class MarkLineView extends MarkerView {
         // Line data for tooltip and formatter
         mlModel.setData(lineData);
 
+        // TODO
+        // Functionally, `symbolSize` & `symbolOffset` can also be 2D array now.
+        // But the related logic and type definition are not finished yet.
+        // Finish it if required
         let symbolType = mlModel.get('symbol');
         let symbolSize = mlModel.get('symbolSize');
         let symbolRotate = mlModel.get('symbolRotate');
         let symbolOffset = mlModel.get('symbolOffset');
+        // TODO: support callback function like markPoint
         if (!isArray(symbolType)) {
             symbolType = [symbolType, symbolType];
         }
@@ -401,10 +406,22 @@ class MarkLineView extends MarkerView {
             data.setItemVisual(idx, {
                 symbolKeepAspect: itemModel.get('symbolKeepAspect'),
                 // `0` should be considered as a valid value, so use `retrieve2` instead of `||`
-                symbolOffset: retrieve2(itemModel.get('symbolOffset'), (symbolOffset as (string | number)[])[isFrom ? 0 : 1]),
-                symbolRotate: retrieve2(itemModel.get('symbolRotate', true), (symbolRotate as number[])[isFrom ? 0 : 1]),
-                symbolSize: retrieve2(itemModel.get('symbolSize'), (symbolSize as number[])[isFrom ? 0 : 1]),
-                symbol: retrieve2(itemModel.get('symbol', true), (symbolType as string[])[isFrom ? 0 : 1]),
+                symbolOffset: retrieve2(
+                    itemModel.get('symbolOffset', true),
+                    (symbolOffset as (string | number)[])[isFrom ? 0 : 1]
+                ),
+                symbolRotate: retrieve2(
+                    itemModel.get('symbolRotate', true),
+                    (symbolRotate as number[])[isFrom ? 0 : 1]
+                ),
+                symbolSize: retrieve2(
+                    itemModel.get('symbolSize', true),
+                    (symbolSize as number[])[isFrom ? 0 : 1]
+                ),
+                symbol: retrieve2(
+                    itemModel.get('symbol', true),
+                    (symbolType as string[])[isFrom ? 0 : 1]
+                ),
                 style
             });
         }
diff --git a/src/util/types.ts b/src/util/types.ts
index 62ddb56..67285a2 100644
--- a/src/util/types.ts
+++ b/src/util/types.ts
@@ -922,7 +922,7 @@ export interface RoamOptionMixin {
 export type SymbolSizeCallback<T> = (rawValue: any, params: T) => number | number[];
 export type SymbolCallback<T> = (rawValue: any, params: T) => string;
 export type SymbolRotateCallback<T> = (rawValue: any, params: T) => number;
-export type SymbolOffsetCallback<T> = (rawValue: any, params: T) => (string | number)[];
+export type SymbolOffsetCallback<T> = (rawValue: any, params: T) => string | number | (string | number)[];
 /**
  * Mixin of option set to control the element symbol.
  * Include type of symbol, and size of symbol.
@@ -941,7 +941,7 @@ export interface SymbolOptionMixin<T = unknown> {
 
     symbolKeepAspect?: boolean
 
-    symbolOffset?: (string | number)[] | (unknown extends T ? never : SymbolOffsetCallback<T>)
+    symbolOffset?: string | number | (string | number)[] | (unknown extends T ? never : SymbolOffsetCallback<T>)
 }
 
 /**
diff --git a/src/visual/symbol.ts b/src/visual/symbol.ts
index e15e425..59fdcfc 100644
--- a/src/visual/symbol.ts
+++ b/src/visual/symbol.ts
@@ -83,7 +83,7 @@ const seriesSymbolTask: StageHandler = {
             symbolSize: seriesSymbolSize as number | number[],
             symbolKeepAspect: keepAspect,
             symbolRotate: seriesSymbolRotate as number,
-            symbolOffset: seriesSymbolOffset as (string | number)[]
+            symbolOffset: seriesSymbolOffset as string | number | (string | number)[]
         });
 
         // Only visible series has each data be visual encoded

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