Open Flash Chart2报表问题
Open Flash Chart2 调用struts action 问题jsp如下:
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<html>
<head>
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript" src="js/json2.js"></script>
<script type="text/javascript">
swfobject.embedSWF(
"open-flash-chart.swf",
"my_chart",
"40%",
"40%",
"9.0.0",
"expressInstall.swf",
{"data-file":"<%=request.getContextPath()%>/testAction.do"},
{wmode:"transparent"});
</script>
</head>
<body>
<p>Hello World</p>
<div id="my_chart"></div>
</body>
</html>
其中<%=request.getContextPath()%>/testAction.do就是指定的我们的Action的路径。
这个是否应该在 格拉struts-config.xml 进行相应的设定
</action>
<action path="/testAction"
validate="false"
type="jp.co.struts.action.OfcAction">
</action>
Struts Action:
try{
BarChart chart = new BarChart(BarChart.Style. GLASS ); // 设置条状图样式
//FilledBarChart chart = new FilledBarChart("red","blue");// 设置条状图样式
//String sMax = "10000" ;
long max = 900; // //Y 轴最大值
Map<String,Long> map = new HashMap<String,Long>();
map.put( "5" , new Long(50));
map.put( "6" , new Long(45));
map.put( "7" , new Long(60));
map.put( "8" , new Long(30));
map.put( "9" , new Long(80));
map.put( "10" , new Long(500));
map.put( "11" , new Long(800));
map.put( "12" , new Long(200));
XAxis x = new XAxis(); // X 轴
int i = 5;
for (String key:map.keySet()){
x.addLabels(i+"月份"); // x 轴的文字
Bar bar = new Bar(map.get(""+i), " 万元 " );
i++;
bar.setColour( "0x336699" ); // 颜色
bar.setTooltip(map.get(""+i) + " 万元 " ); // 鼠标移动上去后的提示
chart.addBars(bar); // 条标题,显示在 x 轴上
}
Chart flashChart = new Chart();
flashChart.addElements(chart); // 把柱图加入到图表
YAxis y = new YAxis(); //y 轴
y.setMax(max+10.0); //y 轴最大值
y.setSteps(max/10*1.0); // 步进
flashChart.setYAxis(y);
flashChart.setXAxis(x);
String json = flashChart.toString();
response.setContentType( "application/json-rpc;charset=utf-8" );
response.setHeader( "Cache-Control" , "no-cache" );
response.setHeader( "Expires" , "0" );
response.setHeader( "Pragma" , "No-cache" );
response.getWriter().print(json);// 写到客户端
}catch(Exception ex){
ex.printStackTrace();
}
return null;
}
在网上找了很多资料可还是没能调用成功,那位高手请指点一下非常感谢! --------------------编程问答--------------------
补充:Java , Java相关