修正了Highcharts中的y轴标签宽度 [英] Fixed y-axis label width in Highcharts

查看:697
本文介绍了修正了Highcharts中的y轴标签宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个数据演示,其中两个Highcharts图表垂直堆叠,旨在共享相同的x轴单位和对齐。像这样:



p>

请注意,由于两个图表的y轴范围不同,因此y轴标签的宽度不同,因此图表本身的宽度略有不同,轴对齐。

能够固定图表的宽度(或相反的y轴标签)以确保两个图表的排列是非常好的。我探索了API,并直接在各种生成的元素上设置样式,但没有运气。使用自定义标签格式化程序来实现这个目标似乎是可能的,但是库存格式化程序(如果我没有定义任何自定义的话)对于缩小大数字等很有效。



关于如何修复图表或y轴标签宽度的想法?

如果您设置 chart.marginLeft 选项,它将覆盖自动尺寸标签,使Y轴对齐。


I'm building a data presentation where two Highcharts charts are stacked vertically and are intended to share the same x-axis units and alignment. Like so:

Notice that since the y-axis ranges are different for the two charts, the y-axis labels are different widths and thus the charts themselves are slightly different widths breaking the nice x-axis alignment.

It would be great to be able to fix the width of the chart (or conversely the y-axis labels) to ensure the two charts line up. I explored the api and played a bit with setting styling directly on the various generated elements but no luck. It seems possible to maybe achieve this goal using a custom label formatter, but the stock formatter (as in if I define nothing custom) works quite well for abbreviating large numbers and such.

Ideas as to how to fix the chart or y-axis label width?

解决方案

If you set the chart.marginLeft option, it will override the auto size labels so the Y axes become aligned.

这篇关于修正了Highcharts中的y轴标签宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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