Setting axis maximum doesn't work in BeforeDrawAxes event (only in BeforeDraw event)

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
bairog
Advanced
Posts: 128
Joined: Fri Dec 07, 2018 12:00 am

Setting axis maximum doesn't work in BeforeDrawAxes event (only in BeforeDraw event)

Post by bairog » Wed Jan 30, 2019 6:03 am

Hello.
I'm using TeeChart Pro 4.2018.12.17 and I use the following code:

Code: Select all

using System;
using System.Windows.Forms;
using Steema.TeeChart;

namespace TeeChartTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            tChart1.Axes.Left.Automatic = false;
            tChart1.Axes.Left.Minimum = 0;
            tChart1.Axes.Left.Maximum = 5;

            //adding points which are higher than tChart1.Axes.Left.Maximum
            fastLine1.Add(0, 7);
            fastLine1.Add(1, 7);
        }


        private void tChart1_BeforeDrawAxes(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            //adjust tChart1.Axes.Left.Maximum if there are points that are higher
            if (fastLine1[0].Y > tChart1.Axes.Left.Maximum)
                tChart1.Axes.Left.Maximum = fastLine1[0].Y;
        }
    }
}
Setting tChart1.Axes.Left.Maximum inside BeforeDrawAxes event doesnt' work (axis will have proper maximum value only if I force TeeChart to redraw immediately - tChart1.Refresh();).
Or I can use BeforeDraw event (and it works correctly without forcing to redraw).
Is that by design or a bug?
BeforeDrawAxes event is supposed to be for all axis manipulations, isn't it?

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

Re: Setting axis maximum doesn't work in BeforeDrawAxes event (only in BeforeDraw event)

Post by Christopher » Wed Jan 30, 2019 12:57 pm

Hello!
bairog wrote:
Wed Jan 30, 2019 6:03 am
BeforeDrawAxes event is supposed to be for all axis manipulations, isn't it?
not exactly - it's primary function is for drawing custom elements onto the chart at different stages of the chart's drawing routines, as can be seen in the demo here:
TeeChartNetExamples_2019-01-30_13-49-28.png
TeeChartNetExamples_2019-01-30_13-49-28.png (190.95 KiB) Viewed 8924 times
given that the chart calculates the position of it's elements at the time of drawing, this means that axes properties set in the BeforeDrawAxis event may be overwritten as the chart makes its calculations at the time of drawing the axes (and not before it).
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

Post Reply