javascript

chart js

i want to change label in static to dynamic

var doctorwisebar  = document.getElementById("doctorwise_collection");

                     window.DoctorBar =  new Chart(doctorwisebar, {
                        type: "bar",
                        defaultFontFamily: 'sans-serif',
                        data: {
                          labels: result[0],

                          datasets: [{
                            label: 'Label 2',
                            data: result[2],
                            backgroundColor: ['#181A19'],
                            "maxBarThickness": 30,
                          },

                          {

                          label: 'Label 1',
                          data: [result[3]],
                            backgroundColor: ['#FBD404'],
                            "maxBarThickness": 30,

                          },],

                        },
                        options: {
//                         indexAxis: 'y',
                         responsive: true,

                        scales: {
                              x: {
                                stacked: true,

                                ticks: {
                                    font: {
                                        size: 11,
                                    }
                                }
                              },
                              y: {
                                stacked: true,


                              }
                            },

                        }
                      });
Output
d

i want to change label in static to dynamic

Was this helpful?