<chart:SfChart Grid.Row="1" Margin="10"
x:Name="chart" >
<chart:SfChart.Behaviors>
<chart:ChartZoomPanBehavior x:Name="zoom"/>
</chart:SfChart.Behaviors>
<chart:SfChart.PrimaryAxis>
<chart:NumericalAxis x:Name="xAxis" />
</chart:SfChart.PrimaryAxis>
<chart:SfChart.SecondaryAxis>
<chart:NumericalAxis x:Name="yAxis" EdgeLabelsDrawingMode="Shift">
</chart:NumericalAxis>
</chart:SfChart.SecondaryAxis>
<chart:ColumnSeries XBindingPath="XValue"
Label="Series"
YBindingPath="YValue"
ItemsSource="{Binding Data}"/>
</chart:SfChart>
<StackPanel Orientation="Horizontal" Margin="10"
Height="30"
VerticalAlignment="Top" HorizontalAlignment="Right">
<Button Content="ZoomIn" Margin="2" x:Name="zoomIn" Click="zoomIn_Click"/>
<Button Content="ZoomOut" Margin="2" x:Name="zoomOut" Click="zoomOut_Click"/>
<Button Content="Reset" Margin="2" x:Name="reset" Click="reset_Click"/>
<Button Content="Panning" Margin="2" x:Name="pan" Click="pan_Click"/>
<Button Content="Select Zoom" Margin="2" x:Name="select" Click="select_Click"/>
</StackPanel>
|
private void zoomIn_Click(object sender, RoutedEventArgs e)
{
xAxis.ZoomFactor = xAxis.ZoomFactor - 0.2;
yAxis.ZoomFactor = yAxis.ZoomFactor - 0.2;
}
private void zoomOut_Click(object sender, RoutedEventArgs e)
{
xAxis.ZoomFactor = xAxis.ZoomFactor + 0.2;
yAxis.ZoomFactor = yAxis.ZoomFactor + 0.2;
}
private void pan_Click(object sender, RoutedEventArgs e)
{
zoom.EnablePanning = true;
zoom.EnableSelectionZooming = false;
}
private void select_Click(object sender, RoutedEventArgs e)
{
zoom.EnablePanning = false;
zoom.EnableSelectionZooming = true;
}
private void reset_Click(object sender, RoutedEventArgs e)
{
zoom.Reset();
}
} |