PHP Highcharts 그래프에 1일~31일 for문으로 넣을려면?
조회수 2430회
이런 모습인데요.
Highcharts.chart('container', {
chart: {
type: 'column'
},
title: {
text: picker+' 매체별 통계 그래프'
},
xAxis: {
categories: ['1일','2일','3일','4일','5일','6일','7일','8일','9일','10일','11일','12일','13일','14일','15일','16일','17일','18일','19일','20일','21일','22일','23일','24일','25일','26일','27일','28일','29일','30일','31일'] **<== 이부분 for문으로 넣으려면 어떻게 해야하나요?**
},
yAxis: {
min: 0,
title: {
text: ''
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
},
legend: {
align: 'right',
x: -30,
verticalAlign: 'top',
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'
}
}
},
series: [{
name: 'test',
data: [parseInt($("#a0").text()), parseInt($("#a1").text()), parseInt($("#a2").text()), parseInt($("#a3").text()), parseInt($("#a4").text()), parseInt($("#a5").text()), parseInt($("#a6").text())]
}, {
name: 'test1',
data: [2, 2, 3, 2, 1]
}, {
name: 'test2',
data: [3, 4, 4, 2, 5]
}, {
name: 'test3',
data: [3, 4, 4, 2, 5]
}, {
name: 'test4',
data: [3, 4, 4, 2, 5]
}, {
name: 'test5',
data: [3, 4, 4, 2, 5]
}, {
name: 'test6',
data: [3, 4, 4, 2, 5]
}, {
type: 'spline',
name: 'test7',
data: [4, 32, 12, 35, 66]
}, {
type: 'test8',
name: '합계',
data: [3, 4, 4, 2, 5]
}]
});
});
위에 categories: ['1일','2일','3일','4일','5일','6일','7일','8일','9일','10일','11일','12일','13일','14일','15일','16일','17일','18일','19일','20일','21일','22일','23일','24일','25일','26일','27일','28일','29일','30일','31일'] 부분에 1~31일가지 for문으로 넣고싶은데 아무리 넣어봐도 안되네요. ㅠ 어떻게하는건지 알려주세요!
-
(•́ ✖ •̀)
알 수 없는 사용자
1 답변
-
데이터를 추가하는 루프문을 외부에서 정의한후에 호출하는 방식으로 해보시면 될 것 같습니다.
var getDay = function() { var data = []; for (var i = 0; i< 31; i++) { data.push(i+'일'); } return data; } Highcharts.chart('container', { chart: { type: 'column' }, title: { text: picker+' 매체별 통계 그래프' }, categories: getDay() }, yAxis: { min: 0, title: { text: '' }, stackLabels: { enabled: true, style: { fontWeight: 'bold', color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray' } } },
-
(•́ ✖ •̀)
알 수 없는 사용자
-
댓글 입력