急急急!如何将jfreechart中的图表在Action中如何实现显示到页面!???

[复制链接]
查看11 | 回复5 | 2011-9-5 08:04:03 | 显示全部楼层 |阅读模式
packagedemo;importjava.awt.Color;importjava.awt.Dimension;importjavax.swing.JPanel;importorg.jfree.chart.ChartFactory;importorg.jfree.chart.ChartPanel;importorg.jfree.chart.JFreeChart;importorg.jfree.chart.axis.NumberAxis;importorg.jfree.chart.plot.PolarPlot;importorg.jfree.data.xy.XYDataset;importorg.jfree.data.xy.XYSeries;importorg.jfree.data.xy.XYSeriesCollection;importorg.jfree.ui.ApplicationFrame;importorg.jfree.ui.RefineryUtilities;publicclassPolarChartDemo1extendsApplicationFrame{publicPolarChartDemo1(Stringtitle){super(title);JPanelchartPanel=createDemoPanel();chartPanel.setPreferredSize(newDimension(500,270));setContentPane(chartPanel);}privatestaticXYDatasetcreateDataset(){XYSeriesCollectionresult=newXYSeriesCollection();XYSeriess1=newXYSeries(\"Series1\");s1.add(0.0,2.0);s1.add(90.0,13.0);s1.add(180.0,9.0);s1.add(270.0,8.0);result.addSeries(s1);XYSeriess2=newXYSeries(\"Series2\");s2.add(90.0,-11.2);s2.add(180.0,21.4);s2.add(250.0,17.3);s2.add(355.0,10.9);result.addSeries(s2);returnresult;}privatestaticJFreeChartcreateChart(XYDatasetdataset){JFreeChartchart=ChartFactory.createPolarChart(\"PolarChartDemo1\",dataset,true,false,false);chart.setBackgroundPaint(Color.white);PolarPlotplot=(PolarPlot)chart.getPlot();plot.setBackgroundPaint(Color.lightGray);plot.addCornerTextItem(\"CornerItem1\");plot.addCornerTextItem(\"CornerItem2\");plot.setAngleGridlinePaint(Color.white);plot.setRadiusGridlinePaint(Color.white);NumberAxisrangeAxis=(NumberAxis)plot.getAxis();rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());returnchart;}publicstaticJPanelcreateDemoPanel(){JFreeChartchart=createChart(createDataset());ChartPanelpanel=newChartPanel(chart);panel.setMouseZoomable(false);returnpanel;}publicstaticvoidmain(String[]args){PolarChartDemo1demo=newPolarChartDemo1(\"PolarChartDemo\");demo.pack();RefineryUtilities.centerFrameOnScreen(demo);demo.setVisible(true);}}
回复

使用道具 举报

千问 | 2011-9-5 08:04:03 | 显示全部楼层
在struts的配置文件中,你画图的这个action的包继承(extends)的是jfreechart这一项这个action返回类型修改为chart即type=\"chart\",这里你也可以设置图标的长宽其它的配置跟普通的action类似,你自己试试呢追问如果通过servlet呢那样怎么显示呢?jfreechart是弹出的窗体呀!
回复

使用道具 举报

千问 | 2011-9-5 08:04:03 | 显示全部楼层
servlet我是没做过,但action其本质也是一个servlet啊,相同道理的应该我就在struts2中用过jfreechartactionname=\"*******action\"class=\"********\"method=\"********\"resultname=\"success\"type=\"chart\"paramname=\"height\"600/paramparamname=\"width\"800/param/result/action这是指向到一个action的,jfreechart自己会生成一个chart在页面打印出来的(暂时我只记得这么多,下班回家以后贴下一个完整的配置)
回复

使用道具 举报

千问 | 2011-9-5 08:04:03 | 显示全部楼层
奥拿在Action中如何实现呢?能贴一下吗?
回复

使用道具 举报

千问 | 2011-9-5 08:04:03 | 显示全部楼层
你贴下你的邮箱,我把jfreechart的类和action的配置文件全部发你邮箱好了
回复

使用道具 举报

千问 | 2011-9-5 08:04:03 | 显示全部楼层
[email protected]能加一下qq吗?这是一个视图如何转换到页面?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行