11-04-2013 03:23 AM
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.
Solved! Go to Solution.
11-04-2013 11:33 AM
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:
11-05-2013 02:32 AM - edited 11-05-2013 02:33 AM
// 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!
11-05-2013 08:46 AM
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}}" />
11-05-2013 09:38 AM
I took Dashes of course
note that numbers are different, I think this is the problem
11-05-2013 10:24 AM
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.