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/02 08:20:38 UTC

[incubator-echarts] branch next updated (beeac98 -> d585560)

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

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


    from beeac98  refact: fix tree visual. fix treemap roam not update caused by refactor
     new e9388aa  refact: rename brushType in visual to drawType. Avoid confusing with brush component
     new d585560  refact: bug squash after inner visual refactoring

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.


Summary of changes:
 src/chart/bar/BarView.ts             | 11 ++++-
 src/chart/boxplot/BoxplotSeries.ts   |  2 +-
 src/chart/graph/categoryVisual.ts    |  2 +-
 src/chart/graph/edgeVisual.ts        |  2 +-
 src/chart/line/LineView.ts           |  2 +-
 src/chart/lines/LinesSeries.ts       |  2 +-
 src/chart/parallel/ParallelSeries.ts |  2 +-
 src/component/helper/MapDraw.ts      |  8 ++--
 src/component/marker/MarkLineView.ts |  4 +-
 src/data/List.ts                     |  6 +--
 src/echarts.ts                       |  3 +-
 src/model/Series.ts                  |  6 +--
 src/visual/helper.ts                 |  6 +--
 src/visual/style.ts                  | 82 ++++++++++++++++++++++--------------
 14 files changed, 84 insertions(+), 54 deletions(-)


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


[incubator-echarts] 02/02: refact: bug squash after inner visual refactoring

Posted by sh...@apache.org.
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

commit d585560d2768728457a76f29cfaba20edf8b3fdd
Author: pissang <bm...@gmail.com>
AuthorDate: Thu Apr 2 16:19:58 2020 +0800

    refact: bug squash after inner visual refactoring
---
 src/chart/graph/categoryVisual.ts |  2 +-
 src/chart/graph/edgeVisual.ts     |  2 +-
 src/component/helper/MapDraw.ts   |  8 ++--
 src/echarts.ts                    |  3 +-
 src/visual/style.ts               | 78 ++++++++++++++++++++++++---------------
 5 files changed, 57 insertions(+), 36 deletions(-)

