【发布时间】:2013-12-19 13:37:50
【问题描述】:
我想让我的 xAxis 不在图表下方,而是在中间(在 yAxis 零值上)。
我也想要 xAxis 标签:
- 在 xAxis 之上,当它是 negavite 值时
- 低于 xAxis,当它是一个正值
这是我所拥有的:jsFiddle
$(function () {
$('#container').highcharts({
xAxis: {
showFirstLabel : true,
showLastLabel : true,
type : "category",
tickLength : 0,
lineWidth : 2
},
series: [{
data: [
{name : 'T1', y: 123},{name : 'T2', y: 152},{name : 'T3', y: -120},{name : 'T4', y: 0},{name : 'T5', y: 142},{name : 'T6', y: 212}
],
type : 'column'
}]
});
});
- 是否有一种简单的方法可以做到这一点?
- 如果没有,该怎么做?
谢谢。
解决办法:
感谢 Pawel Fus(谢谢,谢谢,谢谢),这是我的问题的解决方案:jsFiddle。
$(function () {
$('#container').highcharts({
chart: {
renderTo: 'container',
type: 'column',
events: {
load: function () {
var xAxis = this.xAxis[0];
var serie = this.series[0];
for (var current_tick in xAxis.ticks) {
var tick = xAxis.ticks[current_tick];
if(serie.data[current_tick]){
if (serie.data[current_tick].y > 0) {
tick.label.attr({
y: tick.label.y + 18
});
}
}
}
}
}
},
xAxis: {
showFirstLabel : true,
showLastLabel : true,
type : "category",
tickLength : 0,
crossing:0,
opposite:true,
lineWidth : 2
},
series: [{
data: [
{name : 'T1', y: 123},{name : 'T2', y: 152},{name : 'T3', y: -120},{name : 'T4', y: 0},{name : 'T5', y: 142},{name : 'T6', y: 212}
],
type : 'column'
}]
});
});
【问题讨论】:
标签: javascript jquery highcharts