JFreeChart generate column

  Abstract: JFreeChart generate column 

  </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width="700" border="0"> <tr> <td width = " 421 "><%page contentType = "text / html; GBK charset ="%> 
  <% @ Page import = "java.awt.Color, 
  Java.awt.Font, 
  Org.jfree.chart.ChartFactory, 
  Org.jfree.chart.JFreeChart, 
  Org.jfree.chart.plot.PlotOrientation, 
  Org.jfree.chart.servlet.ServletUtilities, 
  Org.jfree.data.CategoryDataset, 
  Org.jfree.data.DatasetUtilities, 
  Org.jfree.chart.plot.CategoryPlot, 
  Org.jfree.chart.axis.CategoryAxis, 
  Org.jfree.chart.axis.ValueAxis, 
  Org.jfree.chart.renderer.BarRenderer3D, 
  Org.jfree.chart.labels.StandardCategoryItemLabelGenerator, 
  Org.jfree.chart.axis.AxisLocation "%> 
  <% </ Td> <td width="269"> </ td> </ tr> </ table>? 
  Double [] [] data = new double [] [] ((672, 766, 223, 540, 126), (325, 521, 210, 340, 106), (332, 256, 523, 240, 526)) ; 
  RowKeys String [] = ( "Apple", "pear", "grapes"); 
  ColumnKeys String [] = ( "Beijing," "Shanghai", "Guangzhou", "Chengdu" and "Shenzhen"); 
  CategoryDataset dataset = DatasetUtilities.createCategoryDataset (rowKeys, columnKeys, data); 

  JFreeChart chart = ChartFactory.createBarChart3D ( "fruit sales plans Statistics," 
  Null, 
  Null, 
  Dataset, 
PlotOrientation.VERTICAL,
  True, false, false); 
  Chart.setBackgroundPaint (Color.WHITE); 
  CategoryPlot plot = chart.getCategoryPlot (); 

  CategoryAxis domainAxis = plot.getDomainAxis (); 
  DomainAxis.setVerticalCategoryLabels (false); 
  Plot.setDomainAxis (domainAxis); 

  ValueAxis rangeAxis = plot.getRangeAxis (); 
  / / Item set the highest one from the top of the picture and 
  RangeAxis.setUpperMargin (0.15); 
  / / Item set a minimum of the distance between the bottom of the picture 
  RangeAxis.setLowerMargin (0.15); 
  Plot.setRangeAxis (rangeAxis); 

  BarRenderer3D renderer = new BarRenderer3D (); 
  Renderer.setBaseOutlinePaint (Color.BLACK); 
  / / Set the Wall color 
  Renderer.setWallPaint (Color.gray); 
  / / Set up the representative of each fruit color - 
  Renderer.setSeriesPaint (0, new Color (0, 0, 255)); 
  Renderer.setSeriesPaint (1, new Color (0, 100, 255)); 
  Renderer.setSeriesPaint (2, Color.GREEN); 
  / / Set up each region covered by the distance between the parallel columns 
  Renderer.setItemMargin (0.1); 
  / / Show each column values, and modify the font attribute values 
  Renderer.setItemLabelGenerator (new StandardCategoryItemLabelGenerator ()); 
  Renderer.setItemLabelsVisible (true); 
  Plot.setRenderer (renderer); 

  / / Set-transparency 
  Plot.setForegroundAlpha (0.6f); 
  / / Set up, sales of the display position 
  Plot.setDomainAxisLocation (AxisLocation.TOP_OR_RIGHT); 
  Plot.setRangeAxisLocation (AxisLocation.BOTTOM_OR_RIGHT); 

  String filename = ServletUtilities.saveChartAsPNG (chart, 500, 300, null, session); 
  String graphURL = request.getContextPath () + "/ servlet / DisplayChart? Filename =" + filename; 
%>
  "Width = 500 height = 300 border = 0 usemap ="#<%= filename%>"> 

  </ Td> </ tr> <tr> 

  ↑ Back 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • DotNetKicks
  • DZone
  • Netvouz
  • Propeller

Recommend Articles

Comments

Leave a Reply