我目前正在将应用程序从Windows环境迁移到Redhat。此应用程序正在使用JfreeChart 1.0.6。它是在Open-JDK6上运行的Redhat无头环境中的tomcat 7中部署的Web应用程序。
我获得了以下PNG。它看起来像是一个手写的图表,一切都转移到了图像的顶部。
有人已经遇到过这样的问题并得到了修复吗?
请参阅下面的图表:
image http://img194.imageshack.us/img194/4489/graph20120801105017.png
见下面生成图表的代码:
FacesContext facesContext = FacesContext.getCurrentInstance();
ServletContext servlet = (ServletContext)facesContext.getExternalContext().getContext();
HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
String path = null;
if (null != servlet.getRealPath("/"))
{
path = servlet.getRealPath("/");
}
else
{
path = servlet.getResource("/").getPath();
}
File stockageImg = new File(path+Constants.CHEMIN_GRAPH+CM50Util.dateHeureJour()+Constants.EXTENSION_GRAPH);
ChartRenderingInfo info = new ChartRenderingInfo (new StandardEntityCollection());
DefaultXYDataset dataset = new DefaultXYDataset();
XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
try
{
dataset.addSeries("CM moyen Annuel", courbeRef);
dataset.addSeries("CM non dépassé plus de 5% du temps", courbe95);
//creation du graphique
JFreeChart chart = ChartFactory.createXYLineChart(
"Courbes de décroissance",
"Distance en m\u00E8tre",
"Champ",
dataset,
PlotOrientation.VERTICAL,
true,
false,
false);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(renderer);
IntervalMarker intervalIncertitude = new IntervalMarker(Double.parseDouble(resultDistanceMin.replace(Constants.UNITE_DISTANCE, "")), Double.parseDouble(resultDistanceMax.replace(Constants.UNITE_DISTANCE, "")));
intervalIncertitude.setPaint(new Color(222, 222, 255, 128));
plot.addDomainMarker(intervalIncertitude, Layer.BACKGROUND);
Marker distanceTiers = new ValueMarker(Double.parseDouble(resultDistance.replace(Constants.UNITE_DISTANCE, "")));
distanceTiers.setPaint(Color.BLACK);
plot.addDomainMarker(distanceTiers);
renderer.setSeriesPaint(0, Color.GREEN);
renderer.setSeriesPaint(1, Color.BLUE);
ChartUtilities.saveChartAsPNG(stockageImg, chart, 800, 400, info);
} catch (Exception e) {
log.error("erreur generation graphique ",e);
}
答案 0 :(得分:0)
我找到了问题的原因:
sansserif.plain.latin-1 = DejaVu LGC Sans
filename.DejaVu_LGC_Sans =的/ usr /共享/字体/ DEJAVU-LGC / DejaVuLGCSans.ttf
我没有在我的机器上安装此字体,所以我安装了它并且它运行良好。