下面是我的LiveChart.WinForms.CartesianChart,我想知道如何在下面的图表中添加垂直线-例如,我想在8月21日的点添加一条黑色垂直线(带有工具提示),并想知道如何才能做到这一点?

这是我使用的代码:
cartesianChart1.AxisX.Add(new Axis
{
Labels = myDateLabels,
Separator = new LiveCharts.Wpf.Separator { Step = 1 },
LabelsRotation = 270
});
cartesianChart1.AxisY.Add(new Axis
{
});
cartesianChart1.LegendLocation = LegendLocation.Bottom;
var axisSection = new AxisSection
{
Stroke = System.Windows.Media.Brushes.Black,
StrokeThickness = 1,
Value = 2
};
cartesianChart1.AxisX.Add(new Axis
{
Sections = new SectionsCollection
{
axisSection
}
});
SeriesCollection series = new SeriesCollection();
series.Add(new LineSeries { Title = "Sign Ups", Values = signUpsValues, Stroke = System.Windows.Media.Brushes.Blue, Fill = System.Windows.Media.Brushes.Transparent });
cartesianChart1.Series = series;发布于 2021-11-18 07:38:55
您只需要添加以下代码:根据您的情况修改Value的值。
var axisSection = new AxisSection {
Stroke=Brushes.Black,//colocr
StrokeThickness=1,
Value=2,//Modify this.
};
cartesianChart1.AxisX.Add(new Axis {
Sections=new SectionsCollection
{
axisSection
}
});输出:

如果您对此有疑问,请在下面添加评论。
https://stackoverflow.com/questions/70010079
复制相似问题