Asif_Khan Posted February 20, 2008 Report Share Posted February 20, 2008 I have a line chart with upto 15 (or even more) series. the problem that i am facing is the duplication of colors. it becomes very difficult to distinguish between the plotted lines and relate them to a specific item in the legend box. An easy solution which i can think of is to put a single label on each line which would represent which item in the legend box actually relate to the line. Can this be done? if yes then please let me know how to get this sorted. Many thanks in advance! Quote Link to comment Share on other sites More sharing options...
Frank Posted February 20, 2008 Report Share Posted February 20, 2008 You can label the last point of each series, and align the label to the right of the last marker: private void LabelSeries (int seriesIndex) { PointAttributes lastPoint = chart1.Points[seriesIndex,chart1.Data.Points - 1]; lastPoint.PointLabels.Visible = true; lastPoint.PointLabels.Alignment = StringAlignment.Near; lastPoint.PointLabels.Format = "%L"; lastPoint.Text = chart1.Series[seriesIndex].Text; } for (int i = 0; i < chart1.Data.Series; i++) LabelSeries(i); Nothing will guarantee that the labels are not going to overlap with each other. Quote Link to comment Share on other sites More sharing options...
Asif_Khan Posted February 22, 2008 Author Report Share Posted February 22, 2008 Frank, many thanks for your reply. I need some further assistance. using the provided code, the labels can now be produced at the last point on the chart. However, this is not very useful as it is not necessary that all series on the graph would have data available and hence as a result some of the series do not have the label. secondly, it would be good to have this label on the first point on each series. Is there any way this could be acheived? Thanks for being helpful. Quote Link to comment Share on other sites More sharing options...
Frank Posted February 25, 2008 Report Share Posted February 25, 2008 > it is not necessary that all series on the graph would have data available ... If a series has no data at all, what's the label for? You asked how to put the label besides the line. If there is no data there is no line. > it would be good to have this label on the first point on each series This can be easily derived from my code: PointAttributes firstPoint = chart1.Points[seriesIndex,0]; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.