海的响应改变高图表值,这是我的HTML代码取决于服务器
<select id="difques">
<option value="firstfivemonth">firstfivemonth</option>
<option value="nextfivemonth">nextfivemonth</option>
</select>
此我的用于通过使用在jquery的AJAX调用服务器代码........
$('#difques').change(function(){
$.ajax({
type: "GET",
url: "ManyQuestionGraph",
data: "graphfor="+$('#difques :selected').val()+"&value="+${value},
success: function(data){
var obj=jQuery.parseJSON(data);
options.series[0].color='red';
options.xAxis.categories=obj.value;
options.series[0].data=obj.month;
chart = new Highcharts.Chart(options);
}
});
});
我highchart代码
var chart;
$(document).ready(function() {
var options = {
chart: {
renderTo: 'graphreport',
type: 'column'
},
title: {
text: 'Rating'
},
xAxis: {
categories: ['jan','feb','mar','apr','may']
},
yAxis: {
min: 0,
max: 5,
title: {
text: ''
}
},
tooltip: {
formatter: function() {
return ''+
this.series.name +': '+ this.y +'';
}
},
credits: {
enabled: false
},
series: [{
name: 'Rating',
data: [1,2,3,4,5],
color: '#77c4d3'
}]
}
chart = new Highcharts.Chart(options);
和我的servlet代码是
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
JSONObject jsonobject = new JSONObject();
jsonobject.put("value",[5,4,3,2,1]);
jsonobject.put("month",['jun','jul','aug','sep','oct']);
response.setContentType("text/plain");
response.setCharacterEncoding("UTF-8");
response.getWriter().write(jsonobject.toString());
}
和我的网页看起来像这样.....
,但是当我在选择组合框中选择未来五年一个月对其使用Ajax调用服务器,我可以得到JSON数据从服务器在阿贾克斯的成功,但是当我通过数据highchart它看起来像这样.......
我做错了还是我在编码犯了一些错误...... ...
帮我...........
你能展现比如你返回的JSON的?另外,在创建新图表之前,请确保先前的图表被销毁。 – 2013-03-08 14:09:22
{“rate”:“,3.5,0,0,0”,“month”:“'jun','jul','aug','sep','oct'”}这是我返回的json – Kumar 2013-03-09 04:25:52