Example usage for org.jfree.data.xy XYBarDataset XYBarDataset

List of usage examples for org.jfree.data.xy XYBarDataset XYBarDataset

Introduction

In this page you can find the example usage for org.jfree.data.xy XYBarDataset XYBarDataset.

Prototype

public XYBarDataset(XYDataset underlying, double barWidth) 

Source Link

Document

Creates a new dataset.

Usage

From source file:pwm.visualizer.MotivationDistributionPanel.java

private JPanel createPanel(String title) {
    IntervalXYDataset xybardataset = new XYBarDataset(motivationDataSet, 0.2D);
    JFreeChart jfreechart = ChartFactory.createXYBarChart(title, "", false, "Likelihood", xybardataset,
            PlotOrientation.VERTICAL, true, false, false);
    xyplot = (XYPlot) jfreechart.getPlot();
    NumberAxis numberaxis = (NumberAxis) xyplot.getDomainAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer();
    xybarrenderer.setDrawBarOutline(false);

    return new ChartPanel(jfreechart);
}

From source file:netplot.BarPlotPanel.java

private JFreeChart createChart() {
    collection = new XYSeriesCollection();
    collection.addSeries(series);/*  w ww  .j  av  a 2s .com*/
    dataset = new XYBarDataset(collection, 0.9);

    chart = ChartFactory.createXYBarChart(plotTitle, "", false, "", dataset, PlotOrientation.VERTICAL,
            enableLegend, true, true);

    plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.DARK_GRAY);
    plot.setRangeGridlinePaint(Color.DARK_GRAY);
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(true);
    return chart;
}

From source file:edu.psu.citeseerx.misc.charts.CiteChartBuilderJFree.java

protected JFreeChart buildChart(Document doc) throws SQLException {

    Long clusterid = doc.getClusterID();
    if (clusterid == null) {
        return null;
    }//from   www  .j  av  a2 s  .c  om

    java.util.List<ThinDoc> citingDocs = citedao.getCitingDocuments(clusterid, 0, MAX_CITING);
    XYDataset dataset = collectData(citingDocs);
    if (dataset.getItemCount(0) <= 1) {
        return null;
    }

    XYBarDataset ivl_dataset = new XYBarDataset(dataset, 15.0);
    JFreeChart chart = ChartFactory.createXYBarChart(null, "Year", true, "Citation Count", ivl_dataset,
            PlotOrientation.VERTICAL, false, false, false);
    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);

    XYItemRenderer r = plot.getRenderer();

    NumberAxis axis = (NumberAxis) plot.getDomainAxis();
    axis.setNumberFormatOverride(NumberFormat.getIntegerInstance());
    //axis.setTickUnit(new DateTickUnit(DateTickUnit.YEAR, -1));
    //axis.setDateFormatOverride(new SimpleDateFormat("yyyy"));
    return chart;

}

From source file:com.idealista.solrmeter.view.statistic.HistogramChartPanel.java

private Component createChartPanel() {
    XYBarDataset xyBarDataset = new XYBarDataset(xyDataset, BAR_WIDTH);
    NumberAxis xaxis = new NumberAxis(I18n.get("statistic.histogramChartPanel.time"));
    NumberAxis yaxis = new NumberAxis(I18n.get("statistic.histogramChartPanel.numberOfQueries"));

    xaxis.setStandardTickUnits(// w w w.  j  a  va 2 s .  c o m
            new ChartUtils.LowerBoundedTickUnitSource(xaxis.getStandardTickUnits(), LOWER_TICK_UNIT));

    XYPlot plot = new XYPlot(xyBarDataset, xaxis, yaxis, new XYBarRenderer());

    JFreeChart chart = new JFreeChart(I18n.get("statistic.histogramChartPanel.title"), null, plot, false);

    ChartPanel chartPanel = new ChartPanel(chart);

    chartPanel.setBorder(CHART_BORDER);
    chartPanel.setMinimumDrawHeight(0);
    chartPanel.setMinimumDrawWidth(0);
    chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);
    chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);

    return chartPanel;
}

From source file:org.jfree.data.xy.XYBarDatasetTest.java

/**
 * Confirm that the equals method can distinguish all the required fields.
 *///www  .  ja v  a 2s.c om
@Test
public void testEquals() {
    DefaultXYDataset d1 = new DefaultXYDataset();
    double[] x1 = new double[] { 1.0, 2.0, 3.0 };
    double[] y1 = new double[] { 4.0, 5.0, 6.0 };
    double[][] data1 = new double[][] { x1, y1 };
    d1.addSeries("S1", data1);
    DefaultXYDataset d2 = new DefaultXYDataset();
    double[] x2 = new double[] { 1.0, 2.0, 3.0 };
    double[] y2 = new double[] { 4.0, 5.0, 6.0 };
    double[][] data2 = new double[][] { x2, y2 };
    d2.addSeries("S1", data2);

    XYBarDataset bd1 = new XYBarDataset(d1, 5.0);
    XYBarDataset bd2 = new XYBarDataset(d2, 5.0);
    assertTrue(bd1.equals(bd2));
    assertTrue(bd2.equals(bd1));
}

