posts - 10,comments - 1,trackbacks - 0

public class JFreeChart1 extends HttpServlet {

 private static final long serialVersionUID = 1L;

 public JFreeChart1() {
  super();
 }

 public void doGet(HttpServletRequest request, HttpServletResponse response)
   throws ServletException, IOException {
  doPost(request, response);
 }

 public void doPost(HttpServletRequest request, HttpServletResponse response)
   throws ServletException, IOException {

  TimeSeries xyseries = new TimeSeries("finince income", Month.class);

  TimeSeriesCollection xyseriescollection = new TimeSeriesCollection();
  xyseriescollection.addSeries(xyseries);

  JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Example",
    "y", "x", xyseriescollection, true, true, true);
  jfreechart.setBackgroundPaint(Color.white);
  XYPlot xyplot = jfreechart.getXYPlot();

  xyplot.setNoDataMessage("no data to display");// 此名可用来做当没有数据的时候jfreechart面板上的显示
  
    StandardEntityCollection sec = new StandardEntityCollection();
  ChartRenderingInfo info = new ChartRenderingInfo(sec);

  ChartUtilities.writeChartAsPNG(response.getOutputStream(), jfreechart,
    600, 400, info);
 }

}



已有 0 人发表留言,猛击->>这里<<-参与讨论


JavaEye推荐




文章来源:http://java-jun.javaeye.com/blog/602654
posted on 2010-02-25 10:59 uqnetlove 阅读(297) 评论(1)  编辑  收藏

FeedBack:
# re: [导入]jfreechart里当没有数据显示时的处理[未登录]
2014-08-11 16:11 | Aa
代码看的不是很懂
直接贴代码的做法真的不怎么样  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: