wpf - 如何在 WPF 工具包图表中的特定数据点添加垂直线
问题描述
我创建了一个多系列折线图,但我需要在循环的开头和结尾添加一个垂直线标记。我到处研究过,找不到怎么做。我需要从后面的代码中执行此操作,因为每个图表的值都会发生变化。
任何帮助是极大的赞赏。
解决方案
我发现添加垂直线的唯一方法是在特定的 x 和 y 值处添加数据点。请注意,这两个数据点具有相同的 X 值。一个从 100 的 y 值开始,另一个从 1200 开始,因此它是一条垂直直线。
//******************************************************
//This is for plotting vertical lines
//******************************************************
lsStartCycle.IndependentValueBinding = new Binding("Key");
lsStartCycle.DependentValueBinding = new Binding("Value");
lsStartCycle.ItemsSource = new KeyValuePair<DateTime, int>[]
{
new KeyValuePair<DateTime,int>(MyFunctions.StartCycleTime, 100),
new KeyValuePair<DateTime,int>(MyFunctions.StartCycleTime, 1200) };
在 XAML 中,我添加了一个新系列。
<DVC:LineSeries Name="lsStartCycle" Title="Cycle Start"
ItemsSource="{Binding}"
DataPointStyle="{StaticResource myLineDataPointStyle}"
PolylineStyle="{StaticResource DashedPolyLine}"
LegendItemStyle="{StaticResource HideLegend}"
IsSelectionEnabled="True">
</DVC:LineSeries>
注意:我的建议是远离 WPF 工具包图表。改用 MS Chart 控件,效果会更好。我最终改用了那个图表。
推荐阅读
- python - 一次安装Django rest框架项目的所有站点包
- python - 如何获取表单中的动态 html 表格条目到烧瓶?
- python - 如何摆脱csv中的第一列?
- c++ - 从存储为 Windows 资源的 png 获取 png 文件数据 (c++)
- flutter - 如何向 CustomPainter 添加投掷动画?
- java - 我无法为片段的 java 文件添加任何功能
- image-processing - 来自 Google Vision API 的 OCR 置信度得分
- google-search-console - 为什么 PageSpeed Insights 和 Search Console 之间的累积布局偏移不同?
- javascript - 如何按类名正确定位?
- mongodb - 来自少数操作的 MongoDB 聚合