We help IT Professionals succeed at work.

Show line series label only once...

304 Views
Last Modified: 2014-08-07
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

Robert SchuttSoftware Engineer
CERTIFIED EXPERT

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
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Mike EghtebasDatabase and Application Developer

Author

Commented:
That was it.

Thanks,

Mike
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.