Page 1 of 1

Area Series whacky display

Posted: Wed Aug 03, 2005 9:20 pm
by 9637466
I'm attempting to create a stacked Area Series chart but the Areas do not spoon the other Areas. How do I get this to work?

The following image displays the problem accurately.
Image

Here's the code that populated the chart at run-time.

Code: Select all

private void PopulateAreaChart(SpatialData sd)
{
	tchtArea.Series.RemoveAllSeries();
	tchtArea.Series.Clear();
	Steema.TeeChart.Styles.Area areaSeries;
	tchtArea.Axes.Left.Title.Text = cmbTrait.Text;

	foreach(MapUnitGeometry mug in _mugs)
	{
		Trait t = mug.GetTrait(sd.OBJECTID);

		areaSeries = new Steema.TeeChart.Styles.Area();

		for(int i=0;i<t.PixelAttributes.values.Length;i++)
		{
			areaSeries.Add(t.PixelAttributes.values[i],
				GetTrendValue(t.PixelAttributes.frequencies,i,_trendWidth));
		}

//              areaSeries.Origin = 0;
		areaSeries.OutLine.Visible = true;
		areaSeries.OutLine.Width = 1;
		areaSeries.Title = mug.OBJECTID.ToString();
		areaSeries.AreaLines.Visible = false;

		tchtArea.Series.Add(areaSeries);

	}
	((Steema.TeeChart.Styles.Area)tchtArea.Series[0]).MultiArea = Steema.TeeChart.Styles.MultiAreas.Stacked;
	((Steema.TeeChart.Styles.Area)tchtArea.Series[0]).Origin = 0;
	((Steema.TeeChart.Styles.Area)tchtArea.Series[0]).UseOrigin = true;

}

Posted: Thu Aug 04, 2005 10:12 am
by Miguel
Hi Randy,

Have you tried fixing the origin for each areaSeries? I mean in this way:

Code: Select all

private void PopulateAreaChart(SpatialData sd) 
{ 
   tchtArea.Series.RemoveAllSeries(); 
   tchtArea.Series.Clear(); 
   Steema.TeeChart.Styles.Area areaSeries; 
   tchtArea.Axes.Left.Title.Text = cmbTrait.Text; 

   foreach(MapUnitGeometry mug in _mugs) 
   { 
      Trait t = mug.GetTrait(sd.OBJECTID); 

      areaSeries = new Steema.TeeChart.Styles.Area(); 

      for(int i=0;i<t.PixelAttributes.values.Length;i++) 
      { 
         areaSeries.Add(t.PixelAttributes.values[i], 
            GetTrendValue(t.PixelAttributes.frequencies,i,_trendWidth)); 
      } 

      areaSeries.MultiArea = Steema.TeeChart.Styles.MultiAreas.Stacked; 
      areaSeries.Origin = 0; 
      areaSeries.UseOrigin = true; 

      areaSeries.OutLine.Visible = true; 
      areaSeries.OutLine.Width = 1; 
      areaSeries.Title = mug.OBJECTID.ToString(); 
      areaSeries.AreaLines.Visible = false; 

      tchtArea.Series.Add(areaSeries); 

   } 
}
If still does not work, could you provide us the set of values for each series so that we could reproduce the issue?

You could attach the file (excel sheet or txt file) to:
[url]news://www.steema.net/steema.public.attachments[/url]

Posted: Thu Aug 04, 2005 5:00 pm
by 9637466
Your suggestion made a difference, but it's not exactly what I'm expecting.

The chart on the top represents a simple chart of the data for #7. The green trend line for the chart on the top is the same data for the #7 Area series. You can see it's a simple bell curve with mean close to zero and max around 200. I don't understand how the data is represented in the area chart for #7.

The other trend lines have the same bell curve with the mean close to zero and max of 600 and 120 for #5 and #6 repsectively. I would expect the Area stack to accumulate to a max of roughly (600 + 200 + 120) 920 - bell curves stacked on top of one another. That's what I'm trying to accomplish.

I hope this gives you some more insight, so you can help me figure this out..

The data for the Area chart is at - ftp://ftp.i3.com/pub/Steema/Chart2.xls

Image

Code: Select all

private void PopulateAreaChart(SpatialData sd)                                              
{                                                                                           
	tchtArea.Series.RemoveAllSeries();                                                         
	tchtArea.Series.Clear();                                                                   
	Steema.TeeChart.Styles.Area areaSeries;                                                    
	tchtArea.Axes.Left.Title.Text = cmbTrait.Text;                                             
                                                                                            
	foreach(MapUnitGeometry mug in _mugs)                                                      
	{                                                                                          
		Trait t = mug.GetTrait(sd.OBJECTID);                                                      
                                                                                            
		areaSeries = new Steema.TeeChart.Styles.Area();                                                                                              
                                                                                            
		for(int i=0;i<t.PixelAttributes.values.Length;i++)                                        
		{                                                                                         
			areaSeries.Add(t.PixelAttributes.values[i],                                              
				GetTrendValue(t.PixelAttributes.frequencies,i,_trendWidth));                            
                                                                                            
		}                                                                                         
                                                                                            
		areaSeries.MultiArea = Steema.TeeChart.Styles.MultiAreas.Stacked;                         
		areaSeries.Origin = 0;                                                                    
		areaSeries.UseOrigin = true;                                                              
                                                                                            
		areaSeries.OutLine.Visible = true;                                                        
		areaSeries.OutLine.Width = 1;                                                             
		areaSeries.Title = mug.OBJECTID.ToString();                                               
		areaSeries.AreaLines.Visible = false;                                                     
                                                                                            
		tchtArea.Series.Add(areaSeries);                                                          
                                                                                            
	}                                                                                          
                                                                                            
}                                                                                           

