Netcuff @ 2005-01-19 17:12 Columnar Figure Bar.jsp Column Figure 1 bar1.jsp Histogram Figure 2 BAR2.JSP 3D Column Bar3d.jsp Column Bar.jsp:
<% @ Page ContentType = "Text / HTML; Charset = GBK"%> <% @ page import = "org.jfree.chart.chartFactory, Org.jfree.Chart.jfreechart, org.jfree.chart.plot.plotorientation, Org.jfree.Chart.Servlet.Servletutilities, Org.jfree.Data.defaultcategoryDataSet "%> <% @ page import =" java.util.itrator, org.jfree.data.time. *, java.awt.font "% > <% Font font = new font ("black body", font.truetype_font, 12); defaultcategoryDataSet DataSet = new defaultcategoryDataSet (); Dataset.AddValue (300, "" "," Super Member "); DataSet.addValue (200," " "Super speed"); Dataset.addValue (500, "", "free parking"); Dataset.addValue (340, "", "right over the car"); Dataset.AddValue (280, "," Mixed "); Dataset.addValue (500," "" illegal loading "); Dataset.addValue (128," "" "fatigue driving"); dataset.addvalue (263, "", "violating partial driving Principles "); DataSet.addValue (412," "," license card failure "); DataSet.addValue (380," "," other illegal act "); JFreeChart Chart = ChartFactory.createBarchart3D (" Treated illegal information statistics "" Illegal information "," quantity ", Dataset, Plotorientation.Vertical, False, False, false); //CHART.SETTILE ("Website Access Statistics Table", Font); // Optional, Set Picture Title String FileName = ServletUtilities.Savechartaspng (Chart, 500, 300, Null, Session); string graphURL = Request.getContextPath () "/ displaychart? filename =" filename;%> Column Figure 1 bar1.jsp
<% @ Page ContentType = "Text / HTML; Charset = GBK"%> <% @ 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.StandardCategoryLabelGenerator, org.jfree.chart.axis.AxisLocation "%> <% Double [] [] Data = new double [] [] {{672, 766, 223, 540, 126}, {325, 521, 210, 340, 106}, {332, 256, 523, 240, 526 }}; String [] RowKeys = {"Apple", "Pear", "Grape"}; string [] columnKeys = {"Beijing", "Shanghai", "Guangzhou", "Chengdu", "Shenzhen"}; categoryDataSet dataset = DatasetUtilities.createCategoryDataset (rowKeys, columnKeys, data); font font = new font ( "bold", Font.TRUETYPE_FONT, 12); JFreeChart chart = ChartFactory.createBarChart3D ( "FIG fruit sales statistics", null, null, dataset, PlotOrientation.VERTICAL, true, false, false); chart.setBackgroundPaint (Color.white); CategoryPlot plot = chart.getCategoryPlot (); CategoryAxis domainAxis = plot.getDomainAxis (); domainAxis.setVerticalCategoryLabels (false); domainAxis.setTickLabelFont (font); Plot.SetDomainaxis (domainaxis); Valueaxis Rangeaxis = Plot.GetRangeaxis (); Rangeaxis.SetTickLabelfont (font); // Set the highest Item and Picture top Distance Rangeaxis.SetupPermargin (0.15); // Set the lowest An Item and the picture of the picture Rangeaxis.setlowermargin (0.15); Plot.setRangeaxis (Rangeaxis); barrenderer3d renderer =
New barrenderer3d (); renderer.setBaseOutlinePaint (color.black); // Set the color renderer.SetwallPaint (color.gray); // Set the color renderer.setSeriespaint of each fruit representative of the column (0, New Color (0 , 0, 255); renderer.setSeriesPaint (1, New Color (0, 100, 255)); renderer.setSeriesPaint (2, color.green); // Setting between the parallel columns included in each region Renderer.SetItemMargin (0.1); // Displays the value of each column and modifies the font attribute of this value //rendere.setitemlabelgenerator (New StandardcategoryLabelgenerator ()); //rendere.setitemlabelsvisible (true); plot.setrenderer (rendere) ; transparency plot.setForegroundAlpha // set the column (0.6f); // set region, sales 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 () "/ displaychart? Filename =" filename;%> <% @ Page Import = "Java.io. *"%> <% @ page import = "java.awt. *"%> <% @ Page Import = "Org.jfree.data. *"%> <% @ page import = "org.jfree.chart. *"%> <% @ page import = "org.jfree.chart.plot. *"%> <% @ page import = "org.jfree.chart.chartutilities"%> <% @ page import = "org.jfree.Chart.title.texttitle"%>
Score ", // numeric axis display tag DataSet, // Data Set Plotorientation.Vertical, // Chart Direction: horizontal, vertical true, // Whether to display the legend (for simple column chart must be false) false, // Generate tool false // Does a URL link); // Set the title font font = new font ("black body", font.center_baseline, 20); texttitle title = new texttitle ("Student Results Statistics of Each class"); Title.SetFont (font); // Statistics Chart.SetBackgroundPaint (Java.awt.Color.White); Chart.SetTitle (Title); // Get Response OutputStream OutputStream Ostream = response.getoutputstream (); // Setting The picture is 400, high is 300, and output to Ostream Chartutilities.Writechartasjpeg (Ostream, Chart, 400, 300); ostream.clush (); ostream.close ();%> body> html> 3d Columnum map bar3d.jsp
<% @ page contenttype = "text / html; charset = GBK"%> <% @ page import = "org.jfree.chart.chartFactory, Org.jfree.chart.chartPanel, Org.jfree.Chart.jfreechart, org. jfree.chart.StandardLegend, org.jfree.chart.axis.CategoryAxis, org.jfree.chart.axis.CategoryLabelPositions, org.jfree.chart.plot.CategoryPlot, org.jfree.chart.plot.PlotOrientation, org.jfree. Chart.Servlet.ServletUtIlities, Org.jfree.data.categoryDataSet, org.jfree.data.datasetUtilities "%> <% double [] [] data = new double [] [] {{10.0, 4.0, 15.0, 14.0}, {-5.0, -7.0, 14.0, -3.0}, {6.0, 17.0, - 12.0, 7.0, 0.0, 0.0, {-8.0, -6.0, 10.0, -9.0}, {9.0, 8.0, 0.0, 6.0, 7.0, 7.0, 7.0, 13.0, 9.0, 9.0}, {-3.0, 7.0, 11.0, -10.0}}; categoryDataSet DataSet = DataSetUtilities.createcategoryDataSet ("Series "," C Ategory ", DATA); JFreeChart Chart = ChartFactory.createBarchart3d (" 3D Bar Chart Demo ", // Chart Title" Category ", // Domain Axis Label" Value ", // Range Axis Label Dataset, // Data Plotorientation.Vertical , // orientation true, // include legend true, // Tooltips false // URLS); categoryplot plot = chart.getcategoryPlot (); categoryaxis axis = plot.getdomainaxis ();
axis.setCategoryLabelPositions (CategoryLabelPositions.createUpRotationLabelPositions (Math.PI / 8.0)); String filename = ServletUtilities.saveChartAsPNG (chart, 500, 300, null, session); String graphURL = request.getContextPath () "? / DisplayChart filename =" filename;%> Note the above code, all: jfreechart-0.9.20 .jar, JCOMMON-0.9.5.JAR debugging! Web.xml configuration servlet code: XML version = "1.0" eNCoding = "UTF-8"?>