Page 1 of 1

[SOLVED] Forcing values on Bottom Axis

Posted: Wed May 31, 2006 1:07 pm
by 9346307
I need to see all possibles X 'labels' (eg. '125' , '250', '500', '1000' ...) on the BottomAxis, but it doesn't work if the first Series miss one of this values.

For example :

Code: Select all

     Chart1[0].Clear;
     Chart1[0].AddXY(0,20,'125');
     Chart1[0].AddXY(1,30,'250');
     // No Value for '500'
     Chart1[0].AddXY(3,30,'1000');
     Chart1[0].AddXY(4,50,'2000');

     Chart1[1].Clear;
     Chart1[1].AddXY(0,10,'125');
     // No Value for '250'
     Chart1[1].AddXY(2,100,'500');
     Chart1[1].AddXY(3,200,'1000');
     Chart1[1].AddXY(4,30,'2000');
gives :

Image

How to 'force' the value '500' to appear on the BottomAxis ? Eg, I want to get this :

Image

But :

1) I don't want to swap series, because each series might have a missing values.
2) I don't want to use AddNullXY, as I need continuous lines.

Can someone help ?

Posted: Wed May 31, 2006 1:17 pm
by narcis
Hi Kitry,

Then the best option may be using custom labels as shown in the All Features\Welcome !\Axes\Labels\Custom labels example at TeeChart features demo, available at TeeChart's program group.

Posted: Wed May 31, 2006 1:29 pm
by 9346307
Yes, that's perfect !

I was too much focused on the series, and I didn't take care of the Axis properties.

Adding the following code works :

Code: Select all

 with Chart1.Axes.Bottom do
  begin
        Items.Clear;  // remove all custom labels
        Items.Add(0,'125');
        Items.Add(1,'250');
        Items.Add(2,'500');
        Items.Add(3,'1000');
        Items.Add(4,'2000');
 end;
Thank you NarcĂ­s :D

Posted: Wed May 31, 2006 1:56 pm
by narcis
You're welcome Kytry.

I'm happy to hear my suggestion was helpful.

Posted: Wed Jul 12, 2006 9:10 am
by 9346307
In this particular case (see above), I have a problem for Marks Style.

I know that all possible styles are :

smsValue, smsPercent, smsLabel, smsLabelPercent, smsLabelValue, smsLegend, smsPercentTotal, smsLabelPercentTotal, smsXValue, smsXY

but none of them can send me the printed values on the bottom axis.

For exemple :

SmsXValue returns '0' , '1' , '2' ....where I would like to see '125' , '250' , '500'.

I tried all possible styles and none of them could return '125' , '250' , '500'.


Any tips for that ?

Posted: Wed Jul 12, 2006 9:57 am
by narcis
Hi Kitry,

It works fine for me here using the code below except for that series marks are not drawn for those points not existing in one of the series (no mark for '500' in Chart1[0] and no mark for '250' in Chart1[1]). If that's not what you are looking for let us know and we will try to find another solution.

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1[0].Clear;
  Chart1[0].AddXY(0,20,'125');
  Chart1[0].AddXY(1,30,'250');
  // No Value for '500'
  Chart1[0].AddXY(3,30,'1000');
  Chart1[0].AddXY(4,50,'2000');

  Chart1[0].Marks.Style:=smsLabel;


  Chart1[1].Clear;
  Chart1[1].AddXY(0,10,'125');
  // No Value for '250'
  Chart1[1].AddXY(2,100,'500');
  Chart1[1].AddXY(3,200,'1000');
  Chart1[1].AddXY(4,30,'2000');

  Chart1[1].Marks.Style:=smsLabel;


  with Chart1.Axes.Bottom do
  begin
      Items.Clear;  // remove all custom labels
      Items.Add(0,'125');
      Items.Add(1,'250');
      Items.Add(2,'500');
      Items.Add(3,'1000');
      Items.Add(4,'2000');
  end;
end;

Posted: Wed Jul 12, 2006 1:07 pm
by 9346307
My mistake.

It doesn't work because I was doing

Code: Select all

Chart1[0].AddXY(0,20);

with Chart1.Axes.Bottom do 
  begin 
      Items.Clear;  // remove all custom labels 
      Items.Add(0,'125'); 
      Items.Add(1,'250'); 
      Items.Add(2,'500'); 
      Items.Add(3,'1000'); 
      Items.Add(4,'2000'); 
  end; 
 
instead of

Code: Select all

Chart1[0].AddXY(0,20,'125');

with Chart1.Axes.Bottom do 
  begin 
      Items.Clear;  // remove all custom labels 
      Items.Add(0,'125'); 
      Items.Add(1,'250'); 
      Items.Add(2,'500'); 
      Items.Add(3,'1000'); 
      Items.Add(4,'2000'); 
  end; 
 

Sorry about that & Thanks for your help :)