Example usage for org.jfree.chart.renderer.xy XYStepRenderer XYStepRenderer

List of usage examples for org.jfree.chart.renderer.xy XYStepRenderer XYStepRenderer

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy XYStepRenderer XYStepRenderer.

Prototype

public XYStepRenderer(XYToolTipGenerator toolTipGenerator, XYURLGenerator urlGenerator) 

Source Link

Document

Constructs a new renderer with the specified tool tip and URL generators.

Usage

From source file:org.pentaho.plugin.jfreereport.reportcharts.ExtendedXYLineChartExpression.java

protected JFreeChart computeXYChart(final XYDataset xyDataset) {
    final JFreeChart rtn;
    if (xyDataset instanceof TimeSeriesCollection) {
        rtn = ChartFactory.createTimeSeriesChart(computeTitle(), getDomainTitle(), getRangeTitle(), xyDataset,
                isShowLegend(), false, false);
    } else {// w w  w .jav  a 2  s.c  om
        final PlotOrientation orientation = computePlotOrientation();
        rtn = ChartFactory.createXYLineChart(computeTitle(), getDomainTitle(), getRangeTitle(), xyDataset,
                orientation, isShowLegend(), false, false);
    }

    final String chartType = getChartType();
    if (STEP_AREA_CHART_STR.equals(chartType)) {
        final XYItemRenderer renderer;
        if (isMarkersVisible()) {
            renderer = new XYStepAreaRenderer(XYStepAreaRenderer.AREA_AND_SHAPES);
        } else {
            renderer = new XYStepAreaRenderer(XYStepAreaRenderer.AREA);
        }
        rtn.getXYPlot().setRenderer(renderer);
    } else if (STEP_CHART_STR.equals(chartType)) {
        rtn.getXYPlot().setRenderer(new XYStepRenderer(null, null));
    } else if (DIFFERENCE_CHART_STR.equals(chartType)) {
        rtn.getXYPlot().setRenderer(new XYDifferenceRenderer());
    }
    configureLogarithmicAxis(rtn.getXYPlot());
    return rtn;
}

From source file:de.iteratec.visualizationmodel.jfreechart.ChartFactory.java

public JFreeChart createXYStepChart(XYDataset dataset) {
    XYToolTipGenerator toolTipGenerator = !showTooltips ? null : new StandardXYToolTipGenerator();
    XYURLGenerator urlGenerator = !showUrls ? null : new StandardXYURLGenerator();
    XYItemRenderer renderer = new XYStepRenderer(toolTipGenerator, urlGenerator);

    XYPlot plot = new XYPlot(dataset, (ValueAxis) xAxis, (ValueAxis) yAxis, null);
    plot.setRenderer(renderer);/*from   w  w  w  .ja  v  a 2s.c  o m*/
    plot.setOrientation(orientation);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.getRenderer().setSeriesStroke(0, new BasicStroke(5.0f));
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, showLegend);
    THEME.apply(chart);
    return chart;
}

From source file:net.commerce.zocalo.freechart.ChartGenerator.java

private static JFreeChart createCustomXYStepChart(TimePeriodValuesCollection prices) {
    DateAxis xAxis = new DateAxis(null);
    NumberAxis yAxis = new NumberAxis("price");
    yAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());

    XYPlot plot = new XYPlot(prices, xAxis, yAxis, null);
    plot.setRenderer(new XYStepRenderer(null, null));
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    return new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
}

From source file:org.hxzon.demo.jfreechart.XYDatasetDemo2.java

private static JFreeChart createXYStepChart(XYDataset dataset) {

    DateAxis xAxis = new DateAxis(xAxisLabel);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    XYToolTipGenerator toolTipGenerator = null;
    if (tooltips) {
        toolTipGenerator = new StandardXYToolTipGenerator();
    }//  w  ww  .j  a  va2s .  co m

    XYURLGenerator urlGenerator = null;
    if (urls) {
        urlGenerator = new StandardXYURLGenerator();
    }
    XYItemRenderer renderer = new XYStepRenderer(toolTipGenerator, urlGenerator);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
    plot.setRenderer(renderer);
    plot.setOrientation(orientation);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    JFreeChart chart = new JFreeChart("XYStep Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    xAxis.setDateFormatOverride(new SimpleDateFormat("MM-yyyy"));

    return chart;
}

From source file:edu.dlnu.liuwenpeng.ChartFactory.ChartFactory.java

/**    
 * Creates a stepped XY plot with default settings.    
 *    /*from w w w  .  j  a v a  2  s .  co m*/
 * @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 chart.    
 */
public static JFreeChart createXYStepChart(String title, String xAxisLabel, String yAxisLabel,
        XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    DateAxis xAxis = new DateAxis(xAxisLabel);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    XYToolTipGenerator toolTipGenerator = null;
    if (tooltips) {
        toolTipGenerator = new StandardXYToolTipGenerator();
    }

    XYURLGenerator urlGenerator = null;
    if (urls) {
        urlGenerator = new StandardXYURLGenerator();
    }
    XYItemRenderer renderer = new XYStepRenderer(toolTipGenerator, urlGenerator);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
    plot.setRenderer(renderer);
    plot.setOrientation(orientation);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    return chart;

}

From source file:KIDLYFactory.java

/**
 * Creates a stepped XY plot with default settings.
 *
 * @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 chart.//from ww w. ja  v  a2s  . c  o m
 */
public static JFreeChart createXYStepChart(String title, String xAxisLabel, String yAxisLabel,
        XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    DateAxis xAxis = new DateAxis(xAxisLabel);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    XYToolTipGenerator toolTipGenerator = null;
    if (tooltips) {
        toolTipGenerator = new StandardXYToolTipGenerator();
    }

    XYURLGenerator urlGenerator = null;
    if (urls) {
        urlGenerator = new StandardXYURLGenerator();
    }
    XYItemRenderer renderer = new XYStepRenderer(toolTipGenerator, urlGenerator);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
    plot.setRenderer(renderer);
    plot.setOrientation(orientation);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;

}

From source file:org.jfree.chart.ChartFactory.java

/**
 * Creates a stepped XY plot with default settings.
 *
 * @param title  the chart title ({@code null} permitted).
 * @param xAxisLabel  a label for the X-axis ({@code null} permitted).
 * @param yAxisLabel  a label for the Y-axis ({@code null} permitted).
 * @param dataset  the dataset for the chart ({@code null} permitted).
 *
 * @return A chart.// w  w  w  .  ja va 2 s .  c  o  m
 */
public static JFreeChart createXYStepChart(String title, String xAxisLabel, String yAxisLabel,
        XYDataset dataset) {

    DateAxis xAxis = new DateAxis(xAxisLabel);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    XYToolTipGenerator toolTipGenerator = new StandardXYToolTipGenerator();
    XYItemRenderer renderer = new XYStepRenderer(toolTipGenerator, null);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
    plot.setRenderer(renderer);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    JFreeChart chart = new JFreeChart(title, plot);
    currentTheme.apply(chart);
    return chart;

}