Logarithmic chart question

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Don Schoeman
Newbie
Newbie
Posts: 6
Joined: Sat Sep 06, 2003 4:00 am
Location: South Africa

Logarithmic chart question

Post by Don Schoeman » Wed Jan 07, 2004 7:19 am

I'm trying to create a chart with both the X and Y axis being logarithmic based. I have tried playing around with logarithmic axis lines and custom axis lines but currently can't get the result I'm looking for. Both the X and Y axis ranges are known beforehand but the actual series line points are not known (it's only known that the X and Y values of the series line will fall within the range of the X and Yaxis values).

Below is an image I created showing more or less what I need:
Image

Any help will be greatly appreciated!

Thanks in advance,
Don Schoeman

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Wed Jan 07, 2004 11:04 am

Hi, Don.

For simple logarithmic chart setting horizontal and vertical axis Logarithmic property to True should do the trick. But in some cases the built-in algorithm (especially dynamic axis increment) cannot calculate best increment and total number of labels. In this case you have several options:

1) Reformat and control axis labels by using TChart OnGetAxisLabel and OnGetNextAxisLabel events. This method yields good results, but it's a bit difficult to code/set it up. In OnGetAxisLabel event you can format axis labels and in OnGetNextAxisLabel event you can define label increment and total number of labels.

2) If you're using TeeChart v6 you can also use custom axis labels feature (demonstrated in TeeChart demo). In this case all you must do is specify position (value) and text for each axis label. This way you can fully customize both axis scales.
If you have TeeChart v6 then you can use method #2. It's a lot easier to code than #1.

Hope this helps - your image link is not working so I cannot be sure this is what you were looking for :D
Marjan Slatinek,
http://www.steema.com

Don Schoeman
Newbie
Newbie
Posts: 6
Joined: Sat Sep 06, 2003 4:00 am
Location: South Africa

Post by Don Schoeman » Wed Jan 07, 2004 4:17 pm

Hi Marjan,

Thanks for your reply. It is importand that you see how the image looks like. Can I perhaps email it to you instead?

Please have a look at it and tell me if it is possible to get a similar result. Unfortunately I don't have the TeeChart demo's source code to look at how method #2 can be performed. I also tried looking in the Help file but I get an error: "Cannot find the teechart6Guide.hlp Help file. Do you want to try to find the file yourself?" I have downloaded the TeeChart6.chm you provide on your website but can't find the teechart6Guide.hlp file. We bought TeeChart 6.01 with source code from you recently. Could you also tell me where I can find the source code for the TeeChart Demo?

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Thu Jan 08, 2004 6:35 am

Hi, Don.
how method #2 can be performed
The following code might get you there:

Code: Select all

  Series1.FillSampleValues(100);

  With Chart1.Axes.Bottom, Chart1.Axes.Bottom.Items do
  begin
    // Step 1: setup axis
    Grid.Style := psSolid;
    LabelsAngle := 90;
    MinorTickCount := 0;
    Logarithmic :=  True;
    SetMinMax(1,100);
    // Step 2: setup labels
    Clear;
    Add(1.0,FormatFloat('0.0',1.0));
    Add(2,' '); // only grid, no label
    Add(3,' '); // only grid, no label
    Add(5,FormatFloat('0.0',5));
    Add(7,' '); // only grid, no label
    Add(10,FormatFloat('0.0',10));
    Add(20,' '); // only grid, no label
    Add(30,' '); // only grid, no label
    Add(50,FormatFloat('0.0',50));
    Add(70,' '); // only grid, no label
    Add(100,FormatFloat('0.0',100));
  end;
Basically, I manually setup axis scale and axis labels for the logarithmic (bottom axis) plot. The same code can be used for vertical axis as well.
Cannot find the teechart6Guide.hlp Help file. Do you want to try to find the file yourself?"Could you also tell me where I can find the source code for the TeeChart Demo?
Help files, demo sources, additional tutorials are not included in source code installer. They are included in binaries installer. So, you should download and install both binaries and source code installers.
Marjan Slatinek,
http://www.steema.com

Don Schoeman
Newbie
Newbie
Posts: 6
Joined: Sat Sep 06, 2003 4:00 am
Location: South Africa

Post by Don Schoeman » Fri Jan 09, 2004 3:19 pm

Thanks for your help, after playing around with the sample you gave, I received the results I was looking for.

Post Reply