Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change OxyPlot Y-Axis string format?

Tags:

c#

wpf

oxyplot

Can anyone tell me how to change the Y axis string format??

I have Y-Axis percentages that I want to add the percent sign to.

I am using OxyPlot to produce the chart in wpf.

Here is my attempt, but it is NOT working:

Func<double, string> formatFunc = (x) => string.Format("{000.00}%", x);

        formatFunc = new Func<double,string>("{0}");
        // Add the plot to the window
        line.YAxis.LabelFormatter = formatFunc;

This produces null reference error.

Thanks!

like image 778
Hooplator15 Avatar asked Mar 18 '23 23:03

Hooplator15


1 Answers

This is an example I've used previously to format the x-axis on an oxy-plot:

var xAxis = new DateTimeAxis
{
    Position = AxisPosition.Bottom,
    StringFormat = "dd/MM/yyyy",
    Title = "End of Day",
    IntervalLength = 75,
    MinorIntervalType = DateTimeIntervalType.Days,
    IntervalType = DateTimeIntervalType.Days,
    MajorGridlineStyle = LineStyle.Solid,
    MinorGridlineStyle = LineStyle.None,
};

Plot = new PlotModel();
Plot.Axes.Add(xAxis);
like image 82
AwkwardCoder Avatar answered Mar 27 '23 15:03

AwkwardCoder