You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2020/09/18 05:45:40 UTC

[GitHub] [incubator-echarts] Ovilia opened a new pull request #13304: feat: decal

Ovilia opened a new pull request #13304:
URL: https://github.com/apache/incubator-echarts/pull/13304


   <!-- Please fill in the following information to help us review your PR more efficiently. -->
   
   ## Brief Information
   
   This pull request is in the type of:
   
   - [ ] bug fixing
   - [x] new feature
   - [ ] others
   
   
   
   ### What does this PR do?
   
   <!-- USE ONCE SENTENCE TO DESCRIBE WHAT THIS PR DOES. -->
   
   Support decal in ECharts, see #13263 for more details.
   
   ### Fixed issues
   
   - #13263
   
   
   ## Usage
   
   ### Are there any API changes?
   
   - [x] The API has been changed.
   
   <!-- LIST THE API CHANGES HERE -->
   
   
   
   ### Related test cases or examples to use the new APIs
   
   NA.
   
   
   
   ## Others
   
   ### Merging options
   
   - [ ] Please squash the commits into a single one when merge.
   
   ### Other information
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-echarts] pissang commented on a change in pull request #13304: [5.0] [FEATURE] decal

Posted by GitBox <gi...@apache.org>.
pissang commented on a change in pull request #13304:
URL: https://github.com/apache/incubator-echarts/pull/13304#discussion_r508530279



##########
File path: src/visual/aria.ts
##########
@@ -17,123 +17,186 @@
 * under the License.
 */
 
-// @ts-nocheck
-
 import * as zrUtil from 'zrender/src/core/util';
