@blueprint-chart/lib 1.8.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts/axis/axis-service.d.ts +9 -0
- package/dist/charts/axis-options.d.ts +3 -0
- package/dist/charts/canvas/canvas.d.ts +2 -5
- package/dist/charts/category-label-line.d.ts +16 -0
- package/dist/charts/chart-helpers.d.ts +2 -3
- package/dist/charts/chart-options.d.ts +2 -0
- package/dist/charts/contrast.d.ts +4 -3
- package/dist/charts/date-parse.d.ts +6 -0
- package/dist/charts/frame/frame.d.ts +6 -0
- package/dist/charts/legend/legend-size.d.ts +13 -0
- package/dist/charts/parse-data.d.ts +2 -0
- package/dist/charts/plugins/annotations/shared.d.ts +13 -2
- package/dist/charts/plugins/arc-labels.d.ts +9 -1
- package/dist/charts/plugins/highlight.d.ts +9 -3
- package/dist/charts/scale-helpers.d.ts +15 -8
- package/dist/charts/series-helpers.d.ts +22 -1
- package/dist/charts/stack-helpers.d.ts +1 -1
- package/dist/charts/text-measure.d.ts +25 -0
- package/dist/charts/themes/index.d.ts +6 -0
- package/dist/charts/types.d.ts +10 -4
- package/dist/charts/value-label-fit.d.ts +31 -0
- package/dist/dsl/converter.d.ts +5 -0
- package/dist/dsl/quoting.d.ts +16 -0
- package/dist/dsl/types.d.ts +42 -0
- package/dist/dsl/validate.d.ts +6 -0
- package/dist/embed.js +1 -1
- package/dist/enums.d.ts +23 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.js +625 -302
- package/dist/lib/lib.iife.js +44 -16
- package/dist/node-backend/index.js +3410 -2223
- package/dist/render/chart-a11y.d.ts +14 -0
- package/dist/render/frame-svg.d.ts +51 -0
- package/dist/render/index.d.ts +3 -0
- package/dist/render/post-render.d.ts +2 -0
- package/dist/{render-bpc-Bgb7rsgM.js → render-bpc-BSt4wOjf.js} +4191 -2972
- package/dist/runtime/chart-css.d.ts +1 -1
- package/dist/runtime-DDhsXDn5.js +84 -0
- package/dist/runtime.js +2 -2
- package/dist/transforms/applyFilter.d.ts +2 -0
- package/dist/transforms/applyGroupBy.d.ts +2 -0
- package/dist/transforms/applyHideColumns.d.ts +2 -0
- package/dist/transforms/applyParse.d.ts +3 -0
- package/dist/transforms/applyRename.d.ts +2 -0
- package/dist/transforms/applySort.d.ts +2 -0
- package/dist/transforms/applyTranspose.d.ts +2 -0
- package/dist/transforms/index.d.ts +30 -0
- package/dist/transforms/parseOperations.d.ts +15 -0
- package/dist/transforms/shared.d.ts +4 -0
- package/dist/transforms/table.d.ts +22 -0
- package/dist/transforms/transformValue.d.ts +1 -0
- package/dist/transforms/types.d.ts +13 -0
- package/package.json +1 -1
- package/src/charts/chart.scss +29 -4
- package/dist/runtime-BnrDRLyH.js +0 -84
|
@@ -14,6 +14,15 @@ export interface AxisServiceConfig {
|
|
|
14
14
|
};
|
|
15
15
|
order?: 'vertical-first' | 'horizontal-first';
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Drop the cached AxisService when a container switches chart type.
|
|
19
|
+
*
|
|
20
|
+
* The cache is keyed per container only, so the next type inherits the previous
|
|
21
|
+
* one's axis DOM, and d3-axis's tick data-join reuses ticks that match by
|
|
22
|
+
* value, so a type that stripped its tick labels (`labelPosition = off`) leaves
|
|
23
|
+
* the next type's ticks permanently text-less.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resetAxesOnChartTypeChange(container: HTMLElement, chartType: string): void;
|
|
17
26
|
export declare class AxisService {
|
|
18
27
|
private vGroup;
|
|
19
28
|
private hGroup;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Margin } from '../types';
|
|
1
|
+
import { AxisRange, Margin } from '../types';
|
|
2
2
|
export interface CanvasElements {
|
|
3
3
|
svg: SVGSVGElement;
|
|
4
4
|
chartArea: SVGGElement;
|
|
@@ -20,10 +20,7 @@ export declare function computeMarginDelta(priorMargin: Pick<Margin, 'top' | 'le
|
|
|
20
20
|
* Estimate the pixel width of the widest tick label for a vertical axis.
|
|
21
21
|
* Uses an offscreen canvas for measurement, falling back to character-count estimation.
|
|
22
22
|
*/
|
|
23
|
-
export declare function estimateVerticalLabelWidth(values: number[], range?:
|
|
24
|
-
min?: number;
|
|
25
|
-
max?: number;
|
|
26
|
-
}, numberFormat?: string | null, scaleType?: string): number;
|
|
23
|
+
export declare function estimateVerticalLabelWidth(values: number[], range?: AxisRange, numberFormat?: string | null, scaleType?: string): number;
|
|
27
24
|
/**
|
|
28
25
|
* Estimate the pixel width of the widest string label (for band/category axes).
|
|
29
26
|
*/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Height of the strip an inline category label is drawn in. */
|
|
2
|
+
export declare const CATEGORY_LABEL_HEIGHT = 13;
|
|
3
|
+
/**
|
|
4
|
+
* Height the inline category label may take out of `extent` — a band's
|
|
5
|
+
* thickness, or the plot height for column charts. Shrinks the strip, and then
|
|
6
|
+
* gives up on it, rather than letting the subtraction turn the bar's own extent
|
|
7
|
+
* negative: a rect with a negative height is not rendered at all, so a dense
|
|
8
|
+
* chart lost every one of its bars.
|
|
9
|
+
*/
|
|
10
|
+
export declare function categoryLabelLineHeight(extent: number): number;
|
|
11
|
+
/**
|
|
12
|
+
* Whether a horizontal bar chart should draw its category labels above their
|
|
13
|
+
* bars instead of in the left gutter. An explicit `outside` keeps them in the
|
|
14
|
+
* gutter: the author asked for them there.
|
|
15
|
+
*/
|
|
16
|
+
export declare function categoryLabelsNeedTheirOwnLine(containerWidth: number, verticalLabelPosition?: string): boolean;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export declare function buildChartOptions(opts: Partial<ChartTypeOptions>, backgroundColor?: string): Partial<ChartOptions>;
|
|
1
|
+
export { parseData } from './parse-data';
|
|
2
|
+
export { buildChartOptions } from './chart-options';
|
|
@@ -28,9 +28,10 @@ export declare function resolveBackgroundColor(el?: Element | null): string;
|
|
|
28
28
|
export declare function readableColor(color: string, bg?: string): string;
|
|
29
29
|
/**
|
|
30
30
|
* Adjusts an array of colors so that:
|
|
31
|
-
* 1. Every color is readable against `bg` (WCAG contrast ratio >=
|
|
32
|
-
* 2.
|
|
31
|
+
* 1. Every color is readable against `bg` (WCAG contrast ratio >= MIN_CONTRAST).
|
|
32
|
+
* 2. No color is perceptually close to any other (deltaE >= MIN_ADJACENT_DELTA_E).
|
|
33
33
|
*
|
|
34
|
-
*
|
|
34
|
+
* Lightness is changed first; hue rotates only when the lightness axis is
|
|
35
|
+
* exhausted, so a palette whose entries share a hue still comes out distinct.
|
|
35
36
|
*/
|
|
36
37
|
export declare function adjustColorsForBackground(colors: string[], bg: string): string[];
|
|
@@ -6,6 +6,12 @@ export declare function parseDate(s: string): Date | null;
|
|
|
6
6
|
* Jan 1 2020 rather than the number 2020.
|
|
7
7
|
*/
|
|
8
8
|
export declare function parseDateOrNumber(s: string): number | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Parse a string as a plain number or, failing that, as a date (epoch ms).
|
|
11
|
+
* Numbers take precedence so a numeric axis bound like "2000" stays the
|
|
12
|
+
* number 2000 instead of Jan 1 2000.
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseNumberOrDate(s: string): number | undefined;
|
|
9
15
|
export declare function detectDates(labels: string[]): {
|
|
10
16
|
dates: Date[];
|
|
11
17
|
granularity: DateGranularity;
|
|
@@ -5,4 +5,10 @@ export interface FrameElements {
|
|
|
5
5
|
body: HTMLElement;
|
|
6
6
|
footer: HTMLElement;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Expand a CSS `padding` shorthand to its four sides. The stylesheet feeds each
|
|
10
|
+
* side into a separate shorthand slot, so a raw multi-value string would build
|
|
11
|
+
* an over-long declaration that the browser rejects outright.
|
|
12
|
+
*/
|
|
13
|
+
export declare function expandPaddingShorthand(padding: string): [string, string, string, string];
|
|
8
14
|
export declare function createFrame(container: HTMLElement, options?: FrameOptions | null): FrameElements;
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Legend item text and the px advance to the next item. `maxWidth` is the row
|
|
3
|
+
* width: a single item wider than the row is truncated with an ellipsis, since
|
|
4
|
+
* nothing downstream clips it and the text otherwise runs past the frame edge.
|
|
5
|
+
* The suffix carries the value, so it survives and the label absorbs the cut.
|
|
6
|
+
*/
|
|
7
|
+
export declare function fitLegendItem(label: string, suffix?: string, maxWidth?: number): {
|
|
8
|
+
label: string;
|
|
9
|
+
suffix: string;
|
|
10
|
+
width: number;
|
|
11
|
+
};
|
|
12
|
+
/** Width a vertical legend column needs for `texts`. */
|
|
13
|
+
export declare function legendColumnWidth(texts: string[]): number;
|
|
1
14
|
export declare function estimateLegendSize(labels: string[], position: string, availableWidth?: number): {
|
|
2
15
|
width: number;
|
|
3
16
|
height: number;
|
|
@@ -22,6 +22,11 @@ export declare function bboxEdgeToward(bbox: {
|
|
|
22
22
|
y: number;
|
|
23
23
|
};
|
|
24
24
|
export declare function ensureArrowMarker(svg: SVGElement | null, color?: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* A non-positive radius paints nothing — SVG rejects a negative `r` outright —
|
|
27
|
+
* so an unusable size resolves to the documented default instead.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveCircleRadius(size?: number): number;
|
|
25
30
|
export declare function renderTargetCircle(g: d3.Selection<SVGGElement, unknown, null, undefined>, cx: number, cy: number, opts?: {
|
|
26
31
|
size?: number;
|
|
27
32
|
style?: StrokeStyle;
|
|
@@ -53,5 +58,11 @@ export declare function renderAnnotationText(g: d3.Selection<SVGGElement, unknow
|
|
|
53
58
|
backgroundColor?: string;
|
|
54
59
|
textOutline?: boolean;
|
|
55
60
|
}): void;
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Position of a range endpoint on the category axis, or `null` when the endpoint
|
|
63
|
+
* does not resolve. Anchoring an unresolved endpoint at the plot origin would
|
|
64
|
+
* silently highlight a category the author never named.
|
|
65
|
+
*/
|
|
66
|
+
export declare function resolveXPosition(value: number | string, scaleX: AnnotationContext['scaleX'], anchor?: RangeAnchor): number | null;
|
|
67
|
+
/** Position of a range endpoint on the value axis, or `null` when it does not resolve. */
|
|
68
|
+
export declare function resolveYPosition(value: number | string, scaleY: d3.ScaleLinear<number, number> | d3.ScaleSymLog<number, number>): number | null;
|
|
@@ -44,8 +44,16 @@ export declare function renderAutoArcLabels(parent: d3.Selection<SVGGElement, un
|
|
|
44
44
|
* Estimate extra margins needed for arc labels beyond what the arc already
|
|
45
45
|
* occupies. The text column sits at outerRadius + STUB_LENGTH + HORIZONTAL_SEG + 6
|
|
46
46
|
* from centre; we need room for the text itself beyond that.
|
|
47
|
+
*
|
|
48
|
+
* `available` is the box the arc has to fit in. The margins are capped against
|
|
49
|
+
* it, because they are subtracted from the canvas with no other lower bound:
|
|
50
|
+
* one long label, a phone-width container or twenty slices otherwise leave a
|
|
51
|
+
* radius of zero and no arcs are painted.
|
|
47
52
|
*/
|
|
48
|
-
export declare function estimateArcLabelMargins(labels: string[], outerRadius: number
|
|
53
|
+
export declare function estimateArcLabelMargins(labels: string[], outerRadius: number, available?: {
|
|
54
|
+
width: number;
|
|
55
|
+
height: number;
|
|
56
|
+
}): {
|
|
49
57
|
left: number;
|
|
50
58
|
right: number;
|
|
51
59
|
top: number;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
/** Opacity applied to non-targeted marks when a highlight is active. */
|
|
2
2
|
export declare const HIGHLIGHT_DIM_OPACITY = 0.35;
|
|
3
|
-
/**
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Build the set of highlighted target keys from the DSL highlight directives,
|
|
5
|
+
* keeping only the ones present in `keys` (the mark keys the caller will draw).
|
|
6
|
+
* A target naming a renamed or misspelled category would otherwise leave a
|
|
7
|
+
* non-empty set that matches no mark, and `highlightOpacity` would dim
|
|
8
|
+
* everything instead of emphasising anything.
|
|
9
|
+
*/
|
|
10
|
+
export declare function highlightTargetSet(highlights: {
|
|
5
11
|
target: string;
|
|
6
|
-
}[]): Set<string>;
|
|
12
|
+
}[] | undefined, keys: Iterable<string>): Set<string>;
|
|
7
13
|
/**
|
|
8
14
|
* Opacity for a mark given the active highlight targets:
|
|
9
15
|
* no targets → `base`; this key targeted → `base`; otherwise → HIGHLIGHT_DIM_OPACITY.
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
+
import { AxisRange } from './types';
|
|
1
2
|
import { ScaleType } from '../enums';
|
|
2
3
|
/**
|
|
3
4
|
* Filter chart labels (and corresponding data) by a horizontal axis range.
|
|
4
5
|
* Returns the indices of labels that fall within [min, max].
|
|
5
6
|
*/
|
|
6
|
-
export declare function filterLabelsByRange(labels: string[], range?:
|
|
7
|
-
min?: number;
|
|
8
|
-
max?: number;
|
|
9
|
-
}): number[];
|
|
7
|
+
export declare function filterLabelsByRange(labels: string[], range?: AxisRange): number[];
|
|
10
8
|
export declare const DEFAULT_BAR_GAP = 60;
|
|
11
9
|
/**
|
|
12
10
|
* Convert a barGap (percentage of bar size) to a d3 scaleBand paddingInner value.
|
|
@@ -14,7 +12,16 @@ export declare const DEFAULT_BAR_GAP = 60;
|
|
|
14
12
|
* to [0, 100]; non-finite or undefined values fall back to DEFAULT_BAR_GAP.
|
|
15
13
|
*/
|
|
16
14
|
export declare function resolveBarGapPadding(barGap?: number): number;
|
|
17
|
-
export declare function computeLinearDomain(values: number[], range?:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
export declare function computeLinearDomain(values: number[], range?: AxisRange, scaleType?: ScaleType): [number, number];
|
|
16
|
+
/**
|
|
17
|
+
* Decade tick values (1, 10, 100, ...) for a logarithmic axis, or null when the
|
|
18
|
+
* scale is not logarithmic or holds no decade.
|
|
19
|
+
*
|
|
20
|
+
* d3's symlog scale generates ticks linearly, which on a log axis stacks every
|
|
21
|
+
* label into the top decade and emits a 0 that a log axis cannot represent.
|
|
22
|
+
* The domain floor is 0 once `.nice()` has run, so decades start at 1 there.
|
|
23
|
+
*/
|
|
24
|
+
export declare function logTickValues(scale: {
|
|
25
|
+
domain: () => unknown[];
|
|
26
|
+
constant?: () => unknown;
|
|
27
|
+
}, maxTicks: number): number[] | null;
|
|
@@ -1,4 +1,25 @@
|
|
|
1
|
-
import { SeriesOverride } from './types';
|
|
1
|
+
import { ChartData, SeriesOverride } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* The series a multi-series renderer should draw. A `data` block with no
|
|
4
|
+
* `series` meta-row carries its numbers in `values` alone, which left the
|
|
5
|
+
* stacked, grouped and split renderers with an empty series list and nothing
|
|
6
|
+
* to draw. Such data is a stack, a group or a panel of one: it gets a single
|
|
7
|
+
* unnamed series, so every category still renders one bar.
|
|
8
|
+
*/
|
|
9
|
+
export declare function seriesOrImplicit(data: ChartData): {
|
|
10
|
+
name: string;
|
|
11
|
+
values: number[];
|
|
12
|
+
}[];
|
|
13
|
+
/**
|
|
14
|
+
* Extend `colors` so it covers `count` series. `resolveSeriesColor` indexes
|
|
15
|
+
* modulo the palette length, so a chart with more series than the palette has
|
|
16
|
+
* colours paints two of them identically in both the plot and the legend;
|
|
17
|
+
* interpolating through LCH gives every series its own colour, the way the arc
|
|
18
|
+
* renderer already does for slices. Entries chroma cannot parse are dropped
|
|
19
|
+
* rather than fed to `chroma.scale`, which throws on them and would take the
|
|
20
|
+
* whole render down.
|
|
21
|
+
*/
|
|
22
|
+
export declare function expandColorsToSeries(colors: string[], count: number): string[];
|
|
2
23
|
export declare function resolveSeriesColor(name: string, index: number, colors: string[], overrides?: SeriesOverride[]): string;
|
|
3
24
|
export declare function resolveSeriesDash(name: string, overrides?: SeriesOverride[]): string;
|
|
4
25
|
export declare function resolveSeriesWidth(name: string, overrides?: SeriesOverride[]): number;
|
|
@@ -12,6 +12,6 @@ export interface StackedPoint {
|
|
|
12
12
|
export declare function computeStack(data: ChartData): d3.Series<Record<string, number>, string>[];
|
|
13
13
|
/**
|
|
14
14
|
* Compute a stacked layout normalized to 100%.
|
|
15
|
-
* Each category's
|
|
15
|
+
* Each category's magnitudes sum to 100, negatives below the baseline.
|
|
16
16
|
*/
|
|
17
17
|
export declare function computeStack100(data: ChartData): d3.Series<Record<string, number>, string>[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared text measurement for the layout estimators: axis tick density, legend
|
|
3
|
+
* item advance, arc label margins and annotation wrapping all need to know how
|
|
4
|
+
* wide a string will actually render.
|
|
5
|
+
*
|
|
6
|
+
* Three sources, first available wins:
|
|
7
|
+
* 1. an offscreen 2D canvas — the browser and the editor;
|
|
8
|
+
* 2. a detached SVG `<text>` and `getComputedTextLength()` — what the Node
|
|
9
|
+
* backend has, through the jsdom shim in `render/backends/text-shim.ts`;
|
|
10
|
+
* 3. the per-glyph estimate below, when a render environment offers neither.
|
|
11
|
+
*
|
|
12
|
+
* The result is never below the estimate. The font the Node backend bundles
|
|
13
|
+
* (DejaVu Sans) has no CJK glyphs, so measuring Japanese text there returns the
|
|
14
|
+
* width of the notdef box (~0.6em) rather than the ~1em a CJK face advances;
|
|
15
|
+
* without the floor, wide scripts would be under-reserved headlessly.
|
|
16
|
+
*/
|
|
17
|
+
/** Rendered width of `text` in px at `fontSizePx`, in the chart font. */
|
|
18
|
+
export declare function measureTextWidth(text: string, fontSizePx: number): number;
|
|
19
|
+
/** Rendered width of the widest of `texts`, or 0 when there are none. */
|
|
20
|
+
export declare function measureMaxTextWidth(texts: string[], fontSizePx: number): number;
|
|
21
|
+
/**
|
|
22
|
+
* Longest prefix of `text` that fits in `maxWidth`, with `suffix` appended when
|
|
23
|
+
* anything had to be dropped. Returns `text` unchanged when it already fits.
|
|
24
|
+
*/
|
|
25
|
+
export declare function truncateToWidth(text: string, maxWidth: number, fontSizePx: number, suffix?: string): string;
|
package/dist/charts/types.d.ts
CHANGED
|
@@ -16,13 +16,19 @@ export interface ColorizeConfig {
|
|
|
16
16
|
export interface HighlightConfig {
|
|
17
17
|
target: string;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* An axis range bound. A string keeps the raw DSL value so each axis can parse
|
|
21
|
+
* it in its own unit space: a number on a value axis, a date on a
|
|
22
|
+
* date-detected category axis.
|
|
23
|
+
*/
|
|
24
|
+
export interface AxisRange {
|
|
25
|
+
min?: number | string;
|
|
26
|
+
max?: number | string;
|
|
27
|
+
}
|
|
19
28
|
export interface AxisOptions {
|
|
20
29
|
direction?: AxisDirection;
|
|
21
30
|
scaleType?: ScaleType;
|
|
22
|
-
range?:
|
|
23
|
-
min?: number;
|
|
24
|
-
max?: number;
|
|
25
|
-
};
|
|
31
|
+
range?: AxisRange;
|
|
26
32
|
ticks?: number[];
|
|
27
33
|
showAxis?: boolean;
|
|
28
34
|
showTicks?: boolean;
|
|
@@ -9,3 +9,34 @@ export interface ValueLabelFitInput {
|
|
|
9
9
|
}
|
|
10
10
|
export declare function estimateLabelWidth(text: string): number;
|
|
11
11
|
export declare function shouldRenderValueLabel(input: ValueLabelFitInput): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Pixel width of a text's ink, never below the per-glyph floor: `measureText` is
|
|
14
|
+
* asked about 11px sans-serif while the chart renders in its own font, so an
|
|
15
|
+
* under-report is what lets a label cross a boundary it was measured to fit in.
|
|
16
|
+
*/
|
|
17
|
+
export declare function estimateTextInk(text: string, font?: string): number;
|
|
18
|
+
export interface LabelViewport {
|
|
19
|
+
/** Plot extent in chart-area coordinates. */
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
/** Canvas margins around the plot, which the label may reach into. */
|
|
23
|
+
margin: {
|
|
24
|
+
top: number;
|
|
25
|
+
right: number;
|
|
26
|
+
bottom: number;
|
|
27
|
+
left: number;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Place a value label above a point mark, in chart-area coordinates, so its ink
|
|
32
|
+
* box stays inside the SVG viewport. Labels for line and area charts sit outside
|
|
33
|
+
* the plot clip, so nothing else stops the canvas edge from slicing one: a cut
|
|
34
|
+
* number reads as a smaller one, which is worse than a missing label.
|
|
35
|
+
*
|
|
36
|
+
* A mark the axis range excludes is labelled at the plot edge it was clipped to,
|
|
37
|
+
* matching what bar-horizontal does for the same case.
|
|
38
|
+
*/
|
|
39
|
+
export declare function clampPointLabel(text: string, cx: number, cy: number, vp: LabelViewport): {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
};
|
package/dist/dsl/converter.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { PropertyNode, DataNode, SceneNode, ColorizeNode, HighlightNode, AnnotationNode, SeriesNode, AreaFillNode } from './types';
|
|
2
2
|
import { ColorizeConfig, HighlightConfig, AnnotationConfig, AreaFillConfig, SeriesOverride } from '../charts/types';
|
|
3
|
+
/**
|
|
4
|
+
* A DSL boolean is case-insensitive: `validate.ts` lowercases before comparing,
|
|
5
|
+
* so `TRUE` passes validation and must resolve the same way here.
|
|
6
|
+
*/
|
|
7
|
+
export declare const toBool: (v: unknown) => boolean;
|
|
3
8
|
/**
|
|
4
9
|
* Convert an array of AST property nodes into a key→value map.
|
|
5
10
|
*/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrap a label, target, name or value in quotes for emission as DSL. Newlines
|
|
3
|
+
* and tabs are escaped rather than emitted raw: the data-string format read by
|
|
4
|
+
* `parseData` is line-oriented, so a raw newline inside a label costs the row.
|
|
5
|
+
*/
|
|
6
|
+
export declare function quoteDslString(value: string): string;
|
|
7
|
+
/** Reverse of `quoteDslString`, for the escape set the grammar's `EscapeChar` accepts. */
|
|
8
|
+
export declare function unescapeDslString(value: string): string;
|
|
9
|
+
/** Strip the surrounding quotes of a quoted segment, if any, and unescape it. */
|
|
10
|
+
export declare function unquoteDslString(value: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Split on the commas that separate list entries, leaving alone the ones that
|
|
13
|
+
* belong to an entry: inside a quoted string (`"Paris, France"`) or inside a
|
|
14
|
+
* functional notation (`rgb(230,57,70)`).
|
|
15
|
+
*/
|
|
16
|
+
export declare function splitTopLevelCommas(value: string): string[];
|
package/dist/dsl/types.d.ts
CHANGED
|
@@ -13,12 +13,18 @@ export interface PropertyNode {
|
|
|
13
13
|
quotedKey?: boolean;
|
|
14
14
|
/** `//` comment lines authored immediately above this node, text only (no `//`). */
|
|
15
15
|
leadingComments?: string[];
|
|
16
|
+
/** `//` comment authored at the end of this node's own line, text only (no `//`). */
|
|
17
|
+
trailingComment?: string;
|
|
16
18
|
}
|
|
17
19
|
export interface DataNode {
|
|
18
20
|
type: DslNodeType.Data;
|
|
19
21
|
entries: PropertyNode[];
|
|
20
22
|
/** `//` comment lines authored immediately above this node, text only (no `//`). */
|
|
21
23
|
leadingComments?: string[];
|
|
24
|
+
/** `//` comment authored at the end of this node's own line, text only (no `//`). */
|
|
25
|
+
trailingComment?: string;
|
|
26
|
+
/** `//` comment lines authored after this block's last member, text only (no `//`). */
|
|
27
|
+
trailingComments?: string[];
|
|
22
28
|
}
|
|
23
29
|
export interface ColorizeNode {
|
|
24
30
|
type: DslNodeType.Colorize;
|
|
@@ -27,6 +33,10 @@ export interface ColorizeNode {
|
|
|
27
33
|
fromHighlight?: boolean;
|
|
28
34
|
/** `//` comment lines authored immediately above this node, text only (no `//`). */
|
|
29
35
|
leadingComments?: string[];
|
|
36
|
+
/** `//` comment authored at the end of this node's own line, text only (no `//`). */
|
|
37
|
+
trailingComment?: string;
|
|
38
|
+
/** `//` comment lines authored after this block's last member, text only (no `//`). */
|
|
39
|
+
trailingComments?: string[];
|
|
30
40
|
}
|
|
31
41
|
export interface HighlightNode {
|
|
32
42
|
type: DslNodeType.Highlight;
|
|
@@ -34,6 +44,8 @@ export interface HighlightNode {
|
|
|
34
44
|
properties: PropertyNode[];
|
|
35
45
|
/** `//` comment lines authored immediately above this node, text only (no `//`). */
|
|
36
46
|
leadingComments?: string[];
|
|
47
|
+
/** `//` comment authored at the end of this node's own line, text only (no `//`). */
|
|
48
|
+
trailingComment?: string;
|
|
37
49
|
}
|
|
38
50
|
export interface AreaFillNode {
|
|
39
51
|
type: DslNodeType.AreaFill;
|
|
@@ -42,6 +54,10 @@ export interface AreaFillNode {
|
|
|
42
54
|
properties: PropertyNode[];
|
|
43
55
|
/** `//` comment lines authored immediately above this node, text only (no `//`). */
|
|
44
56
|
leadingComments?: string[];
|
|
57
|
+
/** `//` comment authored at the end of this node's own line, text only (no `//`). */
|
|
58
|
+
trailingComment?: string;
|
|
59
|
+
/** `//` comment lines authored after this block's last member, text only (no `//`). */
|
|
60
|
+
trailingComments?: string[];
|
|
45
61
|
}
|
|
46
62
|
export interface PointAnnotationNode {
|
|
47
63
|
type: DslNodeType.Annotation;
|
|
@@ -50,6 +66,10 @@ export interface PointAnnotationNode {
|
|
|
50
66
|
properties: PropertyNode[];
|
|
51
67
|
/** `//` comment lines authored immediately above this node, text only (no `//`). */
|
|
52
68
|
leadingComments?: string[];
|
|
69
|
+
/** `//` comment authored at the end of this node's own line, text only (no `//`). */
|
|
70
|
+
trailingComment?: string;
|
|
71
|
+
/** `//` comment lines authored after this block's last member, text only (no `//`). */
|
|
72
|
+
trailingComments?: string[];
|
|
53
73
|
}
|
|
54
74
|
export interface RangeAnnotationNode {
|
|
55
75
|
type: DslNodeType.Annotation;
|
|
@@ -57,6 +77,10 @@ export interface RangeAnnotationNode {
|
|
|
57
77
|
properties: PropertyNode[];
|
|
58
78
|
/** `//` comment lines authored immediately above this node, text only (no `//`). */
|
|
59
79
|
leadingComments?: string[];
|
|
80
|
+
/** `//` comment authored at the end of this node's own line, text only (no `//`). */
|
|
81
|
+
trailingComment?: string;
|
|
82
|
+
/** `//` comment lines authored after this block's last member, text only (no `//`). */
|
|
83
|
+
trailingComments?: string[];
|
|
60
84
|
}
|
|
61
85
|
export interface FreeAnnotationNode {
|
|
62
86
|
type: DslNodeType.Annotation;
|
|
@@ -64,6 +88,10 @@ export interface FreeAnnotationNode {
|
|
|
64
88
|
properties: PropertyNode[];
|
|
65
89
|
/** `//` comment lines authored immediately above this node, text only (no `//`). */
|
|
66
90
|
leadingComments?: string[];
|
|
91
|
+
/** `//` comment authored at the end of this node's own line, text only (no `//`). */
|
|
92
|
+
trailingComment?: string;
|
|
93
|
+
/** `//` comment lines authored after this block's last member, text only (no `//`). */
|
|
94
|
+
trailingComments?: string[];
|
|
67
95
|
}
|
|
68
96
|
export type AnnotationNode = PointAnnotationNode | RangeAnnotationNode | FreeAnnotationNode;
|
|
69
97
|
export interface SeriesNode {
|
|
@@ -72,6 +100,10 @@ export interface SeriesNode {
|
|
|
72
100
|
properties: PropertyNode[];
|
|
73
101
|
/** `//` comment lines authored immediately above this node, text only (no `//`). */
|
|
74
102
|
leadingComments?: string[];
|
|
103
|
+
/** `//` comment authored at the end of this node's own line, text only (no `//`). */
|
|
104
|
+
trailingComment?: string;
|
|
105
|
+
/** `//` comment lines authored after this block's last member, text only (no `//`). */
|
|
106
|
+
trailingComments?: string[];
|
|
75
107
|
}
|
|
76
108
|
export interface SceneNode {
|
|
77
109
|
type: DslNodeType.Scene;
|
|
@@ -86,6 +118,10 @@ export interface SceneNode {
|
|
|
86
118
|
transforms: TransformNode[];
|
|
87
119
|
/** `//` comment lines authored immediately above this node, text only (no `//`). */
|
|
88
120
|
leadingComments?: string[];
|
|
121
|
+
/** `//` comment authored at the end of this node's own line, text only (no `//`). */
|
|
122
|
+
trailingComment?: string;
|
|
123
|
+
/** `//` comment lines authored after this block's last member, text only (no `//`). */
|
|
124
|
+
trailingComments?: string[];
|
|
89
125
|
}
|
|
90
126
|
export interface TransformNode {
|
|
91
127
|
type: DslNodeType.Transform;
|
|
@@ -93,6 +129,10 @@ export interface TransformNode {
|
|
|
93
129
|
properties: PropertyNode[];
|
|
94
130
|
/** `//` comment lines authored immediately above this node, text only (no `//`). */
|
|
95
131
|
leadingComments?: string[];
|
|
132
|
+
/** `//` comment authored at the end of this node's own line, text only (no `//`). */
|
|
133
|
+
trailingComment?: string;
|
|
134
|
+
/** `//` comment lines authored after this block's last member, text only (no `//`). */
|
|
135
|
+
trailingComments?: string[];
|
|
96
136
|
}
|
|
97
137
|
export interface ChartNode {
|
|
98
138
|
type: DslNodeType.Chart;
|
|
@@ -106,4 +146,6 @@ export interface ChartNode {
|
|
|
106
146
|
series: SeriesNode[];
|
|
107
147
|
scenes: SceneNode[];
|
|
108
148
|
transforms: TransformNode[];
|
|
149
|
+
/** `//` comment lines authored after this block's last member, text only (no `//`). */
|
|
150
|
+
trailingComments?: string[];
|
|
109
151
|
}
|
package/dist/dsl/validate.d.ts
CHANGED
|
@@ -23,6 +23,12 @@ export interface ValidationResult {
|
|
|
23
23
|
* catches the `fromX`/`toX`-on-a-range bug.
|
|
24
24
|
*/
|
|
25
25
|
export declare const POINT_ANNOTATION_KEYS: Set<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Series override body property keys, derived from the keys
|
|
28
|
+
* convertSeriesOverrides() in converter.ts actually reads. Anything not listed
|
|
29
|
+
* never reaches SeriesOverride, so the renderer cannot honour it.
|
|
30
|
+
*/
|
|
31
|
+
export declare const SERIES_OVERRIDE_KEYS: Set<string>;
|
|
26
32
|
export declare const RANGE_ANNOTATION_KEYS: Set<string>;
|
|
27
33
|
export declare const FREE_ANNOTATION_KEYS: Set<string>;
|
|
28
34
|
/**
|
package/dist/embed.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e, i as t, o as n, r, t as i } from "./runtime-
|
|
1
|
+
import { a as e, i as t, o as n, r, t as i } from "./runtime-DDhsXDn5.js";
|
|
2
2
|
export { r as ERROR_MESSAGE, t as RESIZE_MESSAGE, i as buildSrcdoc, e as isErrorMessage, n as readResizeHeight };
|
package/dist/enums.d.ts
CHANGED
|
@@ -192,3 +192,26 @@ export declare enum DslNodeType {
|
|
|
192
192
|
Transform = "transform",
|
|
193
193
|
Chart = "chart"
|
|
194
194
|
}
|
|
195
|
+
export declare enum TransformType {
|
|
196
|
+
Sort = "sort",
|
|
197
|
+
Filter = "filter",
|
|
198
|
+
HideColumns = "hide-columns",
|
|
199
|
+
Transpose = "transpose",
|
|
200
|
+
Parse = "parse",
|
|
201
|
+
Rename = "rename",
|
|
202
|
+
GroupBy = "group-by",
|
|
203
|
+
Computed = "computed"
|
|
204
|
+
}
|
|
205
|
+
export declare enum FilterCondition {
|
|
206
|
+
Equals = "equals",
|
|
207
|
+
NotEquals = "not-equals",
|
|
208
|
+
Contains = "contains",
|
|
209
|
+
GreaterThan = "greater-than",
|
|
210
|
+
LessThan = "less-than"
|
|
211
|
+
}
|
|
212
|
+
export declare enum ParseOperationCategory {
|
|
213
|
+
Type = "type",
|
|
214
|
+
String = "string",
|
|
215
|
+
Numeric = "numeric",
|
|
216
|
+
Date = "date"
|
|
217
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ChartType, AxisDirection, ScaleType, GridStyle, LabelPosition, LabelRotation, TickPosition, FrameSizing, CompassDirection, AnnotationLineStyle, StrokeStyle, AnnotationKind, RangeAnchor, Orientation, SymbolShape, SymbolShowOn, SymbolStyle, SortDirection, SortMode, LegendPosition, Anchor, ValueLabelPosition, CrosshairDirection, CrosshairStyle, StackMode, LineStyle, ChartOptionType, DirectLabelMode, Interpolation, DslNodeType, } from './enums';
|
|
1
|
+
export { ChartType, AxisDirection, ScaleType, GridStyle, LabelPosition, LabelRotation, TickPosition, FrameSizing, CompassDirection, AnnotationLineStyle, StrokeStyle, AnnotationKind, RangeAnchor, Orientation, SymbolShape, SymbolShowOn, SymbolStyle, SortDirection, SortMode, LegendPosition, Anchor, ValueLabelPosition, CrosshairDirection, CrosshairStyle, StackMode, LineStyle, ChartOptionType, DirectLabelMode, Interpolation, DslNodeType, TransformType, FilterCondition, ParseOperationCategory, } from './enums';
|
|
2
2
|
export { ANNOTATION_KIND_KEYWORD } from './enums';
|
|
3
3
|
export type { ChartData, ChartOptions, ChartRenderer, ChartOptionDef, ChartTypeOptions, ChartTypeOptionKey, ColorizeConfig, HighlightConfig, AxisOptions, FrameOptions, AreaFillConfig, AnnotationConfig, PointAnnotationConfig, RangeAnnotationConfig, FreeAnnotationConfig, AnnotationLineConfig, LineSymbolConfig, SeriesOverride, Margin, } from './charts/types';
|
|
4
4
|
export { createFrame } from './charts/frame/frame';
|
|
@@ -19,6 +19,8 @@ export { getChartTypeDefaults, resolveChartTypeOptions } from './charts/resolve'
|
|
|
19
19
|
export { resolveBarGapPadding, DEFAULT_BAR_GAP } from './charts/scale-helpers';
|
|
20
20
|
export { resolvePalette, listPalettes } from './charts/palettes';
|
|
21
21
|
export type { PaletteEntry } from './charts/palettes';
|
|
22
|
+
export { listThemes } from './charts/themes';
|
|
23
|
+
export type { ThemeEntry } from './charts/themes';
|
|
22
24
|
export { resolveSeriesColor, resolveSeriesInterpolation, isSeriesHidden } from './charts/series-helpers';
|
|
23
25
|
export { resolveBackgroundColor, adjustColorsForBackground, wcagContrastRatio, wcagLevel } from './charts/contrast';
|
|
24
26
|
export { getTransitionDuration, snapshotForFadeOut, commitFadeOut, fadeIn } from './charts/motion';
|
|
@@ -27,15 +29,21 @@ export { getCvdFilterId, createCvdSvgFilter, simulateCvdColor, checkCvdColors }
|
|
|
27
29
|
export type { CvdType, CvdIssue } from './charts/colorblind';
|
|
28
30
|
export { parse } from './dsl/parser';
|
|
29
31
|
export { serialize, compactSerialize, compactSerializeDeep } from './dsl/serializer';
|
|
32
|
+
export { quoteDslString } from './dsl/quoting';
|
|
33
|
+
export { toBool } from './dsl/converter';
|
|
30
34
|
export { propertyMap, extractChartTypeOptions, dataEntriesToString, extractSceneOverrides, convertColorizes, convertHighlights, convertAreaFills, convertAnnotations, convertSeriesOverrides } from './dsl/converter';
|
|
31
35
|
export type { AnnotationNode, PointAnnotationNode, RangeAnnotationNode, FreeAnnotationNode, AreaFillNode, ChartNode, DataNode, ColorizeNode, HighlightNode, PropertyNode, SceneNode, SeriesNode, TransformNode } from './dsl/types';
|
|
32
36
|
export { validateChart } from './dsl/validate';
|
|
33
37
|
export type { ValidationIssue, ValidationResult } from './dsl/validate';
|
|
38
|
+
export { TRANSFORM_TYPES, applyTransformSteps, applyTransformNodes, applyTransformNodesToChartData, transformNodesToSteps, transformValue, parseOperations, parseOperationMap, isTypeCompatible, getOutputType, NULL_VALUE, parseBpcData, serializeTableData, chartDataToTable, detectColumnTypes, cleanNumericValue, isDateValue, isNumberValue, } from './transforms';
|
|
39
|
+
export type { ParseOperation, TransformResult, TransformStep } from './transforms';
|
|
34
40
|
export { samples } from './samples';
|
|
35
41
|
export type { ChartSample } from './samples';
|
|
36
42
|
export { renderBpc, renderChart, astToDefinition, resolveScene, render } from './render';
|
|
37
43
|
export type { ChartDefinition, RenderOptions, ResolvedChartState, ChartHandle, RenderApiOptions, OutputOptions } from './render';
|
|
38
44
|
export { ChartParseError, PngBrowserUnsupportedError, MissingNodeRenderDepsError } from './render';
|
|
45
|
+
export { buildFrameSvg } from './render';
|
|
46
|
+
export type { FrameSvgLayout, FrameSvgTextBlock, FrameSvgPlot, ChartAccessibility } from './render';
|
|
39
47
|
export { buildSrcdoc } from './runtime/runtime';
|
|
40
48
|
export { SceneTransition, getSceneTransition, featureJoin, snapshotLiveAttrs, BC_TRANSITION_NAME, } from './transitions';
|
|
41
49
|
export type { CommitOptions, TransitionMode, SceneTransitionState, FeatureRole, FeatureJoinConfig, AttrMap, AttrValue, } from './transitions';
|