Is it possible to have custom axis on left and right?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Metman
Advanced
Posts: 113
Joined: Fri Dec 21, 2007 12:00 am

Is it possible to have custom axis on left and right?

Post by Metman » Tue Apr 16, 2013 3:34 pm

Hi

I would like to have two separate series in one chart as in your Multiple at Runtime demo.

In the demo you only have labels on the left-hand side of the chart, I would like to display labels for each series on both the left and right-hand sides of the chart - is this possible?

I know that I can swap the labels by setting the Boolean property OtherSide but this doesn't help.

Bruce.

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

Re: Is it possible to have custom axis on left and right?

Post by Yeray » Wed Apr 17, 2013 8:51 am

Hi Bruce,

You can set a series to use both the default Left and Right axes:

Code: Select all

Series1.VertAxis:=aBothVertAxis;
However, you can only have one custom vertical axis assigned to a series. You can move it to the right with the OtherSide property, as you said.

A workaround to have two custom vertical axes assigned to a series would be to duplicate the series and set the second custom vertical axis to this dummy series. Ie:

Code: Select all

uses Series, TeeTools;

procedure TForm1.FormCreate(Sender: TObject);
var i, nSeries: Integer;
    tmpAxis: TChartAxis;
begin
  nSeries:=3;

  Chart1.View3D:=false;
  Chart1.MarginLeft:=7;
  Chart1.Legend.HorizMargin:=40;

  for i:=0 to nSeries-1 do
  begin
    with Chart1.AddSeries(TLineSeries) as TLineSeries do
    begin
      FillSampleValues;
      tmpAxis:=Chart1.CustomAxes.Add as TChartAxis;
      CustomVertAxis:=tmpAxis;
      tmpAxis.StartPosition:=i*100/nSeries;
      tmpAxis.EndPosition:=(i+1)*100/nSeries;
      tmpAxis.Axis.Color:=Color;
    end;
  end;

  Chart1.Draw;

  for i:=0 to nSeries-1 do
  begin
    with Chart1.AddSeries(TLineSeries) as TLineSeries do
    begin
      ShowInLegend:=false;
      ShowInEditor:=false;

      tmpAxis:=Chart1.CustomAxes.Add as TChartAxis;
      CustomVertAxis:=tmpAxis;
    end;
    with tmpAxis do
    begin
      StartPosition:=i*100/nSeries;
      EndPosition:=(i+1)*100/nSeries;
      Axis.Color:=Chart1[i].Color;
      OtherSide:=true;
      Grid.Visible:=false;
      SetMinMax(Chart1.CustomAxes[i].Minimum, Chart1.CustomAxes[i].Maximum);
    end;

    if i<nSeries-1 then
    begin
      with Chart1.Tools.Add(TColorLineTool) as TColorLineTool do
      begin
        Axis:=tmpAxis;
        AllowDrag:=false;
        Value:=tmpAxis.Minimum;
      end;
    end;
  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

Post Reply