0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

JFreeChart-インターヴァルチャート-DefaultIntervalCategoryDataset

Last updated at Posted at 2019-07-04

目次 ⇒ JFreeChartサンプル

package jp.avaj.lib.chart;

import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.Plot;
import org.jfree.chart.renderer.category.IntervalBarRenderer;
import org.jfree.data.category.DefaultIntervalCategoryDataset;

/**
■ JFreeChart-インターヴァルチャート-DefaultIntervalCategoryDataset
・データセットにはDefaultIntervalCategoryDatasetを使用する.
・レンダラにはIntervalBarRendererを使用する

 */
public class Chart11_01 {
  // 目次-インターヴァルチャート(IntervalChart)
  A_Chart11 a_Chart11;
  // 目次-Artery-JFreeChart用のライブラリ
  A_Chart00 a_LibChartSampeContents;

  public static void main(String[] args) {
    // 表示データの作成
    DefaultIntervalCategoryDataset dataSet = null;
    {
      // 商品名
      final String[] catKeys = {"A","B","C","D","E"};
      // 日ごとの売り上げの最小値
      final double[][] lows =  {
        {50,30,34,33,60}, // 1-3
        {55,40,45,37,60}  // 4-6
      };
      // 日ごとの売り上げの最大値
      final double[][] highs = {
        {55,48,70,48,65}, // 1-3
        {60,45,75,50,70}, // 4-6
      };
      dataSet = new DefaultIntervalCategoryDataset(lows,highs);
      // 商品名をカテゴリキーとして設定
      dataSet.setCategoryKeys(catKeys);
      // 対象期間をシリーズキーとして設定
      dataSet.setSeriesKeys(new String[] {"1月~3月","4月~6月"});
    }
    // 軸の設定
    CategoryAxis xAxis = new CategoryAxis("商品");
    NumberAxis yAxis = new NumberAxis("売上");
    // レンダラの設定
    IntervalBarRenderer renderer = new IntervalBarRenderer();
    // Plotの作成
    CategoryPlot plot = new CategoryPlot(dataSet,xAxis,yAxis,renderer);
    //
    JFreeChart jfreeChart = new JFreeChart("売上の最小と最大",(Plot)plot);
    ChartFrame cFrame = new ChartFrame("売上の最小と最大",(JFreeChart)jfreeChart);
    cFrame.pack();
    cFrame.setVisible(true);
  }
}

無題.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?