I have a bar chart with very long labels that is shrinking the canvas. I am trying to truncate the label if it has more than 10 characters. I tried a solution I found on another post here:
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
xAxes: [{
ticks: {
callback: function (value: string) {
return value.substr(0, 10);//truncate
},
}
}],
yAxes: [{}]
},
tooltips: {
enabled: true,
mode: 'label',
},
}
This doesn't seem to work and cannot figure out why.
here you just remove string in the function it's work for me
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
xAxes: [{
ticks: {
callback: function (value) {
return value.substr(0, 10);//truncate
},
}
}],
yAxes: [{}]
},
tooltips: {
enabled: true,
mode: 'label',
},
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.