简体   繁体   English

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

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

I am using MSChart in Visual Studio 2013 and am getting some really weird results. 我在Visual Studio 2013中使用MSChart,并且得到了一些非常奇怪的结果。 On a line chart, when graphing the points, the labels show lower valued points as higher on the chart, which is visually confusing. 在折线图上,当绘制点图时,标签在图表上将价值较低的点显示为较高,这在视觉上令人困惑。 See the following: 请参阅以下内容:

在此处输入图片说明

The chart labels are set as follows: 图表标签设置如下:

        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;

in the constructor and in the function adding the points: 在构造函数和函数中添加要点:

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

Any ideas on how to get them in the correct order, or even over the points themselves? 关于如何以正确的顺序甚至是积分本身获取任何想法?

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

I believe the properties you are looking for are these: 我相信您正在寻找的属性是:

MaxMovingDistance  
MinMovingDistance  
MovingDirection  
AllowOutsidePlotArea  

A. Set AllowOutsidePlotArea if it is acceptable for the label to overlap the X-Axis. A.如果标签与X轴重叠是可接受的,则设置AllowOutsidePlotArea。

B. Set MovingDirection to Top in order to force all labels to be displayed over the DataPoint. B.将MovingDirection设置为Top,以强制将所有标签显示在DataPoint上。

C. You could also make the X-Axis cross the Y-Axis on -2 or something similar, making room for the smartlabels inside the plotarea. C.您还可以使X轴在-2或类似位置上与Y轴交叉,为绘图区域内的智能标签腾出空间。

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

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