Skip to content

Commit

Permalink
chore: Update do-graph.html with filter control improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
yjmantilla committed Jun 14, 2024
1 parent a8934d3 commit ceea973
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions _includes/do-graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
const settings = {enableTooltip: false, orSearch: false};
const uniqueCategories = new Set();
const delimiter = '~';
const lowUnique=0;
const midUnique=0;
const lowUnique=5;
const midUnique=10;
gui.add(settings, 'enableTooltip').name('Enable Preview');
gui.add(settings, 'orSearch').name('OR search');
gui.add(settings, 'orSearch').name('OR search').onChange(updateGraph);


// Adding filter controls to GUI
Expand Down Expand Up @@ -79,9 +79,8 @@
function filterNodes(setting,node){
const [field, value] = setting.split(delimiter);
const fieldValue = node[field];

// If the field does not exist in the node, filter it out
if (fieldValue === undefined) {
if (fieldValue === undefined || fieldValue === null || fieldValue === '') {
return true;
}

Expand All @@ -95,7 +94,6 @@
if (filterSettings[setting] === '') {
return true;
}

const searchWords = filterSettings[setting].toLowerCase().split(' ');
const fieldValueLowerCase = fieldValue.toLowerCase();

Expand All @@ -106,12 +104,13 @@
}

// For toggle filters
if (typeof filterSettings[setting] === 'boolean') {
if (typeof filterSettings[setting] === 'boolean' && fieldValue !== undefined && fieldValue !== null && fieldValue !== '') {
return !(filterSettings[setting] === false && fieldValue.includes(value));
//filterSettings[setting] === false || fieldValue.includes(value);
//
}


return true;
}
function updateGraph() {
Expand All @@ -124,15 +123,14 @@

for (let node of data.nodes) {
let includeNode = true;

for (let setting of Object.keys(filterSettings)) {
if (!filterNodes(setting, node)) {
if (!filterNodes(setting, node)) {
includeNode = false;
//console.log(`Node ${node.id} excluded by setting: ${setting}`); // Debugging log
break; // Stop checking further settings for this node
}
}

}
if (includeNode) {
filteredNodes.push(node);
} else {
Expand All @@ -155,7 +153,10 @@

Object.keys(fieldValues).forEach(field => {
const values = Array.from(fieldValues[field]);

if (field.startsWith('_')) {
"pass";
}else
{
if (values.every(val => typeof val === 'number')) {
// Range filter
filterSettings[field] = { min: Math.min(...values), max: Math.max(...values) };
Expand Down Expand Up @@ -191,7 +192,7 @@
folder.add({toggleAll: () => setAllToggles(folder, field, true)}, 'toggleAll').name("Toggle All");
folder.add({toggleAll: () => setAllToggles(folder, field, false)}, 'toggleAll').name("Detoggle All");
}
}
}}
});

function setAllToggles(folder, field, value) {
Expand Down

0 comments on commit ceea973

Please sign in to comment.