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 2024/05/07 09:48:47 UTC
(echarts) 01/01: fix(series): add non-null check for `seriesData.getLinkedData`.
This is an automated email from the ASF dual-hosted git repository.
wangzx pushed a commit to branch fix/seriesModel-getLinkedData-NPE
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit ea0da6344be7aa2207618206ce7f9ea7d1baf4b6
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Tue May 7 17:46:54 2024 +0800
fix(series): add non-null check for `seriesData.getLinkedData`.
---
src/model/Series.ts | 2 +-
test/graph-case.html | 252 ++++++++++++++++++++++++++++++++++-
test/runTest/actions/__meta__.json | 2 +-
test/runTest/actions/graph-case.json | 2 +-
4 files changed, 254 insertions(+), 4 deletions(-)
diff --git a/src/model/Series.ts b/src/model/Series.ts
index 89be20c7d..94e630fc1 100644
--- a/src/model/Series.ts
+++ b/src/model/Series.ts
@@ -347,7 +347,7 @@ class SeriesModel<Opt extends SeriesOption = SeriesOption> extends ComponentMode
const task = getCurrentTask(this);
if (task) {
const data = task.context.data;
- return (dataType == null ? data : data.getLinkedData(dataType)) as SeriesData<this>;
+ return (dataType == null || !data.getLinkedData ? data : data.getLinkedData(dataType)) as SeriesData<this>;
}
else {
// When series is not alive (that may happen when click toolbox
diff --git a/test/graph-case.html b/test/graph-case.html
index 4523593c7..8112b80af 100644
--- a/test/graph-case.html
+++ b/test/graph-case.html
@@ -40,7 +40,7 @@ under the License.
<div id="main0"></div>
<div id="main1"></div>
<div id="main2"></div>
-
+ <div id="main3"></div>
@@ -209,6 +209,256 @@ under the License.
});
});
</script>
+
+ <script>
+ require(['echarts'], function (echarts) {
+ var option = {
+ xAxis: { show: false, type: 'value', min: 0, max: 503 },
+ yAxis: { show: false, type: 'value', min: 0, max: 810 },
+ series: [
+ {
+ name: '马王堆一号+',
+ type: 'graph',
+ coordinateSystem: 'cartesian2d',
+ symbol: 'circle',
+ emphasis: { focus: 'adjacency' },
+ z: 3,
+ scaleLimit: { min: 0.5, max: 2 },
+ draggable: true,
+ roam: 'scale',
+ label: {
+ show: true,
+ position: 'bottom',
+ color: 'black',
+ fontWeight: 'bold'
+ },
+ data: [
+ {
+ value: [430, 257],
+ id: '1',
+ name: '入职指导',
+ symbolSize: 51,
+ attributes: {},
+ itemStyle: { color: '#3ba272' }
+ },
+ {
+ value: [468, 684],
+ id: '2',
+ name: '开发规范参考',
+ symbolSize: 20,
+ attributes: {},
+ itemStyle: { color: '#fc8452' }
+ },
+ {
+ value: [487, 326],
+ id: '3',
+ name: 'Web 前端',
+ symbolSize: 59,
+ attributes: {},
+ itemStyle: { color: '#9a60b4' }
+ },
+ {
+ value: [238, 121],
+ id: '4',
+ name: '响应式分享',
+ symbolSize: 51,
+ attributes: {},
+ itemStyle: { color: '#ea7ccc' }
+ },
+ {
+ value: [394, 529],
+ id: '5',
+ name: '技术文档',
+ symbolSize: 20,
+ attributes: {},
+ itemStyle: { color: '#cfb850' }
+ },
+ {
+ value: [261, 369],
+ id: '6',
+ name: '组件库方案',
+ symbolSize: 57,
+ attributes: {},
+ itemStyle: { color: '#4ee0d7' }
+ },
+ {
+ value: [125, 366],
+ id: '7',
+ name: '数字文博 C 端 Web 技术选型',
+ symbolSize: 41,
+ attributes: {},
+ itemStyle: { color: '#e3698c' }
+ },
+ {
+ value: [230, 55],
+ id: '8',
+ name: '3D 展示调研',
+ symbolSize: 60,
+ attributes: {},
+ itemStyle: { color: '#e3698c' }
+ },
+ {
+ value: [195, 447],
+ id: '9',
+ name: '送审方案',
+ symbolSize: 46,
+ attributes: {},
+ itemStyle: { color: '#eca389' }
+ },
+ {
+ value: [367, 645],
+ id: '10',
+ name: '蜂鸟go-ceres开发规范',
+ symbolSize: 30,
+ attributes: {},
+ itemStyle: { color: '#6939e4' }
+ },
+ {
+ value: [350, 701],
+ id: '11',
+ name: '分库分表规范',
+ symbolSize: 57,
+ attributes: {},
+ itemStyle: { color: '#9f73c7' }
+ }
+ ],
+ edges: [
+ { source: '2', target: '9' },
+ { source: '2', target: '10' },
+ { source: '2', target: '11' },
+ { source: '3', target: '1' },
+ { source: '3', target: '2' },
+ { source: '3', target: '5' },
+ { source: '3', target: '7' },
+ { source: '3', target: '8' },
+ { source: '5', target: '4' },
+ { source: '5', target: '7' },
+ { source: '5', target: '8' },
+ { source: '7', target: '5' },
+ { source: '7', target: '6' },
+ { source: '7', target: '9' },
+ { source: '9', target: '10' }
+ ],
+ lineStyle: { color: 'orange', curveness: 0, width: 1, type: 'solid' }
+ },
+ {
+ name: '线图',
+ type: 'lines',
+ coordinateSystem: 'cartesian2d',
+ effect: {
+ show: true,
+ trailLength: 0,
+ symbol: 'circle',
+ color: 'red',
+ symbolSize: 6,
+ constantSpeed: 60
+ },
+ z: 1,
+ lineStyle: { width: 0 },
+ data: [
+ {
+ coords: [
+ [468, 684],
+ [195, 447]
+ ]
+ },
+ {
+ coords: [
+ [468, 684],
+ [367, 645]
+ ]
+ },
+ {
+ coords: [
+ [468, 684],
+ [350, 701]
+ ]
+ },
+ {
+ coords: [
+ [487, 326],
+ [430, 257]
+ ]
+ },
+ {
+ coords: [
+ [487, 326],
+ [468, 684]
+ ]
+ },
+ {
+ coords: [
+ [487, 326],
+ [394, 529]
+ ]
+ },
+ {
+ coords: [
+ [487, 326],
+ [125, 366]
+ ]
+ },
+ {
+ coords: [
+ [487, 326],
+ [230, 55]
+ ]
+ },
+ {
+ coords: [
+ [394, 529],
+ [238, 121]
+ ]
+ },
+ {
+ coords: [
+ [394, 529],
+ [125, 366]
+ ]
+ },
+ {
+ coords: [
+ [394, 529],
+ [230, 55]
+ ]
+ },
+ {
+ coords: [
+ [125, 366],
+ [394, 529]
+ ]
+ },
+ {
+ coords: [
+ [125, 366],
+ [261, 369]
+ ]
+ },
+ {
+ coords: [
+ [125, 366],
+ [195, 447]
+ ]
+ },
+ {
+ coords: [
+ [195, 447],
+ [367, 645]
+ ]
+ }
+ ]
+ }
+ ]
+ };
+ var chart = testHelper.create(echarts, 'main3', {
+ option,
+ title: [
+ 'Hover on the symbols or lines, **SHOULD NOT** throw NPE',
+ 'See also https://github.com/apache/echarts/issues/19900'
+ ]
+ });
+ });
+ </script>
</body>
</html>
diff --git a/test/runTest/actions/__meta__.json b/test/runTest/actions/__meta__.json
index bf0a57e02..a7aba928f 100644
--- a/test/runTest/actions/__meta__.json
+++ b/test/runTest/actions/__meta__.json
@@ -101,7 +101,7 @@
"geoScatter": 1,
"getOption": 1,
"graph": 2,
- "graph-case": 2,
+ "graph-case": 3,
"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
index a4f345849..aae562b88 100644
--- a/test/runTest/actions/graph-case.json
+++ b/test/runTest/actions/graph-case.json
@@ -1 +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
+[{"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