2016-05-31 117 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

相關問題