Package zdenekdrahos.App.View.Graphs

Source Code of zdenekdrahos.App.View.Graphs.JFreeCharts

package zdenekdrahos.App.View.Graphs;

import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.AxisLocation;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CombinedDomainXYPlot;
import org.jfree.chart.plot.Plot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.StandardXYItemRenderer;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

public class JFreeCharts implements IJFreeCharts {
   
    @Override
    public Plot getCombinedXYPlot(XYSeries[] series, String groupPostfix) {
        CombinedDomainXYPlot plot = new CombinedDomainXYPlot();
        plot.setGap(20.0);
        plot.setOrientation(PlotOrientation.VERTICAL);

        XYItemRenderer renderer;
        NumberAxis rangeAxisY;
        XYPlot xyPlot;

        for (int i = 0; i < series.length; i++) {
            renderer = new StandardXYItemRenderer();
            rangeAxisY = getNumberAxis();
            rangeAxisY.setLabel((i + 1) + groupPostfix);
            xyPlot = new XYPlot(new XYSeriesCollection(series[i]), null, rangeAxisY, renderer);
            xyPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
            plot.add(xyPlot);
        }
        return plot;
    }
   
    @Override
    public Plot getXYPlot(XYSeriesCollection dataset) {
        return new XYPlot(dataset, getNumberAxis(), getNumberAxis(), new StandardXYItemRenderer())
    }

    @Override
    public ChartPanel getChartPanel(Plot plot) {
        JFreeChart chart = new JFreeChart(plot);               
        return new ChartPanel(chart)
    }
   
    @Override
    public NumberAxis getNumberAxis() {       
        NumberAxis axis = new NumberAxis();
        axis.setAutoRangeIncludesZero(false);
        return axis;
    }
   
}
TOP

Related Classes of zdenekdrahos.App.View.Graphs.JFreeCharts

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.