Example usage for org.jfree.chart.plot XYPlot getDomainAxis

List of usage examples for org.jfree.chart.plot XYPlot getDomainAxis

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot getDomainAxis.

Prototype

public ValueAxis getDomainAxis() 

Source Link

Document

Returns the domain axis with index 0.

Usage

From source file:ec.util.chart.swing.Charts.java

/**
 * A sparkline is a type of information graphic characterized by its small
 * size and high data density. Sparklines present trends and variations
 * associated with some measurement, such as average temperature or stock
 * market activity, in a simple and condensed way. Several sparklines are
 * often used together as elements of a small multiple.<br>
 *
 * {@link http://en.wikipedia.org/wiki/Sparkline}
 *
 * @param dataset//w  w  w  .ja  v a 2s.c om
 * @return
 * @author Philippe Charles
 */
@Nonnull
public static JFreeChart createSparkLineChart(@Nonnull XYDataset dataset) {
    JFreeChart result = ChartFactory.createTimeSeriesChart(null, null, null, dataset, false, false, false);
    result.setBorderVisible(false);
    result.setBackgroundPaint(null);
    result.setAntiAlias(true);
    XYPlot plot = result.getXYPlot();
    plot.getRangeAxis().setVisible(false);
    plot.getDomainAxis().setVisible(false);
    plot.setDomainGridlinesVisible(false);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.setOutlineVisible(false);
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    plot.setAxisOffset(RectangleInsets.ZERO_INSETS);
    plot.setBackgroundPaint(null);
    ((XYLineAndShapeRenderer) plot.getRenderer()).setAutoPopulateSeriesPaint(false);
    return result;
}

From source file:eu.cassandra.training.utils.ChartUtils.java

/**
 * This function is used for parsing and presenting the basic and the new
 * pricing schema.//from   w ww.  j av  a 2 s.com
 * 
 * @param basic
 *          The basic pricing schema
 * @param after
 *          The new pricing schema
 * 
 * @return a chart panel with the
 *         graphical representation.
 */
public static ChartPanel parsePricingScheme(String basic, String after) {

    double[] data = Utils.parseScheme(basic);

    double[] data2 = Utils.parseScheme(after);

    XYSeries series1 = new XYSeries("Basic Pricing Scheme");
    for (int i = 0; i < data.length; i++) {
        series1.add(i, data[i]);
    }

    XYSeries series2 = new XYSeries("New Pricing Scheme");
    for (int i = 0; i < data2.length; i++) {
        series2.add(i, data2[i]);
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series1);
    dataset.addSeries(series2);

    PlotOrientation orientation = PlotOrientation.VERTICAL;
    boolean show = true;
    boolean toolTips = false;
    boolean urls = false;

    JFreeChart chart = ChartFactory.createXYLineChart("Pricing Schemes", "Minute of Day", "Euros/kWh", dataset,
            orientation, show, toolTips, urls);

    XYPlot xyplot = (XYPlot) chart.getPlot();
    xyplot.setDomainPannable(true);
    xyplot.setRangePannable(true);
    xyplot.setForegroundAlpha(0.85F);
    NumberAxis domainAxis = (NumberAxis) xyplot.getDomainAxis();

    domainAxis.setTickUnit(new NumberTickUnit(100));
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    return new ChartPanel(chart);
}

From source file:Operacional.Janela2.java

private static JFreeChart createChart(IntervalXYDataset intervalxydataset) {
    JFreeChart jfreechart = ChartFactory.createXYBarChart("Dados Parquimetro", "Mes", true, "Dados",
            intervalxydataset, PlotOrientation.VERTICAL, true, false, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = jfreechart.getXYPlot();
    XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    StandardXYToolTipGenerator standardxytooltipgenerator = new StandardXYToolTipGenerator("{1} = {2}",
            new SimpleDateFormat("yyyy"), new DecimalFormat("0"));
    //xyitemrenderer.setToolTipGenerator(standardxytooltipgenerator);   
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setRangeGridlinePaint(Color.white);
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    dateaxis.setLowerMargin(0.01D);/* ww w  .  j  a  v a 2s .  co m*/
    dateaxis.setUpperMargin(0.01D);
    return jfreechart;
}

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

private static JFreeChart createXYLineChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createXYLineChart("Legal & General Unit Trust Prices", // title
            "Date", // x-axis label
            "Price Per Unit", // y-axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips?
            false // URLs?
    );//from ww  w.ja v  a  2s . com

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    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);

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setNumberFormatOverride(MyNumberFormat.getMyNumberFormat());

    return chart;
}

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

