List of usage examples for org.jfree.chart ChartFactory createStackedAreaChart
public static JFreeChart createStackedAreaChart(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls)
From source file:com.thecoderscorner.groovychart.chart.StackedAreaChart.java
public JFreeChart createChart() { JFreeChart chart = ChartFactory.createStackedAreaChart(getTitle(), getCategoryAxisLabel(), getValueAxisLabel(), (CategoryDataset) getDataset(), getOrientation(), isLegend(), isTooltips(), isUrls());// www .ja v a2s.com return setExtraProperties(chart); }
From source file:jmbench.plots.OverallRelativeAreaPlot.java
public OverallRelativeAreaPlot(String title, int sizes[]) { // createAreaChart chart = ChartFactory.createStackedAreaChart(title, // chart title "Size", // domain axis label "Relative Average Speed", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, false);//from ww w .ja va2s . co m chart.addSubtitle(new TextTitle("Weighted by Operation Speed. Larger is Better.", new Font("SansSerif", Font.ITALIC, 12))); plot = chart.getCategoryPlot(); sizeNames = new String[sizes.length]; for (int i = 0; i < sizes.length; i++) { sizeNames[i] = Integer.toString(sizes[i]); } plot.setRangeGridlinePaint(Color.WHITE); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinesVisible(true); }
From source file:org.operamasks.faces.render.graph.AreaChartRenderer.java
protected JFreeChart createChart(UIChart comp) { Dataset dataset = createDataset(comp); JFreeChart chart = null;/*from w w w . ja v a2 s . co m*/ if (dataset instanceof CategoryDataset) { if (comp.isStacked()) { chart = ChartFactory.createStackedAreaChart(null, null, null, (CategoryDataset) dataset, getChartOrientation(comp), false, false, false); } else { chart = ChartFactory.createAreaChart(null, null, null, (CategoryDataset) dataset, getChartOrientation(comp), false, false, false); } } else if (dataset instanceof XYDataset) { chart = ChartFactory.createXYAreaChart(null, null, null, (XYDataset) dataset, getChartOrientation(comp), false, false, false); if (dataset instanceof TimeSeriesCollection) { DateAxis xAxis = new DateAxis(null); xAxis.setLowerMargin(0.02); xAxis.setUpperMargin(0.02); ((XYPlot) chart.getPlot()).setDomainAxis(xAxis); } } return chart; }
From source file:org.jenkinsci.plugins.todos.TodosChartBuilder.java
/** * Build a trend chart from the provided data. * /*from w ww. ja v a 2s . c o m*/ * @param action * the build action * @return the trend chart */ public static JFreeChart buildChart(TodosBuildAction action) { String strComments = Messages.Todos_ReportSummary_Comments(); JFreeChart chart = ChartFactory.createStackedAreaChart(null, null, strComments, buildDataset(action), PlotOrientation.VERTICAL, true, false, true); chart.setBackgroundPaint(Color.white); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); CategoryAxis domainAxis = new ShiftedCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // Crop extra space around the graph plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); TodosAreaRenderer renderer = new TodosAreaRenderer(action.getUrlName()); plot.setRenderer(renderer); return chart; }
From source file:org.jfree.chart.demo.StackedAreaChartDemo1.java
public static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createStackedAreaChart("Stacked Area Chart", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setForegroundAlpha(0.85F); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setLowerMargin(0.0D);/*from ww w. j a v a 2 s . c o m*/ categoryaxis.setUpperMargin(0.0D); categoryaxis.setCategoryMargin(0.0D); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); CategoryItemRenderer categoryitemrenderer = categoryplot.getRenderer(); categoryitemrenderer.setBaseItemLabelsVisible(true); return jfreechart; }
From source file:com.thalesgroup.hudson.plugins.sourcemonitor.SourceMonitorChartBuilder.java
public static JFreeChart buildChart(SourceMonitorBuildAction action) { JFreeChart chart = ChartFactory.createStackedAreaChart(null, null, "Number of errors", buildDataset(action), PlotOrientation.VERTICAL, true, false, true); chart.setBackgroundPaint(Color.white); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null);/*from www . ja v a2 s . c om*/ plot.setForegroundAlpha(0.8f); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); CategoryAxis domainAxis = new ShiftedCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // crop extra space around the graph plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); CategoryItemRenderer firstRender = new DefaultCategoryItemRenderer(); SourceMonitorRenderer renderer = new SourceMonitorRenderer(action.getUrlName()); plot.setRenderer(firstRender); return chart; }
From source file:net.sourceforge.processdash.ui.web.reports.AreaChart.java
/** Create a line chart. */ public JFreeChart createChart() { JFreeChart chart;// ww w .ja v a 2s. c o m CategoryDataset catData = data.catDataSource(); Object stacked = parameters.get("stacked"); if (stacked != null) { chart = ChartFactory.createStackedAreaChart(null, null, null, catData, PlotOrientation.VERTICAL, true, true, false); if ("pct".equals(stacked)) { ((StackedAreaRenderer) chart.getCategoryPlot().getRenderer()).setRenderAsPercentages(true); DecimalFormat fmt = new DecimalFormat(); fmt.setMultiplier(100); ((NumberAxis) chart.getCategoryPlot().getRangeAxis()).setNumberFormatOverride(fmt); if (parameters.get("units") == null) parameters.put("units", "%"); } } else { chart = ChartFactory.createAreaChart(null, null, null, catData, PlotOrientation.VERTICAL, true, true, false); } setupCategoryChart(chart); Object colorScheme = parameters.get("colorScheme"); if ("consistent".equals(colorScheme)) configureConsistentColors(chart.getCategoryPlot(), catData); else if (parameters.containsKey("c1")) configureIndividualColors(chart.getCategoryPlot(), catData); return chart; }
From source file:org.tap4j.plugin.util.GraphHelper.java
public static JFreeChart createChart(StaplerRequest req, CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createStackedAreaChart("TAP Tests", // chart title null, // unused "TAP Tests Count", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls );//w w w . jav a 2s . co m // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... final LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); CategoryAxis domainAxis = new ShiftedCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); StackedAreaRenderer ar = new StackedAreaRenderer2() { private static final long serialVersionUID = 331915263367089058L; @Override public String generateURL(CategoryDataset dataset, int row, int column) { NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column); return label.build.getNumber() + "/" + AbstractTapProjectAction.URL_NAME + "/"; } @Override public String generateToolTip(CategoryDataset dataset, int row, int column) { NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column); TapBuildAction build = label.build.getAction(TapBuildAction.class); TapResult report = build.getResult(); report.tally(); switch (row) { case 0: return String.valueOf(report.getFailed()) + " Failure(s)"; case 1: return String.valueOf(report.getPassed()) + " Pass"; case 2: return String.valueOf(report.getSkipped()) + " Skip(s)"; default: return ""; } } }; plot.setRenderer(ar); ar.setSeriesPaint(0, ColorPalette.RED); // Failures ar.setSeriesPaint(1, ColorPalette.BLUE); // Pass ar.setSeriesPaint(2, ColorPalette.YELLOW); // Skips // crop extra space around the graph plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); return chart; }
From source file:no.uio.medicine.virsurveillance.charts.StackedChart_AWT.java
public StackedChart_AWT(String applicationTitle, String chartTitle, String xTitle, String yTitle, ArrayList<ArrayList<Float>> dataPoints, ArrayList<ArrayList<Float>> xAxis, ArrayList<String> titles) { super(applicationTitle); this.xAxis = xAxis; this.dataPoints = dataPoints; this.titles = titles; if (this.dataPoints.size() != xAxis.size() && this.dataPoints.size() != titles.size()) { System.out.println("Error: Data size not match"); }// w w w . j a v a 2 s .co m this.chartTitle = chartTitle; this.xAxisTitle = xTitle; this.yAxisTitle = yTitle; JFreeChart stackedChart = ChartFactory.createStackedAreaChart(chartTitle, this.yAxisTitle, this.xAxisTitle, createDataset(this.dataPoints, this.xAxis, this.titles), PlotOrientation.VERTICAL, true, true, false); stackedChart.setBackgroundPaint(Color.white); this.chartPanel = new ChartPanel(stackedChart); this.chartPanel.setPreferredSize(new java.awt.Dimension(800, 500)); this.plot = (CategoryPlot) stackedChart.getPlot(); this.renderer = plot.getRenderer(); for (int i = 0; i < this.dataPoints.size(); i++) { plot.getRenderer().setSeriesPaint(i, getColor(i)); } plot.getRenderer().setItemLabelsVisible(true); //renderer.setSeriesStroke(0, new BasicStroke(4.0f)); //renderer.setSeriesStroke(1, new BasicStroke(3.0f)); //renderer.setSeriesStroke(2, new BasicStroke(2.0f)); setContentPane(this.chartPanel); this.setDefaultCloseOperation(HIDE_ON_CLOSE); }
From source file:com.google.jenkins.flakyTestHandler.plugin.TestFlakyStatsOverRevision.java
private JFreeChart createChart(CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createStackedAreaChart(null, // chart title null, // unused "count", // range axis label*/master dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // urls );/*from w w w. j av a2 s. c om*/ chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); CategoryAxis domainAxis = new ShiftedCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); StackedAreaRenderer ar = new StackedAreaRenderer2() { @Override public String generateToolTip(CategoryDataset dataset, int row, int column) { RevisionLabel label = (RevisionLabel) dataset.getColumnKey(column); Number value = dataset.getValue(row, column); switch (row) { case 0: return label.revision + ": " + value + " fails"; case 1: return label.revision + ": " + value + " passes"; default: return label.revision; } } }; plot.setRenderer(ar); ar.setSeriesPaint(0, ColorPalette.RED); // Fails. ar.setSeriesPaint(1, ColorPalette.BLUE); // Passes. // crop extra space around the graph plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); return chart; }