[Bug] Uncaught TypeError: Cannot set properties of undefined (setting 'dataIndex')
Author: geoguardvadimCreated Sep 19, 2024Updated Oct 10, 2024
Labelsbugneed investigationupstream/outside
Describe the issue
Error
echarts.min.js:45 Uncaught TypeError: Cannot set properties of undefined (setting 'dataIndex')
at t.update (echarts.min.js:45:540135)
at QA (echarts.min.js:45:543909)
at e.getInitialData (echarts.min.js:45:544795)
at e.init (echarts.min.js:45:158856)
at e.init (echarts.min.js:45:544164)
at e.<anonymous> (echarts.min.js:45:113807)
at Array.forEach (<anonymous>)
at E (echarts.min.js:35:5056)
at e.<anonymous> (echarts.min.js:45:113440)
at t.topologicalTravel (echarts.min.js:45:106659)Source Data
{
Users: {
"test": entity.GraphUser {ID: "test"}
}
Devices: {
"test": entity.GraphDevice {ID: "test"}
}
Edges: {
"test->test: *entity.Edge {ID: "test->test", Source: "test", Target: "test"}
}
}Graph Data
*util.GraphData {Nodes: []github.com/go-echarts/go-echarts/v2/opts.GraphNode len: 2, cap: 2,
opts.GraphNode {Name: "test", X: 0, Y: 0, Value: 0, Fixed: *bool nil, Category: interface {}(string) "User", Symbol: "path://M399 384.2C376.9 345.8 335.4 320 288 320l-64 0c-47.4 0-88.9 25.8-111 64.2c35.2 39.2 86.2 63.8 143 63.8s107.8-24.7 143-63.8zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm256 16a72 72 0 1 0 0-144 72 72 0 1 0 0 144z", SymbolSize: interface {}(int) 40, ItemStyle: *github.com/go-echarts/go-echarts/v2/opts.ItemStyle {Color: "#cddffa", Color0: "", BorderColor: "#f70200", BorderColor0: "", BorderColorSaturation: 0, BorderWidth: 1, GapWidth: 0, Opacity: 0, ShadowBlur: 5, ShadowColor: "rgba(0, 0, 0, 0.3)", ShadowOffsetX: 0, ShadowOffsetY: 0
}, Tooltip: *github.com/go-echarts/go-echarts/v2/opts.Tooltip nil
},
opts.GraphNode {Name: "test", X: 0, Y: 0, Value: 0, Fixed: *bool nil, Category: interface {}(string) "Device", Symbol: "path://M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM184 128l72 0c70.7 0 128 57.3 128 128s-57.3 128-128 128l-72 0c-13.3 0-24-10.7-24-24l0-208c0-13.3 10.7-24 24-24zm72 208c44.2 0 80-35.8 80-80s-35.8-80-80-80l-48 0 0 160 48 0z", SymbolSize: interface {}(int) 40, ItemStyle: *github.com/go-echarts/go-echarts/v2/opts.ItemStyle {Color: "#CEF1EE", Color0: "", BorderColor: "#000000", BorderColor0: "", BorderColorSaturation: 0, BorderWidth: 1, GapWidth: 0, Opacity: 0, ShadowBlur: 5, ShadowColor: "rgba(0, 0, 0, 0.3)", ShadowOffsetX: 0, ShadowOffsetY: 0
}, Tooltip: *github.com/go-echarts/go-echarts/v2/opts.Tooltip nil
}
],
opts.GraphLink {Source: interface {}(string) "test", Target: interface {}(string) "test", Value: 0, Label: *github.com/go-echarts/go-echarts/v2/opts.EdgeLabel nil, LineStyle: *github.com/go-echarts/go-echarts/v2/opts.LineStyle nil
},
Categories: []*github.com/go-echarts/go-echarts/v2/opts.GraphCategory len: 2, cap: 2,
[*opts.GraphCategory {Name: "User", ItemStyle: *github.com/go-echarts/go-echarts/v2/opts.ItemStyle {Color: "#cddffa", Color0: "", BorderColor: "", BorderColor0: "", BorderColorSaturation: 0, BorderWidth: 0, GapWidth: 0, Opacity: 0, ShadowBlur: 0, ShadowColor: "", ShadowOffsetX: 0, ShadowOffsetY: 0
}, Label: *github.com/go-echarts/go-echarts/v2/opts.Label nil
},*opts.GraphCategory {Name: "Device", ItemStyle: *github.com/go-echarts/go-echarts/v2/opts.ItemStyle {Color: "#CEF1EE", Color0: "", BorderColor: "", BorderColor0: "", BorderColorSaturation: 0, BorderWidth: 0, GapWidth: 0, Opacity: 0, ShadowBlur: 0, ShadowColor: "", ShadowOffsetX: 0, ShadowOffsetY: 0
}, Label: *github.com/go-echarts/go-echarts/v2/opts.Label nil
}
]
}addNode function inside the library contains a bug. When we add nodes from users and devices from the same name only one of them will be added. Then, in the update function, the count will not match, and in row 6, we will try to take an index that does not exist because one node value will be missed.
t.prototype.addNode = function(t, e) {
t = null == t ? "" + e : "" + t;
var n = this._nodesMap;
if (!n[jA(t)]) {
var i = new KA(t,e);
return i.hostGraph = this,
this.nodes.push(i),
n[jA(t)] = i,
i
}
} t.prototype.update = function() {
for (var t = this.data, e = this.edgeData, n = this.nodes, i = this.edges, r = 0, o = n.length; r < o; r++)
n[r].dataIndex = -1;
for (r = 0,
o = t.count(); r < o; r++)
n[t.getRawIndex(r)].dataIndex = r;
....
}How to reproduce this issue
Use the same name in nodes but in different categories.
Other information
No response
go-echarts version
v2.4.1
Source: go-echarts/go-echarts