Page 1 of 1
Change the margins of the panel with the mouse
Posted: Wed Sep 15, 2010 8:45 am
by 15654539
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
Re: Change the margins of the panel with the mouse
Posted: Wed Sep 15, 2010 1:40 pm
by 10050769
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,
Re: Change the margins of the panel with the mouse
Posted: Thu Sep 16, 2010 9:50 am
by 15654539
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
Re: Change the margins of the panel with the mouse
Posted: Fri Sep 17, 2010 8:49 am
by 10050769
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,
Re: Change the margins of the panel with the mouse
Posted: Fri Sep 17, 2010 10:09 am
by 15654539
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...
Re: Change the margins of the panel with the mouse
Posted: Mon Sep 20, 2010 3:37 pm
by 10050769
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,
Re: Change the margins of the panel with the mouse
Posted: Mon Sep 20, 2010 3:39 pm
by 15654539
That seems to be the best option. Thanks a lot!