2016-05-31 114 views
1

当yAxis标题显示在Highcharts的yAxis顶部时,是否有任何方法可以使yAxis标题居中?这是一个follow-up question;还没有找到解决方案。如何将yAxis标题置于Highcharts中

这是怎么看起来像在当下:

enter image description here

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" 
    } 
    }, 

我想有这三个中心。试用了useHTML并对齐。但不起作用...

Here is a fiddle

感谢您的任何提示。

+0

将x的值从180更改为100或者 –

+0

如果标题应该居中对齐,则可以使用[subtitle](http://api.highcharts.com/highstock#subtitle) –

回答

1

你可以在CSS中做到这一点。

水平居中y轴,添加这些样式,并删除x值:

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

为中心,调整其文本,使用这种风格:

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

Updated Fiddle

+1

只需要fo本文的完整性:Highcharts代码应该集成useHTML标签:'yAxis:{title:{useHTML:true}}' – luftikus143

相关问题