0

別のカテゴリの棒グラフをプロットしたいと思います。グラフの各カテゴリは、異なる色で表す必要があります。

以下は私のコードです:

JFreeChart chart = 
         ChartFactory.createBarChart("Comparison between the average of 2 values",
         XAXIS_NAME, YAXIS_NAME, dataSet, PlotOrientation.VERTICAL, true, true,
         false);    


    final CategoryPlot plot = chart.getCategoryPlot();
    chart.setBackgroundPaint(Color.white);       
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    BarRenderer renderer=new BarRenderer();

  System.out.print( "set the range axis to display integers only...");
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

      System.out.print( "disable bar outlines...");
    renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    renderer.setMaximumBarWidth(0.10);


      System.out.print( "set up gradient paints for series...");
final GradientPaint gp0 = new GradientPaint(
        0.0f, 0.0f, Color.blue, 
        0.0f, 0.0f, Color.lightGray
    );
    final GradientPaint gp1 = new GradientPaint(
        0.0f, 0.0f, Color.green, 
        0.0f, 0.0f, Color.lightGray
    );

    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
4

0 に答える 0