Page 1 of 1

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

Posted: Mon May 17, 2010 8:29 am
by 15653431
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.

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

Posted: Mon May 17, 2010 11:52 am
by 10050769
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,