52,797
社区成员
发帖
与我相关
我的任务
分享
<script type="text/javascript">
$(function () {
$('#container').highcharts({
title: {
text: '档案数量走势',
x: -20 //center
},
subtitle: {
x: -20
},
xAxis: {
categories: []
},
yAxis: {
title: {
text: '单位 (条)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: '条'
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
series: [ {
name: '档案数量',
data:########//这边我需要调用后台写好的JSON数据,这边应该怎么写
}]
});
});
// Apply the theme
var highchartsOptions = Highcharts.setOptions(Highcharts.theme);
//汉化图表菜单
Highcharts.setOptions({
lang: {
contextButtonTitle: "图表菜单",
printChart: "打印图片",
downloadJPEG: "下载JPEG 图片",
downloadPDF: "下载PDF文档",
downloadPNG: "下载PNG 图片",
downloadSVG: "下载SVG 矢量图",
exportButtonTitle: "导出图片"
}
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="container" style="min-width:400px;height:400px"></div>
</form>
</body>
//设定报表对象的初始数据
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
function getForm(){
//使用JQuery从后台获取JSON格式的数据
jQuery.getJSON('http://localhost:8080/JQuery/ajax', null, function(data) {
//为图表设置值
$('#container').series[0].setData(data);
});
}
$(document).ready(function() {
//每隔3秒自动调用方法,实现图表的实时更新
window.setInterval(getForm,3000);
});