/**
   * Creates a chart.
   *
   * @return A chart.
   */
  private static JFreeChart createChart(String symbol) {

    CategoryDataset dataset1 = createDataset1(symbol);
    NumberAxis rangeAxis1 = new NumberAxis("Jumlah");
    rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    LineAndShapeRenderer renderer1 = new LineAndShapeRenderer();
    renderer1.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    CategoryPlot subplot1 = new CategoryPlot(dataset1, null, rangeAxis1, renderer1);
    subplot1.setDomainGridlinesVisible(true);

    CategoryDataset dataset2 = createDataset2(symbol);
    NumberAxis rangeAxis2 = new NumberAxis("Jumlah");
    rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    BarRenderer renderer2 = new BarRenderer();
    renderer2.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    CategoryPlot subplot2 = new CategoryPlot(dataset2, null, rangeAxis2, renderer2);
    subplot2.setDomainGridlinesVisible(true);

    CategoryAxis domainAxis = new CategoryAxis("Tahun Periksa");
    CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(domainAxis);
    //             CombinedCategoryPlot plot = new CombinedCategoryPlot(
    //                     domainAxis, new NumberAxis("Range"));
    plot.add(subplot1, 2);
    plot.add(subplot2, 1);

    JFreeChart result = new JFreeChart("", new Font("SansSerif", Font.BOLD, 10), plot, true);
    return result;
  }
  /**
   * Creates a chart.
   *
   * @return A chart.
   */
  private static JFreeChart createChart() {

    CategoryDataset dataset1 = createDataset1();
    NumberAxis rangeAxis1 = new NumberAxis("Value");
    rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    LineAndShapeRenderer renderer1 = new LineAndShapeRenderer();
    renderer1.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    CategoryPlot subplot1 = new CategoryPlot(dataset1, null, rangeAxis1, renderer1);
    subplot1.setDomainGridlinesVisible(true);

    CategoryDataset dataset2 = createDataset2();
    NumberAxis rangeAxis2 = new NumberAxis("Value");
    rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    BarRenderer renderer2 = new BarRenderer();
    renderer2.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    CategoryPlot subplot2 = new CategoryPlot(dataset2, null, rangeAxis2, renderer2);
    subplot2.setDomainGridlinesVisible(true);

    CategoryAxis domainAxis = new CategoryAxis("Category");
    CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(domainAxis);
    plot.add(subplot1, 2);
    plot.add(subplot2, 1);

    JFreeChart chart =
        new JFreeChart(
            "Combined Domain Category Plot Demo", new Font("SansSerif", Font.BOLD, 12), plot, true);
    ChartUtilities.applyCurrentTheme(chart);
    return chart;
  }
Exemplo n.º 3
0
  private void initCharts() {
    dataset = new DefaultCategoryDataset();

    // XY:s
    NumberAxis rangeAxis1 = new NumberAxis("Values");
    rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    LineAndShapeRenderer renderer1 = new LineAndShapeRenderer();
    renderer1.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    trendPlot = new CategoryPlot(dataset, null, rangeAxis1, renderer1);
    trendPlot.setDomainGridlinesVisible(true);

    // Box:
    NumberAxis rangeAxis2 = new NumberAxis("Values");
    rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    BarRenderer renderer2 = new BarRenderer();
    renderer2.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    sizePlot = new CategoryPlot(dataset, null, rangeAxis2, renderer2);
    sizePlot.setDomainGridlinesVisible(true);
  }