如何在 Highcharts.js 中对齐 xAxes 上的类别标签
How to align category labels on xAxes in Highcharts.js
我是 Highcharts.js 的新手,我想做的是在 x 轴上显示类别标签的柱形图。
我可以将我的 highcharts 对象设置为将类别显示为标签,但我仍然无法将这些标签右对齐,而不是让它们在两个刻度线之间居中。如果我在 xAxes 上看到的标签是我的类别,则应用于 xAxis 标签的 属性 'align' 不起作用。有没有办法做到这一点?
这是我的图表:
$(function () {
$('#histogram').highcharts({
chart: {
type: 'column'
},
series: [{
data: [5,14,17,9,0,1,1,1,0,1,0,0,0]
}],
xAxis: {
categories: [0.7,0.85,1,1.2,1.3,1.5,1.6,1.8,1.9,2.1,2.2,2.4],
labels: {
align:'right',
rotation:'-45'
}
}
});
});
检查以下选项 tickmarkPlacement :
http://api.highcharts.com/highcharts#xAxis.tickmarkPlacement
tickmarkPlacement: String For categorized axes only. If on the tick
mark is placed in the center of the category, if between the tick mark
is placed between categories. The default is between if the
tickInterval is 1, else on. Defaults to null.
检查代码 jsfiddle :
xAxis: {
categories: [0.7,0.85,1,1.2,1.3,1.5,1.6,1.8,1.9,2.1,2.2,2.4],
labels: {
align:'right',
rotation:'-45'
},
tickmarkPlacement:'on',
}
我是 Highcharts.js 的新手,我想做的是在 x 轴上显示类别标签的柱形图。 我可以将我的 highcharts 对象设置为将类别显示为标签,但我仍然无法将这些标签右对齐,而不是让它们在两个刻度线之间居中。如果我在 xAxes 上看到的标签是我的类别,则应用于 xAxis 标签的 属性 'align' 不起作用。有没有办法做到这一点? 这是我的图表:
$(function () {
$('#histogram').highcharts({
chart: {
type: 'column'
},
series: [{
data: [5,14,17,9,0,1,1,1,0,1,0,0,0]
}],
xAxis: {
categories: [0.7,0.85,1,1.2,1.3,1.5,1.6,1.8,1.9,2.1,2.2,2.4],
labels: {
align:'right',
rotation:'-45'
}
}
});
});
检查以下选项 tickmarkPlacement : http://api.highcharts.com/highcharts#xAxis.tickmarkPlacement
tickmarkPlacement: String For categorized axes only. If on the tick mark is placed in the center of the category, if between the tick mark is placed between categories. The default is between if the tickInterval is 1, else on. Defaults to null.
检查代码 jsfiddle :
xAxis: {
categories: [0.7,0.85,1,1.2,1.3,1.5,1.6,1.8,1.9,2.1,2.2,2.4],
labels: {
align:'right',
rotation:'-45'
},
tickmarkPlacement:'on',
}