【问题标题】:OxyPlot : ColumnSeries/BarSeries display value of each columnOxyPlot : ColumnSeries/BarSeries 显示每列的值
【发布时间】:2014-01-02 16:07:20
【问题描述】:

在我的 WPF 应用程序中,我使用 OxyPlot。我将我的数据绑定到 PlotModel 并且一切正常。

我想在图表上显示每一列的值。有可能吗?

作为参考,这个example of BarSeries在现场,我希望在每列分别显示2009年、2010年和2011年苹果的实际价值。即 2009Apples 列的 Value1 的值,2010Apples 的 Value2 等等。

我查看了 BarSeries 的 API(对于 WPF ColumnSeries 可以互换使用)。 条形图和其他图的教程。但是在任何地方都找不到这样的东西。

我如何做到这一点?

【问题讨论】:

    标签: wpf stackedbarseries oxyplot


    【解决方案1】:

    是的,只需设置您的系列的LabelFormatString 属性。

    var theSeries = new ColumnSeries();
    theSeries.LabelFormatString = "{0:F2}"; // Example: 1.2311 will display like "1.23"
    
    // Add your columns
    theSeries.Items.Add(new ColumnItem(someValue);
    // ...
    

    您还可以设置一个名为LabelPlacement 的可选属性。默认值为LabelPlacement.Outside

    theSeries.LabelPlacement = LabelPlacement.Middle;
    

    【讨论】:

    • 感谢您的支持。仅供参考,FormatString 不是选项,你必须输入否则什么都不会显示。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多