Custom Y-Axis Position

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
LebbingUser
Newbie
Newbie
Posts: 12
Joined: Mon Apr 08, 2019 12:00 am

Custom Y-Axis Position

Post by LebbingUser » Mon Jul 15, 2019 6:48 am

Hello Steema Support,

I've got an problem that I don't know how to solve.

Every Line in my Chart got an own Custom Y-Axis, but the first one uses the main Y-Axis.
I implemented a Function that hide or fade in the selected Axis.
But when a Custom Y-Axis is faded in, it doesn't get the same position like the main Axis.

So is there an option to set the same Axis-Position for the Custom Axis as for the main Axis?

Thank you for your help!!

Best regards,
Florian
Attachments
MainAxis.png
MainAxis.png (43.2 KiB) Viewed 381 times
CustomAxis.png
Custom-Axis is too far left
CustomAxis.png (38.66 KiB) Viewed 381 times

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

Re: Custom Y-Axis Position

Post by Christopher » Mon Jul 15, 2019 7:32 am

Hello Florian,

You will need to specify a value for the LeftMargin of the Panel class to shift the Custom Axis across, e.g.

Code: Select all

        private void InitializeChart()
        {
            var line = new Line(tChart1.Chart);
            line.FillSampleValues();
        }

        bool _flag = false;
        Axis _custom = null;

        void SetCustom()
        {
            _flag = !_flag;

            if (_flag)
            {
                tChart1[0].CustomVertAxis = _custom;
                tChart1.Panel.MarginLeft = 7;
            }
            else
            {
                tChart1[0].CustomVertAxis = null;
                tChart1.Panel.MarginLeft = 3;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            _custom = new Axis(tChart1.Chart);
            tChart1.Axes.Custom.Add(_custom);

            SetCustom();
        }
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

LebbingUser
Newbie
Newbie
Posts: 12
Joined: Mon Apr 08, 2019 12:00 am

Re: Custom Y-Axis Position

Post by LebbingUser » Mon Jul 15, 2019 7:34 am

Hello Christopher,

Thanks for your fast help!

But is it possible to post the code in VB.NET?

Thank you very much!

Best regards,
Florian

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

Re: Custom Y-Axis Position

Post by Christopher » Mon Jul 15, 2019 7:52 am

Hello Florian,

I hope you find this more helpful:

Code: Select all

    Private Sub InitializeChart()
        Dim line = New Line(tChart1.Chart)
        line.FillSampleValues()
    End Sub

    Private _flag As Boolean = False
    Private _custom As Axis = Nothing

    Private Sub SetCustom()
        _flag = Not _flag

        If _flag Then
            tChart1(0).CustomVertAxis = _custom
            tChart1.Panel.MarginLeft = 7
        Else
            tChart1(0).CustomVertAxis = Nothing
            tChart1.Panel.MarginLeft = 3
        End If
    End Sub

    Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs)
        _custom = New Axis(tChart1.Chart)
        tChart1.Axes.Custom.Add(_custom)
        SetCustom()
    End Sub
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

LebbingUser
Newbie
Newbie
Posts: 12
Joined: Mon Apr 08, 2019 12:00 am

Re: Custom Y-Axis Position

Post by LebbingUser » Mon Jul 15, 2019 8:23 am

Hello Christopher,

thanks, that works great!

But I've got another question:

How can I change the color of the numbers in the y-axis?

Thanks in advance!

Best regards,
Florian

LebbingUser
Newbie
Newbie
Posts: 12
Joined: Mon Apr 08, 2019 12:00 am

Re: Custom Y-Axis Position

Post by LebbingUser » Mon Jul 15, 2019 8:56 am

I've got it already!

It is:
TChart1.Axes.Left.Labels.Font.Color = Color.Red

Thanks for helping!
Best regards,
Florian

Post Reply