如何更改OxyPlot y轴字符串格式
本文关键字:字符串 格式 何更改 OxyPlot | 更新日期: 2023-09-27 18:14:21
谁能告诉我如何改变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;
这将产生空引用错误。
谢谢!
这是我之前用来在xy-plot上设置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);
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,等。