Edsen's avatar
Level 1

How to create a dynamic labels in month in chart js

labels:cData.label,

This cData.label var had the data of 1-12, how do I convert into Jan, Feb and etc. Anyone have any ideas

0 likes
3 replies
Edsen's avatar
Level 1

@gitwithravish How should I put under this ?

$(function(){ //get the pie chart canvas var cData = JSON.parse(``); var ctx = $("#line-chart"); //pie chart data var data = { labels:cData.label, datasets: [ { label: "Number of order per months", data: cData.data, borderColor: '#0a0ef2', backgroundColor: '#0a0ef2', borderWidth: [1, 1, 1, 1, 1,1,1] } ], scales: { yAxes:[{ ticks:{ beginZero:true } }] }, }; //options (here?) var options = { responsive: true, title: { display: true, position: "top", text: "Order Report", fontSize: 18, fontColor: "#111" }, legend: { display: true, position: "bottom", labels: { fontColor: "#333", fontSize: 16 } } }; var chart = new Chart(ctx, { type: "line", data: data, options: options }); });

Please or to participate in this conversation.