首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >向LiveCharts.WinForms.CartesianChart添加垂直线

问向LiveCharts.WinForms.CartesianChart添加垂直线
EN

Stack Overflow用户
提问于 2021-11-17 18:58:11
回答 1查看 171关注 0票数 0

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

​

​

这是我使用的代码:

代码语言:javascript
复制
        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;
EN

回答 1

Stack Overflow用户

发布于 2021-11-18 07:38:55

您只需要添加以下代码:根据您的情况修改Value的值。

代码语言:javascript
复制
var axisSection = new AxisSection {
    Stroke=Brushes.Black,//colocr
    StrokeThickness=1,
    Value=2,//Modify this.
};

cartesianChart1.AxisX.Add(new Axis {
            Sections=new SectionsCollection
         {
             axisSection         
        }
});

输出:

​

​

如果您对此有疑问,请在下面添加评论。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70010079

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档