我正在strut2
使用JFReeChart
1.0.13
还有一些原因 ai 不能使用ChartUtilities.apply CurrentTheme
。图书馆已导入。
我想尝试其中的一个例子。
但它例外:
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:722) Caused by: java.lang.NoSuchMethodError: org.jfree.chart.ChartUtilities.applyCurrentTheme(Lorg/jfree/chart/JFreeChart;)V
在
我尝试使用public static ChartTheme getChartTheme()
但结果相同
private static JFreeChart createChart(CategoryDataset categorydataset)
{
JFreeChart jfreechart = ChartFactory.createBarChart("Open Source Projects By Licence", "Licence", "Project Count", categorydataset, PlotOrientation.HORIZONTAL, false, true, false);
TextTitle texttitle = new TextTitle("Source: Freshmeat (http://www.freshmeat.net/)", new Font("Dialog", 0, 10));
texttitle.setPosition(RectangleEdge.BOTTOM);
jfreechart.addSubtitle(texttitle);
**ChartUtilities.applyCurrentTheme(jfreechart);**
CategoryPlot categoryplot = (CategoryPlot)jfreechart.getPlot();
categoryplot.setDomainGridlinesVisible(true);
categoryplot.getDomainAxis().setMaximumCategoryLabelWidthRatio(0.8F);
NumberAxis numberaxis = (NumberAxis)categoryplot.getRangeAxis();
numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
BarRenderer barrenderer = (BarRenderer)categoryplot.getRenderer();
barrenderer.setDrawBarOutline(false);
StandardCategoryToolTipGenerator standardcategorytooltipgenerator = new StandardCategoryToolTipGenerator("{1}: {2} projects", new DecimalFormat("0"));
barrenderer.setBaseToolTipGenerator(standardcategorytooltipgenerator);
GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64));
barrenderer.setSeriesPaint(0, gradientpaint);
return jfreechart;
}
它如何解决这个问题?
如果我评论此行,则没有错误,但图表不好。
编辑:
我按照 Roman C 的建议将版本升级到 1.0.15 之后问题得到解决。