Set borders (min,max) to drag chart with right mouse button

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
starnov
Newbie
Newbie
Posts: 7
Joined: Wed Jun 03, 2009 12:00 am

Set borders (min,max) to drag chart with right mouse button

Post by starnov » Mon May 17, 2010 8:29 am

Hello, could You help me. I need to set restrictions for the chart dragging with right mouse button for user. I mean that user couldn't drag chart holding right mouse button to the area with values out of the range (less then Min and larger then Max). How can I do it? Thanks for reply.

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

Re: Set borders (min,max) to drag chart with right mouse button

Post by Sandra » Mon May 17, 2010 11:52 am

Hello starnov,

I have made a simple, that I think you could use it in your application. Please, check next code works as you want.

Code: Select all

        public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        private Steema.TeeChart.Styles.Line line1;

        private void InitializeChart()
        {
            line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            line1.FillSampleValues();
            tChart1.Scroll += new EventHandler(tChart1_Scroll);
        }
        void tChart1_Scroll(object sender, EventArgs e)
        {

            if (tChart1.Axes.Bottom.Maximum > line1.MaxXValue() || tChart1.Axes.Bottom.Minimum < 0)
            {

                tChart1.Axes.Bottom.AutomaticMinimum = false;
                tChart1.Axes.Bottom.Minimum = 0;
                tChart1.Axes.Bottom.AutomaticMaximum = false;
                tChart1.Axes.Bottom.Maximum = line1.MaxXValue();
            }
            if (tChart1.Axes.Left.Maximum > line1.MaxYValue() || tChart1.Axes.Left.Minimum<0)
            {

                tChart1.Axes.Left.AutomaticMinimum = false;
                tChart1.Axes.Left.Minimum = line1.MinYValue();
                tChart1.Axes.Left.AutomaticMaximum = false;
                tChart1.Axes.Left.Maximum = line1.MaxYValue();
            }
        }
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

Post Reply