From source file:com.idealista.solrmeter.view.statistic.QueryTimeHistoryPanel.java

/**
 * Creates and initializes the chart panel.
 *//*from w ww .  j  a v a 2  s. co  m*/
public ChartPanel createChartPanel() {
    XYBarDataset barDataset = new XYBarDataset(dataset, BAR_WIDTH);
    NumberAxis xaxis = new NumberAxis(I18n.get("statistic.queryTimeHistoryPanel.time"));
    NumberAxis yaxis = new NumberAxis(I18n.get("statistic.queryTimeHistoryPanel.averageQueryTime"));

    xaxis.setStandardTickUnits(
            new ChartUtils.LowerBoundedTickUnitSource(xaxis.getStandardTickUnits(), LOWER_TICK_UNIT));

    XYPlot plot = new XYPlot(barDataset, xaxis, yaxis, new XYBarRenderer());

    JFreeChart chart = new JFreeChart(I18n.get("statistic.queryTimeHistoryPanel.queryHistory"), null, plot,
            false);

    ChartPanel chartPanel = new ChartPanel(chart);

    chartPanel.setBorder(CHART_BORDER);
    chartPanel.setMinimumDrawHeight(0);
    chartPanel.setMinimumDrawWidth(0);
    chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);
    chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);

    return chartPanel;
}

From source file:net.nosleep.superanalyzer.analysis.views.PlayCountView.java

private void createPanel() {
    _comboBox = new JComboBox(_analysis.getComboBoxItems());
    _comboBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {
            refreshDataset();// w w  w  . jav  a  2s.  co  m
        }
    });

    _dataset = new XYBarDataset(collection, 0.9);

    createChart();
    _chartPanel = new ChartPanel(_chart);
    _chartPanel.setMouseWheelEnabled(true);

    refreshDataset();
}

From source file:org.jfree.data.xy.XYBarDatasetTest.java

/**
 * Confirm that cloning works.//from   ww  w  .  ja v  a2 s  .c o  m
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    DefaultXYDataset d1 = new DefaultXYDataset();
    double[] x1 = new double[] { 1.0, 2.0, 3.0 };
    double[] y1 = new double[] { 4.0, 5.0, 6.0 };
    double[][] data1 = new double[][] { x1, y1 };
    d1.addSeries("S1", data1);
    XYBarDataset bd1 = new XYBarDataset(d1, 5.0);
    XYBarDataset bd2 = (XYBarDataset) bd1.clone();
    assertTrue(bd1 != bd2);
    assertTrue(bd1.getClass() == bd2.getClass());
    assertTrue(bd1.equals(bd2));

    // check independence
    d1 = (DefaultXYDataset) bd1.getUnderlyingDataset();
    d1.addSeries("S2", new double[][] { { 1.0 }, { 2.0 } });
    assertFalse(bd1.equals(bd2));
    DefaultXYDataset d2 = (DefaultXYDataset) bd2.getUnderlyingDataset();
    d2.addSeries("S2", new double[][] { { 1.0 }, { 2.0 } });
    assertTrue(bd1.equals(bd2));
}

From source file:org.jfree.data.xy.junit.XYBarDatasetTest.java

/**
 * Confirm that the equals method can distinguish all the required fields.
 *///  www.j  ava 2 s .  c  o m
public void testEquals() {
    DefaultXYDataset d1 = new DefaultXYDataset();
    double[] x1 = new double[] { 1.0, 2.0, 3.0 };
    double[] y1 = new double[] { 4.0, 5.0, 6.0 };
    double[][] data1 = new double[][] { x1, y1 };
    d1.addSeries("S1", data1);
    DefaultXYDataset d2 = new DefaultXYDataset();
    double[] x2 = new double[] { 1.0, 2.0, 3.0 };
    double[] y2 = new double[] { 4.0, 5.0, 6.0 };
    double[][] data2 = new double[][] { x2, y2 };
    d2.addSeries("S1", data2);

    XYBarDataset bd1 = new XYBarDataset(d1, 5.0);
    XYBarDataset bd2 = new XYBarDataset(d2, 5.0);
    assertTrue(bd1.equals(bd2));
    assertTrue(bd2.equals(bd1));
}

From source file:org.jfree.chart.demo.XYBarChartDemo4.java

/**
 * Creates a sample dataset./*w w  w.  ja va 2  s. c  o  m*/
 * 
 * @return A sample dataset.
 */
private IntervalXYDataset createDataset() {
    final XYSeries series = new XYSeries("Series 1");
    series.add(1.0, 5.0);
    series.add(2.0, 7.8);
    series.add(3.0, 9.3);
    final XYSeriesCollection collection = new XYSeriesCollection();
    collection.addSeries(series);
    return new XYBarDataset(collection, 0.9);
}