mirror of
https://github.com/MISP/misp-galaxy.git
synced 2024-11-26 16:57:18 +00:00
Add [graph] pre filtering for large data
This commit is contained in:
parent
34b8ce4f3c
commit
7ff99f5201
1 changed files with 16 additions and 2 deletions
|
@ -5,6 +5,12 @@ document$.subscribe(function () {
|
|||
const Parent_Node_COLOR = "#ff0000";
|
||||
|
||||
|
||||
function applyTableFilter(tf) {
|
||||
var valuesToSelect = ['1', '2', '3'];
|
||||
tf.setFilterValue(4, valuesToSelect);
|
||||
tf.filter();
|
||||
};
|
||||
|
||||
function parseFilteredTable(tf, allData) {
|
||||
var data = [];
|
||||
tf.getFilteredData().forEach((row, i) => {
|
||||
|
@ -427,6 +433,8 @@ document$.subscribe(function () {
|
|||
// Restart the simulation with new data
|
||||
simulation.nodes(nodes);
|
||||
simulation.force("link").links(links);
|
||||
linkDistance = Math.sqrt((width * height) / nodes.length);
|
||||
simulation.force("link").distance(linkDistance);
|
||||
simulation.alpha(1).restart();
|
||||
}
|
||||
});
|
||||
|
@ -473,7 +481,13 @@ document$.subscribe(function () {
|
|||
});
|
||||
|
||||
tf.init();
|
||||
var data = parseTable(table);
|
||||
var allData = parseTable(table);
|
||||
if (allData.length > 1000) {
|
||||
applyTableFilter(tf);
|
||||
data = parseFilteredTable(tf, allData);
|
||||
} else {
|
||||
data = allData;
|
||||
}
|
||||
var graphId = "graph" + index;
|
||||
var div = document.createElement("div");
|
||||
div.id = graphId;
|
||||
|
@ -482,7 +496,7 @@ document$.subscribe(function () {
|
|||
|
||||
// Listen for table filtering events
|
||||
tf.emitter.on(['after-filtering'], function () {
|
||||
filterTableAndGraph(tf, simulation, data);
|
||||
filterTableAndGraph(tf, simulation, allData);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue