Reserve margin for Right Axis

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
dhait
Newbie
Newbie
Posts: 11
Joined: Tue Nov 15, 2005 5:00 am

Reserve margin for Right Axis

Post by dhait » Wed Mar 15, 2006 5:57 pm

when I add a series which uses the Right axis, the entire chart area "shrinks" a little bit, to make room on the right margin for showing the axis.

How can I "pre-reserve" this margin, so, the chart area doesn't move when the right axis is displayed? Basically, I want to the Right axis to simply appear or disappear as this series is added, without any change to the layout of existing visible series.

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

Post by Narcís » Thu Mar 16, 2006 4:01 pm

Hi dhait,

To achieve that you'll have to use a custom axis and some code like this:

Code: Select all

    private void Form1_Load(object sender, EventArgs e)
    {
      Steema.TeeChart.Axis custom = new Steema.TeeChart.Axis();
      custom.Horizontal = false;
      custom.OtherSide = true;
      custom.RelativePosition = 0;
      tChart1.Panel.MarginUnits = Steema.TeeChart.PanelMarginUnits.Pixels;
      tChart1.Panel.MarginRight = 50;
      tChart1.Legend.Visible = false;
      tChart1.Axes.Custom.Add(custom);
      line1.FillSampleValues();
      line2.FillSampleValues();
      line2.CustomVertAxis = custom;
      line2.Active = false; 
    }

    private void button1_Click(object sender, EventArgs e)
    {
      line2.Active = !line2.Active;
    }
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

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

Post by Narcís » Mon Mar 20, 2006 9:38 am

Hi dhait,

You can also do something like this:

Code: Select all

    private void button1_Click(object sender, EventArgs e)
    {
      line2.FillSampleValues();

      line2.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Right;     
    }

    private void Form1_Load(object sender, EventArgs e)
    {
      line1.FillSampleValues();

      tChart1.Legend.HorizMargin = 100;
      tChart1.Legend.ResizeChart = false;
      tChart1.Axes.Right.Labels.CustomSize = 50;
    }

    private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
    {
      if (tChart1.Axes.Right.Visible)
      {
        Steema.TeeChart.Axis Right = tChart1.Axes.Right;

        tChart1.Legend.HorizMargin = tChart1.Legend.HorizMargin - Right.Labels.CustomSize - 
                                      Right.AxisPen.Width - Right.Ticks.Length;
      }
    }
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