@d3-maps/core / line
line
Table of contents
Functions
createMidPoint()
function createMidPoint(pointsPair: [[number, number], [number, number]], midpoint?: MapLineMidpoint): [number, number];Creates a generated midpoint for a segment and offsets it relative to the segment itself
midpoint values are percentages of the full segment length
Parameters
| Parameter | Type |
|---|---|
pointsPair | [[number, number], [number, number]] |
midpoint | MapLineMidpoint |
Returns
[number, number]
getDefaultLine()
function getDefaultLine(points: MapLineCoordinates, curve?: MapLineCurve): string | undefined;Builds a line path directly from local points using the provided D3 curve
Parameters
| Parameter | Type |
|---|---|
points | MapLineCoordinates |
curve? | MapLineCurve |
Returns
string | undefined
getLinePath()
function getLinePath(context: MapContext | undefined, __namedParameters: MapLineOptions): string | undefined;Returns an SVG path string for a line in one of three modes:
- geographic
LineStringrendering viacontext.path(...) - projected custom rendering via
d3.line() - cartesian rendering for already-local coordinates
Parameters
| Parameter | Type |
|---|---|
context | MapContext |
__namedParameters | MapLineOptions |
Returns
string | undefined
getLineWithMidpoints()
function getLineWithMidpoints(
points: MapLineCoordinates,
curve?: MapLineCurve,
midpoint?: MapLineMidpoint): string | undefined;Inserts generated midpoints between consecutive points and renders the resulting path
Parameters
| Parameter | Type |
|---|---|
points | MapLineCoordinates |
curve? | MapLineCurve |
midpoint? | MapLineMidpoint |
Returns
string | undefined
Interfaces
MapLineOptions
Core line rendering options shared by framework adapters
Extended by
Properties
| Property | Type |
|---|---|
cartesian? | boolean |
coordinates | MapLineCoordinates |
curve? | MapLineCurve |
custom? | boolean |
midpoint? | MapLineMidpoint |
MapLineProps
Public map line props including map object styling and interaction support
Extends
MapObjectProps<TStyle>.MapLineOptions
Type Parameters
| Type Parameter | Default type |
|---|---|
TStyle | unknown |
Properties
| Property | Type | Inherited from |
|---|---|---|
cartesian? | boolean | MapLineOptions.cartesian |
coordinates | MapLineCoordinates | MapLineOptions.coordinates |
curve? | MapLineCurve | MapLineOptions.curve |
custom? | boolean | MapLineOptions.custom |
midpoint? | MapLineMidpoint | MapLineOptions.midpoint |
styles? | Partial<Record<"default" | "hover" |
Type Aliases
MapLineCoordinates
type MapLineCoordinates = [number, number][];Geographic or cartesian line coordinates expressed as ordered [x, y] pairs
MapLineCurve
type MapLineCurve = CurveFactory | CurveFactoryLineOnly;D3 curve factory used by custom and cartesian line rendering
MapLineMidpoint
type MapLineMidpoint = [number, number];Midpoint adjustment expressed as percentages of the segment length
- first value: moves the generated midpoint along the segment direction
- second value: moves the generated midpoint perpendicular to the segment direction