2012-03-12 5 views
0

왼쪽에 세로 축이있는 일반적인 가로 막 대형 차트를 사용한다고 가정합니다. 차트의 왼쪽과 세로 축 사이의 공간을 어떻게 제어 할 수 있습니까? 축에 표시된 눈금 레이블이 커질 때마다 눈금 레이블을 수용 할 수 있도록 축을 오른쪽으로 밀어 넣는 아이디어입니다. 축을 차트의 전체 너비의 20 %로 항상 표시해야한다고 지정할 수 있습니까? 가능합니까?JFreeChart 축 위치

답변

0

막대 차트의 도메인은 일반적으로 CategoryAxis이므로 setLowerMargin(), setUpperMargin()setCategoryMargin()으로 실험 할 수 있습니다.

// 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을 정의 할 수 있습니다 : 당신은 그냥 차트 이미지를 만드는 가정 http://www.jfree.org/jfreechart/api/gjdoc/org/jfree/chart/plot/XYPlot.html#setFixedRangeAxisSpace:AxisSpace

:

0

당신은 범위 축에 고정 축 공간을 설정해야 모든 Graphics2D rigamarole을 통해, 그러나 이것은 내가 과거에 그것을 한 방법입니다.