实时图表将分隔符设置为边缘

时间:2017-03-16 01:56:37

标签: c# wpf livecharts

将Live Charts与WPF应用程序一起使用。

目前,分隔符设置为我希望分隔符设置为标签边缘/边框的标签

模拟当前图表

|   |   |   |
|   |   |   |
A   B   C   D

我希望图表看起来如何

|   |   |   |   |
|   |   |   |   |
  A   B   C   D

编辑:想提一下实时图表Basic Column有我想要的样子(注意图中x轴上的线条),但我的出现就像Basic Line

1 个答案:

答案 0 :(得分:0)

我使用轴部分来解决这个问题

    myChart.AxisX(0).Sections = New LiveCharts.Wpf.SectionsCollection
    myChart.AxisX(0).Sections.Add(New LiveCharts.Wpf.AxisSection With {.FromValue = -0.5,
                                 .ToValue = -0.5, .Stroke = Brushes.Gainsboro, .StrokeThickness = 0.5})

    For Each xSec In x.Labels.Select(Function(fn) New LiveCharts.Wpf.AxisSection With {.FromValue = x.Labels.IndexOf(fn) + 0.5,
                                 .ToValue = x.Labels.IndexOf(fn) + 0.5, .Stroke = Brushes.Gainsboro, .StrokeThickness = 0.5})
        myChart.AxisX(0).Sections.Add(xSec)
    Next

注意:显然这只适用于你的标签是唯一的,否则你需要实现一个不同的循环