我想開發一個多軸組合圖,使用highcharts api與x軸和y軸的月份,2軸有百分比和1有數字。這與您在link中看到的內容類似。當你有12個月的Y軸數據時,這個工作正常。在某些情況下,y軸數據會丟失幾個月。在這種情況下,我仍然想在沒有數據的x軸上顯示月份。目前,如果我只有2個月的y軸數據(例如6月和12月),它將顯示爲1月和2月的數據。請找到我正在使用的代碼,並讓我知道可以解決這個問題。Highcharts時間系列組合圖,其中幾個月的數據是空的
var chartMonthlyData = {
title: {
text: ''
},
xAxis: [{
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
crosshair: true
}],
yAxis: [{
min: 0,
max: 50,
labels: {
format: '{value} %'
},
title: {
enabled: false
},
opposite: true
}, {
title: {
text: '',
},
labels: {
formatter: function() {
return this.value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
}
}, {
min: 0,
max: 50,
title: {
enabled : false
},
labels: {
enabled: false
},
opposite: true
}],
tooltip: {
shared: true
},
legend: {
layout: 'horizontal',
align: 'right',
x: -30,
verticalAlign: 'top',
y: -5,
floating: true,
backgroundColor: '#FFFFFF'
},
series: [{
color: '#C8102E',
name: 'Delivered',
type: 'column',
yAxis: 1,
data: deliveredMonthly,
tooltip: {
pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>'
+ '{point.y}' +'</b><br/>'
}
}, {
color: '#AAAAAA',
name: 'Open Rate',
type: 'line',
yAxis: 2,
data: openRateMonthly,
lineWidth: 4,
marker: {
enabled: true,
"symbol": "circle"
},
tooltip: {
valueSuffix: ' %'
}
}, {
color: '#5891c8',
name: 'Clickthrough Rate',
type: 'line',
data: clickThroughRateMonthly,
lineWidth: 4,
marker: {
enabled: true,
"symbol": "circle"
},
tooltip: {
valueSuffix: ' %'
}
}]
}
在此圖像中,在x軸的實際月份是一月,六月和八月。我需要在圖表中顯示12個月,y軸數據與月份相適應。
你可以把這個在的jsfiddle? –
你能告訴我們每個系列的數據是什麼嗎?你有x和y數據嗎? –