Currently, I have a network visualization project created with d3 and angular. You can view the visualization by following this link. I'm interested in saving the last state of the network so that even after refreshing the page, it will display the same setup. However, I am unsure of how to achieve this.
I've read about using either `sessionStorage` or `localStorage` for this purpose, but I'm struggling to implement it in my visualization project.
My attempt involved storing JSON data in sessionStorage like so:
if (sessionStorage) {
sessionStorage.setItem("myKey", myJSON.toString());
}
if (sessionStorage) {
sessionStorage.getItem("myKey"); // {"myKey": "some value"}
}
I also tried a similar approach using localStorage:
localStorage.setItem("networkGraph", networkGraph);
var networkGraph = localStorage.getItem("networkGraph");
Unfortunately, these methods did not work as intended. Can anyone confirm if this is the correct way to accomplish my goal?
Your assistance on this matter would be greatly appreciated!