Custom Axis marking the top and bottom.

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Snarkle
Newbie
Newbie
Posts: 91
Joined: Wed Jun 30, 2010 12:00 am

Custom Axis marking the top and bottom.

Post by Snarkle » Fri Oct 15, 2010 6:01 am

Greetings

With the custom axis is there anything in TChart I can use to mark the horizontal boundaries of say the top of the axis and the bottomof the axis ... currently I was using colorlines .. but I had to draw them programatically and the constantly rescaling axis was makign this a nightmare ... (I add and remove custom axis like its going out of fashion)

The built in Axis have wall settings ... is there something like this for custom axes .. or anything that can mark the top and bottom of a custom axis and stay in place without me having to recalculate ..


Cheers Phil.
--------------------
Cheers Phil.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Custom Axis marking the top and bottom.

Post by Sandra » Fri Oct 15, 2010 10:20 am

Hello Phil,

I have made simple example that I think you can use in your application:

Code: Select all

public Form1()
        {
            InitializeComponent();
            InitializeChart();

        }
        Steema.TeeChart.Axis axis1;
        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            Steema.TeeChart.Styles.Line series1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            Steema.TeeChart.Styles.Line series2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            
            series1.FillSampleValues();
            series2.FillSampleValues();
            //Add Custom Axes.
            axis1 = new Steema.TeeChart.Axis(tChart1.Chart);
            tChart1.Axes.Custom.Add(axis1);
            series1.CustomVertAxis = tChart1.Axes.Left;
            series2.CustomVertAxis = axis1;
            tChart1.Axes.Left.StartPosition = 50;
            tChart1.Axes.Left.EndPosition = 100;

            axis1.StartPosition= 0;
            axis1.EndPosition = 50;
            axis1.AxisPen.Color = Color.Blue;

            axis1.SetMinMax(series2.YValues.Minimum,series2.YValues.Maximum);
            tChart1.Axes.Left.SetMinMax(series1.YValues.Minimum, series1.YValues.Maximum);
            tChart1.AfterDraw  = new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
        }

        void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            int pos1 =(int) Math.Abs(tChart1.Axes.Left.StartPosition - axis1.StartPosition);
            g.HorizontalLine(pos1,(int) tChart1.Axes.Bottom.CalcXPosValue(tChart1.Axes.Bottom.Maximum),axis1.CalcYPosValue(axis1.Minimum));
        }
Could you please, tell us if previous code works fine for you?

I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / 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

Snarkle
Newbie
Newbie
Posts: 91
Joined: Wed Jun 30, 2010 12:00 am

Re: Custom Axis marking the top and bottom.

Post by Snarkle » Fri Oct 22, 2010 6:28 am

Thanks Sandra,

that worked pretty well ...
--------------------
Cheers Phil.

Post Reply