书签 分享 收藏 举报 版权申诉 / 23

类型ofcjava学习资料.docx

  • 文档编号:6518188
  • 上传时间:2023-01-07
  • 格式:DOCX
  • 页数:23
  • 大小:1.21MB

其中<%=request.getContextPath()%>/testAction.do就是指定的我们的Action的路径。

二.StrutsAction:

以下代码是Struts1Action中的execute的写法

1)PieChart饼图:

publicActionForwardexecute(ActionMappingmapping,ActionFormform,HttpServletRequestrequest,HttpServletResponseresponse){

//TODOAuto-generatedmethodstub

try{

PieChartpie=newPieChart();

pie.setFontSize(15);//设置字体

pie.addSlice(200000000,"实收费用");//分类

pie.addSlice(60000000,"欠费金额");

pie.addSlice(30000000,"报停金额")

pie.addSlice(20000000,"减免金额");

pie.setStartAngle(100);//设置角度

pie.setAnimate(true);

//设置颜色

pie.setColours(newString[]{"0x336699","0x88AACC","0x999933","0x666699","0xCC9933","0x006666","0x3399FF","0x993300","0xAAAA77","0x666666","0xFFCC66","0x6699CC","0x663366","0x9999CC","0xAAAAAA","0x669999","0xBBBB55","0xCC6600","0x9999FF","0x0066CC","0x99CCCC","0x999999","0xFFCC00","0x009999","0x99CC33","0xFF9900","0x999966","0x66CCCC","0x339966","0xCCCC33"});

pie.setTooltip("#val#/#total#
占百分之#percent#");//鼠标移动上去后提示内容

pie.setRadius(20);

ChartflashChart=newChart("2009至2010年度包烧费分析","font-

size:

30px;color:

#ff0000;");//整个图的标题//flashChart.setBackgroundColour("#3EFFFF");flashChart.addElements(pie);//把饼图加入到图表

Stringjson=flashChart.toString();//转成json格式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(Exceptionex){

ex.printStackTrace();

}

returnnull;

}

显示效果如下:

2)BarChart柱状图:

try{

BarChartchart=newBarChart(BarChart.Style.GLASS);//设置条状图样式

//FilledBarChartchart=newFilledBarChart("red","blue");//设置条状图样式

//StringsMax="10000";

longmax=900;////Y轴最大值

Mapmap=newHashMap();

map.put("5",newLong(50));

map.put("6",newLong(45));

map.put("7",newLong(60));

map.put("8",newLong(30));

map.put("9",newLong(80));

map.put("10",newLong(500));

map.put("11",newLong(800));

map.put("12",newLong(200));

XAxisx=newXAxis();//X轴

inti=5;

for(Stringkey:

map.keySet()){

x.addLabels(i+"月份");//x轴的文

Barbar=newBar(map.get(""+i),"万元");

i++;

bar.setColour("0x336699");//颜色

bar.setTooltip(map.get(""+i)+"万元");//鼠标移动上去后的提示chart.addBars(bar);//条标题,显示在x轴上

}

ChartflashChart=newChart();

flashChart.addElements(chart);//把柱图加入到图表

YAxisy=newYAxis();//y轴

y.setMax(max+10.0);//y轴最大值

y.setSteps(max/10*1.0);//步进

flashChart.setYAxis(y);

flashChart.setXAxis(x);

Stringjson=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(Exceptionex){

ex.printStackTrace();

}

returnnull;

}

显示效果如下:

2)LineChart折线图:

publicActionForwardexecute(ActionMappingmapping,ActionFormform,HttpServletRequestrequest,HttpServletResponseresponse){

//TODOAuto-generatedmethodstub

try{

LineChartlineChart=newLineChart();

lineChart.setFontSize(15);//设置字体

lineChart.setTooltip("#val#%");//设置鼠标移到点上显示的内容

LineChart.Dotdot1=newLineChart.Dot(70);//按照顺序设置各个点的值LineChart.Dotdot2=newLineChart.Dot(85);

LineChart.Dotdot3=newLineChart.Dot(44);

LineChart.Dotdot4=newLineChart.Dot(67);

LineChart.Dotdot5=newLineChart.Dot(90);

LineChart.Dotdot6=newLineChart.Dot(64);

LineChart.Dotdot7=newLineChart.Dot(28);

LineChart.Dotdot8=newLineChart.Dot(99);

lineChart.addDots(dot1);//按照顺序把点加入到图形中lineChart.addDots(dot2);

lineChart.addDots(dot3);

lineChart.addDots(dot4);

lineChart.addDots(dot5);

lineChart.addDots(dot6);

lineChart.addDots(dot7);

lineChart.addDots(dot8);

XAxisx=newXAxis();//X轴

x.addLabels("5月份");

x.addLabels("6月份");

x.addLabels("7月份");

x.addLabels("8月份");

x.addLabels("9月份");

x.addLabels("10月份");

x.addLabels("11月份");

x.addLabels("12月份");

//x.setColour("0x000000");

longmax=100;////Y轴最大值

YAxisy=newYAxis();//y轴

y.setMax(max+0.0);//y轴最大值

y.setSteps(10);//步进

ChartflashChart=newChart("历年收费率报表","font-

size:

12px;color:

#ff0000;");//整个图的标题

flashChart.addElements(lineChart);//把饼图加入到图表

TextyText=newText("历年缴费率曲线图",Text.createStyle(20,

"#736AFF",Text.TEXT_ALIGN_CENTER));

flashChart.setYAxis(y);

flashChart.setXAxis(x);

flashChart.setYLegend(yText);//设置y轴显示内容

Stringjson=flashChart.toString();//转成json格式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(Exceptionex){

ex.printStackTrace();

}

returnnull;

}

显示效果如下:

4)BarChart2组合柱状图:

