我想在负数据的情况下在第0个y轴刻度标签旁边绘制x轴。参考图片:To plot Xaxis next to 0th tick label 有没有办法在Highcharts中实现这个目标?
答案 0 :(得分:0)
请参阅此实时工作演示:http://jsfiddle.net/kkulig/gxxtfn67/
我稍微修改了 xAxis过零插件(https://github.com/ppoliani/xAxis-zero-crossing)的代码。我启用了y轴的渲染并删除了负责定位x轴标签的线。最终代码如下所示:
(function (H) {
H.wrap(H.Axis.prototype, 'render', function (proceed) {
var chart = this.chart,
xAxis, yAxis, extremes, crossing;
if (typeof this.options.zeroCrossing === 'boolean') {
xAxis = chart['xAxis'][0];
yAxis = chart['yAxis'][0];
extremes = yAxis.getExtremes();
crossing = Math.abs(extremes.min) + Math.abs(extremes.max);
this.offset = yAxis.toPixels(crossing, true);
chart.axisOffset[this.side] = 10;
}
proceed.call(this);
});
}(Highcharts));
<强>更新强>
bar 系列的实时工作演示(倒置图表):http://jsfiddle.net/kkulig/gyp8n9ou/