OxyPlot:更改LinearBarSeries条宽

时间:2018-12-11 16:51:33

标签: c# width oxyplot

如何更改LinearBarSeries中条形的宽度。我尝试更改BarWidth属性,但无效。

var series = new LinearBarSeries() {
    BarWidth = 5
};
foreach (var value in values) {
    series.Points.Add(new DataPoint(DateTimeAxis.ToDouble(value.DateTime), value.Value));
}

1 个答案:

答案 0 :(得分:0)

看到类似的答案:https://stackoverflow.com/a/50453471/246758

您可能需要调整属性“ GapWidth”。从Oxyplot的BarSeries源代码中:

    /// <summary>
    /// Gets the actual width/height of the items of this series.
    /// </summary>
    /// <returns>The width or height.</returns>
    /// <remarks>The actual width is also influenced by the GapWidth of the CategoryAxis used by this series.</remarks>
    protected override double GetActualBarWidth()
    {
        var categoryAxis = this.GetCategoryAxis();
        return this.BarWidth / (1 + categoryAxis.GapWidth) / categoryAxis.GetMaxWidth();
    }