Page 1 of 1

Reserve margin for Right Axis

Posted: Wed Mar 15, 2006 5:57 pm
by 9639219
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.

Posted: Thu Mar 16, 2006 4:01 pm
by narcis
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;
    }

Posted: Mon Mar 20, 2006 9:38 am
by narcis
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;
      }
    }