Page 1 of 1

Zoom / Scroll on multiple graphs

Posted: Wed Jul 20, 2011 9:03 pm
by 13052841
Hello, I have searched around and read the tutorials, but I can't seem to find the answer I am looking for. I have two tcharts in one form. They both get updated at the same time with the same X-axis value.

If I scroll around in one graph, is it possible to transfer this scroll to the other graph? (same idea for zoom: if I zoom into one graph I would like to apply the same zoom level to a second graph).

Thanks!!
-Kevin

Re: Zoom / Scroll on multiple graphs

Posted: Fri Jul 22, 2011 9:45 am
by 10050769
Hello Kevin,

I have made a simple project that I think you could use in your application for achieve as you want:

Code: Select all

        public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        Steema.TeeChart.Styles.Points point;
        Steema.TeeChart.Styles.Line line1,line2;

        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            tChart2.Aspect.View3D = false;
            line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            line2 = new Steema.TeeChart.Styles.Line(tChart2.Chart);
            line1.FillSampleValues();
            line2.DataSource = line1;
            tChart1.Zoomed += new EventHandler(tChart1_Zoomed);
            tChart1.Scroll += new EventHandler(tChart1_Scroll);
            tChart1.UndoneZoom += new EventHandler(tChart1_UndoneZoom);
        }
        void tChart1_UndoneZoom(object sender, EventArgs e)
        {
            UpdateAxes();
        }

        void tChart1_Scroll(object sender, EventArgs e)
        {
            UpdateAxes();
        }

        void tChart1_Zoomed(object sender, EventArgs e)
        {
            UpdateAxes();
        }  

        private void UpdateAxes()
        {
            tChart1.Refresh();
            tChart2.Axes.Bottom.SetMinMax(tChart1.Axes.Bottom.Minimum, tChart1.Axes.Bottom.Maximum);
        }
Could you please, check if previous code works as you expected?

I hope will helps,

Thanks,