You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2020/11/01 09:39:06 UTC
[incubator-echarts] 01/05: fix: [decal] (1) move option.decals to
option.area.decal.decals. (2) disable series.decals (3) fix decals default
option merge.
This is an automated email from the ASF dual-hosted git repository.
sushuang pushed a commit to branch decal-custom
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git
commit 4e1e8fce2c9d0cb57d5441b7cf3fd1f800d1923c
Author: 100pah <su...@gmail.com>
AuthorDate: Thu Oct 29 02:24:15 2020 +0800
fix: [decal] (1) move option.decals to option.area.decal.decals. (2) disable series.decals (3) fix decals default option merge.
---
src/chart/helper/enableAriaDecalForTree.ts | 4 +-
src/chart/sankey/SankeySeries.ts | 3 +-
src/component/aria.ts | 4 +-
src/model/Global.ts | 7 +++
src/model/Series.ts | 9 ----
src/model/globalDefault.ts | 72 ++++++++++++++++--------------
src/model/mixin/palette.ts | 28 +++++-------
src/util/types.ts | 6 +--
src/visual/aria.ts | 20 +++++----
9 files changed, 75 insertions(+), 78 deletions(-)
diff --git a/src/chart/helper/enableAriaDecalForTree.ts b/src/chart/helper/enableAriaDecalForTree.ts
index b76aa84..fca0cf9 100644
--- a/src/chart/helper/enableAriaDecalForTree.ts
+++ b/src/chart/helper/enableAriaDecalForTree.ts
@@ -1,5 +1,6 @@
import SeriesModel from '../../model/Series';
import {Dictionary, DecalObject} from '../../util/types';
+import { getDecalFromPalette } from '../../model/mixin/palette';
export default function (seriesModel: SeriesModel) {
const data = seriesModel.getData();
@@ -13,7 +14,8 @@ export default function (seriesModel: SeriesModel) {
current = current.parentNode;
}
- const decal = seriesModel.getDecalFromPalette(
+ const decal = getDecalFromPalette(
+ seriesModel.ecModel,
current.name || current.dataIndex + '',
decalPaletteScope
);
diff --git a/src/chart/sankey/SankeySeries.ts b/src/chart/sankey/SankeySeries.ts
index d57b1ef..eb09f18 100644
--- a/src/chart/sankey/SankeySeries.ts
+++ b/src/chart/sankey/SankeySeries.ts
@@ -39,6 +39,7 @@ import GlobalModel from '../../model/Global';
import List from '../../data/List';
import { LayoutRect } from '../../util/layout';
import { createTooltipMarkup } from '../../component/tooltip/tooltipMarkup';
+import { getDecalFromPalette } from '../../model/mixin/palette';
type FocusNodeAdjacency = boolean | 'inEdges' | 'outEdges' | 'allEdges';
@@ -282,7 +283,7 @@ class SankeySeriesModel extends SeriesModel<SankeySeriesOption> {
const nodes = graph.nodes;
zrUtil.each(nodes, node => {
const name = this.getDataParams(node.dataIndex, 'node').name;
- const paletteDecal = this.getDecalFromPalette(name, null, nodes.length);
+ const paletteDecal = getDecalFromPalette(this.ecModel, name, null, nodes.length);
const decal = zrUtil.defaults(node.getVisual('style').decal || {}, paletteDecal);
node.hostGraph.data.setItemVisual(node.dataIndex, 'decal', decal);
});
diff --git a/src/component/aria.ts b/src/component/aria.ts
index 092236f..baa1252 100644
--- a/src/component/aria.ts
+++ b/src/component/aria.ts
@@ -20,6 +20,7 @@
import * as echarts from '../echarts';
import ariaVisual from '../visual/aria';
import ariaPreprocessor from './aria/preprocessor';
+import { DecalObject } from '../util/types';
const PRIORITY_VISUAL_ARIA = echarts.PRIORITY.VISUAL.ARIA;
@@ -66,7 +67,8 @@ export interface AriaOption extends AriaLabelOption {
label?: AriaLabelOption;
decal?: {
show?: boolean;
- }
+ decals?: DecalObject | DecalObject[];
+ };
}
echarts.registerPreprocessor(ariaPreprocessor);
diff --git a/src/model/Global.ts b/src/model/Global.ts
index 48fefab..a5ba207 100644
--- a/src/model/Global.ts
+++ b/src/model/Global.ts
@@ -813,6 +813,13 @@ class GlobalModel extends Model<ECUnitOption> {
ecModel._componentsMap = createHashMap({series: []});
ecModel._componentsCount = createHashMap();
+ // If user spefied `option.aria`, aria will be enable. This detection should be
+ // performed before theme and globalDefault merge.
+ const airaOption = baseOption.aria;
+ if (isObject(airaOption) && airaOption.enabled == null) {
+ airaOption.enabled = true;
+ }
+
mergeTheme(baseOption, ecModel._theme.option);
// TODO Needs clone when merging to the unexisted property
diff --git a/src/model/Series.ts b/src/model/Series.ts
index 655cf44..47b9782 100644
--- a/src/model/Series.ts
+++ b/src/model/Series.ts
@@ -460,15 +460,6 @@ class SeriesModel<Opt extends SeriesOption = SeriesOption> extends ComponentMode
return color;
}
- getDecalFromPalette(name: string, scope: any, requestColorNum?: number): DecalObject {
- const ecModel = this.ecModel;
- let decal = PaletteMixin.prototype.getDecalFromPalette.call(this, name, scope, requestColorNum);
- if (!decal) {
- decal = ecModel.getDecalFromPalette(name, scope, requestColorNum);
- }
- return decal;
- }
-
/**
* Use `data.mapDimensionsAll(coordDim)` instead.
* @deprecated
diff --git a/src/model/globalDefault.ts b/src/model/globalDefault.ts
index b7cd6c5..d25eab1 100644
--- a/src/model/globalDefault.ts
+++ b/src/model/globalDefault.ts
@@ -56,40 +56,44 @@ export default {
gradientColor: ['#f6efa6', '#d88273', '#bf444c'],
- decals: [{
- color: decalColor,
- dashArrayX: [1, 0],
- dashArrayY: [2, 5],
- symbolSize: 1,
- rotation: Math.PI / 6
- }, {
- color: decalColor,
- symbol: 'circle',
- dashArrayX: [[8, 8], [0, 8, 8, 0]],
- dashArrayY: [6, 0],
- symbolSize: 0.8
- }, {
- color: decalColor,
- dashArrayX: [1, 0],
- dashArrayY: [4, 3],
- dashLineOffset: 0,
- rotation: -Math.PI / 4
- }, {
- color: decalColor,
- dashArrayX: [[6, 6], [0, 6, 6, 0]],
- dashArrayY: [6, 0]
- }, {
- color: decalColor,
- dashArrayX: [[1, 0], [1, 6]],
- dashArrayY: [1, 0, 6, 0],
- rotation: Math.PI / 4
- }, {
- color: decalColor,
- symbol: 'triangle',
- dashArrayX: [[9, 9], [0, 9, 9, 0]],
- dashArrayY: [7, 2],
- symbolSize: 0.75
- }],
+ aria: {
+ decal: {
+ decals: [{
+ color: decalColor,
+ dashArrayX: [1, 0],
+ dashArrayY: [2, 5],
+ symbolSize: 1,
+ rotation: Math.PI / 6
+ }, {
+ color: decalColor,
+ symbol: 'circle',
+ dashArrayX: [[8, 8], [0, 8, 8, 0]],
+ dashArrayY: [6, 0],
+ symbolSize: 0.8
+ }, {
+ color: decalColor,
+ dashArrayX: [1, 0],
+ dashArrayY: [4, 3],
+ dashLineOffset: 0,
+ rotation: -Math.PI / 4
+ }, {
+ color: decalColor,
+ dashArrayX: [[6, 6], [0, 6, 6, 0]],
+ dashArrayY: [6, 0]
+ }, {
+ color: decalColor,
+ dashArrayX: [[1, 0], [1, 6]],
+ dashArrayY: [1, 0, 6, 0],
+ rotation: Math.PI / 4
+ }, {
+ color: decalColor,
+ symbol: 'triangle',
+ dashArrayX: [[9, 9], [0, 9, 9, 0]],
+ dashArrayY: [7, 2],
+ symbolSize: 0.75
+ }]
+ }
+ },
// If xAxis and yAxis declared, grid is created by default.
// grid: {},
diff --git a/src/model/mixin/palette.ts b/src/model/mixin/palette.ts
index c0b6c85..0f74d7d 100644
--- a/src/model/mixin/palette.ts
+++ b/src/model/mixin/palette.ts
@@ -22,6 +22,7 @@ import {isArray} from 'zrender/src/core/util';
import {makeInner, normalizeToArray} from '../../util/model';
import Model from '../Model';
import {ZRColor, PaletteOptionMixin, DecalObject} from '../../util/types';
+import GlobalModel from '../Global';
type Inner<T> = (hostObj: PaletteMixin<PaletteOptionMixin>) => {
paletteIdx: number;
@@ -58,26 +59,17 @@ class PaletteMixin<T extends PaletteOptionMixin = PaletteOptionMixin> {
clearColorPalette(this: PaletteMixin<T>) {
clearPalette<ZRColor>(this, innerColor);
}
-
- getDecalFromPalette(
- this: PaletteMixin<T>,
- name: string,
- scope?: any,
- requestNum?: number
- ): DecalObject {
- let decals = this.get('decals');
- if (!isArray(decals)) {
- decals = [decals as DecalObject];
- }
- const defaultDecals = decals as DecalObject[];
- return getFromPalette<DecalObject>(this, innerDecal, defaultDecals, [defaultDecals], name, scope, requestNum);
- }
-
- clearDecalPalette(this: PaletteMixin<T>) {
- clearPalette<DecalObject>(this, innerDecal);
- }
}
+export function getDecalFromPalette(
+ ecModel: GlobalModel,
+ name: string,
+ scope?: any,
+ requestNum?: number
+): DecalObject {
+ const defaultDecals = normalizeToArray(ecModel.get(['aria', 'decal', 'decals']));
+ return getFromPalette<DecalObject>(ecModel, innerDecal, defaultDecals, null, name, scope, requestNum);
+}
function getNearestPalette<T>(
diff --git a/src/util/types.ts b/src/util/types.ts
index c2411d8..0be5a4c 100644
--- a/src/util/types.ts
+++ b/src/util/types.ts
@@ -711,11 +711,7 @@ export type ComponentLayoutMode = {
ignoreSize?: boolean | boolean[]
};
/******************* Mixins for Common Option Properties ********************** */
-export interface PaletteOptionMixin {
- color?: ZRColor | ZRColor[]
- colorLayer?: ZRColor[][],
- decals?: DecalObject | DecalObject[]
-}
+export type PaletteOptionMixin = ColorPaletteOptionMixin;
export interface ColorPaletteOptionMixin {
color?: ZRColor | ZRColor[]
diff --git a/src/visual/aria.ts b/src/visual/aria.ts
index 21c8b37..41011f1 100644
--- a/src/visual/aria.ts
+++ b/src/visual/aria.ts
@@ -28,9 +28,9 @@ import {TitleOption} from '../component/title';
import {makeInner} from '../util/model';
import {Dictionary, DecalObject, InnerDecalObject} from '../util/types';
import {LocaleOption} from '../locale';
+import { getDecalFromPalette } from '../model/mixin/palette';
-const defaultOption: AriaOption = {
- enabled: true,
+const DEFAULT_OPTION: AriaOption = {
label: {
enabled: true
},
@@ -48,15 +48,15 @@ type SeriesTypes = keyof LocaleOption['series']['typeNames'];
export default function (ecModel: GlobalModel, api: ExtensionAPI) {
const ariaModel: Model<AriaOption> = ecModel.getModel('aria');
- if (ariaModel.option) {
- const labelLocale = ecModel.getLocaleModel().get('aria');
- defaultOption.label = zrUtil.defaults(labelLocale, defaultOption.label);
- ariaModel.option = zrUtil.defaults(ariaModel.option, defaultOption);
- }
+ // See "area enabled" detection code in `GlobalModel.ts`.
if (!ariaModel.get('enabled')) {
return;
}
+ const defaultOption = zrUtil.clone(DEFAULT_OPTION);
+ zrUtil.merge(defaultOption.label, ecModel.getLocaleModel().get('aria'), false);
+ zrUtil.merge(ariaModel.option, defaultOption, false);
+
setDecal();
setLabel();
@@ -107,7 +107,8 @@ export default function (ecModel: GlobalModel, api: ExtensionAPI) {
const idx = idxMap[rawIdx];
const itemStyle = data.ensureUniqueItemVisual(idx, 'style');
const name = dataAll.getName(rawIdx) || (rawIdx + '');
- const paletteDecal = seriesModel.getDecalFromPalette(
+ const paletteDecal = getDecalFromPalette(
+ seriesModel.ecModel,
name,
decalScope,
dataCount
@@ -121,7 +122,8 @@ export default function (ecModel: GlobalModel, api: ExtensionAPI) {
}
else {
const style = data.getVisual('style');
- const paletteDecal = seriesModel.getDecalFromPalette(
+ const paletteDecal = getDecalFromPalette(
+ seriesModel.ecModel,
seriesModel.name,
decalPaletteScope,
ecModel.getSeriesCount()
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org