Skip to content

Function: resolveDashPattern() ​

ts
function resolveDashPattern(dash, lineWidth, viewport?): number[];

Experimental

Resolve a dash spec to on/off lengths in CSS px. Returns an empty array for a solid line.

  • Named styles scale with the line width exactly like Plotly (Drawing.dashStyle), using max(width, 3) so thin lines still get visible dashes.
  • Custom lists follow SVG stroke-dasharray: unitless or px values are CSS px; percentages are relative to the normalized viewport diagonal sqrt((w² + h²) / 2); an odd-length list is repeated to make it even; a negative value, a non-numeric token, or an all-zero list yields a solid line.
  • Lists longer than MAX_DASH_ENTRIES are truncated to an even prefix.

Parameters ​

ParameterType
dashLineDash | undefined
lineWidthnumber
viewport{ height: number; width: number; }
viewport.heightnumber
viewport.widthnumber

Returns ​

number[]

Released under the MIT License.