I am trying to create an interactive graph using d3.js library. I want to alternate between feeding data into my d3 object from either a stored json file or directly from a dictionary (that gets created upon some user input).
To read from a file I use
d3.json('/path/to/file.json')
Upon user input a dictionary d is created. I tried using
user_file = json.dumps(d)
d3.json(user_file)
to no avail.
I have a workaround -- upon user input, create a user_file.json file with json.dump(d, '/path/to/user_file.json') and read directly from there with d3.json('/path/to/user_file.json'). Other than just feeling less elegant this adds the additional problem that the new json file gets cached.
Any advice? I'm new to javascript so advice on 'best practices' would also be appreciated.