Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I force the x-axis to stay at 0 in OxyPlot?

Tags:

c#

wpf

oxyplot

I am creating an application in OxyPlot. I would like for the minimum point on the x-axis to remain at zero, while the maximum point continues to grow as new data is populated on the graph. Currently what is happening, is that the graph seems to look like a sliding window instead, something like:

Here is what the graph looks like now:

[------------]
0           100

and 25 seconds later...

[------------]
25          125

Here is what I actually want:

[-------------]
0            100

and 25 seconds later...

[-------------]
0            125

I looked into some of the methods/properties of the LinearAxis (which I am using to define my x-axis), and the closest thing I could find was the AbsoluteMinimum property, which I've set to 0. Setting the AbsoluteMinimum property, did not seem to do the trick however. Any ideas?

like image 966
Snoop Avatar asked Oct 12 '25 21:10

Snoop


2 Answers

I added that property in my XAML code:

<oxy:Plot.Axes>
   <oxy:LinearAxis  Style="{DynamicResource PlotAxisStyle}" Position="Bottom" Minimum="1" />
   <oxy:LinearAxis Style="{DynamicResource PlotAxisStyle}" Position="Left"  Minimum="0" />
</oxy:Plot.Axes>

This works fine for me, but I am only using values up to 100 in my x-axis (Bottom position)

like image 165
thardes2 Avatar answered Oct 14 '25 12:10

thardes2


You can use Minimum property, and set its equal 0.

like image 43
Ксения Борисова Avatar answered Oct 14 '25 10:10

Ксения Борисова



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!