PathBuilder
projects/common/chart/path/path-builder.ts
Import#
import { PathBuilder } from '@cngx/common/chart'
Description#
Single-slot LRU cache around an SVG d-attribute builder. Returned
by createPathBuilder; consumed by the <cngx-line> /
<cngx-area> family.
Index#
Methods#
build(data: unknown, xScale: ScaleFn, yScale: ScaleFn<number>) Build the SVG d attribute for the given data + scales. Same
(data, xScale, yScale) triple by reference returns the cached
string without re-running the O(n) point projection.
A row whose projected x or y is non-finite (a NaN value, an
invalid Date, a log scale fed zero) is not emitted as a path
command - it breaks the path into subpaths, d3's defined()
semantics. One NaN therefore renders as a gap in the line rather
than invalidating the whole d string.
PathSegment[]buildSegments(data: unknown, xScale: ScaleFn, yScale: ScaleFn<number>) The same projection split at non-finite rows: one entry per run of
consecutive finite points, carrying the run's path data and its
first/last projected x. <cngx-area> consumes this to close
every run to the baseline individually - closing the joined string
once would fill straight across the gaps. Shares the single-slot
cache with build.