title: OxyPlot AutoScale
body: <p>AutoScale OxyPlot Chart.
  For example i have something like this.</p>
  
  <pre><code>using OxyPlot;
  using OxyPlot.Axes;
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Data;
  using System.Windows.Documents;
  using System.Windows.Input;
  using System.Windows.Media;
  using System.Windows.Media.Imaging;
  using System.Windows.Navigation;
  using System.Windows.Shapes;
  using OxyPlot.Wpf;
  using PlotControllerTest.Properties;
  using System.Diagnostics;
  namespace PlotControllerTest
  {
  /// &lt;summary&gt;
  /// Interaction logic for MainWindow.xaml
  /// &lt;/summary&gt;
  /// 
  public class Chart
  {
      public PlotController myController { get; set; }
      private OxyPlot.Series.LineSeries LS;
      OxyPlot.Axes.LinearAxis LAY;
      OxyPlot.Axes.LinearAxis LAX;
      private int i = 0;
      public PlotModel PlotModel {get;set;}
      public Chart()
      {
  
          PlotModel = new PlotModel();
          myController = new PlotController();
          myController.UnbindAll();
          myController.BindMouseDown(OxyMouseButton.Left, OxyPlot.PlotCommands.PanAt);
          LS = new OxyPlot.Series.LineSeries();
          LAY = new OxyPlot.Axes.LinearAxis()
          {
              Position = OxyPlot.Axes.AxisPosition.Left,
              AbsoluteMaximum = 100,
              AbsoluteMinimum = 1,
          };
          LAX = new OxyPlot.Axes.LinearAxis()
          {
              Position = OxyPlot.Axes.AxisPosition.Bottom,
              AbsoluteMaximum = 200,
              AbsoluteMinimum = 1,
              MinorStep=5,
          };
          PlotModel.Series.Add(LS);
          PlotModel.Axes.Add(LAY);
          PlotModel.Axes.Add(LAX);
      }
      public void BeginAddPoints()
      {
          Random rnd = new Random();
          do
          {
              int temp=rnd.Next(1, 100);
              LS.Points.Add(new DataPoint( ++i,temp));
              System.Threading.Thread.Sleep(100);
  
              Update();
          } while (i&lt;30);
          Update();
      }
      public void Update()
      {
          PlotModel.InvalidatePlot(true);
      }
  }
  public partial class MainWindow : Window
  {
      Chart TChart;
      delegate void BeginUpdate();
      private Stopwatch stopwatch = new Stopwatch();
      private long lastUpdateMilliSeconds;
      public MainWindow()
      {
  
          TChart = new Chart();
          BeginUpdate BU = new BeginUpdate(TChart.BeginAddPoints);
          IAsyncResult result = BU.BeginInvoke(null,null);
          DataContext = TChart;
          CompositionTarget.Rendering += CompositionTargetRendering;
          InitializeComponent();
      }
      private void CompositionTargetRendering(object sender, EventArgs e)
      {
          if (stopwatch.ElapsedMilliseconds &gt; lastUpdateMilliSeconds + 300)
          {
              TChart.Update();
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Xaml code look's like</p>
  
  <pre><code>&lt;Window x:Class="PlotControllerTest.MainWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:oxy="http://oxyplot.org/wpf"
      Title="MainWindow" Height="350" Width="525"&gt;
  &lt;Grid&gt;
      &lt;oxy:PlotView Model="{Binding PlotModel}" DefaultTrackerTemplate="{x:Null}" Controller="{Binding myController}"&gt;&lt;/oxy:PlotView&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>How to implement autoscale of Y Axes after dragging? For example when i drag chart in window, and there appears only one Line ((1,2),(4,4)). Y axis will show from 2 to 4.Thanks.</p>