TimeSpanAxis get not refeshed after panning or zooming

Oct 11, 2012 at 11:56 AM


I have a oxyplot (WPF) with some LinearAxis and one TimeSpanAxis. I use MVVM, so I load the data via binding in the corresponding LineSeries. All Axis and Series are defined in the XAML file.

All works well and the TimeSpanAxis gets refresh when I load new values into the oxyplot. But when I pan or zoom the graph and load new data again, the TimeSpanAxis did not get refreshed with the new values, all LineSeries would.

Did I miss something? A call to RefreshPlot() did not change this behavior.



Oct 15, 2012 at 7:29 AM
Edited Oct 15, 2012 at 8:08 AM


After some more investigations over the weekend I found that my new data replaces the old data, but the graph did not update to the new values in the TimeSpanAxis The TimeSpanAxis shows the same values as before and I had to scroll to the new values. I bind the data in the xaml-file  to the lineseries. The data is a collection of class TimeValue which consist only of a TimeSpan and a double. So, how can I reset the TimeSpanAxis?

This only happens when I scroll or pan the graph and load new data after the panning/scrolling.

This is the xaml code:

    <oxy:Plot Grid.Row="1" LegendPlacement="Outside" LegendPosition="BottomCenter" LegendOrientation="Horizontal" LegendItemSpacing="10" LegendMargin="-15" LegendSymbolLength="20" >
        <oxy:LinearAxis Position="Left" Minimum="0" Maximum="350" Title="Data 1" StartPosition="0" EndPosition="0.5" MajorGridlineStyle="Dot" MinorGridlineStyle="None" MajorStep="50" Key="Data1" AxisTitleDistance="20" />
        <oxy:LinearAxis Position="Left" Minimum="0" Maximum="180" Title="Data 2" StartPosition="0.55" EndPosition="1" MajorGridlineStyle="Dot" MinorGridlineStyle="None" MajorStep="20" Key="Data2"  AxisTitleDistance="20" />
        <oxy:TimeSpanAxis Position="Bottom" StringFormat="hh:mm" MajorGridlineStyle="Dot" />
        <oxy:LineSeries ItemsSource="{Binding Data1}" DataFieldX="Time" DataFieldY="Value" StrokeThickness="2" Color="Blue" MarkerType="Diamond" Title="Data 1" YAxisKey="Data1"/>
        <oxy:LineSeries ItemsSource="{Binding Data2}" DataFieldX="Time" DataFieldY="Value" StrokeThickness="2" Color="Green" MarkerType="Square" Title="Data 2" YAxisKey="Data2"/>

And this is the TimeValue class:
  public class TimeValue {
    public TimeSpan Time { getset; }
    public double Value { getset; }

And this is the property which is bound to the Lineseries:
  private Collection<TimeValuedata1;
  public Collection<TimeValueData1 {
     get { return data1; }
     set {
       if (data1 != value) {
         data1 = value;
  private Collection<TimeValuedata2;
  public Collection<TimeValueData2 {      get { return data2; }      set {        if (data2 != value) {          data2 = value;          DoPropertyChanged("Data2");        }      }    }

Oct 19, 2012 at 6:52 AM
Edited Oct 19, 2012 at 6:52 AM

Is there a function to set the range of what I want to see? i.e. from 5:00 to 7:00 on the horizontal axis.



Sep 7, 2013 at 6:49 AM

I met the same problem here in Winform. After pan or zoom, then if you change the series, the axes seems not to be refreshed.

Sep 7, 2013 at 7:07 AM
I found the solution. Just call Reset() on the axis to reset ViewMaximum and ViewMinium after you change the series.
Nov 14, 2013 at 11:19 AM
Thanks Zixys. Reset() works :D