Page 1 of 1

Custom Axes : subdivision of "axes"

Posted: Mon Feb 07, 2005 2:33 pm
by 9340780
Hi,

I would like to recopy below each custom axes the same subdivision as the bottom axe. Here is a picture :
Image

I do not know how to get the step of subdivision and/or where it begins etc.
As you can see, I've already implemented a code, in the AfterDraw event, who draws the main line.

Thank you for your help!
Cordially,
Rodrigue

Posted: Mon Feb 07, 2005 2:33 pm
by 9340780
Here is the link of the picture :
http://cjoint.com/?chpHko5gIK

Posted: Mon Feb 07, 2005 3:30 pm
by narcis
Hi Rodrigue,

Could you please be more specific? What do you refer when speaking about subdivision?

You can copy one axis from another custom or default axis doing:

Code: Select all

Chart1.CustomAxes[1]:=Chart1.CustomAxes[0];
or

Code: Select all

Chart1.CustomAxes[1]:=Chart1.LeftAxis;
And after having copied it you can change it's specific properties.

Posted: Mon Feb 07, 2005 4:09 pm
by 9340780
Hi,

In fact it is not an axis. It is a drawing! I separate several graphs (here 3) by using opaque zone (as in your examples).
For the moment, I separate these various opaque zones by a line from 2 pixels width.

Code: Select all

void __fastcall TForm1::AfterDrawSeries(TObject *Sender)
{
   ...
   Chart1->Canvas->Pen->Width = 2;
   Chart1->Canvas->Pen->Color = clBlack;

   Chart1->Canvas->Line
   (
      Chart1->ChartRect.Left,
      Series1->GetVertAxis->IEndPos,
      Chart1->ChartRect.Right,
      Series1->GetVertAxis->IEndPos
   );

   Chart1->Canvas->Line
   (
      Chart1->ChartRect.Left,
      Series2->GetVertAxis->IEndPos,
      Chart1->ChartRect.Right,
      Series2->GetVertAxis->IEndPos
   );

I would like that this "line" will be a little more complex.
I would like to make it resemble to the axis bottom (without labels)...
Please, look at my picture.
I've copied exactly what I want on the second axis.

Cordially,
Rodrigue

Posted: Tue Feb 08, 2005 11:59 am
by 9340780
If you don't understant what I woud like, I can give more details ....

Posted: Wed Feb 09, 2005 7:35 am
by Marjan
Hi.

Yes, that't be great (as I cannot see the image you posted in this thread). Please send more detailed description directly to my address at "marjan at steema dot com". Tnx.

Posted: Fri Feb 11, 2005 10:39 am
by Marjan
9340780 wrote:If you don't understant what I woud like, I can give more details ....
Ok, got your email. In your case there is a simple solution. If you want to duplicate one axis (draw it multipe times over chart canvas), then all you must do is use TChartAxis.CustomDraw method to draw axis at specific screen coordinate. Example (code placed in TChart OnBeforeDrawSeries event!):

Code: Select all

var pos: Integer;
begin

  // Draw two axes at 100px and 220px
  pos := 100;
  Chart1.Axes.Bottom.CustomDraw(pos+10,pos+30,pos,False);

  pos := 220;
  Chart1.Axes.Bottom.CustomDraw(pos+10,pos+30,pos,False);
end;


Posted: Fri Feb 11, 2005 11:15 am
by 9340780
Thanks for your reply :D!

Your method works but I don't want the text.
If I set :

Code: Select all

Chart->Axes->Bottom->Labels = false;
The text is not draw but the litte line too :(

I saw on an other post that I can use the event OnGetMarkText.
So I would like to draw Text on the bottom Axe. When I use CustomDraw I don't want to draw Text. How to do that ?

Cordially,
Rodrigue [/url]

Posted: Mon Feb 14, 2005 10:13 am
by Marjan
Hi.

OnGetMarkText is not the best approach. Instead, adding a single line of code might works perfectly:

Code: Select all

procedure TForm1.Chart1BeforeDrawSeries(Sender: TObject);
var oldShowLabels : boolean;
var oldTicksOnLabels : boolean;
begin
  oldShowLabels := Chart1.Axes.Bottom.Labels;
  oldTicksOnLabels := Chart1.Axes.Bottom.TickOnLabelsOnly;

  // custom settings for additiona "copies"
  Chart1.Axes.Bottom.TickOnLabelsOnly := False;
  Chart1.Axes.Bottom.Labels := False;
  Chart1.Axes.Bottom.CustomDraw(100,120,80,False);
  Chart1.Axes.Bottom.CustomDraw(150,170,130,False);

  Chart1.Axes.Bottom.Labels := oldShowLabels;
  Chart1.Axes.Bottom.TickOnLabelsOnly := oldTicksOnLabels;
end;