CngxAxisDomain
projects/common/chart/axis/axis-domain.ts
Import#
import { CngxAxisDomain } from '@cngx/common/chart'
Description#
Declares a scale domain to the parent <cngx-chart> without drawing
anything.
A chart builds its xScale from whichever projected axis occupies a
horizontal edge and its yScale from a vertical one. Usually that
axis also draws ticks and labels, and [cngxAxis] is what you want.
Sometimes the domain is all you need: a sparkline has no room for
decoration, but its line still has to know that y runs 0 to 100.
<cngx-chart [data]="readings()">
<svg:g cngxAxisDomain position="bottom" type="band" [domain]="labels()"></svg:g>
<svg:g cngxAxisDomain position="left" [domain]="[0, 100]"></svg:g>
<svg:g cngxLine></svg:g>
</cngx-chart>Reserving nothing is the behavioural difference that matters. The chart shrinks its plot area by the room each axis's decoration needs; this one has none, so an 80x24 sparkline keeps all 80x24 for its mark instead of losing a gutter to ticks nobody draws.
Attribute-selector on <svg:g> for the same reason [cngxAxis] is:
a <cngx-axis-domain> element inside <svg> would land in the XHTML
namespace. Nothing renders either way, but the host stays a legal SVG
child.
Metadata#
Providers#
CNGX_CHART_AXIS- useExisting
CngxAxisDomain