Skip to content

SP4: Support custom dash patterns #2690

@mocakturk

Description

@mocakturk

Feature Suggestion

Feature description: Dash patterns are embedded currently (see code snippet below). In my opinion, they don't look good. I need to change the dash patterns when ScottPlot is creating a pen.

Current GDI class:

var pen = new System.Drawing.Pen(color, (float)width);

if (lineStyle == LineStyle.Solid || lineStyle == LineStyle.None)
{
    pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
}
else if (lineStyle == LineStyle.Dash)
    pen.DashPattern = new float[] { 8.0F, 4.0F };  // LET'S MAKE THIS CONFIGURABLE
else if (lineStyle == LineStyle.DashDot)
    pen.DashPattern = new float[] { 8.0F, 4.0F, 2.0F, 4.0F };  // LET'S MAKE THIS CONFIGURABLE
else if (lineStyle == LineStyle.DashDotDot)
    pen.DashPattern = new float[] { 8.0F, 4.0F, 2.0F, 4.0F, 2.0F, 4.0F };  // LET'S MAKE THIS CONFIGURABLE
else if (lineStyle == LineStyle.Dot)
    pen.DashPattern = new float[] { 2.0F, 4.0F };  // LET'S MAKE THIS CONFIGURABLE
else
    throw new NotImplementedException("line style not supported");

To be added: Following properties can be added to GDI class:

public float[] DashPatternForDash {get;set;} => new float[] { 8.0F, 4.0F };
public float[] DashPatternForDashDot {get;set;} => new float[] { 8.0F, 4.0F, 2.0F, 4.0F };
public float[] DashPatternForDashDotDot {get;set;} => new float[] { 8.0F, 4.0F, 2.0F, 4.0F, 2.0F, 4.0F };
public float[] DashPatternForDot {get;set;} => new float[] { 2.0F, 4.0F };

Thank you,
Murat

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions