ext js linechart前台接不到数据,求解

衆尋 黑龙江八一农垦大学 2012-04-20 06:30:39
js:
Ext.chart.Chart.CHART_URL = '../resources/charts.swf'; // 模板flash
var json_store;

Ext.onReady(function() {
alert('d');
var json_reader = new Ext.data.JsonReader({
idProperty : "name",
root : 'data',
totalProperty : "totalCount",
fields : [{
name : 'name',
type : "string"
}, {
name : 'views',
type : "int"
}, {
name : 'visits',
type : "int"
}]
});

json_store = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
url : 'listSellBillForDemo',
method : 'POST'
}),
reader : json_reader
});

// extra extra simple
new Ext.Panel({
title : 'ExtJS.com Visits Trend, 2007/2008 ',
renderTo : 'container',
width : 500,
height : 300,
layout : 'fit',

items : {
xtype : 'linechart', // 类型
store : json_store,
xField : 'name', // X轴取值
yField : 'visits', // Y轴取值
listeners : {
itemclick : function(o) {// 点击事件.
var rec = store.getAt(o.index);
Ext.example.msg('被选中项:', '你选择了 {0}.', rec
.get('name'));
}
},
series : [{
type : 'line', // line
displayName : '点击数',
yField : 'visits',
style : {
color : '#6666CC'
}
}]
}
});



json_store.load();
});


jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>charts</title>

<link rel="stylesheet" type="text/css" href="resources/css/ext-all.css"/>
<script type="text/javascript" src="ext-base.js"></script>
<script type="text/javascript" src="ext-all.js"></script>
<script type="text/javascript" src="scripts/testDemo.js"></script>

</head>

<body>


<div id="container" >

</div>
</body>
</html>


java
HttpServletResponse response=ServletActionContext.getResponse();
PrintWriter out = response.getWriter ();
String jsonString = "";
List<DataBean> list = new ArrayList<DataBean> ();
String[] names = { "1G", "2G", "3G", "4G", "5G", "6G", "7G", "8G" };
Random random = new Random ();
for (int i = 0; i < names.length; i++) {
int num = random.nextInt ( 100 ) * 100;
DataBean data = new DataBean ( names[i], num, num / 2 );
list.add ( data );
}
JSONArray arryData = null;
arryData = JSONArray.fromObject ( list );
jsonString = "{success:true,totalCount:" + list.size () + ",data:" + arryData.toString ().replaceAll ( "\n", "" ) + "}";
System.out.println (jsonString);
out.print ( jsonString );
//Struts2Utils.renderJson(jsonString);
out.flush ();
out.close ();
return "listSellBillForDemoResult";

我后台输出的数据形式:
{totalCount:8,data:[{"views":3550,"name":"1G","visits":7100},{"views":2200,"name":"2G","visits":4400},{"views":3000,"name":"3G","visits":6000},{"views":4000,"name":"4G","visits":8000},{"views":4900,"name":"5G","visits":9800},{"views":3150,"name":"6G","visits":6300},{"views":350,"name":"7G","visits":700},{"views":1250,"name":"8G","visits":2500}]}
前台不显示数据,坐标轴也不显示,求解释~~~~(>_<)~~~~
...全文
155 回复 点赞 打赏 收藏 举报
写回复
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2012-04-20 06:30
社区公告
暂无公告