Show line series label only once...

Mike Eghtebas
Mike Eghtebas used Ask the Experts™
on
By setting the following property to true:

series2.IsValueShownAsLabel = true;

Understandably, I am getting series value show for all occurrences.

Question: How can I change my code to make it show only once as displayed on the attached image?

Thank you.
Series series2 = new Series("Default2");
            series2.ChartType = SeriesChartType.Line;
            series2.Color = System.Drawing.Color.Purple;
            series2.BorderWidth = 2; 
            series2.BorderDashStyle = ChartDashStyle.Dash;
            series2.IsValueShownAsLabel = true; //********************************
            chart.Series.Add(series2);

Open in new window

chartLabel.png
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Robert SchuttSoftware Engineer

Commented:
should be as easy as:
                series2.IsValueShownAsLabel = false;
                series2.Points[0].IsValueShownAsLabel = true;

Open in new window

Mike EghtebasDatabase and Application Developer

Author

Commented:
Hi Robert,

I am getting ArgumentOutOfRangeException error at line 14.
Chart chart = new Chart();

            Series series = new Series("Default");
            series.ChartType = SeriesChartType.Column;
            chart.Series.Add(series);

            Series series2 = new Series("Default2");
            series2.ChartType = SeriesChartType.Line;
            series2.Color = System.Drawing.Color.Purple;// change color to put
            series2.BorderWidth = 2; // this is actually the line width...
            series2.BorderDashStyle = ChartDashStyle.Dash;
            //series2.IsValueShownAsLabel = true;
            series2.IsValueShownAsLabel = false;
            series2.Points[0].IsValueShownAsLabel = true;
            chart.Series.Add(series2);

Open in new window

Software Engineer
Commented:
Ah, I'm working off a different version of your code I think. Make sure this is called after the chart.DataBind() call. Also couldn't hurt probably to double check in the code that series2.Points.Count > 0.
Mike EghtebasDatabase and Application Developer

Author

Commented:
That was it.

Thanks,

Mike

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial