简体   繁体   English

如何在 Highcharts 中居中 yAxis 标题

[英]How to center the yAxis title in Highcharts

Is there any way to center the yAxis title, when it's displayed on top of the yAxis in Highcharts?当 yAxis 标题显示在 Highcharts 中的 yAxis 顶部时,有什么方法可以使 yAxis 标题居中? This is a follow-up question ;这是一个后续问题 haven't found a solution yet.还没有找到解决办法。

This is how it looks like in the moment:这就是它此刻的样子:

在此处输入图片说明

yAxis: {
  title: {
    text: "Cumulative mean<br />annual mass balance<br />(mm w.e.)",
    align: "high",
    rotation: 0,
    x: 180,
    y: -30,
    useHTML: true,
    style: {
      align: "center",
      fontWeight: "bold"
    }
  },

I'd like to have these three centered.我想让这三个居中。 Tried it with useHTML and align.尝试使用 useHTML 并对齐。 But doesn't work...但不起作用...

Here is a fiddle .这是一个小提琴

Thanks for any hints.感谢您的任何提示。

You can do this in CSS.你可以在 CSS 中做到这一点。

To horizontally center the y-axis, add these styles, and remove the x value:要使 y 轴水平居中,请添加这些样式,并删除 x 值:

.highcharts-axis {
  position: relative;
  left: 50% !important;
  transform: translateX(-50%);
}

To center-align its text, use this style:要居中对齐其文本,请使用以下样式:

.highcharts-axis {
  text-align: center;
}

Updated Fiddle更新的小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM