2012-07-03 3 views
7

JFreeChart에서 범례를 차트 자체에 포함시킬 수 있습니까? 범례는 다음과 같이 차트의 위, 아래, 왼쪽, 오른쪽에 설정할 수 있지만 차트에 임 베딩 할 수 있습니까? JFreeChart SamplesXYTitleAnnotationDemo1에 포함 된 polt 내부의 전설을 설정하는 방법의 예입니다JFreeChart의 플롯 영역에 범례를 포함하십시오

LegendTitle legend=chart.getLegend(); 
legend.setPosition(RectangleEdge.TOP); 

답변

11

, 이것은 핵심 부분입니다 : BoxAndWhisker하여 해당 작업을 수행하는 방법

XYPlot plot = (XYPlot) chart.getPlot(); 
LegendTitle lt = new LegendTitle(plot); 
lt.setItemFont(new Font("Dialog", Font.PLAIN, 9)); 
lt.setBackgroundPaint(new Color(200, 200, 255, 100)); 
lt.setFrame(new BlockBorder(Color.white)); 
lt.setPosition(RectangleEdge.BOTTOM); 
XYTitleAnnotation ta = new XYTitleAnnotation(0.98, 0.02, lt,RectangleAnchor.BOTTOM_RIGHT); 

ta.setMaxWidth(0.48); 
plot.addAnnotation(ta); 

enter image description here

+0

플롯? 나는 사용할 애노테이션과 CategoryPlot을 알지 못한다. – CGFoX