Got this chart which I'm feeding with two constants. I have a third constant with url for each one of those values, and I would like to assign those url to each bar. There's a way to make that? I've come across and example for bars with links but it needs to use data structures and I haven't find a way to use my constants in the data structure.
const numPostPerCat= <?php echo json_encode($countCateT); ?>;
const catName= <?php echo json_encode($cateTforChart); ?>;
const data2= {
labels:catName,
datasets: [{
label: 'Terri',
backgroundColor: 'rgb(166,166,166)',
borderColor: 'rgb(166,166,166)',
data: numPostPerCat,
borderWidth: 2,
barThickness: 3,
datalabels: {
color:'gray',
anchor: 'end',
align: 'top',
},
}]
};
// Config Block
const config2={
type: 'bar',
data: data2,
plugins: [ChartDataLabels],
options: {
scales: {
x:{
grid:{
display: false,
},
},
y:{
ticks:{
display: false,
},
grid: {
display: false,
},
},
},
plugins:{
legend: {
display: false
},
title:{
display: true,
text: 'Territorios',
align: 'start',
},
},
responsive: true,
maintainAspectRatio: false,
}
};
// Render Block
const myChart2 = new Chart(
document.getElementById('myChart2'),
config2
);