Oddly no, not seeing any errors in console. Just refreshed the query to get new console results. It just seems to log the mapped data.
I’m doing a series mapping from 2 Elastic queries (“nodes” and “links”) using “ref id” and then adding the results of each array to the “graph” object. Would you recommend a different approach?
Here’s the full code:
let nodes;
data.series.map((s) => {
if (s.refId === ‘nodes’) {
var title = s.fields.find((f) => f.name === ‘sIp’).values.buffer;
var symbolSize = s.fields.find((f) => f.name === ‘bytes’).values.buffer;
var category = s.fields.find((f) => f.name === “Count”).values.buffer;
nodes = title.map((title, i) => {
return { "name": title,
"symbolSize": symbolSize[i],
"category": category[i] };
})
}
});
let links;
data.series.map((s) => {
if (s.refId === “links”) {
var sources = s.fields.find((f) => f.name === “sIp”).values.buffer;
var targets = s.fields.find((f) => f.name === “dIp”).values.buffer;
links = sources.map((sources, i) => {
return { "source": sources,
"target": targets[i] }
});
}
});
const categories = [
{ “name”: “1” }, { “name”: “2” }, { “name”: “3” }, { “name”: “4” }, { “name”: “5” }, { “name”: “6” }, { “name”: “7” }, { “name”: “8” }, { “name”: “9” }]
let graph = {};
graph[“nodes”] = nodes;
graph[“links”] = links;
graph[“categories”] = categories;
//console.log(‘graph’, graph)
graph.nodes.forEach(function (node) {
node.symbolSize > 500,
node.label = {
show: graph.nodes.title
};
});
return {
tooltip: {},
legend: [
{
data: graph.categories.map(function (a) {
return a.name;
})
}
],
animationDurationUpdate: 1500,
animationEasingUpdate: ‘quinticInOut’,
series: [
{
name: ‘netflow’,
type: ‘graph’,
layout: ‘circular’,
circular: {
rotateLabel: true
},
data: graph.nodes,
links: graph.links,
categories: graph.categories,
roam: true,
label: {
position: ‘right’,
formatter: ‘{b}’
},
lineStyle: {
color: ‘source’,
curveness: 0.3
}
}
]
};