0

I am currently migrating an application from a windows environment to a Redhat one. This application is using JfreeChart 1.0.6. It is a web app deployed in a tomcat 7 on a Redhat headless environment running on a Open-JDK6).

I obtain the following PNG. It looks like handwrited chart and everything is shifted towards the top of the image.

Did someone already encounter such issue and got a fix?

See my chart below :

image http://img194.imageshack.us/img194/4489/graph20120801105017.png

See below the piece of code generating the chart :

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);
    }
Albaku
  • 82
  • 8
  • Font substitution may have occurred. Please edit your question to include an [sscce](http://sscce.org/) that produces the chart shown. – trashgod Aug 01 '12 at 20:15

1 Answers1

0

I found the cause of the problem :

  • I logged the font use by JfreeChart : it was SansSerif.plain
  • Looking into OpenJDK, in the file fontconfig.properties, I found :

sansserif.plain.latin-1=DejaVu LGC Sans

filename.DejaVu_LGC_Sans=/usr/share/fonts/dejavu-lgc/DejaVuLGCSans.ttf

I didnt have this font installed on my machine, so I installed it and it went fine.

Albaku
  • 82
  • 8