dashed lines in chart become solid if points are close together

Posted on 2012-08-17
Last Modified: 2012-10-12
I am using the Microsoft chart control in visual studio 2010 on a Windows application. When I set the property to select the line style to dashed, it works, but if the line segment between data points is smaller than the dash length, the line restarts at each point and effectively becomes a solid line.

                var series = chart1.Series.Add(TagGroup);
                series.BorderDashStyle = ChartDashStyle.Dash;

Is there a way around this?
Question by:cgammans
    LVL 43

    Expert Comment

    >>Is there a way around this?

    Use less data points?

    Author Comment

    Unfortunately that is not an option.
    LVL 43

    Accepted Solution

    Change style to dots - or put up with the current behaviour.  :-(

    Author Comment

    The requirements are that the user must be able to select between line types of solid, dots, dash, dot-dash.

    I will look around at other chart controls.

    I may also have to try to catch the onPaint event for each line segment and adjust the pen that is used. I believe the pen is based off of an array of floats that can set the Dashpattern property of the line.

    If I keep track of the line segments as they are drawn, I can adjust the dashpattern array so that it doesn't just start over again from the beginning at each segment. That will give it a smooth pattern, even around multiple segments.

    I was hoping it would be easier though. But apparently I'll have to give this a try.

    I am creating a chart control which is inherited from the MS Chart control and then trying to find how to get at the OnPaint event for each segment.

    Any ideas?

    Author Closing Comment

    I'll live with it for now.

    1) If the line thickness is small, then the problem is not as bad.

    2) I've added zooming to the chart, so in places where the problem exists, they can zoom in for clarification.

    I put the problem on a back burner then demo'ed it to the client and they were OK for now.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now