Posted: Fri Aug 05, 2005 8:47 am
by Chris
Hi Randy,

I think I can see what's happening here. If you plot three area series, all of which have *common* XValues, then they stack without a problem, e.g.

Code: Select all

	 private void InitializeChart() 
		{
			for(double i = 0; i < 200; ++i) 
			{
				if(i < 100) 
				{
					area1.Add(i, i);
					area2.Add(i, i);
					area3.Add(i, i);
				}
				else 
				{
					area1.Add(i, 200 - i);
					area2.Add(i, 200 - i);
					area3.Add(i, 200 - i);
				}
			}

			area1.MultiArea = Steema.TeeChart.Styles.MultiAreas.Stacked;
			area2.MultiArea = Steema.TeeChart.Styles.MultiAreas.Stacked;
			area3.MultiArea = Steema.TeeChart.Styles.MultiAreas.Stacked;
		}
What's happening in your case is that the three area series have different XValues, for example, the XValue -135 is present in the second series but not in the first or the third.

What I suggest is that you "normalise" you data making sure that all the XValues are shared by all the series; you can set Color.Transparent to points you don't wish to be visible.

Posted: Sat Aug 06, 2005 12:51 am
by 9637466
Thanks for the response Christopher,

I never would of thought I would have to do this but it works.

Image

Code: Select all

/// <summary>                                                                                           
/// Populate the Area Chart.  The Area chart requires the same number of XValues for each               
/// Area series.  Throwing all the XValues into the same bucket, sorting, and finding the unique        
/// was required, so that the XValue could be added to all Area Series.  Then find the matching         
/// Y value in the PixelAttributes or 0 was used for the Y values.                                      
/// </summary>                                                                                          
/// <param name="sd"></param>                                                                           
private void PopulateAreaChart(SpatialData sd)                                                          
{                                                                                                       
	// ************************************************                                                    
	// Clear out and initialize some stuff.                                                                
	tchtArea.Series.RemoveAllSeries();                                                                     
	tchtArea.Series.Clear();                                                                               
	Steema.TeeChart.Styles.Area areaSeries;                                                                
	tchtArea.Axes.Left.Title.Text = cmbTrait.Text;                                                         
	Trait t = null;                                                                                        
                                                                                                        
	ArrayList alXValues = new ArrayList();                                                                 
                                                                                                        
	// ************************************************                                                    
	// Loop thru each one of the Map Unit Geometries                                                       
	// Throw the XValues into the same ArrayList and                                                       
	// create an Area Series (add it to the chart).                                                        
	for(int mug=0;mug<_mugs.Length;mug++)                                                                  
	{                                                                                                      
		t = _mugs[mug].GetTrait(sd.OBJECTID);                                                                 
		alXValues.AddRange(t.PixelAttributes.values);                                                         
                                                                                                        
		areaSeries = new Steema.TeeChart.Styles.Area();                                                       
		areaSeries.OutLine.Visible = true;                                                                    
		areaSeries.OutLine.Width = 1;                                                                         
		areaSeries.Title = _mugs[mug].OBJECTID.ToString();                                                    
		areaSeries.AreaLines.Visible = false;                                                                 
		areaSeries.MultiArea = 
                   Steema.TeeChart.Styles.MultiAreas.Stacked;                                     
                                                                                                        
		tchtArea.Series.Add(areaSeries);                                                                      
	}                                                                                                      
                                                                                                        
	// ************************************************                                                    
	// Sort and find all the unique X values.                                                              
	int[] sorted = AppUtility.Sort((int[])alXValues.ToArray(typeof(int)));                                 
	alXValues = new ArrayList();                                                                           
                                                                                                        
	for(int i=0;i<sorted.Length-1;i++)                                                                     
	{                                                                                                      
		if (sorted[i]!=sorted[i+1])                                                                           
			alXValues.Add(sorted[i]);                                                                            
	}                                                                                                      
	if (sorted[sorted.Length-1]!=sorted[sorted.Length-2])                                                  
		alXValues.Add(sorted[sorted.Length-1]);                                                               
                                                                                                        
	int[] aryXValues =  (int[])alXValues.ToArray(typeof(int));                                             
	                                                                                                       
	// ************************************************                                                    
	// Add the unique X Values to each of the series                                                       
	// Find the Y value for each of the Map Unit Geometries                                                
	for(int x=0;x<aryXValues.Length;x++)                                                                   
	{                                                                                                      
		for(int mug=0;mug<_mugs.Length;mug++)                                                                 
		{                                                                                                     
			t = _mugs[mug].GetTrait(sd.OBJECTID);                                                                
			tchtArea[mug].Add(aryXValues[x],
                      GetX_YValue(aryXValues[x],t.PixelAttributes));                      
		}                                                                                                     
	}                                                                                                      
                                                                                                        
}