How to make a zoom in a chart?
-
vendredi 12 février 2010 14:31Hello,
I'm programming with microsoft chart controls. But I don't know how to do a zoom.
My intention is to draw a square with gdi and do zoom the part of the square in the chart with the area of the square.
I've viewed the method scaleview.zoom, but I don't know how to use it. There isn't documentation with examples.
Could anybody write a expample about it?
Thank you very much.
PS. Sorry for my English.
Toutes les réponses
-
vendredi 12 février 2010 15:58Modérateur
Hi eldruida
no need to use GDI to draw a square
just need to set the IsUserSelectionEnabled property to true. Then you can put your cursor at the start of the range you want to zoom, hold the mouse button down, move it to the end of the range and release the button
try this in an app with 1 chartcontrol
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim rndm As New Random For i As Integer = 1 To 30 Dim temp1 As Integer = rndm.Next(0, 31) Dim temp2 As Integer = rndm.Next(0, 31) Dim dpNew As DataPoint = New DataPoint With dpNew .BorderWidth = 2 .MarkerBorderColor = Color.DarkBlue .MarkerBorderWidth = 2 .MarkerColor = Color.Red .MarkerSize = 10 .MarkerStyle = MarkerStyle.Star5 .XValue = temp1 .YValues(0) = temp2 .Label = temp1.ToString & "," & temp2.ToString End With Chart1.Series(0).Points.Add(dpNew) Next Chart1.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Point Chart1.ChartAreas(0).AxisX.Interval = 1 Chart1.ChartAreas(0).AxisX.Minimum = 0 Chart1.ChartAreas(0).AxisX.Maximum = 31 Chart1.ChartAreas(0).CursorX.IsUserSelectionEnabled = True End Sub- Proposé comme réponse jwavilaMVP, Moderator vendredi 12 février 2010 18:58
- Marqué comme réponse Alex GorevMicrosoft Employee, Owner jeudi 25 février 2010 04:40
-
vendredi 12 février 2010 17:17Thank you very much, xD. It was so easy.
You are the best.
Bye. -
jeudi 8 avril 2010 18:56
Hi, I tried implementing this in c# bu found that CursorX.IsUserSelectionEnabled isn't a valid statement. Any ideas on how to do this in c#?
Thanks,
Steve.
-
vendredi 9 avril 2010 14:25
Can you show your C# code?
Cephas Lin This posting is provided "AS IS" with no warranties. -
jeudi 9 août 2012 07:07
<p>I am using the same code in C# but it dosnt support CursorX property for ChartAreas..</p><p>please help</p><p>Chart1.ChartAreas(0).CursorX.IsUserSelectionEnabled = True</p>

