2012-03-12 112 views
0

左の縦軸を持つ共通の棒グラフを想定します...チャートの左側と縦軸の間のスペースをどうすれば制御できますか?軸上に表示される目盛ラベルが大きくなるたびに、軸が目盛りラベルに対応するように右にプッシュされるという考えがあります。私は、軸がグラフの全幅の20%で常に表示されるべきであることを指定できるようにしたいと考えています。これは可能ですか?JFreeChartの軸の位置

答えて

0

通常、棒グラフにはドメインのCategoryAxisがあるため、setLowerMargin(),setUpperMargin()およびsetCategoryMargin()を試してみるとよいでしょう。

0

あなたは範囲軸に固定された軸のスペースを設定する必要があります。 http://www.jfree.org/jfreechart/api/gjdoc/org/jfree/chart/plot/XYPlot.html#setFixedRangeAxisSpace:AxisSpace

あなただけのチャート画像を作成していると仮定:

// Get your plot from the chart object.. 
XYPlot plot = (XYPlot)chart.getPlot(); 

// Create an instance of the image so we can do some calculations 
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); 

// Create an instance of the Graphics2D from your image 
Graphics2D g2 = image.createGraphics(); 

// Get the reserve space that jfree chart sets aside for the axis 
AxisSpace space = yAxis.reserveSpace(g2, plot, new Rectangle(width,height), plot.getRangeAxisEdge(), plot.getFixedRangeAxisSpace()); 

// Give that space a fixed width 
space.setLeft(fixedAxisWidth); 

// Set it in the plot 
plot.setFixedRangeAxisSpace(space); 

あなただけ行くことなくAxisSpaceを定義することができるかもしれませんすべてのGraphics2D rigamaroleを通じて、これは私が過去にそれをやった方法です。

関連する問題