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 2023/05/14 09:36:26 UTC
[echarts] 01/02: fix(graph): fix graph chart can't be hidden by legend due to edgeLabel NPE.
This is an automated email from the ASF dual-hosted git repository.
wangzx pushed a commit to branch fix/graph/edgeLabel-NPE
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit a237e0a781521fae6772f0549620cf72802a2714
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Sun May 14 17:20:28 2023 +0800
fix(graph): fix graph chart can't be hidden by legend due to edgeLabel NPE.
---
src/label/LabelManager.ts | 12 +++++---
test/graph-case.html | 60 +++++++++++++++++++++++++++++++++++-
test/runTest/actions/__meta__.json | 1 +
test/runTest/actions/graph-case.json | 1 +
4 files changed, 68 insertions(+), 6 deletions(-)
diff --git a/src/label/LabelManager.ts b/src/label/LabelManager.ts
index c1c7d9152..f2b2aefd3 100644
--- a/src/label/LabelManager.ts
+++ b/src/label/LabelManager.ts
@@ -487,10 +487,11 @@ class LabelManager {
const defaultStyle: PathStyleProps = {};
const visualStyle = data.getItemVisual(dataIndex, 'style');
- const visualType = data.getVisual('drawType');
- // Default to be same with main color
- defaultStyle.stroke = visualStyle[visualType];
-
+ if (visualStyle) {
+ const visualType = data.getVisual('drawType');
+ // Default to be same with main color
+ defaultStyle.stroke = visualStyle[visualType];
+ }
const labelLineModel = itemModel.getModel('labelLine');
setLabelLineStyle(el, getLabelLineStatesModels(itemModel), defaultStyle);
@@ -591,4 +592,5 @@ class LabelManager {
}
-export default LabelManager;
\ No newline at end of file
+export default LabelManager;
+
diff --git a/test/graph-case.html b/test/graph-case.html
index e6d311b41..7f199f5a4 100644
--- a/test/graph-case.html
+++ b/test/graph-case.html
@@ -38,7 +38,7 @@ under the License.
<div id="main0"></div>
-
+ <div id="main1"></div>
@@ -95,6 +95,64 @@ under the License.
});
</script>
+ <script>
+ require(['echarts'], function (echarts) {
+ var option = {
+ legend: {},
+ series: {
+ type: 'graph',
+ name: 'graph',
+ edgeLabel: {
+ show: true,
+ fontSize: 16
+ },
+ lineStyle: {
+ width: 5,
+ curveness: 0.2,
+ opacity: 0.9
+ },
+ data: [
+ {
+ x: 10,
+ y: 100,
+ name: 'Node 1'
+ },
+ {
+ x: 100,
+ y: -50,
+ name: 'Node 2'
+ },
+ {
+ x: 400,
+ y: 200,
+ name: 'Node 3'
+ }
+ ],
+ links: [
+ {
+ source: 'Node 1',
+ target: 'Node 2'
+ },
+ {
+ source: 'Node 1',
+ target: 'Node 3'
+ },
+ {
+ source: 'Node 2',
+ target: 'Node 3'
+ }
+ ]
+ }
+ };
+
+ var chart = testHelper.create(echarts, 'main1', {
+ title: [
+ 'Should not throw error when hiding by legend'
+ ],
+ option: option
+ });
+ });
+ </script>
</body>
</html>
diff --git a/test/runTest/actions/__meta__.json b/test/runTest/actions/__meta__.json
index b1cc9c96a..9f6155e61 100644
--- a/test/runTest/actions/__meta__.json
+++ b/test/runTest/actions/__meta__.json
@@ -100,6 +100,7 @@
"geoScatter": 1,
"getOption": 1,
"graph": 2,
+ "graph-case": 1,
"graph-grid": 1,
"graph-simple": 2,
"graphic-animation": 1,
diff --git a/test/runTest/actions/graph-case.json b/test/runTest/actions/graph-case.json
new file mode 100644
index 000000000..ace16dc41
--- /dev/null
+++ b/test/runTest/actions/graph-case.json
@@ -0,0 +1 @@
+[{"name":"Action 1","ops":[{"type":"mousemove","time":475,"x":416,"y":188},{"type":"mousemove","time":675,"x":406,"y":208},{"type":"mousedown","time":848,"x":406,"y":210},{"type":"mousemove","time":881,"x":406,"y":210},{"type":"mouseup","time":979,"x":406,"y":210},{"time":980,"delay":400,"type":"screenshot-auto"},{"type":"mousedown","time":1837,"x":406,"y":210},{"type":"mouseup","time":1988,"x":406,"y":210},{"time":1989,"delay":400,"type":"screenshot-auto"},{"type":"mousemove","time":234 [...]
\ 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