SciChart WPF 2D Charts > ChartModifier API > Zooming And Panning > YAxisDragModifier
YAxisDragModifier

The YAxisDragModifier allows you to add Y-Axis scaling or panning on mouse-drag.

Declaring a YAxisDragModifier in XAML

Declaring a YAxisDragModifier
Copy Code
<!-- where xmlns:s="http://schemas.abtsoftware.co.uk/scichart" -->
<s:SciChartSurface>
   <s:SciChartSurface.ChartModifier>
      <s:ModifierGroup>
         <s:YAxisDragModifier DragMode="Scale"/>
      </s:ModifierGroup>
   </s:SciChartSurface.ChartModifier>
</s:SciChartSurface>

Declaring a YAxisDragModifier in Code

Declaring a YAxisDragModifier
Copy Code
var sciChartSurface = new SciChartSurface();
sciChartSurface.ChartModifier = new ModifierGroup(new YAxisDragModifier());

Switching from YAxis Drag to Pan Mode

The property YAxisDragModifier.DragMode allows you to switch between Panning and Scaling on drag of an axis.

Allow Zooming or Panning only one YAxis

By default a YAxisDragModifier is applied to all the axes in the SciChartSurface.YAxes collection. You can apply dragging or zooming to only one axis by setting the YAxisDragModifier.AxisId property:

Allow Zooming or Panning only one YAxis
Copy Code
<!-- where xmlns:s="http://schemas.abtsoftware.co.uk/scichart" -->
<s:SciChartSurface>

   <s:SciChartSurface.YAxes>
      <s:NumericAxis x:Name="yAxis0" />
         <s:NumericAxis x:Name="yAxis1" Id="SecondaryYAxis"/>
   </s:SciChartSurface.YAxes>
  
   <s:SciChartSurface.ChartModifier>
      <s:ModifierGroup>
              <!-- Set YAxisDragModifier.AxisId = yAxis1.Id -->
              <!-- This will allow dragging on only the secondary y axis -->
         <s:YAxisDragModifier AxisId="{Binding ElementName=yAxis1, Path=Id}"/>
      </s:ModifierGroup>
   </s:SciChartSurface.ChartModifier>
</s:SciChartSurface>

Allow Zooming or Panning all but one YAxis

By default a YAxisDragModifier is applied to all the axes in the SciChartSurface.YAxes collection. You can exclude one or more YAxis by setting the YAxisDragModifier.IncludeAxis attached property to false.

Allow Zooming or Panning all but one YAxis
Copy Code
<!-- where xmlns:s="http://schemas.abtsoftware.co.uk/scichart" -->
<s:SciChartSurface>

   <s:SciChartSurface.YAxes>
      <!-- This axis will be excluded from YAxis Dragging -->
      <s:NumericAxis x:Name="yAxis0" YAxisDragModifier.IncludeAxis="False"/>
         <s:NumericAxis x:Name="yAxis1" Id="SecondaryYAxis"/>
   </s:SciChartSurface.YAxes>
  
   <s:SciChartSurface.ChartModifier>
      <s:ModifierGroup>
         <s:YAxisDragModifier/>
      </s:ModifierGroup>
   </s:SciChartSurface.ChartModifier>
</s:SciChartSurface>

 

 

See Also