How to show data in pan rectangle to other chart?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
tomking
Newbie
Newbie
Posts: 20
Joined: Thu Jan 15, 2009 12:00 am
Contact:

How to show data in pan rectangle to other chart?

Post by tomking » Wed Jul 08, 2009 1:22 pm

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
Attachments
Pan.jpg
I want to make like this image
Pan.jpg (111.11 KiB) Viewed 10919 times

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

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

Post by Yeray » Wed Jul 08, 2009 2:40 pm

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);
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

tomking
Newbie
Newbie
Posts: 20
Joined: Thu Jan 15, 2009 12:00 am
Contact:

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

Post by tomking » Thu Jul 09, 2009 1:08 am

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!
Attachments
pan3.jpg
pan3.jpg (120.88 KiB) Viewed 10879 times

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

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

Post by Yeray » Thu Jul 09, 2009 8:43 am

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));
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

tomking
Newbie
Newbie
Posts: 20
Joined: Thu Jan 15, 2009 12:00 am
Contact:

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

Post by tomking » Thu Jul 09, 2009 10:37 am

Hi Yeray Alonso !
That is function I need.
Thank you very much!
Best regards

tomking
Newbie
Newbie
Posts: 20
Joined: Thu Jan 15, 2009 12:00 am
Contact:

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

Post by tomking » Wed Jul 15, 2009 1:06 am

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
Attachments
pan2.jpg
pan2.jpg (120.62 KiB) Viewed 10842 times

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

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

Post by Yeray » Wed Jul 15, 2009 10:45 am

Hi tomking,

Try the following:

Code: Select all

tChart1.ClipPoints = true;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

tomking
Newbie
Newbie
Posts: 20
Joined: Thu Jan 15, 2009 12:00 am
Contact:

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

Post by tomking » Wed Jul 15, 2009 11:56 am

Hi Yeray Alonso !
It is not correct. Can you review?
Thanks

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

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

Post by Yeray » Wed Jul 15, 2009 12:09 pm

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?
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply