Search in sources :

Example 26 with NumberAxis

use of org.jfree.chart.axis.NumberAxis in project processdash by dtuma.

the class AreaChart method createChart.

/** Create a line chart. */
public JFreeChart createChart() {
    JFreeChart chart;
    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;
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) CategoryDataset(org.jfree.data.category.CategoryDataset) DecimalFormat(java.text.DecimalFormat) JFreeChart(org.jfree.chart.JFreeChart) StackedAreaRenderer(org.jfree.chart.renderer.category.StackedAreaRenderer)

Aggregations

NumberAxis (org.jfree.chart.axis.NumberAxis)26 JFreeChart (org.jfree.chart.JFreeChart)21 CategoryAxis (org.jfree.chart.axis.CategoryAxis)12 CategoryPlot (org.jfree.chart.plot.CategoryPlot)11 XYPlot (org.jfree.chart.plot.XYPlot)10 RectangleInsets (org.jfree.ui.RectangleInsets)10 DateAxis (org.jfree.chart.axis.DateAxis)9 Color (java.awt.Color)6 DefaultCategoryDataset (org.jfree.data.category.DefaultCategoryDataset)6 TimeSeriesCollection (org.jfree.data.time.TimeSeriesCollection)6 Paint (java.awt.Paint)5 CategoryDataset (org.jfree.data.category.CategoryDataset)5 BasicStroke (java.awt.BasicStroke)4 Font (java.awt.Font)4 LocalDate (java.time.LocalDate)4 StackedAreaRenderer (org.jfree.chart.renderer.category.StackedAreaRenderer)4 ShiftedCategoryAxis (hudson.util.ShiftedCategoryAxis)3 DateFormat (java.text.DateFormat)3 SimpleDateFormat (java.text.SimpleDateFormat)3 ArrayList (java.util.ArrayList)3