1

Java Web アプリケーションの BAR チャートに次の値を表示します。9.46373791E8 9.45942547E8 9.45559945E8 9.45187023E8 9.44856693E8 9.44417826E8 9.44007878E8

ご覧のとおり、値は非常に近く、わずかな違いがあります。Jfreechart を使用して棒グラフを生成すると、すべての棒がほぼ同じ高さで表示され、違いを視覚的に伝える方法がありません。したがって、(0,0) を (0,9) に変更して、x 軸が y 軸の 9 番になるようにします。バーが表す実際の値をバーの上のどこかに表示したいと考えています。

アイデアを提案してください。私は以下を試しましたが、うまくいきませんでした

    Double d=(double) 9;
ValueAxis rangeAxis = plot.getRangeAxis();
rangeAxis.setLowerMargin(d);

編集:これは参考のための私のオリジナルのプログラムです

JFreeChart chart =
            ChartFactory.createBarChart(
                    title,
            "File Date",
            "File Size",
            dataset,
            PlotOrientation.VERTICAL,
            true,
            true,
            false);
         chart.setBackgroundPaint(Color.white);



      // Set the background color of the chart
        chart.getTitle().setPaint(Color.DARK_GRAY);
        chart.setBorderVisible(true);
        // Adjust the color of the title
        CategoryPlot plot = chart.getCategoryPlot();
        plot.getRangeAxis().setLowerBound(d);
        // Get the Plot object for a bar graph

        plot.setBackgroundPaint(Color.white);     
        plot.setRangeGridlinePaint(Color.blue);
        CategoryItemRenderer renderer = plot.getRenderer();
        renderer.setSeriesPaint(0, Color.decode("#00008B"));
4

2 に答える 2

1

この例の y 軸は のインスタンスであるため、軸NumberAxisでメソッドを呼び出すことができますsetAutoRangeIncludesZero()(フラグの新しい値に false を渡します)。
次に、新しいデータを に追加してもdataset、軸の範囲は正しく更新されます (一方、 を呼び出すsetLowerBound()と、指定した下限で軸の範囲が固定され、自動範囲機能が無効になります)。

于 2013-09-09T19:48:00.030 に答える