如何从最左点开始获取Highcharts X-Axis类别 [英] How to get Highcharts X-Axis Categories starting at the left most point

查看:182
本文介绍了如何从最左点开始获取Highcharts X-Axis类别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张Highcharts区域图表,X轴上有字符串类别。
我希望图表从x轴的最左边开始,结束于最右边,没有任何填充。在下面的图片中,红色箭头显示了我想摆脱的间距。没有文本类别这很容易实现,但我似乎无法弄清楚。
任何帮助表示感谢。

I have a Highcharts area chart, with string categories on the X-Axis. I want the chart to start at the left most edge of the x-axis and end at the rightmost edge, without any padding. In the image below, the red arrows show the spacing that I want to get rid of. Without text categories this is easily achievable, but with I just can't seem to figure it out. Any help appreciated, thanks.

推荐答案

您可以通过在轴上重新定义labels.formatter来获得所需的结果。 jsFiddle 就在这里。

You can achieve the desired result by redefining labels.formatter on axis. jsFiddle is here.

但是如果你想要保持简单并以传统方式传递 axis.categories (我认为这样更好一些),我建议你使用一个小小的hack并重新定义 Axis.init 函数。试试 jsFiddle

But if you want to keep it simple and pass axis.categories in traditional way (I think that this is a way more better), I suggest you to use a tiny hack and redefine an Axis.init function. Try it on jsFiddle.

UPD :我已经更新了我以前的小提琴。 查看。我认为你可以结合我所有的解决方案来获得更好的解决方案。

UPD: I've updated my previous fiddle a little. Check it out. I think that you can combine all my solution to get a nicer one.

这篇关于如何从最左点开始获取Highcharts X-Axis类别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