Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

wpf graph dot line type not working

Solved!
Go to solution

When I set line type to dot, dash-dot, dash-dot-dot, I don't see any dots, only dashes. Graph is in vector mode. Solid lines are also working of course.

0 Kudos
Message 1 of 6
(7,201 Views)
Solution
Accepted by topic author eugenem

I was not able to reproduce the issue. Here is the test code I used:


    XAML
    <ni:Graph x:Name="graph" RenderMode="Vector">
        <ni:Graph.DefaultPlotRenderers>
            <ni:LinePlotRenderer /> <!-- Solid -->
            <ni:LinePlotRenderer StrokeDashArray="4 4" /> <!-- Dash -->
            <ni:LinePlotRenderer StrokeDashArray="1 4" /> <!-- Dot -->
            <ni:LinePlotRenderer StrokeDashArray="4 4 1 4" /> <!-- Dash Dot -->
            <ni:LinePlotRenderer StrokeDashArray="4 4 1 4 1 4" /> <!-- Dash Dot Dot -->
        </ni:Graph.DefaultPlotRenderers>
    </ni:Graph>

    Code
        graph.DataSource = Enumerable.Range( 0, 5 ).Select( plot =>
            Enumerable.Range( 0, 201 )
                .Select( i => plot + Math.Sin( i * Math.PI / 200 ) )
                .ToArray( )
        ).ToArray( );


When I run, it looks like this:


Graph Line Styles

~ Paul H
0 Kudos
Message 2 of 6
(7,194 Views)

  // Summary:

  //     Implements a set of predefined System.Windows.Media.DashStyle objects.

  public static class DashStyles

  {

    // Summary:

    //     Gets a System.Windows.Media.DashStyle with a System.Windows.Media.DashStyle.Dashes

    //     property equal to 2,2.

    //

    // Returns:

    //     A dash sequence of 2,2, which describes a sequence composed of a dash that

    //     is twice as long as the pen System.Windows.Media.Pen.Thickness followed by

    //     a space that is twice as long as the System.Windows.Media.Pen.Thickness.

    public static DashStyle Dash { get; }

    //

    // Summary:

    //     Gets a System.Windows.Media.DashStyle with a System.Windows.Media.DashStyle.Dashes

    //     property equal to 2,2,0,2.

    //

    // Returns:

    //     A dash sequence of 2,2,0,2.

    public static DashStyle DashDot { get; }

    //

    // Summary:

    //     Gets a System.Windows.Media.DashStyle with a System.Windows.Media.DashStyle.Dashes

    //     property equal to 2,2,0,2,0,2.

    //

    // Returns:

    //     A dash sequence of 2,2,0,2,0,2.

    public static DashStyle DashDotDot { get; }

    //

    // Summary:

    //     Gets a System.Windows.Media.DashStyle with a System.Windows.Media.DashStyle.Dashes

    //     property equal to 0,2.

    //

    // Returns:

    //     A dash sequence of 0,2.

    public static DashStyle Dot { get; }

 

 

These are standard definitions and they aren't working. Yours do work though. Thanks!

0 Kudos
Message 3 of 6
(7,183 Views)

From what I can tell, DashStyle is only used to initialize a Pen, whereas other objects like shapes expose separate StrokeDashArray and StrokeDashOffset properties instead. If you want to use the pre-defined styles, you can select the Dashes property on the appropriate instance:


    <Rectangle Stroke="Black"
               StrokeThickness="5"
               StrokeDashCap="Square"
               StrokeDashArray="{Binding Dashes, Source={x:Static DashStyles.DashDot}}" />

~ Paul H
0 Kudos
Message 4 of 6
(7,176 Views)

I took Dashes of course

 

note that numbers are different, I think this is the problem

0 Kudos
Message 5 of 6
(7,174 Views)

I think which numbers you need depends on the stroke dash cap being used: Flat requires a non-zero size, while other values can use a zero size and still show a line.

~ Paul H
0 Kudos
Message 6 of 6
(7,172 Views)