这是我的js代码。
function paint(){
var chart = new Highcharts.Chart({
chart:{
renderTo:'container',
type:'scatter',//显示类型 散点图
zoomType: 'xy'
},
title:{
text:'散点图' //图表的标题
},
xAxis:{
title: {
enabled: true,
text: 'sepal length'
},
startOnTick: true,
endOnTick: true,
showLastLabel: true
},
yAxis:{
title:{
text:'sepal width' //Y轴的名称
}
},
legend: {
layout: 'vertical',
align: 'left',
verticalAlign: 'top',
x: 100,
y: 70,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF',
borderWidth: 1
},
credits:{
enabled:false
},
plotOptions: {
scatter: {
marker: {
radius: 5,
states: {
hover: {
enabled: true,
lineColor: 'rgb(100,100,100)'
}
}
},
states: {
hover: {
marker: {
enabled: false
}
}
},
tooltip: {
headerFormat: '<b>{series.name}</b><br>',
pointFormat: '{point.x}, {point.y}'
}
}
},
series:[]
});
chart.series[0].setData[2.0,3.6];
$.ajax({
type:'post',
url:'ScatterServlet',//请求数据的地址
data:{"name":"scatter"},
dataType:'json',
async:'true',
success:function(data,status){
alert("data:"+data);
alert("status:"+status);
}
},
error:function(XMLHttpRequest,textStatus,errorThrown){
alert("异常! "+"XMLHttpRequest.status:"+XMLHttpRequest.status+" XMLHttpRequest.readyState:"+XMLHttpRequest.readyState+" textStatus:"+textStatus);
}
});
}
$(document).ready(function(){
var showId= $("#scatter");
showId.click(function(){
paint();
});
});
我的ajax获取的json数据里有5个属性,我现在想取其中两个属性值,然后将这两个属性值动态加载到series里?求助各位了,弄了两天没弄出来。。在线等啊!!