Heim > Fragen und Antworten > Hauptteil
<script src="assets/highcharts/highcharts.js"></script>
<script src="assets/highcharts/modules/exporting.js"></script>
<p class="row">
<p id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></p>
</p>
<script>
$(document).ready(function () {
var options = {
chart: {
renderTo: 'container',
type: 'line'
},
title: {
text: '内存占用信息图',
x: -20 //center
},
xAxis: {
title: {
text: '时间'
}
},
yAxis: {
title: {
text: '单位:kb'
}
},
legend: {
enabled: false
},
series: []
};
$.getJSON("<?php echo $jsonUrl; ?>", function (json) {
//console.log(json['data']);
//options.xAxis.categories = json[0]['data']; //xAxis: {categories: []}
var temp = json['data'];
var data = [];
for (i = 0; i < temp.length; i++) {
date = temp[i].start_time;
value = parseFloat(temp[i].memusg);
data.push([
date,
value]);
}
//console.log(data);
options.series[0] = data;
chart = new Highcharts.Chart(options);
});
});
</script>
下面是data的值