$(function() {
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Precipitation'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
},
yAxis: [{
min: 0,
title: {
text: 'Preipitation volume (mm)'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
},{
min: 0,
title: {
text: 'Preipitation intensity (mm/hr)'
},
opposite: true
}],
legend: {
//align: 'bottom',
//x: -30,
//verticalAlign: 'bottom',
//y: 25,
//floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
headerFormat: '<b>{point.x}</b><br/>',
pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
style: {
textShadow: '0 0 3px black'
}
}
}
},
series: [{
name: 'rain',
data: [5, 3, 4, 7, 2],
color: '#b3b3ff'
}, {
name: 'sleet',
data: [2, 2, 3, 2, 1],
color: '#d9b3ff'
}, {
name: 'snow',
data: [3, 4, 4, 2, 5],
color: '#c2c2f0'
},{
name: 'rain intensity',
data: [5, 3, 4, 7, 2],
color: 'blue',
type: 'line',
yAxis: 1
}, {
name: 'sleet intensity',
data: [2, 2, 3, 2, 1],
color: 'purple',
type: 'line',
yAxis: 1
}, {
name: 'snow intensity',
data: [3, 4, 4, 2, 5],
color: 'indigo',
type: 'line',
yAxis: 1
}]
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
戴夫,你找誰繪製兩個沉澱量和降水強度在同一張圖? –
是@MikeZavarello這是我的目標 –
戴夫,你怎麼看待使用兩個yAxs並添加一個系列到一個軸?看看這個例子:http://jsfiddle.net/csts55kf/1/ –