Page 1 of 1

Want to set minorTicks inside/outside the axis at sametime

Posted: Wed Dec 23, 2015 6:43 am
by 9526439
Hi Steema Support,

we want to create minor ticks of axis like that(as shown in image below).
minor ticks.png
minorTicks
minor ticks.png (4.04 KiB) Viewed 10168 times
As shown in image minor ticks shown some upside and downside the axis at same time. Is it possible to show minorticks like this.
In teechart if we set length of minor ticks >0 then minor ticks shown down side of the axis and if length of minor ticks <0 then minor ticks shown upside of the axis.
But in my case i want to show minorticks upside and down side at the same time as shown in image above.

Please provide any solution asap.

Thanks in advance.

Thanks,

Re: Want to set minorTicks inside/outside the axis at sametime

Posted: Wed Dec 23, 2015 12:47 pm
by Christopher
Hello,

You could try code similar to this:

Code: Select all

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;

      Line line1 = new Line(tChart1.Chart);

      line1.Add(2, 2);
      line1.Add(8, 8);

      tChart1.Axes.Bottom.Increment = 1;

      tChart1.Axes.Bottom.MinorTicks.Length = 3;
      tChart1.Axes.Bottom.MinorTicks.Color = Color.Red;
      tChart1.Axes.Bottom.MinorTicks.Visible = false;
      tChart1.AfterDraw += AfterDraw;

    }

    private void AfterDraw(object sender, Graphics3D g)
    {
      Axis bottom = tChart1.Axes.Bottom;
      double min = bottom.Minimum;
      double max = bottom.Maximum;
      double inc = bottom.Increment;
      double delta = inc / ( bottom.MinorTickCount + 1);

      g.Pen = bottom.MinorTicks;
      g.Pen.Visible = true;

      for (double i = min; i < max; i += inc)
      {
        for (int j = 0; j < bottom.MinorTickCount; j++)
        {
          g.VerticalLine(bottom.CalcXPosValue(i + (delta * (j + 1))), bottom.Position - bottom.MinorTicks.Length, bottom.Position + bottom.MinorTicks.Length);
        }
      }
    }

Re: Want to set minorTicks inside/outside the axis at sametime

Posted: Thu Dec 24, 2015 7:36 am
by 9526439
Thanks Steema support for your prompt reply and valuable feedback.

This code works well for Linear axis. But if use logarithmic axis, in that case increment is setted by chart automatically.
So how we calculate Delta value(that you are calculating in after draw event).

Thanks,

Re: Want to set minorTicks inside/outside the axis at sametime

Posted: Thu Dec 24, 2015 8:24 am
by Christopher
amol wrote: This code works well for Linear axis. But if use logarithmic axis, in that case increment is setted by chart automatically.
So how we calculate Delta value(that you are calculating in after draw event).
This code requires that the Increment property is set manually either for linear or logarithmic axes.

Re: Want to set minorTicks inside/outside the axis at sametime

Posted: Thu Dec 24, 2015 10:18 am
by 9526439
Thanks...... :) :)