Bar Chart - Reduce Length Of The Display Name
The script below can be used to reduce the length of the labels in the bar chart to a specified length and add an ellipsis (if it reduced the length).
The script will reduce the length of the displayed names if it greater than specified varlength whether there is space in the chart or not. However, note that you will see the actual full description when you hover over the bar itself.
widget.on('beforeviewloaded', function (widget, ev) {
var newMaxCharactersPerLabel = 18;
ev.options.xAxis.labels.maxCharactersPerLabel = newMaxCharactersPerLabel;
ev.options.xAxis.labels.useHTML = true;
ev.options.xAxis.labels.formatter = function () {
// Change this to change the length of the substring
var lengthVar = 15;
var text = this.value;
var newText = '';
if (text.length <= lengthVar) {
newText = text;
}
else {
newText = text.substring(0,lengthVar) + '...';
}
return newText;
}
});


Updated 03-02-2023
intapiuser
Admin
Joined December 15, 2022