diff --git a/src/chart/graph/categoryVisual.ts b/src/chart/graph/categoryVisual.ts
index 593d493..fe5c36c 100644
--- a/src/chart/graph/categoryVisual.ts
+++ b/src/chart/graph/categoryVisual.ts
@@ -37,7 +37,7 @@ export default function (ecModel: GlobalModel) {
             categoryNameIdxMap['ec-' + name] = idx;
             const itemModel = categoriesData.getItemModel<GraphNodeItemOption>(idx);
 
-            const style = itemModel.getItemStyle();
+            const style = itemModel.getModel('itemStyle').getItemStyle();
             if (!style.fill) {
                 // Get color from palette.
                 style.fill = seriesModel.getColorFromPalette(name, paletteScope);
diff --git a/src/chart/graph/edgeVisual.ts b/src/chart/graph/edgeVisual.ts
index 7c74786..ba298b1 100644
--- a/src/chart/graph/edgeVisual.ts
+++ b/src/chart/graph/edgeVisual.ts
@@ -53,7 +53,7 @@ export default function (ecModel: GlobalModel) {
         edgeData.setVisual('fromSymbolSize', symbolSize && symbolSize[0]);
         edgeData.setVisual('toSymbolSize', symbolSize && symbolSize[1]);
 
-        edgeData.setVisual('style', seriesModel.getModel('itemStyle').getItemStyle());
+        edgeData.setVisual('style', seriesModel.getModel('lineStyle').getLineStyle());
 
         edgeData.each(function (idx) {
             const itemModel = edgeData.getItemModel<GraphEdgeItemOption>(idx);
diff --git a/src/component/helper/MapDraw.ts b/src/component/helper/MapDraw.ts
index 11d1a1d..eeec778 100644
--- a/src/component/helper/MapDraw.ts
+++ b/src/component/helper/MapDraw.ts
@@ -147,6 +147,9 @@ class MapDraw {
         const hoverLabelAccessPath = ['emphasis', 'label'] as const;
         const nameMap = zrUtil.createHashMap<RegionsGroup>();
 
+
+        const isVisualEncodedByVisualMap = data.getVisual('visualMeta') && data.getVisual('visualMeta').length > 0;
+
         zrUtil.each(geo.regions, function (region) {
             // Consider in GeoJson properties.name may be duplicated, for example,
             // there is multiple region named "United Kindom" or "France" (so many
@@ -185,13 +188,12 @@ class MapDraw {
             // Use the itemStyle in data if has data
             if (data) {
                 dataIdx = data.indexOfName(region.name);
-                // Only visual color of each item will be used. It can be encoded by dataRange
+                // Only visual color of each item will be used. It can be encoded by visualMap
                 // But visual color of series is used in symbol drawing
                 //
                 // Visual color for each series is for the symbol draw
                 const style = data.getItemVisual(dataIdx, 'style');
-                const globalStyle = data.getVisual('style');
-                if (style !== globalStyle) {
+                if (isVisualEncodedByVisualMap && style.fill) {
                     itemStyle.fill = style.fill;
                 }
             }
diff --git a/src/echarts.ts b/src/echarts.ts
index 6a4c646..9711a77 100644
--- a/src/echarts.ts
+++ b/src/echarts.ts
@@ -40,7 +40,7 @@ import ChartView, {ChartViewConstructor} from './view/Chart';
 import * as graphic from './util/graphic';
 import * as modelUtil from './util/model';
 import {throttle} from './util/throttle';
-import {seriesStyleTask, dataStyleTask} from './visual/style';
+import {seriesStyleTask, dataStyleTask, dataColorPaletteTask} from './visual/style';
 import aria from './visual/aria';
 import loadingDefault from './loading/default';
 import Scheduler from './stream/Scheduler';
@@ -2344,6 +2344,7 @@ export function getMap(mapName: string) {
 // Buitlin global visual
 registerVisual(PRIORITY_VISUAL_GLOBAL, seriesStyleTask);
 registerVisual(PRIORITY_VISUAL_CHART_DATA_CUSTOM, dataStyleTask);
+registerVisual(PRIORITY_VISUAL_CHART_DATA_CUSTOM, dataColorPaletteTask);
 
 registerVisual(PRIORITY_VISUAL_GLOBAL, seriesSymbolTask);
 registerVisual(PRIORITY_VISUAL_CHART_DATA_CUSTOM, dataSymbolTask);
diff --git a/src/visual/style.ts b/src/visual/style.ts
index d96a0cd..8b77540 100644
--- a/src/visual/style.ts
+++ b/src/visual/style.ts
@@ -18,7 +18,7 @@
 */
 
 import { isFunction, extend } from 'zrender/src/core/util';
-import { StageHandler, CallbackDataParams, ZRColor } from '../util/types';
+import { StageHandler, CallbackDataParams, ZRColor, Dictionary } from '../util/types';
 import makeStyleMapper from '../model/mixin/makeStyleMapper';
 import { ITEM_STYLE_KEY_MAP } from '../model/mixin/itemStyle';
 import { LINE_STYLE_KEY_MAP } from '../model/mixin/lineStyle';
@@ -127,41 +127,59 @@ const dataStyleTask: StageHandler = {
             || 'itemStyle';
         // Set in itemStyle
         const getStyle = getStyleMapper(seriesModel, stylePath);
-        const colorKey = getDefaultColorKey(seriesModel, stylePath);
-
-        const idxMap: {[key: number]: number} = {};
-        data.each(function (idx) {
-            const rawIdx = data.getRawIndex(idx);
-            idxMap[idx] = rawIdx;
-        });
 
         return {
-            dataEach: data.hasItemOption ? function (data, idx) {
+            dataEach: (data.hasItemOption || seriesModel.useColorPaletteOnData) ? function (data, idx) {
                 // Not use getItemModel for performance considuration
-                const rawItem = data.getRawDataItem(idx) as any;
-                if (rawItem && rawItem[stylePath]) {
-                    sharedModel.option = rawItem[stylePath];
-                    const style = getStyle(sharedModel);
-
-                    const existsStyle = data.ensureUniqueItemVisual(idx, 'style');
-                    extend(existsStyle, style);
-                }
-
-                if (seriesModel.useColorPaletteOnData) {
-                    const dataAll = seriesModel.getRawData();
-                    const existsStyle = data.ensureUniqueItemVisual(idx, 'style');
-                    const rawIdx = idxMap[idx];
-                    if (!existsStyle[colorKey]) {
-                        // Get color from palette.
-                        existsStyle[colorKey] = seriesModel.getColorFromPalette(
-                            dataAll.getName(rawIdx) || (rawIdx + ''),
-                            (seriesModel as SeriesModelWithPaletteScope).__paletteScope,
-                            dataAll.count()
-                        );
+                if (data.hasItemOption) {
+                    const rawItem = data.getRawDataItem(idx) as any;
+                    if (rawItem && rawItem[stylePath]) {
+                        sharedModel.option = rawItem[stylePath];
+                        const style = getStyle(sharedModel);
+
+                        const existsStyle = data.ensureUniqueItemVisual(idx, 'style');
+                        extend(existsStyle, style);
                     }
                 }
             } : null
         };
     }
 };
-export {seriesStyleTask, dataStyleTask};
\ No newline at end of file
+
+const dataColorPaletteTask: StageHandler = {
+    createOnAllSeries: true,
+    performRawSeries: true,
+    reset(seriesModel, ecModel) {
+        if (seriesModel.ignoreStyleOnData) {
+            return;
+        }
+
+        const dataAll = seriesModel.getRawData();
+        const idxMap: Dictionary<number> = {};
+        const data = seriesModel.getData();
+
+        const stylePath = seriesModel.visualStyleAccessPath
+            || 'itemStyle';
+        const colorKey = getDefaultColorKey(seriesModel, stylePath);
+
+        data.each(function (idx) {
+            const rawIdx = data.getRawIndex(idx);
+            idxMap[rawIdx] = idx;
+        });
+
+        dataAll.each(function (rawIdx) {
+            const idx = idxMap[rawIdx];
+            const existsStyle = data.ensureUniqueItemVisual(idx, 'style');
+            if (!existsStyle[colorKey]) {
+                // Get color from palette.
+                existsStyle[colorKey] = seriesModel.getColorFromPalette(
+                    dataAll.getName(rawIdx) || (rawIdx + ''),
+                    (seriesModel as SeriesModelWithPaletteScope).__paletteScope,
+                    dataAll.count()
+                );
+            }
+        });
+    }
+};
+
+export {seriesStyleTask, dataStyleTask, dataColorPaletteTask};
\ No newline at end of file


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


[incubator-echarts] 01/02: refact: rename brushType in visual to drawType. Avoid confusing with brush component

Posted by sh...@apache.org.
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

commit e9388aa743e569e3a92b7a7fcfac67ce7a9954fc
Author: pissang <bm...@gmail.com>
AuthorDate: Thu Apr 2 12:15:54 2020 +0800

    refact: rename brushType in visual to drawType. Avoid confusing with brush component
---
 src/chart/bar/BarView.ts             | 11 ++++++++++-
 src/chart/boxplot/BoxplotSeries.ts   |  2 +-
 src/chart/line/LineView.ts           |  2 +-
 src/chart/lines/LinesSeries.ts       |  2 +-
 src/chart/parallel/ParallelSeries.ts |  2 +-
 src/component/marker/MarkLineView.ts |  4 ++--
 src/data/List.ts                     |  6 +++---
 src/model/Series.ts                  |  6 +++---
 src/visual/helper.ts                 |  6 +++---
 src/visual/style.ts                  |  4 ++--
 10 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/src/chart/bar/BarView.ts b/src/chart/bar/BarView.ts
index f7e4719..9fb9ce2 100644
--- a/src/chart/bar/BarView.ts
+++ b/src/chart/bar/BarView.ts
@@ -19,7 +19,16 @@
 
 import {__DEV__} from '../../config';
 import * as zrUtil from 'zrender/src/core/util';
-import {Rect, Sector, getECData, updateProps, initProps, enableHoverEmphasis, setLabelStyle, clearStates} from '../../util/graphic';
+import {
+    Rect,
+    Sector,
+    getECData,
+    updateProps,
+    initProps,
+    enableHoverEmphasis,
+    setLabelStyle,
+    clearStates
+} from '../../util/graphic';
 import Path, { PathProps } from 'zrender/src/graphic/Path';
 import Group from 'zrender/src/graphic/Group';
 import {throttle} from '../../util/throttle';
diff --git a/src/chart/boxplot/BoxplotSeries.ts b/src/chart/boxplot/BoxplotSeries.ts
index d65e505..61f6eb4 100644
--- a/src/chart/boxplot/BoxplotSeries.ts
+++ b/src/chart/boxplot/BoxplotSeries.ts
@@ -97,7 +97,7 @@ class BoxplotSeriesModel extends SeriesModel<BoxplotSeriesOption> {
 
     dimensions: string[];
 
-    visualColorBrushType = 'stroke' as const;
+    visualDrawType = 'stroke' as const;
 
     static defaultOption: BoxplotSeriesOption = {
         zlevel: 0,
diff --git a/src/chart/line/LineView.ts b/src/chart/line/LineView.ts
index 80a2f3f..1093124 100644
--- a/src/chart/line/LineView.ts
+++ b/src/chart/line/LineView.ts
@@ -513,7 +513,7 @@ class LineView extends ChartView {
         }
 
         const visualColor = getVisualGradient(data, coordSys)
-            || data.getVisual('style')[data.getVisual('brushType')];
+            || data.getVisual('style')[data.getVisual('drawType')];
 
         polyline.useStyle(zrUtil.defaults(
             // Use color in lineStyle first
diff --git a/src/chart/lines/LinesSeries.ts b/src/chart/lines/LinesSeries.ts
index 41d514a..4163ee1 100644
--- a/src/chart/lines/LinesSeries.ts
+++ b/src/chart/lines/LinesSeries.ts
@@ -150,7 +150,7 @@ class LinesSeriesModel extends SeriesModel<LinesSeriesOption> {
     static readonly dependencies = ['grid', 'polar', 'geo', 'calendar'];
 
     visualStyleAccessPath = 'lineStyle';
-    visualColorBrushType = 'stroke' as const;
+    visualDrawType = 'stroke' as const;
 
     private _flatCoords: ArrayLike<number>;
     private _flatCoordsOffset: ArrayLike<number>;
diff --git a/src/chart/parallel/ParallelSeries.ts b/src/chart/parallel/ParallelSeries.ts
index 6b9dbfc..10f764d 100644
--- a/src/chart/parallel/ParallelSeries.ts
+++ b/src/chart/parallel/ParallelSeries.ts
@@ -86,7 +86,7 @@ class ParallelSeriesModel extends SeriesModel<ParallelSeriesOption> {
     static dependencies = ['parallel'];
 
     visualStyleAccessPath = 'lineStyle';
-    visualColorBrushType = 'stroke' as const;
+    visualDrawType = 'stroke' as const;
 
     coordinateSystem: Parallel;
 
diff --git a/src/component/marker/MarkLineView.ts b/src/component/marker/MarkLineView.ts
index cf0b933..3174c7d 100644
--- a/src/component/marker/MarkLineView.ts
+++ b/src/component/marker/MarkLineView.ts
@@ -49,7 +49,7 @@ import {
 import ComponentView from '../../view/Component';
 import { makeInner } from '../../util/model';
 import { LineDataVisual } from '../../visual/commonVisualTypes';
-import { getItemVisualFromData, getVisualFromData } from '../../visual/helper';
+import { getVisualFromData } from '../../visual/helper';
 
 // Item option for configuring line and each end of symbol.
 // Line option. be merged from configuration of two ends.
@@ -345,7 +345,7 @@ class MarkLineView extends MarkerView {
             ]);
 
             if (lineStyle.stroke == null) {
-                lineStyle.stroke = getItemVisualFromData(fromData, idx, 'color') as ColorString;
+                lineStyle.stroke = fromData.getItemVisual(idx, 'style').fill;
             }
 
             lineData.setItemVisual(idx, {
diff --git a/src/data/List.ts b/src/data/List.ts
index 16777a6..1a0c93b 100644
--- a/src/data/List.ts
+++ b/src/data/List.ts
@@ -124,10 +124,10 @@ const CLONE_PROPERTIES = [
 
 export interface DefaultDataVisual {
     style: PathStyleProps
-    // Brush type determined which prop should be set with encoded color.
-    // It's only available on the global visual. Use getVisual('brushType') to access it.
+    // Draw type determined which prop should be set with encoded color.
+    // It's only available on the global visual. Use getVisual('drawType') to access it.
     // It will be set in visual/style.ts module in the first priority.
-    brushType: 'fill' | 'stroke'
+    drawType: 'fill' | 'stroke'
 
     symbol?: string
     symbolSize?: number | number[]
diff --git a/src/model/Series.ts b/src/model/Series.ts
index e370663..d6613bb 100644
--- a/src/model/Series.ts
+++ b/src/model/Series.ts
@@ -142,7 +142,7 @@ class SeriesModel<Opt extends SeriesOption = SeriesOption> extends ComponentMode
     // Access path of style for visual
     visualStyleAccessPath: string;
     // Which property is treated as main color. Which can get from the palette.
-    visualColorBrushType: 'fill' | 'stroke';
+    visualDrawType: 'fill' | 'stroke';
     // Style mapping rules.
     visualStyleMapper: ReturnType<typeof makeStyleMapper>;
     // If ignore style on data. It's only for global visual/style.ts
@@ -169,7 +169,7 @@ class SeriesModel<Opt extends SeriesOption = SeriesOption> extends ComponentMode
         proto.defaultSymbol = 'circle';
         // Make sure the values can be accessed!
         proto.visualStyleAccessPath = 'itemStyle';
-        proto.visualColorBrushType = 'fill';
+        proto.visualDrawType = 'fill';
     })();
 
 
@@ -481,7 +481,7 @@ class SeriesModel<Opt extends SeriesOption = SeriesOption> extends ComponentMode
         const isValueArr = zrUtil.isArray(value);
 
         const style = data.getItemVisual(dataIndex, 'style');
-        const color = style[this.visualColorBrushType];
+        const color = style[this.visualDrawType];
         let colorStr: ColorString;
         if (zrUtil.isString(color)) {
             colorStr = color;
diff --git a/src/visual/helper.ts b/src/visual/helper.ts
index affe031..814ef31 100644
--- a/src/visual/helper.ts
+++ b/src/visual/helper.ts
@@ -32,7 +32,7 @@ export function getItemVisualFromData(data: List, dataIndex: number, key: string
     switch (key) {
         case 'color':
             const style = data.getItemVisual(dataIndex, 'style');
-            return style[data.getVisual('brushType')];
+            return style[data.getVisual('drawType')];
         case 'opacity':
             return data.getItemVisual(dataIndex, 'style').opacity;
         case 'symbol':
@@ -50,7 +50,7 @@ export function getVisualFromData(data: List, key: string) {
     switch (key) {
         case 'color':
             const style = data.getVisual('style');
-            return style[data.getVisual('brushType')];
+            return style[data.getVisual('drawType')];
         case 'opacity':
             return data.getVisual('style').opacity;
         case 'symbol':
@@ -69,7 +69,7 @@ export function setItemVisualFromData(data: List, dataIndex: number, key: string
         case 'color':
             // Make sure not sharing style object.
             const style = data.ensureUniqueItemVisual(dataIndex, 'style');
-            style[data.getVisual('brushType')] = value;
+            style[data.getVisual('drawType')] = value;
             break;
         case 'opacity':
             data.ensureUniqueItemVisual(dataIndex, 'style').opacity = value;
diff --git a/src/visual/style.ts b/src/visual/style.ts
index 85a1879..d96a0cd 100644
--- a/src/visual/style.ts
+++ b/src/visual/style.ts
@@ -51,7 +51,7 @@ function getStyleMapper(seriesModel: SeriesModel, stylePath: string) {
 
 function getDefaultColorKey(seriesModel: SeriesModel, stylePath: string): 'stroke' | 'fill' {
     // return defaultColorKey[stylePath] ||
-    const colorKey = seriesModel.visualColorBrushType
+    const colorKey = seriesModel.visualDrawType
         || defaultColorKey[stylePath as 'itemStyle' | 'lineStyle'];
 
     if (!colorKey) {
@@ -92,7 +92,7 @@ const seriesStyleTask: StageHandler = {
         }
 
         data.setVisual('style', globalStyle);
-        data.setVisual('brushType', colorKey);
+        data.setVisual('drawType', colorKey);
 
         // Only visible series has each data be visual encoded
         if (!ecModel.isSeriesFiltered(seriesModel)) {


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