/*
* highChart 초기화
*
* type : column(바차트) / spline(꺽은선차트)
* title : 차트 제목
* stacking : 차트 형태 (normal , percent, 빈값)
* data : json 데이터
*/
var yearArr = new Array();
for(var year = calcBeginYear; year <= calcEndYear; year++) {
yearArr.push(year);
}
var arr1 = new Array();
for(var i = 0; i < 5; i++) {
var arr2 = new Array();
for(var j = 0; j < yearArr.length; j++) {
arr2.push(getRandomInt(-10, 50));
}
arr1.push(arr2);
}
Highcharts.chart('container', {
chart: {
type: type
},
title: {
text: title
},
xAxis: {
categories: yearArr,
tickWidth: 10
},
yAxis: {
min: -50,
title: {
text: ''
},
stackLabels: {
enabled: false,
style: {
fontWeight: 'bold',
color: ( // theme
Highcharts.defaultOptions.title.style &&
Highcharts.defaultOptions.title.style.color
) || 'gray'
}
}
},
legend: {
align: 'right',
x: -30,
verticalAlign: 'top',
y: 25,
floating: true,
backgroundColor:
Highcharts.defaultOptions.legend.backgroundColor || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
headerFormat: '{point.x}
',
pointFormat: '{series.name}: {point.y}
Total: {point.stackTotal}'
},
plotOptions: {
column: {
stacking: stacking, //Whether to stack the values of each series on top of each other. "normal" to stack by value or "percent"
dataLabels: {
enabled: false
}
},
series: {
pointWidth: 40
}
},
exporting: { //context menu hide
enabled: false
},
series: [{
name: '에너지',
data: arr1[0]
}, {
name: '산업공정',
data: arr1[1]
}, {
name: '농업',
data: arr1[2]
}, {
name: 'LULUCF',
data: arr1[3]
}, {
name: '폐기물',
data: arr1[4]
}
]
});