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:org.sakaiproject.sitestats.impl.ServerWideReportManagerImpl.java
private byte[] generateStackedAreaChart(CategoryDataset dataset, int width, int height) { JFreeChart chart = ChartFactory.createStackedAreaChart(null, // chart title null, // domain axis label null, // range axis label dataset, // data PlotOrientation.VERTICAL, // the plot orientation true, // legend true, // tooltips false // urls );/*from w w w . jav a 2 s . c om*/ // set background chart.setBackgroundPaint(parseColor(statsManager.getChartBackgroundColor())); // set chart border chart.setPadding(new RectangleInsets(10, 5, 5, 5)); chart.setBorderVisible(true); chart.setBorderPaint(parseColor("#cccccc")); // set anti alias chart.setAntiAlias(true); CategoryPlot plot = (CategoryPlot) chart.getPlot(); // set transparency plot.setForegroundAlpha(0.7f); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); // set colour of regular users using Karate belt colour: white, green, blue, brown, black/gold CategoryItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, new Color(205, 173, 0)); // gold users renderer.setSeriesPaint(1, new Color(139, 69, 19)); renderer.setSeriesPaint(2, Color.BLUE); renderer.setSeriesPaint(3, Color.GREEN); renderer.setSeriesPaint(4, Color.WHITE); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); CategoryAxis domainAxis = (CategoryAxis) plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); BufferedImage img = chart.createBufferedImage(width, height); final ByteArrayOutputStream out = new ByteArrayOutputStream(); try { ImageIO.write(img, "png", out); } catch (IOException e) { log.warn("Error occurred while generating SiteStats chart image data", e); } return out.toByteArray(); }
From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java
/** * *///from ww w . j a v a 2 s. co m protected JFreeChart createStackedAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createStackedAreaChart( (String) evaluateExpression(getChart().getTitleExpression()), (String) evaluateExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()), (String) evaluateExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()), (CategoryDataset) getDataset(), getPlot().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); JRAreaPlot areaPlot = (JRAreaPlot) getPlot(); // Handle the axis formating for the category axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(), (Comparable) evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable) evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), (Comparable) evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable) evaluateExpression(areaPlot.getRangeAxisMaxValueExpression())); ((CategoryPlot) jfreeChart.getPlot()).getDomainAxis().setCategoryMargin(0); return jfreeChart; }
From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java
/** * *//*from w w w . j av a2 s. c o m*/ protected JFreeChart createStackedAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createStackedAreaChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()), (CategoryDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); JRAreaPlot areaPlot = (JRAreaPlot) getPlot(); // Handle the axis formating for the category axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(), false, (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(), true, (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMaxValueExpression())); ((CategoryPlot) jfreeChart.getPlot()).getDomainAxis().setCategoryMargin(0); return jfreeChart; }
From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java
/** * *///from w w w. jav a 2 s . c o m protected JFreeChart createStackedAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createStackedAreaChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()), (CategoryDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); JRAreaPlot areaPlot = (JRAreaPlot) getPlot(); // Handle the axis formating for the category axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(), (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMaxValueExpression())); ((CategoryPlot) jfreeChart.getPlot()).getDomainAxis().setCategoryMargin(0); return jfreeChart; }
From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java
/** * *///from w w w . j ava2 s . c om protected JFreeChart createStackedAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createStackedAreaChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()), (CategoryDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart); JRAreaPlot areaPlot = (JRAreaPlot) getPlot(); // Handle the axis formating for the category axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getCategoryAxisLineColor(), false, (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getValueAxisLineColor(), true, (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMaxValueExpression())); ((CategoryPlot) jfreeChart.getPlot()).getDomainAxis().setCategoryMargin(0); return jfreeChart; }