Java 隐藏jfreechart/PiePlot3D piechart上的标签
我正在尝试让jfreechart PieChart3D隐藏标签。我在文档中找不到任何东西 有人知道怎么做吗Java 隐藏jfreechart/PiePlot3D piechart上的标签,java,jfreechart,Java,Jfreechart,我正在尝试让jfreechart PieChart3D隐藏标签。我在文档中找不到任何东西 有人知道怎么做吗 <% response.setContentType("image/png"); %><%@page import="org.jfree.data.general.*"%><%@page import="org.jfree.chart.*"%><%@page import="org.jfree.chart.plot.*"%><%@pag
<% 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);
%>
事实上,这似乎是一个更简单的方法,也更短 只需自己执行标签分发匿名实现,并通过在getItemCount中返回零来假装没有要显示的标签 旧的解决方案: 不知道是否有更简单的方法,但这应该是可行的。应该是不言自明的。不显示链接将某些颜色设置为透明且不生成标签。否则就问吧
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 "";
}
});
事实上,这似乎是一个更简单的方法,也更短 只需自己执行标签分发匿名实现,并通过在getItemCount中返回零来假装没有要显示的标签 旧的解决方案: 不知道是否有更简单的方法,但这应该是可行的。应该是不言自明的。不显示链接将某些颜色设置为透明且不生成标签。否则就问吧
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 "";
}
});
这将隐藏所有标签:
plot.setLabelGenerator(null); //null means no labels
这将隐藏所有标签:
plot.setLabelGenerator(null); //null means no labels
这是我的工作:
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setTickLabelsVisible(false);
这是我的工作:
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setTickLabelsVisible(false);
所以这是你想要的吗?那么?这是你想要的吗?你检查我的答案了吗?对此不予置评,也不予接受。这对你不管用吗?或者这不是你想要的?你查过我的答案了吗?对此不予置评,也不予接受。这对你不管用吗?或者这不是你想要的?