I wanted to modify this script by Neal Caren to create an adjustable graph that allows you to control the threshold of citations for nodes that will appear on the graph. If for example, you wanted to see only those nodes with twenty or more citations, you can just move the slider over to see those, and the data will automatically update.
I have created three of these: Modernist Journals, Literary Theory, and Rhetoric and Composition. I’m sure there are several ways of going about doing this, and I’m equally as sure that mine is far from the most efficient or practical.
To do this requires modfiying Caren’s script. Add the following lines to the beginning:
1 2 3
Then find these lines in Caren’s script
1 2 3
And change them to:
1 2 3
This allows you to send arguments to the script to change the filename and also the allowable citation threshold. The next step is to use a simple script to iterate over the range of desired thresholds:
1 2 3 4 5
The arguments are set to 3 and 20 here, but these can be easily adjusted (or easily modified to be able be called from the script itself). You also call the script with the name of the data file downloaded from Web of Science. This script will then generate a series of json files labeled cites-3.json, cites-4.json, etc.
The trick now is changes the cites.js code to enable the updates. You have to wrap the entire code that generates the force-directed layout in a function. I call this updateData():
1 2 3 4 5 6 7 8 9
You then need to add this line before the d3.json definition:
Then at the end of the file, add this:
1 2 3 4 5 6 7 8 9 10
The first ending bracket is for the updateData function at the beginning. You can also leave out the console logs if you choose. The final step is to add the slider code to the cites.html file:
1 2 3 4 5
The min and max should be adjusted to match your own thresholds, and the starting value should also be altered for your desired starting point.
I’m @joncgoodwin on twitter and gmail if you have any questions or suggestions.