Domain axis problem (many series)

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Filoche
Posts: 26
Joined: Sat Jul 28, 2007 7:23 pm

Domain axis problem (many series)

Post by Filoche » Mon Jun 09, 2008 4:37 pm

Hi all.
I'll try to to explain my problem the best I can :)

I'm using a categorie dataset to fetch data I want on my chart. When using only 1 dataset, the new series added display fine on my chart. Notice the gap on the blue serie at the S02 which is correct.

Image

But, is I'm using a new dataset for each serie (I need to do this because I need 1 range axis per serie) it creates a new domain axis (of course). However, when superposing many series, it seems to use the first serie domain axis and thus a gap appears on the new series added if they dont have the same values on x axis (see the gap around S03).

Image

My question is the following : is it possible to use the same X axis for all the series I want to insert in my chart (i.e I want to see no data at S02 on the blue serie since I have no value for that station) ?

I hope you can understand what I'm trying to say. If no, I'll try to give more information.

Best regards and tx for your help.

ndhai
Posts: 10
Joined: Thu Jun 05, 2008 2:00 pm

Post by ndhai » Tue Jun 10, 2008 9:48 am

hi
i don't know why it doesn't work for you
see here

Image

and I get out the points in [24 - 28] on blue serie:

Image



best regards
ndhai

Filoche
Posts: 26
Joined: Sat Jul 28, 2007 7:23 pm

Post by Filoche » Tue Jun 10, 2008 12:52 pm

Hi there and tx for your reply. Thats exacly what I'm tyrying to do.

Here's a bit of code I use to create my dataset :

Code: Select all

public void CreateLineSerie(String serie, String xValues[], double yValues[],double stdev[])
	{
		final ExtendedDefaultStatisticalCategoryDataset result = new ExtendedDefaultStatisticalCategoryDataset();			
		
		for( int x = 0; x < xValues.length; x++ )		
		{
			if(stdev != null) //we want stdv on the cart
			{
				result.add(yValues[x], stdev[x], serie, xValues[x]); 				
			}
			else //dont add stdev
			{
				result.add(yValues[x],0, serie, xValues[x]);			
			}	
			
		}	
		
		CategoryPlot plot = chart.getCategoryPlot();
	    // AXIS
        NumberAxis axis = new NumberAxis(serie);
        axis.setLabelPaint(Color.BLACK);
        axis.setTickLabelPaint(Color.BLACK);        
        axis.setLabelFont(new Font("Times new roman",0,11));
        plot.setRangeAxis(pos, axis);       
        

	    plot.setDataset(pos, result);
	    CategoryItemRenderer renderer = new StatisticalLineAndShapeRenderer();
	    plot.setRenderer(pos, renderer);
	    plot.mapDatasetToRangeAxis(pos, pos);	  
	    	 
	    pos++;
	 
		
	}
As you can see, I create a new dataset everytime I need a new serie and then set it to my axis.
If you could give me a hand with this, I would greatly appreciate it.

Best regards, and ty for any help.

Filoche
Posts: 26
Joined: Sat Jul 28, 2007 7:23 pm

Post by Filoche » Thu Jun 12, 2008 1:37 pm

Hi all.

I have been trying to resolve my problem. What I was thinking was to map all the dataset to the same domain axis (Look at plot.mapDatasetToDomainAxis(pos, 0);):

Code: Select all

public void CreateLineSerie(String serie, String xValues[], double yValues[],double stdev[])
   {
      final ExtendedDefaultStatisticalCategoryDataset result = new ExtendedDefaultStatisticalCategoryDataset();         
      
      for( int x = 0; x < xValues.length; x++ )      
      {
         if(stdev != null) //we want stdv on the cart
         {
            result.add(yValues[x], stdev[x], serie, xValues[x]);             
         }
         else //dont add stdev
         {
            result.add(yValues[x],0, serie, xValues[x]);         
         }   
         
      }   
      
      CategoryPlot plot = chart.getCategoryPlot();
       // AXIS
        NumberAxis axis = new NumberAxis(serie);
        axis.setLabelPaint(Color.BLACK);
        axis.setTickLabelPaint(Color.BLACK);       
        axis.setLabelFont(new Font("Times new roman",0,11));
        plot.setRangeAxis(pos, axis);       
       

       plot.setDataset(pos, result);
       CategoryItemRenderer renderer = new StatisticalLineAndShapeRenderer();
       plot.setRenderer(pos, renderer);
       plot.mapDatasetToRangeAxis(pos, pos);    

       plot.mapDatasetToDomainAxis(pos, 0);
          
       pos++;
   
      
   }
I think all my series should "share" the same domain axis right?

I will appreciate any suggestions about that.

Best regards.

Philippe

ndhai
Posts: 10
Joined: Thu Jun 05, 2008 2:00 pm

Post by ndhai » Wed Jun 25, 2008 10:13 am

why don't like this:

Code: Select all

for( int x = 0; x < xValues.length; x++ )       
      { 
         if(stdev != null) //we want stdv on the cart 
         { 
            result.add(yValues[x], stdev[x], serie, xValues[x]);              
         } 
/*         else //dont add stdev 
         { 
            result.add(yValues[x],0, serie, xValues[x]);          
         }    */
          
      } 

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Wed Jun 25, 2008 9:38 pm

I think it would be easier to spot the problem if you posted a small self-contained demo. But check that all your datasets have the same category values (add a null y-value if you have to) and that you don't have any calls to this method in the renderer:

Code: Select all

public void setUseSeriesOffset(boolean offset);
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Filoche
Posts: 26
Joined: Sat Jul 28, 2007 7:23 pm

Post by Filoche » Mon Jul 07, 2008 4:10 pm

david.gilbert wrote:...check that all your datasets have the same category values (add a null y-value if you have to)
Hi David and ty for your reply.

The problem is most likely this.

Lets say I have 2 datasets. Each dataset have been created with his own x-axis.

And make x axis of each ds be :

ds1 (x values) = 1,2,3,4,5
ds2 (x values) = 1,3,4,5

Are you sugessting I should have :

ds1 (x values) = 1,2,3,4,5
ds2 (x values) = 1,null,3,4,5

Best regards,
Phil

Locked