feat: add buttons to anonymise nodes on graph

This commit is contained in:
James Graham
2021-05-12 19:56:18 +01:00
parent b28d714e9e
commit e7a113c4ee
2 changed files with 32 additions and 1 deletions

View File

@@ -6,11 +6,21 @@ var hide_organisations = false;
var organisation_nodes;
var organisation_edges;
var anonymise_people = false;
var anonymise_organisations = false;
var network_style = [
{
selector: 'node[name]',
style: {
label: 'data(name)',
label: function (ele) {
var anonymise = anonymise_people;
if (ele.data('kind') == 'organisation') {
anonymise = anonymise_organisations;
}
return anonymise ? ele.data('id') : ele.data('name')
},
width: '100px',
height: '100px',
'text-halign': 'center',
@@ -63,6 +73,22 @@ function toggle_organisations() {
}
}
/**
* Toggle person node labels between names and ids.
*/
function toggle_anonymise_people() {
anonymise_people = !anonymise_people
cy.elements().remove().restore();
}
/**
* Toggle organisation node labels between names and ids.
*/
function toggle_anonymise_organisations() {
anonymise_organisations = !anonymise_organisations
cy.elements().remove().restore();
}
/**
* Populate a Cytoscape network from :class:`Person` and :class:`Relationship` JSON embedded in page.
*/

View File

@@ -73,6 +73,11 @@
<div class="col-md-4">
<button class="btn btn-block btn-info mb-3" onclick="toggle_organisations();">Toggle Organisations</button>
</div>
<div class="col-md-4">
<button class="btn btn-block btn-info mb-3" onclick="toggle_anonymise_people();">Toggle Anonymise People</button>
<button class="btn btn-block btn-info mb-3" onclick="toggle_anonymise_organisations();">Toggle Anonymise Organisations</button>
</div>
</div>
<div id="cy"