In the response of a POST request, I have got the following JSON data,
{"chart":
{
"data":[
{
"x": [0, 1, 2, 3, 4, 5, 6, 7, 8],
"y": [0, 3, 6, 4, 5, 2, 3, 5, 4],
"type": "scatter",
"name":"Plot 1"
},
{
"x": [0, 1, 2, 3, 4, 5, 6, 7, 8],
"y": [0, 4, 7, 8, 3, 6, 3, 3, 4],
"type": "scatter",
"name":"Plot 2"
},
{
"x": [0, 1, 2, 3, 4, 5, 6, 7, 8],
"y": [0, 5, 3, 10, 5.33, 2.24, 4.4, 5.1, 7.2],
"type": "scatter",
"name":"Plot 3"
}
],
"layout":{
"showlegend": true,
"legend": {"orientation": "h"}
}
}
}
now that, I have got the response yet cannot plot the graph as expected. following is the js code I have written so far,
const dataForPost = {
dataset_id: 1,
features: [],
analysis_level: 1
};
export default function DomainAssesment(){
const [graphData, setGraphData] = useState('');
const postData = (event) => {
axios.post('http://localhost:5000/Plot', dataForPost)
.then((response) =>{
setGraphData(response.data.chart);
console.log(graphData);
});
}
return (
<Container>
<Button className="success" onClick={postData}>Get Graph</Button>
<Plot data={graphData.data} layout={graphData.layout} />
</Container>
);
}
And the outcome in the console log is something like this,

Any kind of advice or suggestion will be much appreciated.