Search in sources :

Example 1 with StackedXYAreaRenderer2

use of org.jfree.chart.renderer.xy.StackedXYAreaRenderer2 in project cubrid-manager by CUBRID.

the class CombinedBarTimeSeriesChart method createSeriesChart.

/**
	 * Create the series chart
	 * 
	 * @return an instance of series chart
	 */
private JFreeChart createSeriesChart() {
    if (isAreaRender) {
        seriesdataset = createTableSeriesDataset();
    } else {
        seriesdataset = createTimeSeriesDataset();
    }
    JFreeChart chart = ChartFactory.createTimeSeriesChart("", "", "", seriesdataset, false, false, false);
    chart.setBorderVisible(false);
    chart.setBorderStroke(new BasicStroke(0.0f));
    //plot
    XYPlot xyplot = (XYPlot) chart.getPlot();
    xyplot.setOutlineVisible(false);
    RectangleInsets rectangleInsets = new RectangleInsets();
    xyplot.setAxisOffset(rectangleInsets);
    xyplot.setDomainGridlineStroke(new BasicStroke(0.4f));
    xyplot.setRangeGridlineStroke(new BasicStroke(0.4f));
    xyplot.setBackgroundPaint(Color.BLACK);
    xyplot.setDomainGridlinePaint(new Color(0, 128, 64));
    xyplot.setRangeGridlinePaint(new Color(0, 128, 64));
    if (isAreaRender) {
        XYAreaRenderer2 render = new StackedXYAreaRenderer2();
        render.setSeriesPaint(0, Color.GREEN);
        render.setSeriesPaint(1, Color.RED);
        xyplot.setRenderer(render);
    } else {
        XYLineAndShapeRenderer render = (XYLineAndShapeRenderer) xyplot.getRenderer();
        render.setSeriesPaint(0, Color.GREEN);
        render.setSeriesPaint(1, Color.RED);
    }
    //dateAxis
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setFixedAutoRange(300000d);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setVisible(isShowSeriesAxis);
    numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setVisible(isShowSeriesAxis);
    numberaxis.setRange(0 - 0.5, barMax + 0.5);
    return chart;
}
Also used : BasicStroke(java.awt.BasicStroke) StackedXYAreaRenderer2(org.jfree.chart.renderer.xy.StackedXYAreaRenderer2) DateAxis(org.jfree.chart.axis.DateAxis) XYPlot(org.jfree.chart.plot.XYPlot) Color(java.awt.Color) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) RectangleInsets(org.jfree.ui.RectangleInsets) JFreeChart(org.jfree.chart.JFreeChart) XYAreaRenderer2(org.jfree.chart.renderer.xy.XYAreaRenderer2) StackedXYAreaRenderer2(org.jfree.chart.renderer.xy.StackedXYAreaRenderer2)

Example 2 with StackedXYAreaRenderer2

use of org.jfree.chart.renderer.xy.StackedXYAreaRenderer2 in project pentaho-platform by pentaho.

the class JFreeChartEngine method createStackedTimeSeriesChart.

/*
   * The only type of chart this method will produce is a stacked XY area chart with a time series dimension. This
   * is because the dataset that jFreeChart expects is different than the regular TimeSeriesCOllection. More
   * lipstick on this homely pig.
   */
