简体   繁体   中英

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? 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. But doesn't work...

Here is a fiddle .

Thanks for any hints.

You can do this in CSS.

To horizontally center the y-axis, add these styles, and remove the x value:

.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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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