Example usage for org.jfree.data DatasetUtilities createCategoryDataset

List of usage examples for org.jfree.data DatasetUtilities createCategoryDataset

Introduction

In this page you can find the example usage for org.jfree.data DatasetUtilities createCategoryDataset.

Prototype

public static CategoryDataset createCategoryDataset(final String[] rowKeys, final String[] columnKeys,
        final double[][] data) 

Source Link

Document

Creates a CategoryDataset that contains a copy of the data in an array (instances of Double are created to represent the data items).

Usage

From source file:org.eclipse.mylyn.tests.chart.ChartTest.java

public static CategoryDataset createCategoryDataset() {

    final double[][] data = new double[][] { { 10.0, 4.0, 15.0, 14.0, 0, 0, 0 },
            { 5.0, 7.0, 14.0, 3.0, 0, 0, 0 }, { 6.0, 17.0, 12.0, 7.0, 0, 0, 0 } };

    String[] measurements = { "navigating", "editing", "other" };
    String[] days = { "mon", "tue", "wed", "thu", "fri", "sat", "sun" };

    return DatasetUtilities.createCategoryDataset(measurements, days, data);
}

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

/**
 * Creates a new demo.// w ww.j  av  a  2  s  .com
 *
 * @param title  the frame title.
 */
public OverlaidCategoryChartDemo(String title) {

    super(title);
    DefaultIntervalCategoryDataset barData = null;
    double[][] lows = { { -.0315, .0159, .0306, .0453, .0557 } };
    double[][] highs = { { .1931, .1457, .1310, .1163, .1059 } };
    barData = new DefaultIntervalCategoryDataset(lows, highs);

    double[][] vals = { { 0.0808, 0.0808, 0.0808, 0.0808, 0.0808 } };
    CategoryDataset dotData = DatasetUtilities.createCategoryDataset("Series ", "Category ", vals);

    double[][] lineVals = new double[4][5];
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 5; j++) {
            lineVals[i][j] = (Math.random() * 0.56) - 0.18;
        }
    }
    CategoryDataset lineData = DatasetUtilities.createCategoryDataset("Series ", "Category ", lineVals);

    String ctitle = "Strategie Sicherheit";
    String xTitle = "Zeitraum (in Jahren)";
    String yTitle = "Performance";
    CategoryAxis xAxis = new CategoryAxis(xTitle);
    xAxis.setLabelFont(titleFont);
    xAxis.setTickLabelFont(labelFont);
    xAxis.setTickMarksVisible(false);
    NumberAxis yAxis = new NumberAxis(yTitle);
    yAxis.setLabelFont(titleFont);
    yAxis.setTickLabelFont(labelFont);
    yAxis.setRange(-0.2, 0.4);
    DecimalFormat formatter = new DecimalFormat("0.##%");
    yAxis.setTickUnit(new NumberTickUnit(0.05, formatter));

    IntervalBarRenderer barRenderer = new IntervalBarRenderer();
    barRenderer.setItemLabelsVisible(Boolean.TRUE);

    CategoryPlot plot = new CategoryPlot(barData, xAxis, yAxis, barRenderer);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setOutlinePaint(Color.black);

    LineAndShapeRenderer dotRenderer = new LineAndShapeRenderer(LineAndShapeRenderer.SHAPES);
    dotRenderer.setItemLabelsVisible(Boolean.TRUE);

    plot.setSecondaryDataset(0, dotData);
    plot.setSecondaryRenderer(0, dotRenderer);

    LineAndShapeRenderer lineRenderer = new LineAndShapeRenderer(LineAndShapeRenderer.SHAPES_AND_LINES);
    plot.setSecondaryDataset(1, lineData);
    plot.setSecondaryRenderer(1, lineRenderer);

    this.chart = new JFreeChart(ctitle, titleFont, plot, false);
    this.chart.setBackgroundPaint(Color.white);

    ChartPanel chartPanel = new ChartPanel(this.chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);

}

From source file:include.picture.MyBarChart.java

/**
*paintseries,category,data ????/*from  w w w .  ja v  a 2  s .co m*/
*/
private CategoryDataset getDataSet(String[] series, String[] category, double[][] data) {
    return DatasetUtilities.createCategoryDataset(series, category, data);
}