publicActionForwardexecute(ActionMappingmapping,ActionFormform,HttpServletRequestrequest,HttpServletResponseresponse){

//TODOAuto-generatedmethodstub

try{

StackedBarChartchart=newStackedBarChart();//设置组合柱状图longmax=900;////Y轴最大值

Mapmap=newHashMap();

map.put("5",newLong(50));

map.put("6",newLong(45));

map.put("7",newLong(60));

map.put("8",newLong(30));

map.put("9",newLong(80));

map.put("10",newLong(500));

map.put("11",newLong(800));

map.put("12",newLong(200));

XAxisx=newXAxis();//X轴

x.set3D(0);

x.setColour("#909090");

x.setGridColour("#ADB5C7");

inti=5;

for(Stringkey:

map.keySet()){

StackedBarChart.Stackstack=newStackedBarChart.Stack();//新建柱组

x.addLabels(i+"月份");//x轴的文字

StackedBarChart.StackValuestackValue=newStackedBarChart.StackValue(map.get(""+i),"0x336699");//每组柱状图每个

柱的设置

StackedBarChart.StackValuestackValue2=newStackedBarChart.StackValue(i*5+10,"#3334AD");StackedBarChart.StackValuestackValue3=newStackedBarChart.StackValue(i*10+20,"#D54C78");i++;

stack.addStackValues(stackValue);

stack.addStackValues(stackValue2);

stack.addStackValues(stackValue3);

chart.addStack(stack);//条标题,显示在x轴上

}

StackedBarChart.Keykey1=newStackedBarChart.Key("0x336699","包烧费",10);

StackedBarChart.Keykey2=newStackedBarChart.Key("#3334AD","热表收费",10);

StackedBarChart.Keykey3=newStackedBarChart.Key("#D54C78","生活热水收费",10);

chart.addKeys(key1);

chart.addKeys(key2);

chart.addKeys(key3);

ChartflashChart=newChart("组合柱状图","{font-size:

20px;color:

#FFFFFF;margin:

5px;background-color:

#505050;padding:

5px;padding-

left:

20px;padding-right:

20px;}");

flashChart.addElements(chart);//把柱图加入到图表

YAxisy=newYAxis();//y轴

y.set3D(0);

y.setColour("#909090");

y.setGridColour("#ADB5C7");

y.setMax(max+10.0);//y轴最大值

y.setSteps(max/10*1.0);//步进

flashChart.setYAxis(y);

flashChart.setXAxis(x);

Texttext=newText("OpenFlashChart3DBar");text.setStyle(Text.createStyle(15,"#736AFF",

Text.TEXT_ALIGN_RIGHT));

flashChart.setYLegend(text);//设置Y轴左侧的文字

Stringjson=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(Exceptionex){

ex.printStackTrace();

}

returnnull;

}

显示效果如下图

====================2010.11.24==========================

===

使用JOFC2在Web和RCP中展现图表

雷真,软件工程师,IBM

简介:

OpenFlashChart是一款使用Flash来展示图表的开源工具,图形美观、直接,JOFC2是实现了OpenFlashChart的JavaAPI,文章通过PieChart和StackedBarChart的实例,介绍了使用JOFC2来开发OpenFlashChart图表的流程。

标记本文!

发布日期:

2010年10月21日

级别:

初级

访问情况509次浏览

建议:

0(添加评论)

平均分(共0个评分)

1.OpenFlashChart简介

OpenFlashChart(OFC)使用Flash来动态展示生成的图表,具有简洁、美观的特点,其官方主页为:

http:

//teethgrinder.co.uk/open-flash-chart-2/。

现在OpenFlashChart已经更新到V2,在新的版本中,作者使用AdobeFlex来编译Actionscript3,并且采用JSON作为数据交互的格式,OFC提供了对PieChart、StackedBarChart、LineChart等常见图表的支持。

当前实现了OFC的编程语言有PHP、Perl、Python、Ruby、.NET、GoogleWebToolkit和Java,我们可以从http:

//teethgrinder.co.uk/open-flash-chart-2/tutorial-other-libraries.php获取详细信息,其中,JOFC2是OFC的一种Java实现,它可以将OFC使用的数据结构模型通过Java语言进行描述,然后序列成JS

配套讲稿:

如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

特殊限制:

部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

关 键  词:
ofcjava 学习 资料
提示  冰豆网所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
关于本文
本文标题:ofcjava学习资料.docx
链接地址:https://www.bdocx.com/doc/6518188.html
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2008-2022 冰点文档网站版权所有

经营许可证编号:鄂ICP备2022015515号-1

收起
展开