Style class for describing a line that is partly hidden and partly visible. The pattern is repetitive and can be configured.

Instances of DashedLine, like all LCJS style classes, are immutable, meaning that its setters don't modify the actual object, but instead return a completely new modified object.

Properties of DashedLine:

  • thickness : thickness of line as pixels.
  • fillStyle : description of line fill color. The supported fillStyles vary per component.
  • pattern : description of the repeating pattern of ON and OFF sections that defines the DashedLine.
  • patternScale : scaling factor for the length of each repeating stipple pattern.

DashedLine Usage:

Use DashedLine with:

Watch out! A common misuse is to attempt styling strokes or borders directly using fill style or color. Remember, when calling a setStrokeStyle method, a line style is expected! Carefully observe the order of wrapped styles: line style <- fill style <- color

 // Example, set line series stroke style to 1px dashed red.
LineSeries.setStrokeStyle(new DashedLine({
thickness: 1,
fillStyle: new SolidFill({ color: ColorRGBA( 255, 0, 0 ) }),
patternScale: StipplePatterns.DashedEqual,
patternScale: 1,
}))
 // Example, change stroke style to DashedLine without changing color / thickness
LineSeries.setStrokeStyle((stroke) => new DashedLine({
thickness: stroke.getThickness(),
fillStyle: stroke.getFillStyle(),
pattern: StipplePatterns.Dashed,
patternScale: 2,
}))

Related information:

For more line styles, see:

Hierarchy

  • DashedLineRecord
    • DashedLine

Implements

Constructors

  • Construct a DashedLine object, specifying any amount of its properties.

     // Example, 1px thick dashed red line.
    const solidRed = new DashedLine({
    thickness: 1,
    fillStyle: new SolidFill({ color: ColorRGBA( 255, 0, 0 ) }),
    pattern: StipplePatterns.Dashed,
    })

    Axis.setStrokeStyle(solidRed)

    Parameters

    • Optional props: Partial<Omit<DashedLineProperties, "type" | "lineType">>

      Object containing any amount of DashedLine properties.

    Returns DashedLine

Properties

fillStyle: FillStyle

Line fill style.

lineType: "solid" | "dashed"

Stipple pattern that describes the repeating pattern of ON and OFF sections that defines the DashedLine.

See StipplePattern for more information.

Defaults to StipplePatterns.DashedEqual

patternScale: number

Scaling factor for the length of each repeating stipple pattern.

Defaults to 3

thickness: number

Line thickness.

-1 can be used to signify smallest available thickness. With most features, this will result in slightly better GPU performance, but less detailed line.

Default value: 1.

type: "linestyle"

Methods

  • Get stipple pattern of the DashedLine object.

    Returns

    •    Stipple pattern.
      

    Returns StipplePattern

  • Get stipple pattern scale of the DashedLine object.

    Returns

    Stipple pattern scale.

    Returns number

  • Get thickness of DashedLine

    Returns

    Thickness as pixels

    Returns number

  • Construct a new line style object based on this one, but with modified fill style.

    Example (SolidFill):

    // specify new fillstyle
    lineStyle.setFillStyle( new SolidFill({
    color: ColorHex('#F00')
    }) )
    // change fillstyle properties
    lineStyle.setFillStyle(
    solidfill => solidfill.setA( 80 )
    )

    Returns

    New SolidLine object

    Parameters

    Returns DashedLine

  • Construct a new DashedLine object based on this one, but with modified stipple pattern scale.

    Scaling factor for the length of each repeating stipple pattern. By default 5.

    Returns

    New DashedLine object.

    Parameters

    Returns DashedLine

  • Construct a new DashedLine object based on this one, but with modified thickness.

    -1 can be used to signify smallest available thickness. With most features, this will result in slightly better GPU performance, but less detailed line.

    Parameters

    Returns DashedLine