Here I want to fetch data from a REST API URL which will be fed into the pie chart rather than manually entering data as given in the piechart below.
The API URL will have a JSON response.
ex:
[{"Development stage:1,"no.of.project:60},{"Development stage:2,"no.of.project:50}]
I want to display the data on the basis of JSON .
<Chart
width={'450px'}
height={'310px'}
chartType="PieChart"
loader={<div>Loading Chart</div>}
data={[
['Development Stages', 'Number of Project'],
['Stage 1', 60 ],
['Stage 2',40],
['Stage 3',20 ],
['Stage 4',10],
['Stage 5', 30],
]}
options={{
title: 'Projects',
}}
rootProps={{ 'data-testid': '1' }}
/>
How can I use async axios for the same???? and pass it into Chart.
const [stage,setStage]=useState([]);
const getStageData = async() => {
try{
const data=await axios.get(APIurl
);
setStage(data.data)
}
catch(e){
}
};
useEffect(()=> {
getStageData();
},[]);