-import { retrieveRawValue }
-
-from '../data/helper/dataProvider';
-
-export default function (dom, ecModel) {
-    const ariaModel = ecModel.getModel('aria');
-    if (!ariaModel.get('show')) {
-        return;
-    }
-    else if (ariaModel.get('description')) {
-        dom.setAttribute('aria-label', ariaModel.get('description'));
+import ExtensionAPI from '../ExtensionAPI';
+import {retrieveRawValue} from '../data/helper/dataProvider';
+import GlobalModel from '../model/Global';
+import Model from '../model/Model';
+import {AriaOption} from '../component/aria';
+import {TitleOption} from '../component/title';
+
+export default function (ecModel: GlobalModel, api: ExtensionAPI) {
+    const ariaModel: Model<AriaOption> = ecModel.getModel('aria');

Review comment:
       A default option can be merged here.
   ```ts
   ariaModel.option = isObject(ariaModel.option) ? defaults(ariaModel.option, defaultOption) : null;
   ```
   
   And the `enabled` property can be default true.
   
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-echarts] pissang commented on a change in pull request #13304: [5.0] [FEATURE] decal

Posted by GitBox <gi...@apache.org>.
pissang commented on a change in pull request #13304:
URL: https://github.com/apache/incubator-echarts/pull/13304#discussion_r508523173



##########
File path: src/visual/aria.ts
##########
@@ -17,123 +17,186 @@
 * under the License.
 */
 
-// @ts-nocheck
-
 import * as zrUtil from 'zrender/src/core/util';
-import { retrieveRawValue }
-
-from '../data/helper/dataProvider';
-
-export default function (dom, ecModel) {
-    const ariaModel = ecModel.getModel('aria');
-    if (!ariaModel.get('show')) {
-        return;
-    }
-    else if (ariaModel.get('description')) {
-        dom.setAttribute('aria-label', ariaModel.get('description'));
+import ExtensionAPI from '../ExtensionAPI';
+import {retrieveRawValue} from '../data/helper/dataProvider';
+import GlobalModel from '../model/Global';
+import Model from '../model/Model';
+import {AriaOption} from '../component/aria';
+import {TitleOption} from '../component/title';
+
+export default function (ecModel: GlobalModel, api: ExtensionAPI) {
+    const ariaModel: Model<AriaOption> = ecModel.getModel('aria');
+    if (ariaModel.get('show') === false) {

Review comment:
       still use `show` here.

##########
File path: src/component/aria.ts
##########
@@ -0,0 +1,73 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+import * as echarts from '../echarts';
+import ariaVisual from '../visual/aria';
+
+const PRIORITY_VISUAL_ARIA = echarts.PRIORITY.VISUAL.ARIA;
+
+export interface AriaLabelOption {
+    enabled?: boolean;
+    show?: boolean; // @deprecated use enabled instead

Review comment:
       `deprecated` option can be removed from type declarations.

##########
File path: src/component/aria.ts
##########
@@ -0,0 +1,73 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+import * as echarts from '../echarts';
+import ariaVisual from '../visual/aria';
+
+const PRIORITY_VISUAL_ARIA = echarts.PRIORITY.VISUAL.ARIA;
+
+export interface AriaLabelOption {
+    enabled?: boolean;
+    show?: boolean; // @deprecated use enabled instead
+    description?: string;
+    general?: {
+        withTitle?: string;
+        withoutTitle?: string;
+    };
+    series?: {
+        maxCount?: number;
+        single?: {
+            prefix?: string;
+            withName?: string;
+            withoutName?: string;
+        };
+        multiple?: {
+            prefix?: string;
+            withName?: string;
+            withoutName?: string;
+            separator?: {
+                middle?: string;
+                end?: string;
+            }
+        }
+    },
+    data?: {
+        maxCount?: number;
+        allData?: string;
+        partialData?: string;
+        withName?: string;
+        withoutName?: string;
+        separator?: {
+            middle?: string;
+            end?: string;
+        }
+    }
+}
+
+// Extending is for compating ECharts 4
+export interface AriaOption extends AriaLabelOption {

Review comment:
       deprecated option can be removed from type declarations.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-echarts] pissang merged pull request #13304: [5.0] [FEATURE] decal

Posted by GitBox <gi...@apache.org>.
pissang merged pull request #13304:
URL: https://github.com/apache/incubator-echarts/pull/13304


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-echarts] pissang edited a comment on pull request #13304: [5.0] [FEATURE] decal

Posted by GitBox <gi...@apache.org>.
pissang edited a comment on pull request #13304:
URL: https://github.com/apache/incubator-echarts/pull/13304#issuecomment-712890831






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-echarts] pissang edited a comment on pull request #13304: [5.0] [FEATURE] decal

Posted by GitBox <gi...@apache.org>.
pissang edited a comment on pull request #13304:
URL: https://github.com/apache/incubator-echarts/pull/13304#issuecomment-712890831


   Some bugs from my test:
   
   + [x] Chart has no effect when decal is enabled: Scatter, Graph, Tree series which use Symbol. Sankey, Line, Treemap
   + [ ] SVG has performance issues.
   + [ ] When toggling legend in pie series. Decal doesn't follow the fade out animation


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-echarts] pissang commented on a change in pull request #13304: [5.0] [FEATURE] decal

Posted by GitBox <gi...@apache.org>.
pissang commented on a change in pull request #13304:
URL: https://github.com/apache/incubator-echarts/pull/13304#discussion_r509270302



##########
File path: src/component/aria/preprocessor.ts
##########
@@ -0,0 +1,41 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+import * as zrUtil from 'zrender/src/core/util';
+import { ECUnitOption } from '../../util/types';
+
+export default function (option: ECUnitOption) {
+    if (!option || !option.aria) {
+        return;
+    }
+
+    const aria = option.aria as any;
+    // aria.show is deprecated and should use aria.enabled instead
+    if (aria.show != null) {
+        option.aria.enabled = aria.show;
+    }

Review comment:
       Can use `aria` instead of `option.aria` here




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-echarts] pissang commented on pull request #13304: [5.0] [FEATURE] decal

Posted by GitBox <gi...@apache.org>.
pissang commented on pull request #13304:
URL: https://github.com/apache/incubator-echarts/pull/13304#issuecomment-712890831


   Some bugs from my test:
   
   [ ] Chart has no effect when decal is enabled: Scatter, Graph, Tree series which use Symbol. Sankey, Line.
   [ ] SVG has performance issues.
   [ ] When toggling legend in pie series. Decal doesn't follow the fade out animation


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-echarts] Ovilia edited a comment on pull request #13304: [5.0] [FEATURE] decal

Posted by GitBox <gi...@apache.org>.
Ovilia edited a comment on pull request #13304:
URL: https://github.com/apache/incubator-echarts/pull/13304#issuecomment-707059157


   TODO:
   - [x] Default decal styles for aria


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-echarts] pissang edited a comment on pull request #13304: [5.0] [FEATURE] decal

Posted by GitBox <gi...@apache.org>.
pissang edited a comment on pull request #13304:
URL: https://github.com/apache/incubator-echarts/pull/13304#issuecomment-712890831


   Some bugs from my test:
   
   + [ ] Chart has no effect when decal is enabled: Scatter, Graph, Tree series which use Symbol. Sankey, Line, Treemap
   + [ ] SVG has performance issues.
   + [ ] When toggling legend in pie series. Decal doesn't follow the fade out animation


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-echarts] pissang commented on a change in pull request #13304: feat: decal

Posted by GitBox <gi...@apache.org>.
pissang commented on a change in pull request #13304:
URL: https://github.com/apache/incubator-echarts/pull/13304#discussion_r505466593



##########
File path: src/util/decal.ts
##########
@@ -0,0 +1,280 @@
+import WeakMap from 'zrender/src/core/WeakMap';
+import {DecalObject, DecalDashArrayX, DecalDashArrayY} from 'zrender/src/graphic/Decal';
+import Pattern from 'zrender/src/graphic/Pattern';
+import {brushSingle} from 'zrender/src/canvas/graphic';
+import {defaults, createCanvas, map} from 'zrender/src/core/util';
+import {getLeastCommonMultiple} from './number';
+import {createSymbol} from './symbol';
+
+const decalMap = new WeakMap<DecalObject, Pattern>();
+
+/**
+ * Create or update pattern image from decal options
+ *
+ * @param {DecalObject} decalObject decal options
+ * @return {Pattern} pattern with generated image
+ */
+export function createOrUpdatePatternFromDecal(
+    decalObject: DecalObject
+): Pattern {
+    const oldPattern = decalMap.get(decalObject);
+    if (oldPattern) {
+        return oldPattern;
+    }
+
+    const decalOpt = defaults(decalObject, {
+        symbol: 'rect',
+        symbolSize: 1,
+        symbolKeepAspect: true,
+        color: 'rgba(0, 0, 0, 0.2)',
+        backgroundColor: null,
+        dashArrayX: 5,
+        dashArrayY: 5,
+        dashLineOffset: 0,
+        rotation: 0,
+        maxTileWidth: 512,
+        maxTileHeight: 512
+    } as DecalObject);
+    if (decalOpt.backgroundColor === 'none') {
+        decalOpt.backgroundColor = null;
+    }
+
+    const dashArrayX = normalizeDashArrayX(decalOpt.dashArrayX);
+    const dashArrayY = normalizeDashArrayY(decalOpt.dashArrayY);
+
+    const lineBlockLengthsX = getLineBlockLengthX(dashArrayX);
+    const lineBlockLengthY = getLineBlockLengthY(dashArrayY);
+
+    const canvas = createCanvas();
+    const pSize = getPatternSize();
+
+    canvas.width = pSize.width;
+    canvas.height = pSize.height;
+    canvas.style.width = canvas.width + 'px';
+    canvas.style.height = canvas.height + 'px';
+

Review comment:
       No need to set canvas.style

##########
File path: src/visual/aria.ts
##########
@@ -20,111 +20,160 @@
 // @ts-nocheck

Review comment:
       `@ts-nocheck` needs to be removed since types have been added.

##########
File path: src/component/aria.ts
##########
@@ -0,0 +1,64 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+export interface AriaLabelOption {
+    show?: boolean;
+    description?: string;
+    general?: {
+        withTitle?: string;
+        withoutTitle?: string;
+    };
+    series?: {
+        maxCount?: number;
+        single?: {
+            prefix?: string;
+            withName?: string;
+            withoutName?: string;
+        };
+        multiple?: {
+            prefix?: string;
+            withName?: string;
+            withoutName?: string;
+            separator?: {
+                middle?: string;
+                end?: string;
+            }
+        }
+    },
+    data?: {
+        maxCount?: number;
+        allData?: string;
+        partialData?: string;
+        withName?: string;
+        withoutName?: string;
+        separator?: {
+            middle?: string;
+            end?: string;
+        }
+    }
+}
+
+// Extending is for compating ECharts 4
+export interface AriaOption extends AriaLabelOption {
+    show?: boolean;
+    label?: AriaLabelOption;
+    decal?: {
+        show?: boolean;
+    }
+}

Review comment:
       `visual/aria.ts` should be imported here instead of `echarts.ts`
   
   Then import this aria component in the `echarts.all.ts`, `echarts.common.ts`, `echarts.simple.ts`

##########
File path: src/visual/decal.ts
##########
@@ -0,0 +1,47 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+// @ts-nocheck
+
+import ExtensionAPI from '../ExtensionAPI';
+import GlobalModel from '../model/Global';
+import {createOrUpdatePatternFromDecal} from '../util/decal';
+
+export default function (ecModel: GlobalModel, api: ExtensionAPI) {
+    ecModel.eachRawSeries(seriesModel => {
+        const data = seriesModel.getData();
+
+        if (seriesModel.useColorPaletteOnData) {

Review comment:
       It should be
   ```ts
   if (data.hasItemVisual()) { ... }
   ```
   Since in the `itemStyle` of each data decal can be set respectively.
   
   `hasItemVisual` is not implemented yet. It should be in the `List` and determine if `_itemVisuals.length > 0`
   
   ```ts
   hasItemVisual() {
     return this._itemVisuals.length > 0
   }
   ```

##########
File path: src/util/decal.ts
##########
@@ -0,0 +1,280 @@
+import WeakMap from 'zrender/src/core/WeakMap';
+import {DecalObject, DecalDashArrayX, DecalDashArrayY} from 'zrender/src/graphic/Decal';
+import Pattern from 'zrender/src/graphic/Pattern';
+import {brushSingle} from 'zrender/src/canvas/graphic';
+import {defaults, createCanvas, map} from 'zrender/src/core/util';
+import {getLeastCommonMultiple} from './number';
+import {createSymbol} from './symbol';
+
+const decalMap = new WeakMap<DecalObject, Pattern>();
+
+/**
+ * Create or update pattern image from decal options
+ *
+ * @param {DecalObject} decalObject decal options
+ * @return {Pattern} pattern with generated image
+ */
+export function createOrUpdatePatternFromDecal(
+    decalObject: DecalObject
+): Pattern {
+    const oldPattern = decalMap.get(decalObject);
+    if (oldPattern) {
+        return oldPattern;
+    }
+
+    const decalOpt = defaults(decalObject, {
+        symbol: 'rect',
+        symbolSize: 1,
+        symbolKeepAspect: true,
+        color: 'rgba(0, 0, 0, 0.2)',
+        backgroundColor: null,
+        dashArrayX: 5,
+        dashArrayY: 5,
+        dashLineOffset: 0,
+        rotation: 0,
+        maxTileWidth: 512,
+        maxTileHeight: 512
+    } as DecalObject);
+    if (decalOpt.backgroundColor === 'none') {
+        decalOpt.backgroundColor = null;
+    }
+
+    const dashArrayX = normalizeDashArrayX(decalOpt.dashArrayX);
+    const dashArrayY = normalizeDashArrayY(decalOpt.dashArrayY);
+
+    const lineBlockLengthsX = getLineBlockLengthX(dashArrayX);
+    const lineBlockLengthY = getLineBlockLengthY(dashArrayY);
+
+    const canvas = createCanvas();
+    const pSize = getPatternSize();
+
+    canvas.width = pSize.width;
+    canvas.height = pSize.height;
+    canvas.style.width = canvas.width + 'px';
+    canvas.style.height = canvas.height + 'px';
+
+    const ctx = canvas.getContext('2d');
+
+    brushDecal();
+
+    const pattern = new Pattern(canvas, 'repeat', decalOpt.rotation);
+    decalMap.set(decalObject, pattern);
+
+    return pattern;
+
+    /**
+     * Get minumum length that can make a repeatable pattern.
+     *
+     * @return {Object} pattern width and height
+     */
+    function getPatternSize()
+        : {
+            width: number,
+            height: number,
+            lines: number
+        }
+    {
+        /**
+         * For example, if dash is [[3, 2], [2, 1]] for X, it looks like
+         * |---  ---  ---  ---  --- ...
+         * |-- -- -- -- -- -- -- -- ...
+         * |---  ---  ---  ---  --- ...
+         * |-- -- -- -- -- -- -- -- ...
+         * So the minumum length of X is 15,
+         * which is the least common multiple of `3 + 2` and `2 + 1`
+         * |---  ---  ---  |---  --- ...
+         * |-- -- -- -- -- |-- -- -- ...
+         *
+         * When consider with dashLineOffset, it means the `n`th line has the offset
+         * of `n * dashLineOffset`.
+         * For example, if dash is [[3, 1], [1, 1]] and dashLineOffset is 3,
+         * and use `=` for the start to make it clear, it looks like
+         * |=-- --- --- --- --- -...
+         * | - = - - - - - - - - ...
+         * |- --- =-- --- --- -- ...
+         * | - - - - = - - - - - ...
+         * |--- --- --- =-- --- -...
+         * | - - - - - - - = - - ...
+         * In this case, the minumum length is 12, which is the least common
+         * multiple of `3 + 1`, `1 + 1` and `3 * 2` where `2` is xlen
+         * |=-- --- --- |--- --- -...
+         * | - = - - - -| - - - - ...
+         * |- --- =-- --|- --- -- ...
+         * | - - - - = -| - - - - ...
+         */
+        const offsetMultipleX = decalOpt.dashLineOffset || 1;
+        let width = 1;
+        for (let i = 0, xlen = lineBlockLengthsX.length; i < xlen; ++i) {
+            const x = getLeastCommonMultiple(offsetMultipleX * xlen, lineBlockLengthsX[i]);
+            width = getLeastCommonMultiple(width, x);
+        }
+        const columns = decalOpt.dashLineOffset
+            ? width / offsetMultipleX
+            : 2;
+        let height = lineBlockLengthY * columns;
+
+        return {
+            width: Math.max(1, Math.min(width, decalOpt.maxTileWidth)),
+            height: Math.max(1, Math.min(height, decalOpt.maxTileHeight)),
+            lines: columns
+        };
+    }
+
+    function fixStartPosition(lineOffset: number, blockLength: number) {
+        let start = lineOffset || 0;
+        while (start > 0) {
+            start -= blockLength;
+        }
+        return start;
+    }
+
+    function brushDecal() {
+        ctx.clearRect(0, 0, pSize.width, pSize.height);
+        if (decalOpt.backgroundColor) {
+            ctx.fillStyle = decalOpt.backgroundColor;
+            ctx.fillRect(0, 0, pSize.width, pSize.height);
+        }
+
+        ctx.fillStyle = decalOpt.color;
+
+        let yCnt = 0;
+        let y = -pSize.lines * lineBlockLengthY;
+        let yId = 0;
+        let xId0 = 0;
+        while (y < pSize.height) {
+            if (yId % 2 === 0) {
+                let x = fixStartPosition(
+                    decalOpt.dashLineOffset * (yCnt - pSize.lines) / 2,
+                    lineBlockLengthsX[0]
+                );
+                let xId1 = 0;
+                while (x < pSize.width * 2) {
+                    // E.g., [15, 5, 20, 5] draws only for 15 and 20
+                    if (xId1 % 2 === 0) {
+                        const size = (1 - decalOpt.symbolSize) * 0.5;
+                        const left = x + dashArrayX[xId0][xId1] * size;
+                        const top = y + dashArrayY[yId] * size;
+                        const width = dashArrayX[xId0][xId1] * decalOpt.symbolSize;
+                        const height = dashArrayY[yId] * decalOpt.symbolSize;
+                        brushSymbol(left, top, width, height);
+                    }
+
+                    x += dashArrayX[xId0][xId1];
+                    ++xId1;
+                    if (xId1 === dashArrayX[xId0].length) {
+                        xId1 = 0;
+                    }
+                }
+
+                ++xId0;
+                if (xId0 === dashArrayX.length) {
+                    xId0 = 0;
+                }
+            }
+
+            ++yCnt;
+            y += dashArrayY[yId];
+
+            ++yId;
+            if (yId === dashArrayY.length) {
+                yId = 0;
+            }
+        }
+    }
+
+    function brushSymbol(x: number, y: number, width: number, height: number) {
+        const symbol = createSymbol(decalOpt.symbol, x, y, width, height);
+        symbol.style.fill = decalOpt.color;
+        brushSingle(ctx, symbol);
+    }
+
+}
+
+/**
+ * Convert dash input into dashArray
+ *
+ * @param {DecalDashArrayX} dash dash input
+ * @return {number[][]} normolized dash array
+ */
+function normalizeDashArrayX(dash: DecalDashArrayX): number[][] {
+    if (!dash || typeof dash === 'object' && dash.length === 0) {
+        return [[0, 0]];

Review comment:
       No need to check `typeof dash === 'object'` here?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-echarts] echarts-bot[bot] commented on pull request #13304: feat: decal

Posted by GitBox <gi...@apache.org>.
echarts-bot[bot] commented on pull request #13304:
URL: https://github.com/apache/incubator-echarts/pull/13304#issuecomment-694666530


   Thanks for your contribution!
   The community will review it ASAP. In the meanwhile, please checkout [the coding standard](https://echarts.apache.org/en/coding-standard.html) and Wiki about [How to make a pull request](https://github.com/apache/incubator-echarts/wiki/How-to-make-a-pull-request).
   
   The pull request is marked to be `PR: author is committer` because you are a committer of this project.
   
   Document changes are required in this PR. Please also make a PR to [apache/incubator-echarts-doc](https://github.com/apache/incubator-echarts-doc) for document changes. When the doc PR is merged, the maintainers will remove the `PR: awaiting doc` label.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-echarts] pissang commented on a change in pull request #13304: [5.0] [FEATURE] decal

Posted by GitBox <gi...@apache.org>.
pissang commented on a change in pull request #13304:
URL: https://github.com/apache/incubator-echarts/pull/13304#discussion_r508970699



##########
File path: src/visual/aria.ts
##########
@@ -17,123 +17,186 @@
 * under the License.
 */
 
-// @ts-nocheck
-
 import * as zrUtil from 'zrender/src/core/util';
-import { retrieveRawValue }
-
-from '../data/helper/dataProvider';
-
-export default function (dom, ecModel) {
-    const ariaModel = ecModel.getModel('aria');
-    if (!ariaModel.get('show')) {
-        return;
-    }
-    else if (ariaModel.get('description')) {
-        dom.setAttribute('aria-label', ariaModel.get('description'));
+import ExtensionAPI from '../ExtensionAPI';
+import {retrieveRawValue} from '../data/helper/dataProvider';
+import GlobalModel from '../model/Global';
+import Model from '../model/Model';
+import {AriaOption} from '../component/aria';
+import {TitleOption} from '../component/title';
+
+export default function (ecModel: GlobalModel, api: ExtensionAPI) {
+    const ariaModel: Model<AriaOption> = ecModel.getModel('aria');
+    if (ariaModel.get('show') === false) {
         return;
     }
 
-    let seriesCnt = 0;
-    ecModel.eachSeries(function (seriesModel, idx) {
-        ++seriesCnt;
-    }, this);
+    setDecal();
+    setLabel();
 
-    const maxDataCnt = ariaModel.get('data.maxCount') || 10;
-    const maxSeriesCnt = ariaModel.get('series.maxCount') || 10;
-    const displaySeriesCnt = Math.min(seriesCnt, maxSeriesCnt);
+    function setDecal() {
+        const decalModel = ariaModel.getModel('decal');
 
-    let ariaLabel;
-    if (seriesCnt < 1) {
-        // No series, no aria label
-        return;
-    }
-    else {
-        const title = getTitle();
-        if (title) {
-            ariaLabel = replace(getConfig('general.withTitle'), {
-                title: title
+        const useDecal = decalModel.get('show');
+        if (useDecal) {
+            // default decal show value is true
+            ecModel.eachRawSeries(seriesModel => {
+                const data = seriesModel.getData();
+
+                if (seriesModel.useColorPaletteOnData) {
+                    const dataCount = data.count();
+                    data.each(idx => {
+                        const itemStyle = data.ensureUniqueItemVisual(idx, 'style');
+                        const name = data.getName(idx) || (idx + '');
+                        const paletteDecal = seriesModel.getDecalFromPalette(
+                            name,
+                            null,
+                            dataCount
+                        );
+                        const decal = zrUtil.defaults(
+                            itemStyle.decal || {},
+                            paletteDecal
+                        );
+                        data.setItemVisual(idx, 'decal', decal);
+                    });
+                }
+                else {
+                    const style = data.getVisual('style');
+                    const paletteDecal = seriesModel.getDecalFromPalette(
+                        seriesModel.name,
+                        null,
+                        ecModel.getSeriesCount()
+                    );
+                    const decal = style.decal
+                        ? zrUtil.defaults(style.decal, paletteDecal)
+                        : paletteDecal;
+                    decal.dirty = true;
+                    data.setVisual('decal', decal);
+                }
             });
         }
-        else {
-            ariaLabel = getConfig('general.withoutTitle');
+    }
+
+    function setLabel() {
+        const labelModel = ariaModel.getModel('label') || ariaModel;
+        // Label enabled default: true
+        let labelEnabled = labelModel.get('enabled');
+        if (labelEnabled == null) {
+            const show = labelModel.get('show');
+            if (show == null) {
+                labelEnabled = true;
+            }
+            else {
+                labelEnabled = show;
+            }
+        }
+        if (!labelEnabled) {
+            return;
         }
 
-        const seriesLabels = [];
-        const prefix = seriesCnt > 1
-            ? 'series.multiple.prefix'
-            : 'series.single.prefix';
-        ariaLabel += replace(getConfig(prefix), { seriesCount: seriesCnt });
-
-        ecModel.eachSeries(function (seriesModel, idx) {
-            if (idx < displaySeriesCnt) {
-                let seriesLabel;
-
-                const seriesName = seriesModel.get('name');
-                const seriesTpl = 'series.'
-                    + (seriesCnt > 1 ? 'multiple' : 'single') + '.';
-                seriesLabel = getConfig(seriesName
-                    ? seriesTpl + 'withName'
-                    : seriesTpl + 'withoutName');
-
-                seriesLabel = replace(seriesLabel, {
-                    seriesId: seriesModel.seriesIndex,
-                    seriesName: seriesModel.get('name'),
-                    seriesType: getSeriesTypeName(seriesModel.subType)
+        const dom = api.getZr().dom;
+        if (labelModel.get('description')) {
+            dom.setAttribute('aria-label', labelModel.get('description'));
+            return;
+        }
+
+        const seriesCnt = ecModel.getSeriesCount();
+        const maxDataCnt = labelModel.get(['data', 'maxCount']) || 10;
+        const maxSeriesCnt = labelModel.get(['series', 'maxCount']) || 10;
+        const displaySeriesCnt = Math.min(seriesCnt, maxSeriesCnt);
+
+        let ariaLabel;
+        if (seriesCnt < 1) {
+            // No series, no aria label
+            return;
+        }
+        else {
+            const title = getTitle();
+            if (title) {
+                ariaLabel = replace(getConfig(labelModel, 'general.withTitle'), {
+                    title: title
                 });
+            }
+            else {
+                ariaLabel = getConfig(labelModel, 'general.withoutTitle');
+            }
 
-                const data = seriesModel.getData();
-                window.data = data;
-                if (data.count() > maxDataCnt) {
-                    // Show part of data
-                    seriesLabel += replace(getConfig('data.partialData'), {
-                        displayCnt: maxDataCnt
+            const seriesLabels: string[] = [];
+            const prefix = seriesCnt > 1
+                ? 'series.multiple.prefix'
+                : 'series.single.prefix';
+            ariaLabel += replace(getConfig(labelModel, prefix), { seriesCount: seriesCnt });
+
+            ecModel.eachSeries(function (seriesModel, idx) {
+                if (idx < displaySeriesCnt) {
+                    let seriesLabel;
+
+                    const seriesName = seriesModel.get('name');
+                    const seriesTpl = 'series.'
+                        + (seriesCnt > 1 ? 'multiple' : 'single') + '.';
+                    seriesLabel = getConfig(labelModel, seriesName
+                        ? seriesTpl + 'withName'
+                        : seriesTpl + 'withoutName');
+
+                    seriesLabel = replace(seriesLabel, {
+                        seriesId: seriesModel.seriesIndex,
+                        seriesName: seriesModel.get('name'),
+                        seriesType: getSeriesTypeName(seriesModel.subType)
                     });
-                }
-                else {
-                    seriesLabel += getConfig('data.allData');
-                }
 
-                const dataLabels = [];
-                for (let i = 0; i < data.count(); i++) {
-                    if (i < maxDataCnt) {
-                        const name = data.getName(i);
-                        const value = retrieveRawValue(data, i);
-                        dataLabels.push(
-                            replace(
-                                name
-                                    ? getConfig('data.withName')
-                                    : getConfig('data.withoutName'),
-                                {
-                                    name: name,
-                                    value: value
-                                }
-                            )
-                        );
+                    const data = seriesModel.getData();
+                    (window as any).data = data;

Review comment:
       Remove it




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-echarts] Ovilia commented on a change in pull request #13304: feat: decal

Posted by GitBox <gi...@apache.org>.
Ovilia commented on a change in pull request #13304:
URL: https://github.com/apache/incubator-echarts/pull/13304#discussion_r506082319



##########
File path: src/visual/aria.ts
##########
@@ -142,11 +190,12 @@ export default function (dom, ecModel) {
         return result;
     }
 
-    function getConfig(path) {
-        const userConfig = ariaModel.get(path);
+    function getConfig(model: Model, path: string) {
+        const userConfig = model.get(path);
         if (userConfig == null) {
             const pathArr = path.split('.');
-            let result = ecModel.getLocale('aria');
+            // FIXME: remove as any

Review comment:
       @pissang Please help improve the type here.

##########
File path: src/visual/aria.ts
##########
@@ -158,14 +207,15 @@ export default function (dom, ecModel) {
     }
 
     function getTitle() {
-        let title = ecModel.getModel('title').option;
-        if (title && title.length) {
-            title = title[0];
+        let title = ecModel.get('title') as TitleOption | TitleOption[];
+        if (title && (title as TitleOption[]).length) {
+            title = (title as TitleOption[])[0];
         }
-        return title && title.text;
+        return title && (title as TitleOption).text;
     }
 
-    function getSeriesTypeName(type) {
-        return ecModel.getLocale(['series', 'typeNames'])[type] || '自定义图';
+    function getSeriesTypeName(type: string) {
+        // FIXME: remove as any

Review comment:
       @pissang Please help improve the type here.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [incubator-echarts] pissang edited a comment on pull request #13304: [5.0] [FEATURE] decal

Posted by GitBox <gi...@apache.org>.
pissang edited a comment on pull request #13304:
URL: https://github.com/apache/incubator-echarts/pull/13304#issuecomment-712890831


   Some bugs from my test:
   
   + [ ] Chart has no effect when decal is enabled: Scatter, Graph, Tree series which use Symbol. Sankey, Line.
   + [ ] SVG has performance issues.
   + [ ] When toggling legend in pie series. Decal doesn't follow the fade out animation


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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