JFREECHART/PIEPLOT3D PIEECHART의 레이블을 숨 깁니다
-
05-07-2019 - |
문제
나는 JfreeChart piechart3d를 레이블을 숨기려고 노력하고 있습니다. 문서에서 아무것도 찾을 수 없습니다.
누구 든지이 작업을 수행하는 방법을 알고 있습니까?
<% response.setContentType("image/png"); %><%@page import="org.jfree.data.general.*"%><%@page import="org.jfree.chart.*"%><%@page import="org.jfree.chart.plot.*"%><%@page import="java.awt.Color" %><%
DefaultPieDataset ds = (DefaultPieDataset)session.getAttribute("usagePieOutputDataset");
JFreeChart chart = ChartFactory.createPieChart3D
(
null, // Title
ds, // Dataset
false, // Show legend
false, // Use tooltips
false // Configure chart to generate URLs?
);
chart.setBackgroundPaint(Color.WHITE);
chart.setBorderVisible(false);
PiePlot3D plot = ( PiePlot3D )chart.getPlot();
plot.setDepthFactor(0.0);
plot.setLabelOutlinePaint(Color.LIGHT_GRAY);
plot.setLabelFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 10));
ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart, 150, 144);
%>
http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/plot/pieplot3d.html
해결책
이것은 모든 레이블을 숨 깁니다.
plot.setLabelGenerator(null); //null means no labels
다른 팁
실제로 이것은 훨씬 쉬운 방법이며 훨씬 짧은 것 같습니다.
레이블 배포를 직접 (익명 구현) 만 수행하고 0을 반환하여 표시 할 레이블이없는 척하십시오. getItemCount()
.
plot.setLabelDistributor(new AbstractPieLabelDistributor() {
public int getItemCount() { return 0; }
public void distributeLabels(double minY,double height) {}
});
오래된 해결책 :
더 쉬운 방법이 있는지 모르지만 이것이 효과가 있어야합니다. 자기 설명이어야합니다. 링크를 보여주지 마십시오. 일부 색상은 투명하고 레이블을 생성하지 않습니다. 그렇지 않으면 물어보세요.
Color transparent = new Color(0.0f,0.0f,0.0f,0.0f);
plot.setLabelLinksVisible(Boolean.FALSE);
plot.setLabelOutlinePaint(transparent);
plot.setLabelBackgroundPaint(transparent);
plot.setLabelShadowPaint(transparent);
plot.setLabelGenerator(new PieSectionLabelGenerator(){
@Override
public AttributedString generateAttributedSectionLabel(PieDataset dataset, Comparable key) {
return new AttributedString("");
}
@Override
public String generateSectionLabel(PieDataset dataset, Comparable key) {
return "";
}
});
이것은 나를위한 일 :
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setTickLabelsVisible(false);
제휴하지 않습니다 StackOverflow