繁体   English   中英

有没有一种方法可以在MSChart折线图中对齐标签?

[英]Is there a way to align labels in MSChart line charts?

我在Visual Studio 2013中使用MSChart,并且得到了一些非常奇怪的结果。 在折线图上,当绘制点图时,标签在图表上将价值较低的点显示为较高,这在视觉上令人困惑。 请参阅以下内容:

在此处输入图片说明

图表标签设置如下:

        recentFailureChart.Series["FailureCount"].BorderWidth = 3;
            recentFailureChart.Series["FailureCount"].Color = Color.Red;
            recentFailureChart.Series["FailureCount"].LabelBackColor = Color.Red;
            recentFailureChart.Series["FailureCount"].LabelBorderColor = Color.Black;
            recentFailureChart.Series["FailureCount"].LabelBorderDashStyle = ChartDashStyle.Solid;
            recentFailureChart.Series["FailureCount"].LabelBorderWidth = 1;
            recentFailureChart.Series["FailureCount"].LabelForeColor = Color.White;
        SmartLabelStyle smartLabel = new SmartLabelStyle();
        smartLabel.AllowOutsidePlotArea = LabelOutsidePlotAreaStyle.Partial;
        smartLabel.IsMarkerOverlappingAllowed = true;
        recentFailureChart.Series["FailureCount"].SmartLabelStyle = smartLabel;

在构造函数和函数中添加要点:

        recentFailureChart.Series["FailureCount"].Points.InsertY(0, failCount);
        recentFailureChart.Series["FailureCount"].Points[0].Font = labelFont;

关于如何以正确的顺序甚至是积分本身获取任何想法?

我看不到上面的“图表图像”有什么问题,点14和12正确地绘制在5、3和1较低点的上方。我注意到的唯一一点是,并不是所有的点都在图表中可见,可以通过使用Chart1.ChartAreas(0).AxisY.Maximum = 100将Y轴的最大值设置为较高的值(例如100)来更改此值。

我相信您正在寻找的属性是:

MaxMovingDistance  
MinMovingDistance  
MovingDirection  
AllowOutsidePlotArea  

A.如果标签与X轴重叠是可接受的,则设置AllowOutsidePlotArea。

B.将MovingDirection设置为Top,以强制将所有标签显示在DataPoint上。

C.您还可以使X轴在-2或类似位置上与Y轴交叉,为绘图区域内的智能标签腾出空间。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM