diff --git a/src/chart/sankey/SankeySeries.ts b/src/chart/sankey/SankeySeries.ts index 9dca447cad..a91f907b27 100644 --- a/src/chart/sankey/SankeySeries.ts +++ b/src/chart/sankey/SankeySeries.ts @@ -156,9 +156,9 @@ class SankeySeriesModel extends SeriesModel { * Init a graph data structure from data in option series */ getInitialData(option: SankeySeriesOption, ecModel: GlobalModel) { - const links = option.edges || option.links; - const nodes = option.data || option.nodes; - const levels = option.levels; + const links = option.edges || option.links || []; + const nodes = option.data || option.nodes || []; + const levels = option.levels || []; this.levelModels = []; const levelModels = this.levelModels; @@ -172,10 +172,10 @@ class SankeySeriesModel extends SeriesModel { } } } - if (nodes && links) { - const graph = createGraphFromNodeEdge(nodes, links, this, true, beforeLink); - return graph.data; - } + + const graph = createGraphFromNodeEdge(nodes, links, this, true, beforeLink); + return graph.data; + function beforeLink(nodeData: SeriesData, edgeData: SeriesData) { nodeData.wrapMethod('getItemModel', function (model: Model, idx: number) { const seriesModel = model.parentModel as SankeySeriesModel; diff --git a/test/sankey.html b/test/sankey.html index f9e16bd30e..7b6205d108 100644 --- a/test/sankey.html +++ b/test/sankey.html @@ -38,6 +38,7 @@
+
@@ -79,9 +80,8 @@ }); if (chart) { - window.onresize = function () { - chart.resize(); - }; + window.addEventListener('resize', chart.resize); + chart.on('click', function (params) { console.log(params, params.data); }); @@ -131,9 +131,8 @@ if (chart) { - window.onresize = function () { - chart.resize(); - }; + window.addEventListener('resize', chart.resize); + chart.on('click', function (params) { console.log(params, params.data); }); @@ -168,11 +167,10 @@ title: 'emphasis trajectory', option: option }); - + if (chart) { - window.onresize = function () { - chart.resize(); - }; + window.addEventListener('resize', chart.resize); + chart.on('click', function (params) { console.log(params, params.data); }); @@ -180,5 +178,47 @@ }); + + - \ No newline at end of file +