[英]Hide Labels from JFree Spider Chart
我試圖使用JFree庫隱藏蜘蛛圖表上的所有標簽。
我一直認為以下行會起作用,但是當我添加它時我收到錯誤。
webPlot.setLabelGenerator(null);
我的代碼:
private static JFreeChart createSpiderChart(DefaultCategoryDataset dataset) {
SpiderWebPlot webPlot = new SpiderWebPlot(dataset);
Font labelFont = new Font("Arial", Font.BOLD, 10);
CategoryToolTipGenerator tooltipGenerator = new StandardCategoryToolTipGenerator();
tooltipGenerator.generateToolTip(dataset, 1, 0);
Color back_color = new Color(255,255,255,0);
webPlot.setOutlineVisible(false);
webPlot.setLabelFont(labelFont);
webPlot.setSeriesPaint(0, java.awt.Color.decode("#000000"));
webPlot.setSeriesPaint(1, java.awt.Color.decode("#209ad4"));
webPlot.setBackgroundPaint(back_color);
webPlot.setLabelGenerator(null); /** THIS THROWS AN ERROR **/
JFreeChart chart = new JFreeChart("", null /* JFreeChart.DEFAULT_TITLE_FONT */, webPlot, false);
chart.setBorderVisible(false);
ImageIcon icon = new ImageIcon("C:\\TestCharts\\report-assets\\chart-bg.gif");
chart.setBackgroundImage(icon.getImage());
return chart;
}
我的錯誤:
java.lang.IllegalArgumentException: Null 'generator' argument.
at org.jfree.chart.util.ParamChecks.nullNotPermitted(ParamChecks.java:65)
at org.jfree.chart.plot.SpiderWebPlot.setLabelGenerator(SpiderWebPlot.java:993)
at JavaAgent.createSpiderChart(Unknown Source)
at JavaAgent.NotesMain(Unknown Source)
at lotus.domino.AgentBase.runNotes(Unknown Source)
at lotus.domino.NotesThread.run(Unknown Source)
任何想法和提前謝謝。
setLabelGenerator()
API非常清楚: null not permitted
。 您可以嘗試在CategoryDataset
為columnKey
使用不同數量的空格。
適合我(JFreeChart 1.5.0):
webplot.setLabelGenerator(new StandardCategoryItemLabelGenerator() {
@Override
public String generateColumnLabel(CategoryDataset dataset, int column) {
return "";
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.