winform中OxyPlot的X轴文本45°显示
时间: 2023-05-26 13:05:35 浏览: 367
OxyPlotWinform-Demo.zip
您可以使用OxyPlot的AxisClass.AxisTitleStyle.FontSize属性和Transform方法来实现X轴文本45°显示。
以下是一个示例代码片段:
```csharp
var plotModel = new PlotModel();
var linearAxis = new LinearAxis { Title = "X-Axis", Position = AxisPosition.Bottom };
plotModel.Axes.Add(linearAxis);
var categoryAxis = new CategoryAxis { Title = "Y-Axis", Position = AxisPosition.Left };
plotModel.Axes.Add(categoryAxis);
// 设置X轴文本角度和字体大小
linearAxis.AxisTitleStyle = new OxyPlot.Axes.AxisTitleStyle
{
FontSize = 10.0,
Transform = OxyPlot.Axes.AxisTitleTransform.Rotate270
};
var series = new OxyPlot.Series.ColumnSeries();
series.Items.Add(new OxyPlot.Series.ColumnItem(1, "First"));
series.Items.Add(new OxyPlot.Series.ColumnItem(2, "Second"));
series.Items.Add(new OxyPlot.Series.ColumnItem(3, "Third"));
series.Items.Add(new OxyPlot.Series.ColumnItem(4, "Fourth"));
plotModel.Series.Add(series);
var plotView = new OxyPlot.WindowsForms.PlotView();
plotView.Model = plotModel;
this.Controls.Add(plotView);
```
这将在WinForms窗体中创建一个带有旋转45°的X轴标题的脱颖而出的OxyPlot图表。
阅读全文