private static JFreeChart createStackedTimeSeriesChart(final TimeTableXYDatasetChartDefinition chartDefinition) {
    JFreeChart chart = null;
    // TODO Make the following accessible from the chartDefinition
    String domainAxisLabel = null;
    String rangeAxisLabel = null;
    boolean tooltips = true;
    boolean urls = true;
    // -----------------------------------------------------------
    String title = chartDefinition.getTitle();
    boolean legend = chartDefinition.isLegendIncluded();
    DateAxis domainAxis = new DateAxis(domainAxisLabel, TimeZone.getDefault());
    ValueAxis rangeAxis = new NumberAxis(rangeAxisLabel);
    XYItemRenderer renderer = null;
    switch(chartDefinition.getChartType()) {
        case AREA_CHART_TYPE:
            renderer = chartDefinition.isStacked() ? new StackedXYAreaRenderer2() : new XYAreaRenderer();
            break;
        default:
            // should log an error if invalid chart type passed in - at least return null for no renderer
            return null;
    }
    if (tooltips) {
        XYToolTipGenerator generator = new StandardXYToolTipGenerator(chartDefinition.getTooltipContent(), new SimpleDateFormat(chartDefinition.getTooltipXFormat()), new DecimalFormat(chartDefinition.getTooltipYFormat()));
        renderer.setToolTipGenerator(generator);
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }
    renderer.setStroke(JFreeChartEngine.getLineStyleStroke(chartDefinition.getLineStyle(), chartDefinition.getLineWidth()));
    XYPlot plot = new XYPlot(chartDefinition, domainAxis, rangeAxis, renderer);
    JFreeChartEngine.updatePlot(plot, chartDefinition);
    chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    return chart;
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) NumberAxis(org.jfree.chart.axis.NumberAxis) DecimalFormat(java.text.DecimalFormat) JFreeChart(org.jfree.chart.JFreeChart) XYAreaRenderer(org.jfree.chart.renderer.xy.XYAreaRenderer) StackedXYAreaRenderer2(org.jfree.chart.renderer.xy.StackedXYAreaRenderer2) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) XYPlot(org.jfree.chart.plot.XYPlot) ValueAxis(org.jfree.chart.axis.ValueAxis) StandardXYURLGenerator(org.jfree.chart.urls.StandardXYURLGenerator) AbstractXYItemRenderer(org.jfree.chart.renderer.xy.AbstractXYItemRenderer) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator) SimpleDateFormat(java.text.SimpleDateFormat)

Example 3 with StackedXYAreaRenderer2

use of org.jfree.chart.renderer.xy.StackedXYAreaRenderer2 in project SIMVA-SoS by SESoS.

the class ChartFactory method createStackedXYAreaChart.

/**
 * Creates a stacked XY area plot.  The chart object returned by this
 * method uses an {@link XYPlot} instance as the plot, with a
 * {@link NumberAxis} for the domain axis, a {@link NumberAxis} as the
 * range axis, and a {@link StackedXYAreaRenderer2} as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
 * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the plot orientation (horizontal or vertical)
 *                     (<code>null</code> NOT permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A stacked XY area chart.
 */
public static JFreeChart createStackedXYAreaChart(String title, String xAxisLabel, String yAxisLabel, TableXYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) {
    ParamChecks.nullNotPermitted(orientation, "orientation");
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    XYToolTipGenerator toolTipGenerator = null;
    if (tooltips) {
        toolTipGenerator = new StandardXYToolTipGenerator();
    }
    XYURLGenerator urlGenerator = null;
    if (urls) {
        urlGenerator = new StandardXYURLGenerator();
    }
    StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(toolTipGenerator, urlGenerator);
    renderer.setOutline(true);
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(orientation);
    // forces recalculation of the axis range
    plot.setRangeAxis(yAxis);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;
}
Also used : StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) StackedXYAreaRenderer2(org.jfree.chart.renderer.xy.StackedXYAreaRenderer2) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) StandardXYURLGenerator(org.jfree.chart.urls.StandardXYURLGenerator) XYURLGenerator(org.jfree.chart.urls.XYURLGenerator) StandardXYURLGenerator(org.jfree.chart.urls.StandardXYURLGenerator) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator)

Aggregations

XYPlot (org.jfree.chart.plot.XYPlot)3 StackedXYAreaRenderer2 (org.jfree.chart.renderer.xy.StackedXYAreaRenderer2)3 JFreeChart (org.jfree.chart.JFreeChart)2 DateAxis (org.jfree.chart.axis.DateAxis)2 NumberAxis (org.jfree.chart.axis.NumberAxis)2 StandardXYToolTipGenerator (org.jfree.chart.labels.StandardXYToolTipGenerator)2 XYToolTipGenerator (org.jfree.chart.labels.XYToolTipGenerator)2 StandardXYURLGenerator (org.jfree.chart.urls.StandardXYURLGenerator)2 BasicStroke (java.awt.BasicStroke)1 Color (java.awt.Color)1 DecimalFormat (java.text.DecimalFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ValueAxis (org.jfree.chart.axis.ValueAxis)1 AbstractXYItemRenderer (org.jfree.chart.renderer.xy.AbstractXYItemRenderer)1 XYAreaRenderer (org.jfree.chart.renderer.xy.XYAreaRenderer)1 XYAreaRenderer2 (org.jfree.chart.renderer.xy.XYAreaRenderer2)1 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)1 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)1 XYURLGenerator (org.jfree.chart.urls.XYURLGenerator)1 RectangleInsets (org.jfree.ui.RectangleInsets)1