Change the margins of the panel with the mouse

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
acastro
Advanced
Posts: 204
Joined: Tue Oct 27, 2009 12:00 am

Change the margins of the panel with the mouse

Post by acastro » Wed Sep 15, 2010 8:45 am

I know it can be done in the chart editor, but Is there any way to change the margings of the panel with the mouse dragging the axis of the graph?

Thanks in advance

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

Re: Change the margins of the panel with the mouse

Post by Sandra » Wed Sep 15, 2010 1:40 pm

Hello wakeup,

I think you could use property ,of tChart1 Panel, for change size of margins(MarginBottom,MarginLeft,MarginRight,MarginTop) in the Scroll Event, because every time you want do scroll margins change their size as you want. Following you can find an example how you do for change size of margins:

Code: Select all

            tChart1.Panel.MarginBottom = 30;
            tChart1.Panel.MarginLeft = 30;
            tChart1.Panel.MarginRight = 20;
            tChart1.Panel.MarginTop = 20;

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

acastro
Advanced
Posts: 204
Joined: Tue Oct 27, 2009 12:00 am

Re: Change the margins of the panel with the mouse

Post by acastro » Thu Sep 16, 2010 9:50 am

Sorry, I understand you mean about change the margin in the panel with that code. But how can I use the scroll event to modify each margin independently?

Do you have any example?

Thanks

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

Re: Change the margins of the panel with the mouse

Post by Sandra » Fri Sep 17, 2010 8:49 am

Hello wakeup,


Sorry for delay. I have made a simple code that I think you can use in your application. Please, check next code works as you want.

Code: Select all

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

        double OldMarginLeft, OldMarginTop, OldMarginRight,OldMarginBottom;
        private void InitializeChart()
        {

            Steema.TeeChart.Styles.Line series = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            series.FillSampleValues();
                       
            OldMarginLeft = tChart1.Panel.MarginLeft;
            OldMarginTop = tChart1.Panel.MarginTop;
             OldMarginRight= tChart1.Panel.MarginRight;
            OldMarginBottom= tChart1.Panel.MarginBottom;
            tChart1.Scroll += new EventHandler(tChart1_Scroll);
            tChart1.UndoneZoom += new EventHandler(tChart1_UndoneZoom);
        }

        void tChart1_UndoneZoom(object sender, EventArgs e)
        {
            tChart1.Axes.Bottom.SetMinMax(tChart1[0].XValues.Minimum, tChart1[0].XValues.Maximum);
            tChart1.Panel.MarginLeft = OldMarginLeft;
            tChart1.Panel.MarginTop = OldMarginTop;
            tChart1.Panel.MarginRight = OldMarginRight;
            tChart1.Panel.MarginBottom = OldMarginBottom;
          
        }

        void tChart1_Scroll(object sender, EventArgs e)
        {
            tChart1.Panel.MarginLeft = tChart1.Panel.MarginLeft+0.5;
            tChart1.Panel.MarginTop = tChart1.Panel.MarginTop+0.5;
            tChart1.Panel.MarginRight = tChart1.Panel.MarginRight + 0.5;
            tChart1.Panel.MarginBottom= tChart1.Panel.MarginBottom + 0.5;
           
        }
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

acastro
Advanced
Posts: 204
Joined: Tue Oct 27, 2009 12:00 am

Re: Change the margins of the panel with the mouse

Post by acastro » Fri Sep 17, 2010 10:09 am

Thanks Sandra, it's a good trick.
But I need to move each margin independently, and its a bit dirty zoom and scrooll the chart to move the margins. And if I disable the zoom the event doesn't fire...

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

Re: Change the margins of the panel with the mouse

Post by Sandra » Mon Sep 20, 2010 3:37 pm

Hello wakeup,

Sorry for the delay. If you want to move each margin independently I suggest you use 4 different ScrollBars,one for each margin, so you can change size of margins using values of ScrollBars and their events.

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

acastro
Advanced
Posts: 204
Joined: Tue Oct 27, 2009 12:00 am

Re: Change the margins of the panel with the mouse

Post by acastro » Mon Sep 20, 2010 3:39 pm

That seems to be the best option. Thanks a lot!

Post Reply