4

谁能告诉我如何更改 Y 轴字符串格式?

我有要添加百分号的 Y 轴百分比。

我正在使用 OxyPlot 在 wpf 中生成图表。

这是我的尝试,但它不起作用:

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;

这会产生空引用错误。

谢谢!

4

2 回答 2

7

这是我之前用来在氧绘图上格式化 x 轴的示例:

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);
于 2014-07-24T10:14:55.927 回答
0
        this._PlotModel.Axes.Add( new LinearAxis
        {
            Position = AxisPosition.Left,
            Minimum = 0.025,
            Maximum = 0.205,
            StringFormat = "0.00%",
            MajorStep = 0.005
        } );

- 添加百分比作为比率:20.5% --> 0.205、0.5% --> 0.005 等。

于 2017-05-03T07:56:02.753 回答