Example usage for org.jfree.chart JFreeChart getPlot

List of usage examples for org.jfree.chart JFreeChart getPlot

Introduction

In this page you can find the example usage for org.jfree.chart JFreeChart getPlot.

Prototype

public Plot getPlot() 

Source Link

Document

Returns the plot for the chart.

Usage

From source file:net.sf.jasperreports.customizers.marker.RangeValueMarkerCustomizer.java

@Override
public void customize(JFreeChart jfc, JRChart jrc) {
    if (jfc.getPlot() instanceof XYPlot) {
        Marker marker = createMarker();/*from   w w  w  .  java2s  . c  om*/
        if (marker != null) {
            addMarker(jfc.getXYPlot(), marker);
        }
    }
}

From source file:net.sf.jasperreports.customizers.SplineCustomizer.java

@Override
public void customize(JFreeChart jfc, JRChart jrc) {
    Plot plot = jfc.getPlot();
    if (plot instanceof XYPlot) {
        ((XYPlot) plot).setRenderer(new XYSplineRenderer());
    }//from w w  w. ja  v  a2  s.co  m
}

From source file:net.sf.jasperreports.customizers.StepCustomizer.java

@Override
public void customize(JFreeChart jfc, JRChart jrc) {
    Plot plot = jfc.getPlot();
    if (plot instanceof XYPlot) {
        ((XYPlot) plot).setRenderer(new XYStepRenderer());
    }// w  w w.  j  av a  2s . c om
}

From source file:org.talend.dataprofiler.chart.util.TopChartFactory.java

/**
 * Method "createBubbleChart"./*from  w w  w  . j a va  2s  .  co m*/
 * 
 * @param indic the indicator
 * @param numericColumn the analyzed numeric column
 * @return the bubble chart
 */
public static JFreeChart createBubbleChart(String chartName, Object dataset,
        Map<String, ValueAggregator> xyzDatasets) {
    final Map<String, ValueAggregator> xyzDatasetsFinal = xyzDatasets;
    JFreeChart chart = TopChartFactory.createBubbleChart(chartName,
            Messages.getString("TopChartFactory.average"), Messages.getString("TopChartFactory.count"), //$NON-NLS-1$//$NON-NLS-2$
            (DefaultXYZDataset) dataset, PlotOrientation.HORIZONTAL, true, true, true);
    final XYPlot plot = (XYPlot) chart.getPlot();
    final XYItemRenderer renderer = plot.getRenderer();
    renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator() {

        private static final long serialVersionUID = 1L;

        /*
         * (non-Javadoc)
         * 
         * @see org.jfree.chart.labels.StandardXYZToolTipGenerator#createItemArray(org.jfree.data.xy.XYZDataset,
         * int, int)
         */
        @Override
        protected Object[] createItemArray(XYZDataset dset, int series, int item) {
            final Comparable<?> seriesKey = dset.getSeriesKey(series);
            final String seriesK = String.valueOf(seriesKey);
            String label = seriesK;
            if (xyzDatasetsFinal != null) {
                ValueAggregator valueAggregator = xyzDatasetsFinal.get(seriesKey);
                label = valueAggregator.getLabels(seriesK).get(item);
            }
            final Object[] itemArray = super.createItemArray(dset, series, item);
            itemArray[0] = label;// label;
            itemArray[1] = "avg=" + itemArray[1]; //$NON-NLS-1$
            itemArray[2] = "record count=" + itemArray[2]; //$NON-NLS-1$
            itemArray[3] = "null count=" + itemArray[3]; //$NON-NLS-1$
            return itemArray;
        }

    });
    return chart;
}

From source file:ca.sqlpower.wabit.swingui.chart.effect.BarChartAnimatorFactory.java

public boolean canAnimate(JFreeChart chart) {
    if (!(chart.getPlot() instanceof CategoryPlot)) {
        return false;
    }/*from w  ww . ja v a 2s. c o  m*/
    CategoryPlot cplot = chart.getCategoryPlot();
    if (cplot.getDatasetCount() != 1) {
        return false;
    }
    if (!(cplot.getDataset() instanceof DefaultCategoryDataset)) {
        return false;
    }
    return true;
}

From source file:net.sf.jasperreports.customizers.axis.DomainAxisCustomizer.java

@Override
public void customize(JFreeChart jfc, JRChart jrc) {
    if (jfc.getPlot() instanceof XYPlot) {
        ValueAxis valueAxis = jfc.getXYPlot().getDomainAxis();

        configValueAxis(valueAxis, PROPERTY_MIN_VALUE, PROPERTY_MAX_VALUE);

        if (valueAxis instanceof NumberAxis) {
            configNumberAxis((NumberAxis) valueAxis, PROPERTY_TICK_UNIT);
        }// w w  w  .  jav a 2 s.c  o  m
    }
}

From source file:SpiderChartCustomizer.java

@Override
public void customize(JFreeChart chart, ChartComponent chartComponent) {
    chart.getPlot().setOutlineVisible(true);
    chart.getPlot().setOutlinePaint(new Color(0, 0, 255));
    chart.getPlot().setOutlineStroke(new BasicStroke(1f));
}

From source file:net.sf.jasperreports.samples.spiderchartcomponent.SpiderChartCustomizer.java

public void customize(JFreeChart chart, ChartComponent chartComponent) {
    chart.getPlot().setOutlineVisible(true);
    chart.getPlot().setOutlinePaint(new Color(0, 0, 255));
    chart.getPlot().setOutlineStroke(new BasicStroke(1f));
}

From source file:net.sf.jasperreports.customizers.marker.RangeIntervalMarkerCustomizer.java

@Override
public void customize(JFreeChart jfc, JRChart jrc) {
    if (jfc.getPlot() instanceof XYPlot || jfc.getPlot() instanceof CategoryPlot) {
        Marker marker = createMarker();//from  ww w. j  a  v  a  2s  . co  m
        if (marker != null) {
            addMarker(jfc.getPlot(), marker);
        }
    }
}

From source file:org.amanzi.splash.chart.Charts.java

/**
 * Creates a bar chart//from  ww  w .j a va 2 s  .c  o  m
 *
 * @param reportChart chart model
 * @return a JFreeChart
 */
public static JFreeChart createBarChart(Chart reportChart) {

    // create the chart...
    JFreeChart chart = ChartFactory.createBarChart(reportChart.getTitle(), // chart title
            reportChart.getDomainAxisLabel(), // domain axis label
            reportChart.getRangeAxisLabel(), // range axis label
            ((CategoryPlot) reportChart.getPlot()).getDataset(), // data
            reportChart.getOrientation(), // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    // set the range axis to display integers only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    // set up gradient paints for series...
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    renderer.setSeriesPaint(0, gp0);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
    return chart;
}