I have a problem showing the horizontal labels in the chartjs, try changing the size of the letter and obviously reducing it, but what I really want is that apart from the size being reduced, the label also fits in two rows of be necessary. And not just one as it is by default (and as seen in the image).
As you can see in the image, there should be 9 labels, but it is only showing the title of three, and I managed to rotate it, because I like it more horizontal, but I still need to reduce the letter and / or arrange it so that it fits in two or three lines
The option that accesses the horizontal axes is
xAxes: [{
ticks: {
fontSize: 10,
maxRotation: 0 // angle in degrees
}
}],
This is the complete code:
<script>
var data = {
labels: ["Cuidado Del Cabello", "Listerine - Aceite", "Cremas Corporales - Estuches", "Resto", "Jabon Adulto - Crema Liq. Baby", "Jabon Baby", "Carefree - Bano Liquido", "OB - Toallitas", "Stayfree - Desitin"],
datasets: [
{"label" : "Cuota marzo","backgroundColor" :"#5DA5DA","data" : [195872263, 221779339, 161250805, 141306654, 175639549, 147123174, 251369895, 54415438, 199509073, ]},{"label" : "Venta marzo","backgroundColor" :"#FAA43A","data" : [12588888, 300000000, 1919191, 0, 91919113, 0, 9411191, 54000000, 0, ]}
]
}
var ctx = $("#grafico1").get(0).getContext("2d");
var myChart = new Chart(ctx, {
type: 'bar',
options: {
scales: {
xAxes: [{
ticks: {
fontSize: 10,
maxRotation: 0 // angle in degrees
}
}],
yAxes: [{
ticks: {
// Include a dollar sign in the ticks
callback: function(value, index, values) {
var formmatedvalue=formatMoneda(value);
return formmatedvalue;
}
}
}]
},
responsive: true,
maintainAspectRatio: false,
animation: {
animateScale: true
},
tooltips: {
// enabled: false,
intersect: 'false',
mode: 'index',
callbacks: {
label: function(tooltipItem, data) {
var allData = data.datasets[tooltipItem.datasetIndex].data;
var tooltipLabel = data.labels[tooltipItem.index];
var tooltipData = allData[tooltipItem.index];
var formmatedvalue=formatMoneda(tooltipData);
return formmatedvalue;
}
}
}
},
data: data,
});
</script>
Thanks