我需要为xAxis Label设置最大宽度,以便当它太长并且其余字母(字符)将会到达下一行。设置Highcharts x轴标签的宽度
我看了Highcharts x axis label text wrapping lost on setting label step,发现设置“width”对英文单词(用空格分隔)正常工作。
但是,如果没有空白空间,说“VeryLongLongLongWord”或“这是一个很长很长很长的中文”,那是行不通的。
我也试过设置wordWrap: break-word
,还是没有用。
$(function() {
$('#container').highcharts({
chart: {
type: 'column',
},
xAxis: {
categories: ['This is a long Text', 'VeryLongLongLongWord', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec','这是一个很长很长很长的中文'],
labels: {
style:{
width:'30px',// not work for text without empty space
wordWrap: 'break-word'//no use
},
step: 1
}
},
plotOptions: {
series: {
pointWidth: 30
}
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
});
Fidder酒店:http://jsfiddle.net/uehbmzgx/