그래프 작업 중이지만 표시되지 않습니다.하이 차트 그래프가 표시되지 않습니다.
내 코드에는 작동중인 코드와 작동하지 않는 코드 두 줄이 있습니다. (내가 그들을 댓글을 달았)
//this line does not work
//data3.push([new Date(d.timestamp).getTime(),data.data.risk);
//this line works
data3.push([new Date(d.timestamp).getTime(),data.data.threshold[0].amber_threshold]);
내 목표 : 나는이 작동하지 않는 줄을 실행하려는 .
데이터를 제대로 전달하지 못하고 있다고 생각합니다. 그래프를 만들려면 risk
배열을 전달하고 싶습니다.
코드를 복사하여 파일에 붙여 넣기 만하면됩니다.
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
</head>
<body style="background:#212224;">
<div id="container2" style="max-width: 1666px; margin: 0 auto"></div>
<script type="text/javascript">
$.getJSON('https://dl.dropboxusercontent.com/u/76618626/data2.json', function (data) {
console.log("data is : ");
console.log(data);
var minX = _.min(data.data.risk, function (d) {
return new Date(d.timestamp).getTime();
});
var maxX = _.max(data.data.risk, function (d) {
return new Date(d.timestamp).getTime();
});
var data3 = [];
$.each(data.data.risk, function (i, d) {
//this line does not work
//data3.push([new Date(d.timestamp).getTime(),data.data.risk);
//this line works
data3.push([new Date(d.timestamp).getTime(),data.data.threshold[0].amber_threshold]);
});
$('#container2').highcharts({
chart: {
backgroundColor: '#000000',
},
title: {
text: 'Test Graph',
style: {
color: '#FFFFFF',
fontWeight: 'bold'
}
},
xAxis: {
type: 'datetime',
title: {
text: 'Time Stamp'
},
gridLineColor: 'grey',
gridLineWidth: 1,
lineWidth:1
},
yAxis: {
title: {
text: 'Value'
},
gridLineColor: 'grey',
gridLineWidth: 1,
lineWidth:1
},
legend: {
enabled: true
},
exporting: false,
plotOptions: {
line: {
lineColor: 'red',
fillOpacity: 1,
lineWidth: 2,
states: {
hover: {
lineWidth: 2
}
},
threshold: null,
marker: {
fillColor: '#e57255'
}
},
},
series: [{
name: 'Graph',
data: data3
}]
});
});
</script>
</body>
</html>
는 콘솔에 어떤 오류가 발생 했습니까? – abarisone