Page 1 of 1

How to show data in pan rectangle to other chart?

Posted: Wed Jul 08, 2009 1:22 pm
by 13051494
Hi everyone?
Have a nice day!
I am using teechart to make my historian trends. I have 2 charts, first one for full trend and second one for displays pan data from first one.
And I create a rectangle in first chart to get pan window. I want to display all data in pan window to show in second chart.
Has anyone got this code or has made the same with this issue?
Please, help me.
Thanks in advance!
Please, see the attach file

Re: How to show data in pan rectangle to other chart?

Posted: Wed Jul 08, 2009 2:40 pm
by yeray
Hi tomking,

Here you have a simple example:

Code: Select all

        public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }

        FastLine fast1, fast2;
        ColorBand colorband1;

        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            tChart2.Aspect.View3D = false;
            tChart1.Legend.Visible = false;
            tChart2.Legend.Visible = false;

            fast1 = new FastLine(tChart1.Chart);
            fast2 = new FastLine(tChart2.Chart);

            fast1.FillSampleValues(200);
            fast2.DataSource = fast1;
            
            colorband1 = new ColorBand(tChart2.Chart);
            colorband1.Axis = tChart2.Axes.Bottom;
            colorband1.Pen.Color = Color.Red;
            colorband1.Transparency = 50;
            colorband1.Start = 50;
            colorband1.End = 150;
            colorband1.ResizeStart = true;
            colorband1.ResizeEnd = true;
            colorband1.StartLine.DragLine += new EventHandler(ColorBand_DragLine);
            colorband1.EndLine.DragLine += new EventHandler(ColorBand_DragLine);
        }

        void ColorBand_DragLine(object sender, EventArgs e)
        {
            tChart1.Axes.Bottom.SetMinMax(colorband1.Start, colorband1.End);
        }

Re: How to show data in pan rectangle to other chart?

Posted: Thu Jul 09, 2009 1:08 am
by 13051494
Hi Yeray Alonso
Thank you very much!
Your sample is very nice. But I want to create pan window by RECTANGLE because I want to DRAG and RESIZE on both side (Vertical, Horizontal, Both).
Could you please help me?
Thanks

Please, see the attach image!

Re: How to show data in pan rectangle to other chart?

Posted: Thu Jul 09, 2009 8:43 am
by yeray
Hi

In that case you should do something similar to the above but you could use a RectangleTool that allows dragging and resizing in all directions. And you should also do a SetMinMax for the left axis too. Here is an example:

Code: Select all

        public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }

        FastLine fast1, fast2;
        RectangleTool rectangle1;

        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            tChart2.Aspect.View3D = false;
            tChart1.Legend.Visible = false;
            tChart2.Legend.Visible = false;

            fast1 = new FastLine(tChart1.Chart);
            fast2 = new FastLine(tChart2.Chart);

            fast1.FillSampleValues(200);
            fast2.DataSource = fast1;

            rectangle1 = new RectangleTool(tChart2.Chart);

            rectangle1.Shape.Pen.Color = Color.Red;
            rectangle1.Shape.Transparency = 50;
            rectangle1.AllowDrag = true;
            rectangle1.AllowResize = true;

            rectangle1.Dragging += new RectangleToolDraggingEventHandler(rectangle1_Recalc);
            rectangle1.Resizing += new RectangleToolResizingEventHandler(rectangle1_Recalc);

            rectangle1.Left = 50;
            rectangle1.Top = 50;
            rectangle1.Width = 100;
            rectangle1.Height = 100;

        }

        void rectangle1_Recalc(object sender, EventArgs e)
        {
            tChart1.Axes.Bottom.SetMinMax(tChart2.Axes.Bottom.CalcPosPoint(rectangle1.Left), tChart2.Axes.Bottom.CalcPosPoint(rectangle1.Left + rectangle1.Width));
            tChart1.Axes.Left.SetMinMax(tChart2.Axes.Left.CalcPosPoint(rectangle1.Top + rectangle1.Height), tChart2.Axes.Left.CalcPosPoint(rectangle1.Top));
        }

Re: How to show data in pan rectangle to other chart?

Posted: Thu Jul 09, 2009 10:37 am
by 13051494
Hi Yeray Alonso !
That is function I need.
Thank you very much!
Best regards

Re: How to show data in pan rectangle to other chart?

Posted: Wed Jul 15, 2009 1:06 am
by 13051494
Hi Yeray Alonso !
How can I set the area limitation of rectangle only in DATA AREA like below image?
(If I don't set limitation the rectangle will exceed DATA AREA when I drag or resize)
Could you help me?
Thank you very much!
Best regards

Re: How to show data in pan rectangle to other chart?

Posted: Wed Jul 15, 2009 10:45 am
by yeray
Hi tomking,

Try the following:

Code: Select all

tChart1.ClipPoints = true;

Re: How to show data in pan rectangle to other chart?

Posted: Wed Jul 15, 2009 11:56 am
by 13051494
Hi Yeray Alonso !
It is not correct. Can you review?
Thanks

Re: How to show data in pan rectangle to other chart?

Posted: Wed Jul 15, 2009 12:09 pm
by yeray
Hi tomking,

I can't reproduce it with the code I posted above. Could you please send us a simple example project we can run as-is to reproduce the problem here?