3 Replies Latest reply: Nov 11, 2008 9:06 AM by 800282 RSS

    JFreeChart - Linegraph / x-axis values get altered

    807589
      Hello.. hope I'm posting this in the right part of the forum.. I'm trying to make a graph using JFreeChart out of some data data and I'm almost succeeding.

      I wrote the following class:
      public class GrafiekPanel extends JPanel {
          public GrafiekPanel( Meetgegevens meetgegevens, int maand, int jaar ) {
              JFreeChart freechart;
              ChartFrame chartframe;
              
              XYSeries minTemps = new XYSeries( "Mininum temperatuur", true, false );            
              XYSeries maxTemps = new XYSeries( "Maximum temperatuur", true, false );   
              
              String testString = "";
              for( Waarneming wn : meetgegevens.gegevens ) {
                  if( wn.getJaar() == jaar && wn.getMaand() == maand ) {
                      maxTemps.add( wn.getDag(), wn.getMaxTemp() / 10 ); //Conversion to degrees celcius
                      minTemps.add( wn.getDag(), wn.getMinTemp() / 10 ); //Conversion to degrees celcius
                      testString += wn.getDag()+" ";
                  }
              }
              System.out.println( testString );
              
              DefaultTableXYDataset dataset = new DefaultTableXYDataset();
              dataset.addSeries( maxTemps );
              dataset.addSeries( minTemps );
                  
              freechart = ChartFactory.createXYLineChart( "Temperaturen van "+ new Maandnaam().getNaam( maand ) 
              +" - "+ jaar, null, "Temperatuur", dataset, PlotOrientation.VERTICAL, true, true, false );
              
              chartframe = new ChartFrame ("x",freechart);
              add( chartframe.getChartPanel() );
          }
      }
      And it's almost doing what I want as I can get the following graph:
      [http://www.imagebam.com/image/1b648f18045794] (This board doesn't seem to allow the posting of images?)

      The problem I have is that along the bottom you see some nice numbers that are supposed to be the days of the month.. but JFreeChart is displaying 0.0/2,5/5.0-27.5 instead of simply 1-28.
      To confirm that the numbers going to it are actually the ones I want, this is the terminal output:
      1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 
      As JFreeChart doesn't seem to have a forum I thought I'd try my luck here as someone else might have experience with it. JFreeChart does offer very extensive documentation at [http://www.jfree.org/jfreechart/api/gjdoc/alphaindex-1.html] .. but it's a bit too extensive as I can't find out what to change to prevent it from doing what it's doing. Any help/pointers on where to look or what to change would be appreciated.

      Edited by: Axeia on Nov 11, 2008 5:41 AM

      Edited by: Axeia on Nov 11, 2008 5:45 AM