0
我試圖以百分比顯示我的時間圖上的值。我的代碼是目前在TimeSeriesChart中將座標軸更改爲百分比
TimeSeries ts = new TimeSeries("Test");
ts.add(new Month(2,2001), 50);
ts.add(new Month(2,2002), 70);
TimeSeriesCollection ts1 = new TimeSeriesCollection();
ts1.addSeries(ts);
JFreeChart chart = ChartFactory.createTimeSeriesChart("test", "x", "y", ts1, true, true,false);
XYPlot plot = (XYPlot) chart.getXYPlot();
NumberAxis axis = (NumberAxis) plot.getRangeAxis();
axis.setTickUnit(new NumberTickUnit(10));
DecimalFormat format = new DecimalFormat("#%");
axis.setNumberFormatOverride(format);
axis.setRange(0, 100);
ChartPanel chartPanel = new ChartPanel(chart);
這確實顯示比例,但它們顯示爲1000%,2000%等。我想他們是10%,20%等,有誰知道我在哪裏呢?