How to make series labels to show without overlapping each other? ASP.NET 4.0

那年仲夏 提交于 2019-12-11 07:57:48

问题


I am developing a chart (using ASP.NET CHART CONTROL) with about 2 or 3 series on it. Please look how it looks like now. As you can see, the labels are overlapping each other and it does not look very good. Is there any way I can solve this problem and improve the overall look of the chart?

Thanks.

My code:

series.ChartType = SeriesChartType.Line
series.YValueType = ChartValueType.Double
series.XValueType = ChartValueType.String
series.BorderWidth = 1
series.ShadowOffset = 1
series.IsValueShownAsLabel = True
series.ToolTip = dtrow.ToString
series.LabelForeColor = Color.Gray

series.LabelToolTip = dtrow.ToString

ChartRatings.Series.Add(series)

回答1:


Enable Smart Labels.

Chart1.Series["Series1"].SmartLabels.Enabled = true;

Take a look here SmartLabels




回答2:


You can also set labels outside the chart for more clear presentation.

Chart1.Series[0]["PieLabelStyle"] = "Outside";

For more, refer good article here: http://betterdashboards.wordpress.com/2009/01/20/overlapping-labels-on-a-pie-chart




回答3:


Adding to the marked answer, you can also add these

 chart1.Series[1].SmartLabelStyle.AllowOutsidePlotArea = LabelOutsidePlotAreaStyle.Yes
 chart1.Series[1].SmartLabelStyle.IsMarkerOverlappingAllowed = False
 chart1.Series[1].SmartLabelStyle.MovingDirection = LabelAlignmentStyles.Right


来源:https://stackoverflow.com/questions/12670580/how-to-make-series-labels-to-show-without-overlapping-each-other-asp-net-4-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!