private static JFreeChart createXYAreaChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createXYAreaChart("Legal & General Unit Trust Prices", // title
            "Date", // x-axis label
            "Price Per Unit", // y-axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips?
            false // URLs?
    );//from  ww  w  .j a  v  a 2s .c om

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    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);

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setNumberFormatOverride(MyNumberFormat.getMyNumberFormat());

    return chart;
}

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

private static JFreeChart createXYStepAreaChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createXYStepAreaChart("Legal & General Unit Trust Prices", // title
            "Date", // x-axis label
            "Price Per Unit", // y-axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips?
            false // URLs?
    );/*from  ww  w . j a  v  a2 s  . c  om*/

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    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);

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setNumberFormatOverride(MyNumberFormat.getMyNumberFormat());

    return chart;
}

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

private static JFreeChart createScatterChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createScatterPlot("Legal & General Unit Trust Prices", // title
            "Date", // x-axis label
            "Price Per Unit", // y-axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips?
            false // URLs?
    );/*from   ww  w  .ja v  a  2s  .c o  m*/

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    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);

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setNumberFormatOverride(MyNumberFormat.getMyNumberFormat());

    return chart;

}

From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.charts.JFreeChartConn.java

/**
 * Creates a histogram chart that displays the given long histogram data.
 * /*from  w  ww. j av  a  2s .  c  o  m*/
 * @param aHistogram
 *            Complex parameter that stores the data to be visualized.
 * @param aSettings
 *            Settings group for long histogram.
 * @return Newly created chart control.
 */
public static JFreeChart createHistogram(LongHistogram aHistogram, LongHistogramGroup aSettings) {
    XYSeriesCollection collection = fromLongHistogram(aHistogram);
    JFreeChart chart = ChartFactory.createHistogram(null, // title
            convertLabel(aSettings.axes.getDomainAxisLabel()), // label of X axis
            convertLabel(aSettings.axes.getRangeAxisLabel()), // label of Y axis
            collection, // dataset
            PlotOrientation.VERTICAL, // orientation
            false, // create legend
            false, // display tooltips
            false); // generate urls
    XYPlot plot = chart.getXYPlot();
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    updateGeneral(plot, aSettings.general);
    updateAxes(chart, aSettings.axes, aSettings.grid);
    updateBars(plot, aSettings.bars);
    chart.setBackgroundPaint(null);
    return chart;
}

From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.charts.JFreeChartConn.java

/**
 * Creates a histogram chart that displays the given integer histogram data.
 * /*from   w  w  w  .  j ava2  s. co m*/
 * @param aHistogram
 *            Complex parameter that stores the data to be visualized.
 * @param aSettings
 *            Settings group for integer histogram.
 * @return Newly created chart control.
 */
public static JFreeChart createHistogram(IntHistogram aHistogram, IntHistogramGroup aSettings) {

    XYSeriesCollection collection = fromIntHistogram(aHistogram);
    JFreeChart chart = ChartFactory.createHistogram(null, // title
            convertLabel(aSettings.axes.getDomainAxisLabel()), // label of X axis
            convertLabel(aSettings.axes.getRangeAxisLabel()), // label of Y axis
            collection, // dataset
            PlotOrientation.VERTICAL, // orientation
            false, // create legend
            false, // display tooltips
            false); // generate urls
    XYPlot plot = chart.getXYPlot();
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    updateGeneral(plot, aSettings.general);
    updateAxes(chart, aSettings.axes, aSettings.grid);
    updateBars(plot, aSettings.bars);
    chart.setBackgroundPaint(null);
    return chart;
}

From source file:fr.amap.commons.javafx.chart.ChartViewer.java

public static JFreeChart createBasicChart(String title, XYSeriesCollection dataset, String xAxisLabel,
        String yAxisLabel) {/*  w w w.  j a  v  a 2 s  .c o  m*/

    JFreeChart chart = ChartFactory.createXYLineChart(title, xAxisLabel, yAxisLabel, dataset,
            PlotOrientation.VERTICAL, true, true, false);

    String fontName = "Palatino";
    chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18));
    XYPlot plot = (XYPlot) chart.getPlot();

    plot.setDomainPannable(true);
    plot.setRangePannable(true);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.getDomainAxis().setLowerMargin(0.0);

    plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
    plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));

    chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14));
    chart.getLegend().setFrame(BlockBorder.NONE);

    LegendTitle subtitle = (LegendTitle) chart.getSubtitles().get(0);
    subtitle.setHorizontalAlignment(HorizontalAlignment.LEFT);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);

        Ellipse2D.Float shape = new Ellipse2D.Float(-2.5f, -2.5f, 5.0f, 5.0f);
        renderer.setSeriesShape(0, shape);
    }

    return chart;
}