@blueprint-chart/lib 2.0.0 → 2.2.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/legend/legend-size.d.ts +13 -0
- package/dist/charts/plugins/annotations/shared.d.ts +13 -2
- package/dist/charts/plugins/arc-labels.d.ts +10 -1
- package/dist/charts/scale-helpers.d.ts +1 -1
- package/dist/charts/text-measure.d.ts +25 -0
- package/dist/charts/value-label-fit.d.ts +5 -0
- package/dist/embed.js +1 -1
- package/dist/enums.d.ts +18 -0
- package/dist/index.js +161 -157
- package/dist/lib/lib.iife.js +65 -15
- package/dist/node-backend/index.js +2065 -1928
- package/dist/{render-bpc-BWiUALXY.js → render-bpc-C4y50x4-.js} +2176 -2035
- package/dist/runtime/chart-css.d.ts +1 -1
- package/dist/runtime-gzeMNwqx.js +84 -0
- package/dist/runtime.js +2 -2
- package/dist/transforms/table.d.ts +0 -1
- package/package.json +1 -1
- package/src/charts/chart.scss +21 -0
- package/dist/runtime-DDhsXDn5.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,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;
|
|
@@ -31,6 +31,7 @@ export declare function renderInsideArcLabels(parent: d3.Selection<SVGGElement,
|
|
|
31
31
|
chartWidth: number;
|
|
32
32
|
chartHeight: number;
|
|
33
33
|
fontSize?: number;
|
|
34
|
+
bgColor?: string;
|
|
34
35
|
}): void;
|
|
35
36
|
export declare function renderAutoArcLabels(parent: d3.Selection<SVGGElement, unknown, null, undefined>, data: ArcLabelDatum[], opts: {
|
|
36
37
|
outerRadius: number;
|
|
@@ -44,8 +45,16 @@ export declare function renderAutoArcLabels(parent: d3.Selection<SVGGElement, un
|
|
|
44
45
|
* Estimate extra margins needed for arc labels beyond what the arc already
|
|
45
46
|
* occupies. The text column sits at outerRadius + STUB_LENGTH + HORIZONTAL_SEG + 6
|
|
46
47
|
* from centre; we need room for the text itself beyond that.
|
|
48
|
+
*
|
|
49
|
+
* `available` is the box the arc has to fit in. The margins are capped against
|
|
50
|
+
* it, because they are subtracted from the canvas with no other lower bound:
|
|
51
|
+
* one long label, a phone-width container or twenty slices otherwise leave a
|
|
52
|
+
* radius of zero and no arcs are painted.
|
|
47
53
|
*/
|
|
48
|
-
export declare function estimateArcLabelMargins(labels: string[], outerRadius: number
|
|
54
|
+
export declare function estimateArcLabelMargins(labels: string[], outerRadius: number, available?: {
|
|
55
|
+
width: number;
|
|
56
|
+
height: number;
|
|
57
|
+
}): {
|
|
49
58
|
left: number;
|
|
50
59
|
right: number;
|
|
51
60
|
top: number;
|
|
@@ -12,7 +12,7 @@ export declare const DEFAULT_BAR_GAP = 60;
|
|
|
12
12
|
* to [0, 100]; non-finite or undefined values fall back to DEFAULT_BAR_GAP.
|
|
13
13
|
*/
|
|
14
14
|
export declare function resolveBarGapPadding(barGap?: number): number;
|
|
15
|
-
export declare function computeLinearDomain(values: number[], range?: AxisRange, scaleType?: ScaleType): [number, number];
|
|
15
|
+
export declare function computeLinearDomain(values: number[], range?: AxisRange, scaleType?: ScaleType, anchorZero?: boolean): [number, number];
|
|
16
16
|
/**
|
|
17
17
|
* Decade tick values (1, 10, 100, ...) for a logarithmic axis, or null when the
|
|
18
18
|
* scale is not logarithmic or holds no decade.
|
|
@@ -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;
|
|
@@ -7,6 +7,11 @@ export interface ValueLabelFitInput {
|
|
|
7
7
|
/** px extent along y (vertical bar: length; horizontal bar: thickness) */
|
|
8
8
|
barHeight: number;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* A per-character estimate held while labels were bare numbers. A number
|
|
12
|
+
* format adds a prefix and a suffix (`$1,200,000.0M`), and the shared measurer
|
|
13
|
+
* keeps the `max(measured, floor)` shape that a headless CJK render needs.
|
|
14
|
+
*/
|
|
10
15
|
export declare function estimateLabelWidth(text: string): number;
|
|
11
16
|
export declare function shouldRenderValueLabel(input: ValueLabelFitInput): boolean;
|
|
12
17
|
/**
|
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-gzeMNwqx.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
|
@@ -44,6 +44,24 @@ export declare enum TickPosition {
|
|
|
44
44
|
Above = "above",
|
|
45
45
|
Below = "below"
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* How the frame sizes itself, as the *renderer* names it.
|
|
49
|
+
*
|
|
50
|
+
* These are deliberately not the DSL's vocabulary. The `sizing` property in BPC
|
|
51
|
+
* source takes `responsive`, `fixed` or `max-width`, and the two sets share no
|
|
52
|
+
* value, so `sizing = standard` in a chart is not valid DSL. The mapping:
|
|
53
|
+
*
|
|
54
|
+
* | DSL `sizing` | FrameSizing | meaning |
|
|
55
|
+
* |--------------|----------------|-----------------------------------------|
|
|
56
|
+
* | `responsive` | `Auto` | fill the container |
|
|
57
|
+
* | `fixed` | `Standard` | a fixed width, set by `fixedWidth` |
|
|
58
|
+
* | `max-width` | `Standard` | fill up to `maxWidth` |
|
|
59
|
+
* | (n/a) | `AspectRatio` | reached through `heightMode`, not `sizing` |
|
|
60
|
+
*
|
|
61
|
+
* Renaming either side is a breaking change with no automatic migration (it
|
|
62
|
+
* would mean rewriting user BPC source), so the two vocabularies stay and this
|
|
63
|
+
* table is the contract. See issue #122.
|
|
64
|
+
*/
|
|
47
65
|
export declare enum FrameSizing {
|
|
48
66
|
Auto = "auto",
|
|
49
67
|
Standard = "standard",
|