I have a formatted json data that I want to use in d3 to draw a hierarchy. It was working with old data but after adding more dimension in the json data, its giving following error.
Argument of type '{ name: string; children: { group: number; name: string; }[]; group: number; }[]' is not assignable to parameter of type 'readonly string[]'. Type '{ name: string; children: { group: number; name: string; }[]; group: number; }' is not assignable to type 'string'.
The output of my reformatted data is following which is generated by using the code from @Dacre Denny's answer from Change Json data into new format by JavaScript link
{
name: "program",
children: (1)[
{
name: "file1",
children: (1)[
{
name: "function1",
calls: (2)[
{
line: 105,
file: "file2",
function: "function5"
},
{
line: 106,
file: "file2",
function: "function6"
}
],
point: (2)[
102,
105
],
point2: (3)[
(2)[
102,
102
],
(3)[
105,
106,
107
],
(2)[
106,
107
]
],
group: 1
}
],
group: 1
}
],
group: 0
}
My existing code snippet for d3 is following:
const data = TestFunction.test(); //from here i am calling the reformatted output
const root = d3.hierarchy(data);
const colorScale = d3.scaleOrdinal()
.domain(data.children) // here its showing the error.
.range(d3.schemeCategory10);
I would really appreciate your help.