Page 1 of 1

Gap between border and chart

Posted: Fri Nov 24, 2017 12:00 pm
by 16681948
Hello guys,

I have problem with area, that is creating between border and chart itself.
With one chart line it is okay, but with more custom axis in the chart, distance between border and chart itself increases.

Code: Select all

 Axis axis2 = new Axis(false, false, ch1);
 ch1.Axes.Custom.Add(axis2);
zmesP.CustomVertAxis = axis2;

Axis axis1 = new Axis(false, false, ch1);
ch1.Axes.Custom.Add(axis1);
zp.CustomVertAxis = axis1;

axis1.StartPosition = 0;
axis1.EndPosition = 22;
axis2.StartPosition = 25;
axis2.EndPosition = 47;
Thank you for your help.

Peter

Re: Gap between border and chart

Posted: Mon Nov 27, 2017 9:39 am
by Christopher
Hello,

One way of controlling this space is by using the Panel class' Margin* properties, e.g.

Code: Select all

    private void InitializeChart()
    {
      for (int i = 0; i < 5; i++)
      {
        tChart1.Series.Add(typeof(Line)).FillSampleValues();
      }

      tChart1.Axes.Left.Visible = false;
      tChart1.Panel.MarginUnits = PanelMarginUnits.Percent;
      tChart1.Panel.MarginLeft = 15;
    }

    private void button2_Click(object sender, EventArgs e)
    {
      int count = tChart1.Axes.Custom.Count;

      if(count < tChart1.Series.Count)
      {
        Axis axis = new Axis(tChart1.Chart);
        tChart1.Axes.Custom.Add(axis);
        tChart1.Series[count].CustomVertAxis = axis;

        tChart1.Header.Text = "There are " + tChart1.Axes.Custom.Count + " custom axes";
      }
    }