Example usage for org.jfree.chart.plot CombinedRangeCategoryPlot add

List of usage examples for org.jfree.chart.plot CombinedRangeCategoryPlot add

Introduction

In this page you can find the example usage for org.jfree.chart.plot CombinedRangeCategoryPlot add.

Prototype

public void add(CategoryPlot subplot, int weight) 

Source Link

Document

Adds a subplot and sends a PlotChangeEvent to all registered listeners.

Usage

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

/**
 * Creates a chart.// w  ww.  j  av  a  2s .c o  m
 *
 * @return A chart.
 */
private JFreeChart createChart() {

    final CategoryDataset dataset1 = createDataset1();
    final CategoryAxis domainAxis1 = new CategoryAxis("Class 1");
    domainAxis1.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    //        domainAxis1.setMaxCategoryLabelWidthRatio(5.0f);
    final LineAndShapeRenderer renderer1 = new LineAndShapeRenderer();
    renderer1.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    final CategoryPlot subplot1 = new CategoryPlot(dataset1, domainAxis1, null, renderer1);
    subplot1.setDomainGridlinesVisible(true);

    final CategoryDataset dataset2 = createDataset2();
    final CategoryAxis domainAxis2 = new CategoryAxis("Class 2");
    domainAxis2.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    //    domainAxis2.setMaxCategoryLabelWidthRatio(5.0f);
    final BarRenderer renderer2 = new BarRenderer();
    renderer2.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    final CategoryPlot subplot2 = new CategoryPlot(dataset2, domainAxis2, null, renderer2);
    subplot2.setDomainGridlinesVisible(true);

    final ValueAxis rangeAxis = new NumberAxis("Value");
    final CombinedRangeCategoryPlot plot = new CombinedRangeCategoryPlot(rangeAxis);
    plot.add(subplot1, 3);
    plot.add(subplot2, 2);
    plot.setOrientation(PlotOrientation.HORIZONTAL);

    final JFreeChart result = new JFreeChart("Combined Range Category Plot Demo",
            new Font("SansSerif", Font.BOLD, 12), plot, true);
    //      result.getLegend().setAnchor(Legend.SOUTH);
    return result;

}