Page 1 of 1
Zooming,Scrolling,Aoutomatic Scaling...
Posted: Tue Oct 04, 2005 12:18 pm
by 8120345
I have one sample and three questions ..
I have two charts ..ChartA has values on y-axis between 3 and 40.
ChartB has values on y-axis between 2500 and 8000.Both of them has got same x-axis (dateTime)
1- When user zoom(only horizontal) on ChartA ,ChartB will be zoomed as same way as ChartA..(SetMinMax is not solution !..
ChartA has values on y-axis between 3 and 40.
ChartB has values on y-axis between 2500 and 8000
)
2-When user zoom(only horizontal) on ChartA , Minimum-Maximum values of Y-Axis will be set to visible values on chart ..
3-I have one scroll bar for two chart ..I easily scrool both chart as you see
Code: Select all
ChartList[i].Axes.Bottom.Scroll(e.NewValue - e.OldValue, true);
But problem is that I couldn sychronize scroll bar with chart..If chart is not scrollable(all values visible) my scrollbar must disabled..Or if rightest value is visible scrollbar must push right side (u couldnt drag it to right )..
Thx for advice ...
Posted: Tue Oct 04, 2005 12:57 pm
by narcis
Hi glikoz,
1- When user zoom(only horizontal) on ChartA ,ChartB will be zoomed as same way as ChartA..(SetMinMax is not solution !..
You can associate one series to left axis and the other to right axis:
Code: Select all
fastLine1.VertAxis=Steema.TeeChart.Styles.VerticalAxis.Left; fastLine2.VertAxis=Steema.TeeChart.Styles.VerticalAxis.Right;
Another option is using a custom vertical axis for one of the series. For more information on custom axes please have a look at the tutorials at the Teechart program group. If you want to zoom the custom axis you can do something like:
Code: Select all
private int myX0, myX1, myY0, myY1;
private void tChart1_Zoomed(object sender, System.EventArgs e)
{
axis1.SetMinMax(axis1.CalcPosPoint(myX1), axis1.CalcPosPoint(myX0));
}
private void tChart1_UndoneZoom(object sender, System.EventArgs e)
{
axis1.Automatic=true;
}
private void tChart1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
myX0=e.X;
myY0=e.Y;
}
private void tChart1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
myX1=e.X;
myY1=e.Y;
}
2-When user zoom(only horizontal) on ChartA , Minimum-Maximum values of Y-Axis will be set to visible values on chart ..
You can set your axes having overall maximum and minimum scaling by using:
Code: Select all
tChart1.Axes.Left.SetMinMax(Math.Min(fastLine1.YValues.Minimum,fastLine2.YValues.Minimum),
Math.Max(fastLine1.YValues.Maximum,fastLine2.YValues.Maximum));
3-I have one scroll bar for two chart ..I easily scrool both chart as you see
Code:
ChartList.Axes.Bottom.Scroll(e.NewValue - e.OldValue, true);
But problem is that I couldn sychronize scroll bar with chart..If chart is not scrollable(all values visible) my scrollbar must disabled..Or if rightest value is visible scrollbar must push right side (u couldnt drag it to right )..
For axis scrolling you could use Axis Arrows tool or also "play" a little bit with different SetMinMax approaches I've shown you.
Detailed Description for My Questions
Posted: Fri Oct 07, 2005 2:17 pm
by 8120345
Im sending u a detailed description
For first Question
I have two chart as you see
So I have to synchronize both of them..
When one of them be zoomed the other one will be zoomed..
When I add new chart it has to be inserted as zoomed..
For Second Question
I have to rescale Y axis when chart scrolled or zoomed ..I try to call SetMinMax on AfterDraw Event ...But I couldnt call Repaint method (endless Cycle)
Which event do you advice for rescaling axes job?
Extra Question
How could I cancel Event for example:
Code: Select all
void TChart_Zoomed(object sender, EventArgs e)
{
if .......
CancleZoom () // Dont zoom
}
Posted: Mon Oct 10, 2005 9:41 am
by narcis
Hi glikoz,
When one of them be zoomed the other one will be zoomed..
When I add new chart it has to be inserted as zoomed..
You have to synchronize both charts using SetMinMax and Zoom events as done here:
Code: Select all
private void tChart1_Zoomed(object sender, System.EventArgs e)
{
UpdateAxes();
}
private void tChart1_Scroll(object sender, System.EventArgs e)
{
UpdateAxes();
}
private void tChart1_UndoneZoom(object sender, System.EventArgs e)
{
UpdateAxes();
}
private void UpdateAxes()
{
tChart1.Refresh();
tChart2.Axes.Bottom.SetMinMax(tChart1.Axes.Bottom.Minimum,tChart1.Axes.Bottom.Maximum);
}
Note that you'll have to do the synchronization for zooming on both charts, here is only done for one of them.
For Second Question
I have to rescale Y axis when chart scrolled or zoomed ..I try to call SetMinMax on AfterDraw Event ...But I couldnt call Repaint method (endless Cycle)
Which event do you advice for rescaling axes job?
See code above for that as well.
Extra Question
How could I cancel Event for example:
Code:
void TChart_Zoomed(object sender, EventArgs e)
{
if .......
CancleZoom () // Dont zoom
}
You have two options:
1) Disabling zoom on your chart:
2) Don't let the axes being zommed in the zoom event:
Code: Select all
private void tChart1_Zoomed(object sender, System.EventArgs e)
{
tChart1.Axes.Left.Automatic=true;
tChart1.Axes.Bottom.Automatic=true;
}