Search code examples
wpfoxyplot

Trouble zooming with axis crossing at 0 in Oxyplot


[Edit: I submitted an issue about this on the OxyPlot GitHub]

I have an OxyPlot cartesian graph in a WPF Window with some FunctionSeries. When I set PositionAtZeroCrossing at true for both the axes, several problems appear :

1) The titles are not displayed correctly, one doesn't even appear. Changing the value of TitlePosition does not seem to change anything.

2) When zooming in or moving around, the x axis goes outside the graph area, as shown below : screenshot

Both problems do not appear when PositionAtZeroCrossing is not set as true.

I am wondering if there is a correct way to fix those problems, or a workaround (I am not familiar with OxyPlot).

//My PlotModel is binded to the Model of a PlotView in my WPF control.

//FonctionQlimPlim, maxX, maxY, minX and maxY are defined elsewhere
PlotModel plot = new PlotModel() 
{
    PlotType = PlotType.Cartesian
};

plot.Axes.Add(new LinearAxis()
{
    Position = AxisPosition.Bottom,
    Minimum = minX,
    Maximum = maxX,
    Title = "Q (kVAR)",
    PositionAtZeroCrossing = true 
});

plot.Axes.Add(new LinearAxis()
{
    Position = AxisPosition.Left,
    Minimum = minY,
    Maximum = maxY,
    Title = "P (kW)",
    PositionAtZeroCrossing = true
});

//One of the FunctionSeries
var f = FonctionQlimPlim;
f.Color = OxyColors.Red;
plot.Series.Add(f);

Solution

  • It was a bug, traced here, that was fixed in October 2014.