I have a working d3.js (v 4.0) hierarchical tree. Each level in the tree structure has a type parameter field determined in the process of creating the JSON from a MySQL database.
An example of the JSON is at the end.
I want to add another data/parameter field dynamically in the d3.js script where nodes d.type == 'unit'.
That data/parameter field can be called dv.
I would need to do a separate query on the unit table for this in another script, then iterate through those nodes, where nodes d.type == 'unit', for example to change the node's appearance if dv equals something.
How should this be done?
E.g. from
d3.json("json/data.json", function(treeData) {
Example JSON:
"name": "1.1 Ensure the appropriateness of sample collection procedures",
"column_to_sort_by": null,
"type": "program_outcome",
"children": [
{
"name": "PATH5121 Clinical Biochemistry",
"column_to_sort_by": "PATH5121 Clinical Biochemistry",
"children": [
{
"name": "Learning Events - PATH5121",
"column_to_sort_by": null,
"type": "unit_group"
},
{
"name": "Assessments - PATH5121",
"column_to_sort_by": null,
"type": "unit_group"
}
],
"type": "unit"
},