JFreechart works a column map

xiaoxiao2021-03-06  39

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"%> testchartdemo </ title> </ head> <body bgcolor = "# ffffff"> <% // set DEFAULTCATEGORYDATASET DATASET = New DefaultcategoryDataSet (); DataSet.AddValue (2, "0-60 points", "one class"); dataset.addValue (34, "61-80 points", "one class"); dataset.addvalue (12, "81-100 points", "one class"); Dataset.AddValue (1, "0-60 points", "two Class "); Dataset.addValue (40," 61-80 points "," two classes "); Dataset.addValue (9," 81-100 points "," two classes "); Dataset.AddValue (0," 0 -60 points, "three classes"); dataset.addvalue (23, "61-80 points", "three classes"); Dataset.AddValue (32, "81-100 points", "three classes"); Dataset .addValue (3, "0-60 points", "four classes"); Dataset.addValue (33, "61-80 points", "four classes"); Dataset.AddValue (4, "81-100 points", "Four classes"); DATASE T. ADVALUE (4, "0-60 points", "five classes"); Dataset.addValue (37, "61-80 points", "five classes"); Dataset.AddValue (11, "81-100 points" , "Five Class"); // Creating a histogram jfreechart chart = chartfactory.createbarchart3d ("", // chart title "class", // directory axis display tag "</p> <p>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</p> <p><% @ 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 ();</p> <p>axis.setCategoryLabelPositions (CategoryLabelPositions.createUpRotationLabelPositions (Math.PI / 8.0)); String filename = ServletUtilities.saveChartAsPNG (chart, 500, 300, null, session); String graphURL = request.getContextPath () "? / DisplayChart filename =" filename;%> <img src = "<= graphURL%>" width = 500 height = 300 border = 0 usemap = "# <% = 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"?> <! doctype web-app public "- // sun microsystems, Inc.//dtd web application 2.3 // en" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <servlet> <servlet-name> displaychart </ servlet-name> <servlet-class> Org.jfree.Chart .SERVLET.DISPLAYCHART </ servlet-class> </ servlet> <servlet-maping> <servlet-name> Displaychart </ servlet-name> <url-pattern> / displaychart </ url-pattern> </ servlet-mapping> </ web-app></p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-63333.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="63333" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.045</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'oE2EUWB_2B9DSqV5lq9uNqPHOwpMDpnBz9JCLIiHCIHJITcpV19EpNfIYUcWcNtr_2BBsEmsI78Z63ahiiE_2FjH1BCA_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>