0👍
Take your data as Objects. Consider Keys are Labels and Values in objects are Points. then draw the graph. using this code.
data = {"countAgree":1,"countSomewhatAgree":0,"countDisagree":1,
"countAgree":0,"countSomewhatAgree":1,"countDisagree":1,
"countAgree":0,"countSomewhatAgree":1,"countDisagree":1};
const CHART = document.getElementById('lineChart');
var lineChart = new Chart(CHART, {
type: 'line',
data: {
labels: Object.keys(data),
datasets: [{
label: 'My first dataset',
fill: false,
lineTension: 0,
backgroundColor: "rgba(75,192,192,0.4)",
borderColor: "rgba(75,192,192,1)",
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0,
borderJointStyle: 'miter',
data: Object.values(data)
}]
}
})
- Chartjs-Chart.js pie chart in table shows weird behavior on page resize
- Chartjs-ChartJS timeline graph with events
Source:stackexchange.com