Show line series label only once...

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
LVL 34
Mike EghtebasDatabase and Application DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Open in new window

0
Mike EghtebasDatabase and Application DeveloperAuthor 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

0
Robert SchuttSoftware EngineerCommented:
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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
That was it.

Thanks,

Mike
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.