StackedareActor

xiaoxiao2021-03-14  184

import java.awt.Color; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree. chart.axis.NumberAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.data.category. CategoryDataset; import org.jfree.data.general.DatasetUtilities; import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RefineryUtilities; / ** * A simple demonstration application showing how to create a stacked area chart using data from ... a * {@link CategoryDataset} * / public class StackedAreaChartDemo extends applicationFrame {/ ** * Creates a new demo * * @param title the frame title * / public StackedAreaChartDemo (final String title) {super (title); CategoryDataset DataSet = createDataSet (); jfreechart chart = cretechart (dataset); Final ChartPanel Chartpa Nel = New ChartPanel (Chart); ChartPanel.SetPreferredSize (NEW JAVA.AWT.DIMENSION (500, 270)); setContentPane (chartpanel);} / ** * creates a sample dataset. * * @return a sample dataset. * / Public categoryDataSet createDataSet () {Final Double [] [] Data = new double [] [] {= new double [] [] {{1.0, 4.0, 3.0, 5.0, 5.0, 7.0, 7.0, 6.0, 8.0, 4.0, 4.0, 2.0, 1.0, 3.0, 6.0, 3.0, 4.0, 3.0}}; Final CategoryDataSet DataSet = DatasetUtilities.createcategoryDataSet; Return DataSet;} / ** * Creates a sample chart. * * @

param dataset the dataset. * * @return A sample chart. * / public JFreeChart createChart (CategoryDataset dataset) {final JFreeChart chart = ChartFactory.createStackedAreaChart ( "Stacked Area Chart", // chart title "Category", // domain axis label "Value", // Range Axis Label Dataset, // Data Plotorientation.Vertical, // Orientation True, // Include Legend True, False; Chart.SetBackgroundPaint (Color.White); Final CategoryPlot Plot = (categoryPlot) Chart. getPlot (); plot.setForegroundAlpha (0.5f); plot.setBackgroundPaint (Color.lightGray); plot.setDomainGridlinePaint (Color.white); plot.setRangeGridlinePaint (Color.white); final CategoryAxis domainAxis = plot.getDomainAxis (); domainAxis .SETLOWERMARGIN (0.0); DomainAxis.SetupPermargin (0.0); // change the auto tick unit selection to integer units only ... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis (); rangeAxis.setStandardTickUnits (NumberAxis.createIntegerTickUnits ()); final CategoryItemRenderer renderer = plot.getRenderer (); renderer .setItemLabelsVisible (true); return chart;..} / ** * Starting point for the demonstration application * * @param args ignored * / public static void main (final String [] args) {final StackedAreaChartDemo demo = new StackedAreaChartDemo ( " STACKED Area Chart Demo "); demo.Pack (); RefineryUtilities.Centerframeonscreen (Demo);

转载请注明原文地址:https://www.9cbs.com/read-129363.html

New Post(0)