【问题标题】:How to increase the drawing area for an Axis in Oxyplot?如何增加 Oxyplot 中轴的绘图区域?
【发布时间】:2014-07-08 17:41:19
【问题描述】:

我正在编写一个实用程序来通过电子邮件发送一个显示每个人任务的堆积柱形图。现在我在OxyPlot.WindowsForms 中使用PngExporter 来导出绘图,但我似乎无法弄清楚如何控制图像的下限。用户名可能很长并且会溢出,我想扩展底部轴的绘图区域,以便所有名称都可见。

这就是它现在的样子

这是我目前所拥有的代码

        var plot = new PlotModel()
        {
            Title = "Mantis Report"
        };

        // CATEGORY AXIS CODE====================================
        var categoryaxis = new CategoryAxis();
        foreach (var e in employees)
            categoryaxis.ActualLabels.Add(paddedString("Jebediah Kerman"));
        categoryaxis.Angle = 30;

        categoryaxis.AxisTickToLabelDistance = 10;
        // CATEGORY AXIS CODE====================================

        plot.Axes.Add(categoryaxis);
        plot.Axes.Add(new LinearAxis());

        var series = new ColumnSeries();
        series.IsStacked = true;

        int employeeindex = 0;
        foreach (var employee in employees)
        {
            foreach (var entry in employee.Tasks)
            {
                series.Items.Add(new ColumnItem(entry.Value, employeeindex) { Color = colors[entry.Key] });
            }
            employeeindex++;
        }

        plot.Series.Add(series);

        plot.LegendTitle = "legend";
        plot.LegendPlacement = LegendPlacement.Outside;
        foreach (string task in tasktypes)
        {
            var newseries = new ColumnSeries()
            {
                FillColor = colors[task]
                , Title = task
            };
            plot.Series.Add(newseries);
        }

paddedString() 将给定字符串的长度添加到空格中并返回它。这是我目前“翻译”标签的方法,但现在我担心绘制名称的其余部分。

我浏览了CategoryAxis 页面,但我似乎找不到扩展轴区域以便完全显示名称的方法。不,我不想只是缩短用户名。

【问题讨论】:

    标签: c# oxyplot


    【解决方案1】:

    这在 WPF 应用程序中对我有用。

    var currentMargins = plotModel.PlotMargins;
    plotModel.PlotMargins = new OxyThickness(currentMargins.Left, currentMargins.Top, currentMargins.Right, 100);
    

    【讨论】:

      猜你喜欢
      • 2018-01-12
      • 2012-03-03
      • 2019-03-13
      • 2021-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多