Common Reference > LineStyle Struct

LineStyle Struct

Line-styles (built-in and user-defined dash-repeat sequences).

public struct LineStyle

Public Constructor

Creates a custom dashed line from a vector of even length giving on-off pattern, proportionally to the line width.

public LineStyle(
    int[] dashPattern 
);
public LineStyle(
    double[] dashPattern 
);

Example

sp.SetContourStyle(Color.Red,LineStyle.Dash,1.2);
sp.SetDatumLineStyle(Color.Maroon,new LineStyle(new int[] {12,4,24,4})); // Long dashes

Public Static Properties

Dash

Specifies a dashed line

DashDot

Specifies a line with alternating dashes and dots

DashDotDot

Specifies a line with alternating dashes and paired dots

Dot

Specifies a dotted line

Invisible

Specifies an undrawn (invisible) line

Solid

Specifies a solid line

Creating Custom Dashed Lines

A dashed line is defined by an array of numbers which give the on-off-on-off cycle. Dash lengths are always proportional the line width. Custom lines are drawn with square ends to make the segments exactly the length you ask for. The cycle always begins at the start of the pattern (so the dash-offset is zero) here. For example:

LineStyle mydash = new LineStyle(new int[]{1,2,2,2,3,2,4,2});

Note that in charts rendered to SVG you can animate the dash-offset to give the effect of a ‘walking line’.

Using a Pen object with Raster Output

It is possible to use an existing .Net Pen object to create your line, but this method will only be effective in charts rendered to raster formats.

public LineStyle(
    Pen myPen
);

The color and Width of the pen will be overridden by the color setting and width of the line being drawn.

Requirements

Namespace: Causeway

Assembly: SharpPlot (in sharpplot.dll)

See also ...

BoxStyle Structure | SharpPlot.SetDatumLineStyle Method | SharpPlot.SetGridLineStyle Method | SharpPlot.SetLineStyles Method


Send comments on this topic
© Dyalog Ltd 2021