Page 1 of 1

Draw Axis without a series:?:

Posted: Thu Jul 03, 2008 4:32 am
by 9231389
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

Posted: Thu Jul 03, 2008 9:32 am
by yeray
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;

drawing an axis without assigning a series

Posted: Wed Jul 23, 2008 1:29 am
by 9231389
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 :?:

Posted: Wed Jul 23, 2008 7:58 am
by narcis
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.