我相信這是一個錯誤,但這種情況下的一個簡單的解決方法是設置一個左邊距。 一個例子來看看這個小提琴:http://jsfiddle.net/zc1Lc5c6/6/
小提琴代碼:
$(function() {
$('#container').highcharts({
title: "",
chart: {
spacing: [5, 5, 5, 5],
marginLeft: 32
},
legend: {
layout: "horizontal",
align: "right",
verticalAlign: "top",
itemDistance: 10,
symbolHeight: 8,
symbolPadding: 1,
padding: 0,
margin: 20,
itemMarginBottom: 3
},
plotOptions: {
series: {
dataLabels: {
enabled: false
},
marker: {
symbol: "circle",
radius: 4,
states: {
hover: {
radiusPlus: 1
}
}
},
showInLegend: true
},
line: {
states: {
hover: {
halo: {
size: 8
}
}
}
}
},
series: [{
type: "column",
name: "First column",
data: [5, 2, 13, 3, 3, 6, 2, 3, 2, 1, 5, 2, 1]
}, {
type: "line",
name: "First line",
data: [3, 1, 7, 1, 1, 5, 1, 2, 1, 1, 3, 1, 0],
yAxis: 1,
showInLegend: false
}, {
type: "column",
name: "Second column",
data: [7, 1, 2, 6, 2, 6, 4, 2, 3, 3, 6, 2, 3]
}, {
type: "line",
name: "Second line",
data: [3, 0, 2, 3, 1, 3, 2, 2, 3, 1, 3, 2, 2],
yAxis: 1,
showInLegend: false
}],
yAxis: [{
visible: true,
tickPosition: "inside",
offset: 0,
title: {
text: "# tasks",
align: "high",
textAlign: "left",
rotation: 0,
offset: 0,
margin: 0,
y: -5,
x: -7
},
labels: {
align: "right",
y: -5
}
}, {
visible: true,
tickPosition: "inside",
offset: 0,
type: "linear",
title: {
text: "# completed",
align: "high",
textAlign: "left",
rotation: 0,
offset: 0,
margin: 0,
y: 12,
x: -7
},
labels: {
align: "right",
y: 12
}
}],
xAxis: {
labels: {
y: 16
},
categories: [
"2016 W31",
"2016 W32",
"2016 W33",
"2016 W34",
"2016 W35",
"2016 W36",
"2016 W37",
"2016 W38",
"2016 W39",
"2016 W40",
"2016 W41",
"2016 W42",
"2016 W43"
]
}
});
});
使用自定義標籤或字幕來代替。如果rotation = 0,它不會創建額外的空間,並且它可以更容易定位。 http://jsfiddle.net/zc1Lc5c6/4/ – morganfree
感謝您的提示,但我通過在我的圖表上設置了marginLeft來解決了問題。看到這個小提琴:http://jsfiddle.net/zc1Lc5c6/6/ – Nejc