Hey i am trying to implement json API data value in stacked bar chart but i don't know how to do it here is json api http://www.mocky.io/v2/5e96ff763000006500b6da20 and its look like
{"topology": [
{
"label": "living_street",
"value": 0.010549953326361517
},
{
"label": "tertiary",
"value": 0.767246375468044
},
{
"label": "primary",
"value": 0.21522791175081937
},
{
"label": "service",
"value": 0.006975759454774865
}
]
}
here is what i did so far in my code .
`fetchData() {
fetch(`http://www.mocky.io/v2/5e96ff763000006500b6da20`)
.then(response => response.json())
.then(dat => {
const dat1 = dat.map(c => {
return c.label;
});
const dat2 = dat.map(c => {
return c.value;
});
const newXaxis = dat1;
const newSeries = [];
newSeries.push({
data: dat2,
name: this.state.series.labels
});
this.setState({
series: newSeries,
options: {
...this.state.options,
labels: newXaxis,
xaxis: { ...this.state.options.xaxis, categories: newXaxis }
}
});
});
}
componentDidMount() {
this.fetchData();
}`
...
return (
<Chart
options={this.state.options}
series={newSeries}
type="bar"
height="150px"
/>
}
but it did not show in stacked chart is shows like this
And i want that result will look like this.