Draw Axis without a series:?:

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Scott
Newbie
Newbie
Posts: 5
Joined: Fri Mar 12, 2004 5:00 am
Location: New Zealand

Draw Axis without a series:?:

Post by Scott » Thu Jul 03, 2008 4:32 am

hi
Is there any way to display axis without assigning a visible series :?:

I need to draw multiple vertical axis, the axis should be displayed regardless of whether there is a visible series associated with it.
I've tried using OnAfterDraw events and then calling Axis->CustomDraw
however this does not work as it only draws the Axis line not the labels, ticks or title if there is no visible series.

adding a dummy series to the custom axis doesn't work because it shows in the legend even though its show in legend property is false.

Using TeeChart Pro v7.12 Win32. C++ Personality in RAD Studio 2007 with Dec2007 update + June hotfix

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

Post by Yeray » Thu Jul 03, 2008 9:32 am

Hi Scott,

Here is how you could do it. The axes need a series associated to them to be displayed but the series doesn't need to have any value because you can use SetMinMax method.

Note that you can remove the series from the legend with ShowInLegend property. And also note that this code is in delphi, but you shouldn't find too much problems converting it to c++.

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.AddSeries(TPointSeries.Create(self));
  Chart1.AddSeries(TPointSeries.Create(self));

  Chart1.CustomAxes.Add;

  Chart1[1].CustomVertAxis := Chart1.CustomAxes.Items[0];

  for i:=0 to Chart1.SeriesCount-1 do
  begin
    Chart1[i].Clear;
    Chart1[i].ShowInLegend:=false;
  end;

  Chart1.View3D := false;
  Chart1.MarginLeft := 5;

  Chart1.Axes.Left.SetMinMax(0,100);
  Chart1.Axes.Bottom.SetMinMax(0,100);
  Chart1.CustomAxes.Items[0].SetMinMax(200, 300);
  Chart1.CustomAxes.Items[0].PositionUnits:=muPixels;
  Chart1.CustomAxes.Items[0].PositionPercent:=-30;
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

Scott
Newbie
Newbie
Posts: 5
Joined: Fri Mar 12, 2004 5:00 am
Location: New Zealand

drawing an axis without assigning a series

Post by Scott » Wed Jul 23, 2008 1:29 am

Hi Yeray

thanks for your response.

problem is that the series still shows up in the TChartListBox,
I've already used the technique you described. i.e assign an empty series.
I need to be able to add several additional axes without having a how bunch of empty series show up in the TChartListBox.

I've tried using CustomAxisDraw but it doesn't draw the axis labels if no series is assigned. even if I set the min max values.

Is there a solution for this :?:

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Jul 23, 2008 7:58 am

Hi Scott,
problem is that the series still shows up in the TChartListBox,
I've already used the technique you described. i.e assign an empty series.
I need to be able to add several additional axes without having a how bunch of empty series show up in the TChartListBox.
I'm afraid this is not possible.
I've tried using CustomAxisDraw but it doesn't draw the axis labels if no series is assigned. even if I set the min max values.
You could try using custom labels as shown in the All Features\Welcome!\Axes\Labels\Custom labels example at the new featuers demo, available at TeeChart's program group.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply