Chart for WPF and Silverlight / Chart Features / Interaction / Zooming in C1Chart
In This Topic
Zooming in C1Chart
In This Topic

To add zooming behavior in C1Chart, use some custom code in the Chart's MouseWheel event.

C#
Copy Code
private void chart_MouseWheel(object sender, MouseWheelEventArgs e)
{    
      if (Keyboard.Modifiers == ModifierKeys.Control && e.Delta == -120)    
      {
       chart.View.AxisX.Scale += .1;
       chart.View.AxisY.Scale += .1; 
       }
else if (Keyboard.Modifiers == ModifierKeys.Control && e.Delta == 120)
      {
          chart.View.AxisX.Scale -= .1;
          chart.View.AxisY.Scale -= .1;    
          }
} 

To enable the user to move the chart around when it’s zoomed, add the following to C1Chart’s XAML markup:

XAML
Copy Code
 <c1c:C1Chart x:Name="chart" MouseWheel="chart_MouseWheel" >
    <c1c:C1Chart.Actions>
         <c1c:TranslateAction MouseButton="Left" />
    </c1c:C1Chart.Actions>
</c1c:C1Chart>

 

See Also