You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by ov...@apache.org on 2023/03/31 02:01:37 UTC
[echarts] branch master updated: fix(lines): symbolSize should be updated #18350
This is an automated email from the ASF dual-hosted git repository.
ovilia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/echarts.git
The following commit(s) were added to refs/heads/master by this push:
new 8abf36c2e fix(lines): symbolSize should be updated #18350
8abf36c2e is described below
commit 8abf36c2e509dc4a7cd7573abc026eb1f3964973
Author: cvSoldier <43...@users.noreply.github.com>
AuthorDate: Fri Mar 31 10:01:28 2023 +0800
fix(lines): symbolSize should be updated #18350
---
src/chart/helper/Line.ts | 20 +++-
test/lines-symbolSize-update.html | 107 ++++++++++++++++++++++
test/runTest/actions/__meta__.json | 1 +
test/runTest/actions/lines-symbolSize-update.json | 1 +
4 files changed, 127 insertions(+), 2 deletions(-)
diff --git a/src/chart/helper/Line.ts b/src/chart/helper/Line.ts
index 961502bda..bbfb774ba 100644
--- a/src/chart/helper/Line.ts
+++ b/src/chart/helper/Line.ts
@@ -64,6 +64,22 @@ interface InnerLineLabel extends LineLabel {
function makeSymbolTypeKey(symbolCategory: 'fromSymbol' | 'toSymbol') {
return '_' + symbolCategory + 'Type' as '_fromSymbolType' | '_toSymbolType';
}
+function makeSymbolTypeValue(name: 'fromSymbol' | 'toSymbol', lineData: LineList, idx: number) {
+ const symbolType = lineData.getItemVisual(idx, name);
+ if (!symbolType || symbolType === 'none') {
+ return symbolType;
+ }
+ const symbolSize = lineData.getItemVisual(idx, name + 'Size' as 'fromSymbolSize' | 'toSymbolSize');
+ const symbolRotate = lineData.getItemVisual(idx, name + 'Rotate' as 'fromSymbolRotate' | 'toSymbolRotate');
+ const symbolOffset = lineData.getItemVisual(idx, name + 'Offset' as 'fromSymbolOffset' | 'toSymbolOffset');
+ const symbolKeepAspect = lineData.getItemVisual(idx,
+ name + 'KeepAspect' as 'fromSymbolKeepAspect' | 'toSymbolKeepAspect');
+ const symbolSizeArr = symbolUtil.normalizeSymbolSize(symbolSize);
+
+ const symbolOffsetArr = symbolUtil.normalizeSymbolOffset(symbolOffset || 0, symbolSizeArr);
+
+ return symbolType + symbolSizeArr + symbolOffsetArr + (symbolRotate || '') + (symbolKeepAspect || '');
+}
/**
* @inner
@@ -164,7 +180,7 @@ class Line extends graphic.Group {
// it will be updated after line#update.
// Or symbol position and rotation update in line#beforeUpdate will be one frame slow
this.add(symbol);
- this[makeSymbolTypeKey(symbolCategory)] = lineData.getItemVisual(idx, symbolCategory);
+ this[makeSymbolTypeKey(symbolCategory)] = makeSymbolTypeValue(symbolCategory, lineData, idx);
}, this);
this._updateCommonStl(lineData, idx, seriesScope);
@@ -184,7 +200,7 @@ class Line extends graphic.Group {
graphic.updateProps(line, target, seriesModel, idx);
each(SYMBOL_CATEGORIES, function (symbolCategory) {
- const symbolType = (lineData as LineList).getItemVisual(idx, symbolCategory);
+ const symbolType = makeSymbolTypeValue(symbolCategory, lineData as LineList, idx);
const key = makeSymbolTypeKey(symbolCategory);
// Symbol changed
if (this[key] !== symbolType) {
diff --git a/test/lines-symbolSize-update.html b/test/lines-symbolSize-update.html
new file mode 100644
index 000000000..2ed2fa7d3
--- /dev/null
+++ b/test/lines-symbolSize-update.html
@@ -0,0 +1,107 @@
+<!DOCTYPE html>
+<!--
+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.
+-->
+
+
+<html>
+ <head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <script src="lib/simpleRequire.js"></script>
+ <script src="lib/config.js"></script>
+ <script src="lib/jquery.min.js"></script>
+ <script src="lib/facePrint.js"></script>
+ <script src="lib/testHelper.js"></script>
+ <!-- <script src="ut/lib/canteen.js"></script> -->
+ <link rel="stylesheet" href="lib/reset.css" />
+ </head>
+ <body>
+ <div id="main0"></div>
+
+ <script>
+ // See <https://github.com/apache/echarts/issues/18350>
+ require([
+ 'echarts',
+ ], function (echarts) {
+ var maxValue = 10;
+ var linesData = Array.from(Array(maxValue).keys()).map((value) => {
+ return {
+ coords: [
+ [value * Math.random(), value * Math.random()],
+ [value * Math.random(), value * Math.random()]
+ ]
+ };
+ });
+
+ var option = {
+ xAxis: {
+ type: 'value',
+ min: 0,
+ max: maxValue
+ },
+ yAxis: {
+ type: 'value',
+ min: 0,
+ max: maxValue
+ },
+ series: [
+ {
+ id: '1',
+ type: 'lines',
+ symbol: ['none', 'arrow'],
+ symbolSize: 10,
+ coordinateSystem: 'cartesian2d',
+ lineStyle: {
+ color: '#c46e54',
+ width: 1
+ },
+ data: linesData
+ }
+ ]
+ };
+
+
+ var chart = testHelper.create(echarts, 'main0', {
+ title: ['Lines series symbolSize should be updated'],
+ option: option,
+ buttons: [{
+ text: 'Click to change symbolSize',
+ onclick: function () {
+ chart.setOption(
+ {
+ series: [
+ {
+ id: '1',
+ type: 'lines',
+ symbol: ['none', 'arrow'],
+ symbolSize: 30,
+ }
+ ]
+ },
+ );
+ }
+ }],
+ });
+ });
+ </script>
+
+
+ </body>
+</html>
+
diff --git a/test/runTest/actions/__meta__.json b/test/runTest/actions/__meta__.json
index 46d6b8e41..7ee9a1520 100644
--- a/test/runTest/actions/__meta__.json
+++ b/test/runTest/actions/__meta__.json
@@ -130,6 +130,7 @@
"line-sampling": 2,
"line-visual2": 2,
"lines-bus": 1,
+ "lines-symbolSize-update": 1,
"map": 3,
"map-contour": 2,
"map-default": 1,
diff --git a/test/runTest/actions/lines-symbolSize-update.json b/test/runTest/actions/lines-symbolSize-update.json
new file mode 100644
index 000000000..aee5b6746
--- /dev/null
+++ b/test/runTest/actions/lines-symbolSize-update.json
@@ -0,0 +1 @@
+[{"name":"Action 1","ops":[{"type":"mousemove","time":484,"x":83,"y":96},{"type":"mousemove","time":685,"x":91,"y":83},{"type":"mousemove","time":899,"x":92,"y":83},{"type":"mousedown","time":1506,"x":92,"y":83},{"type":"mouseup","time":1511,"x":92,"y":83},{"time":1512,"delay":400,"type":"screenshot-auto"}],"scrollY":0,"scrollX":0,"timestamp":1679391497375}]
\ 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