0👍
Value for data
property when dealing with datasets should have the following shape
PropTypes.shape({
datasets: PropTypes.arrayOf(PropTypes.shape({
data: PropTypes.array
}))
})
{
datasets: [
{
_id: '238940890234809234',
data: [10, 20, 10, 20, 10, 20, 10]
},
{
_id: '098340598345839455',
data: [50, 100, 50, 100, 50, 100, 50]
}
]
}
You have to plot a different bar graph for each question.
render() {
return (
<div>
{this.state.chartData.map(data => <Bar key={data._id} data={data} /> }
</div>
);
}
The _id has been included to be used for the component key property.
chartData.push({
_id: element._id,
labels: element.answer_set,
datasets:[{
data: element.count_set
}]
});
- Chartjs-ChartJS labels along the edges
- Chartjs-How to differentiate the data of one topic or another coming from Mercure hub if the client is suscribed to two topics
Source:stackexchange.com