Polar axis labels just duplicate LeftAxis

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Nick
Newbie
Newbie
Posts: 14
Joined: Wed Feb 13, 2008 12:00 am

Polar axis labels just duplicate LeftAxis

Post by Nick » Tue May 26, 2009 11:25 am

Hi,

I'm having a problem plotting PolarSeries that use separate axes. I'd like things to work the same way as linear plots, where I can assign one LineSeries to the LeftAxis and a second one to the RightAxis (or even a custom axis) and display two different quantities at once, on different scales.

Here's an illustration of what happens when I try it. In the chart below, I've enabled the left and right axes (in the polar chart, left displays as the lower axis, and right as the uppper one). I created two polar series - Series1 (the blue one) and Series2 (orange) - and set Series1's vertical axis to aLeftAxis, and Series2's to aRightAxis. I manually set the left axis to minimum 0, maximum 1000, and the right axis to min 0, max 2000. Then I set Series2's data source to Series1.

So, I should expect Series2 to be a half-size copy of Series1 (which it is) but with the upper ('right') axis running from 0-2000 and showing that the values are the same as in Series1. Instead, the scale is just a copy of the left axis, and displays 0-1000. What is wrong with the right axis labels?

Image

I'm running Windows XP SP3, RAD Studio 2007 and TeeChart 8.04.

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Tue May 26, 2009 1:16 pm

Hi Nick,

I'm afraid that Polar series wasn't thought to allow this and it's not possible to assign more than one custom axis to series' vertical axes (or vertical). I've added the request to the wish list (TV52014183).
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Nick
Newbie
Newbie
Posts: 14
Joined: Wed Feb 13, 2008 12:00 am

Post by Nick » Tue May 26, 2009 2:12 pm

Thanks Yeray,

It looks like it's just the axis labels that would need changing to make it work. The axes are, in other respects, independent - e.g. they can have different titles, and series assigned to them scale properly as the axis range is changed, etc. It's just the labels that read the same as the LeftAxis.

Just to be clear, I didn't particularly need to assign the same series to more than one axis. I just wanted to assign different series to different 'vertical' axes, same as I can on a linear chart. I only used series from the same data source in my post because it illustrated the point (that the second series was being plotted, correctly, as a small version of the original, but the labels were incorrect).

If you can think of something that might give me a work-around, let me know and I'll be happy to investigate the details myself (maybe something with the OnDrawLabel event?).

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Tue May 26, 2009 2:45 pm

Hi Nick,

Yes, if you only want to change Axis labels, you could do something as follows:

Code: Select all

procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
  Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
var Relation: Double;
begin
  if Sender = Chart1.Axes.Right then
  begin
    Relation := 2;
    LabelText := FloatToStr(StrToFloat(LabelText) / Relation);
  end;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Nick
Newbie
Newbie
Posts: 14
Joined: Wed Feb 13, 2008 12:00 am

Post by Nick » Wed May 27, 2009 1:16 pm

Thanks Yeray. I've done something a bit like that, but generalised it so it works whatever the difference in scales between right and left axes are.

I notice that, when OnGetAxisLabel is triggered by the RightAxis, its Minimum and Maximum get set to the same values as the LeftAxis, even though they seem to have the 'correct' values at all other times (odd behaviour..). So I added a couple of properties to my form:

Code: Select all

    RightScaling, RightOffset: Double;
and set them before it draws the axes:

Code: Select all

procedure TMainForm.Chart1BeforeDrawAxes(Sender: TObject);
begin
  with (Sender as TChart) do
  begin
    RightScaling := (RightAxis.Maximum - RightAxis.Minimum) / (LeftAxis.Maximum - LeftAxis.Minimum);
    RightOffset := RightAxis.Minimum - LeftAxis.Minimum;
  end;
end;
then change the labels like you did:

Code: Select all

procedure TMainForm.Chart1GetAxisLabel(Sender: TChartAxis; Series: TChartSeries;
  ValueIndex: Integer; var LabelText: string);
begin
  if (Sender = Sender.ParentChart.RightAxis) then
    LabelText := FloatToStr(StrToFloat(LabelText) * RightScaling + RightOffset);
end;
(although there's a bit of error handling and formatting in the version I use) and that works well enough for my purposes. It makes the labels at the same places as the LeftAxis, even if they're not nice round numbers on the RightAxis scale, but I can live with that.

Thanks for your help.

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Wed May 27, 2009 2:09 pm

Hi Nick,

Another possibility I can think would be to clear all the labels of this axis and add the labels you want as custom labels. Bu then you'll have to calculate how many to add and where.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply