score:2

Accepted answer

you can set the labels using .map() method on mydata array like:

data: {
   labels: mydata.map(d => d.region),
   ....
},

edit:

you can create a new function and add all chart init code into it like:

function createchart() {
   new chart(document.getelementbyid("chart"), {
      type: 'horizontalbar',
      data: {
         labels: mydata.map(d => d.region),
         ... you code here
      },
      ...
   });
}

createchart();

and then on gridview click, again call this createchart function in the end like:

$("#gridview").click(function() {
   // all your code logic here
   console.log(mydata);
   createchart();
});

Related Query

More Query from same tag