[英]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.