Skip to content

Commit bb12cee

Browse files
authored
Merge pull request #20380 from sz-p/fix-20336
fix(sankey): avoid throwing errors when the `links` / `nodes` / `levels` option is undefined
2 parents 38613d2 + d60b241 commit bb12cee

2 files changed

Lines changed: 58 additions & 18 deletions

File tree

src/chart/sankey/SankeySeries.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ class SankeySeriesModel extends SeriesModel<SankeySeriesOption> {
156156
* Init a graph data structure from data in option series
157157
*/
158158
getInitialData(option: SankeySeriesOption, ecModel: GlobalModel) {
159-
const links = option.edges || option.links;
160-
const nodes = option.data || option.nodes;
161-
const levels = option.levels;
159+
const links = option.edges || option.links || [];
160+
const nodes = option.data || option.nodes || [];
161+
const levels = option.levels || [];
162162
this.levelModels = [];
163163
const levelModels = this.levelModels;
164164

@@ -172,10 +172,10 @@ class SankeySeriesModel extends SeriesModel<SankeySeriesOption> {
172172
}
173173
}
174174
}
175-
if (nodes && links) {
176-
const graph = createGraphFromNodeEdge(nodes, links, this, true, beforeLink);
177-
return graph.data;
178-
}
175+
176+
const graph = createGraphFromNodeEdge(nodes, links, this, true, beforeLink);
177+
return graph.data;
178+
179179
function beforeLink(nodeData: SeriesData, edgeData: SeriesData) {
180180
nodeData.wrapMethod('getItemModel', function (model: Model, idx: number) {
181181
const seriesModel = model.parentModel as SankeySeriesModel;

test/sankey.html

Lines changed: 51 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)