Skip to content

Instantly share code, notes, and snippets.

@pzzrudlf
Last active November 3, 2015 08:31
Show Gist options
  • Save pzzrudlf/b850db75a8980697031c to your computer and use it in GitHub Desktop.
Save pzzrudlf/b850db75a8980697031c to your computer and use it in GitHub Desktop.
/**
* ajax请求json格式数据给highchart绘图
* @url http://kunyali.blog.51cto.com/4890065/1292803
*/
$.ajax({
type: "POST",
url: "seriesjson.action?region="+encodeURI(region_name),
dataType:"json",
success: function(data){
alert(data);
data=$.parseJSON(data);
alert(data[0].one);
var one = data[0].one;
var two = data[0].two;
var three =data[0].three;
var four =data[0].four;
var five =data[0].five;
var mon =data[0].mon;
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'spline'
},
title: {
text: '各等级客户数'
},
xAxis:[{
categories: mon
}],
yAxis: {
title: {
text: '客户数 (户)'
},
min: 0
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b>'+': '+ this.y +' 户';
}
},
series: [{
name: '一星用户',
// Define the data points. All series have a dummy year
// of 1970/71 in order to be compared on the same x axis. Note
// that in JavaScript, months start at 0 for January, 1 for February etc.
data: one
}, {
name: '二星用户',
data: two
}, {
name: '三星用户',
data: three
}, {
name: '四星用户',
data: four
}, {
name: '五星用户',
data: five
}]
});
});
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment