Want to set minorTicks inside/outside the axis at sametime

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

Want to set minorTicks inside/outside the axis at sametime

Post by amol » Wed Dec 23, 2015 6:43 am

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 10690 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,

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

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

Post by Christopher » Wed Dec 23, 2015 12:47 pm

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);
        }
      }
    }
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

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

Post by amol » Thu Dec 24, 2015 7:36 am

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,

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

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

Post by Christopher » Thu Dec 24, 2015 8:24 am

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.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

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

Post by amol » Thu Dec 24, 2015 10:18 am

Thanks...... :) :)

Post Reply