I am a beginner with the D3 API and I need to create a tree-like structure using a JSON file with hardcoded values. Additionally, I have a servlet that retrieves some values from a database which I want to dynamically convert into JSON in the servlet and send back the response to D3. Below are snippets of my HTML where I've written the D3 code. I'm able to generate JSON using a Java class but facing issues calling it from D3.js. Also included are excerpts from my Java file containing the created JSON and the HTML file...
public class Test {
// Java code for creating hierarchical data
...
}
This is our JSON:
{
"children": {
"Toyota": {
...
},
"Honda": {
...
}
}
}
Below is my HTML file:
<meta charset="utf-8">
...
<script type="text/javascript" src="d3/d3.v3.min.js"></script>
<script>
// D3 script for displaying the tree structure
...
</script>
I need assistance in dynamically generating the JSON and sending the response back to the D3 API. Any help would be appreciated.