@blueprint-chart/lib 2.5.0 → 2.6.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/horizontal-axis.d.ts +1 -1
- package/dist/charts/canvas/canvas.d.ts +7 -0
- package/dist/charts/plugins/annotations/context.d.ts +2 -2
- package/dist/charts/plugins/annotations/shared.d.ts +2 -1
- package/dist/charts/plugins/proximity.d.ts +2 -0
- package/dist/charts/scale-helpers.d.ts +1 -0
- package/dist/charts/types/scatter/emphasis.d.ts +7 -0
- package/dist/charts/types/scatter/issues.d.ts +20 -0
- package/dist/charts/types/scatter/labels.d.ts +17 -0
- package/dist/charts/types/scatter/legend.d.ts +11 -0
- package/dist/charts/types/scatter/mapping.d.ts +10 -0
- package/dist/charts/types/scatter/points.d.ts +24 -0
- package/dist/charts/types/scatter/scales.d.ts +18 -0
- package/dist/charts/types/scatter/scatter.d.ts +6 -0
- package/dist/charts/types/scatter/tooltip.d.ts +8 -0
- package/dist/charts/types/scatter/trend.d.ts +24 -0
- package/dist/charts/types.d.ts +14 -0
- package/dist/dsl/suggest.d.ts +6 -0
- package/dist/enums.d.ts +3 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +447 -334
- package/dist/lib/lib.iife.js +17 -15
- package/dist/node-backend/index.js +2065 -1417
- package/dist/recommendations/types.d.ts +2 -2
- package/dist/{render-bpc-BnD9HqZ-.js → render-bpc-B8L42qjL.js} +2103 -1453
- package/dist/runtime.js +1 -1
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@ interface AxisDatum {
|
|
|
12
12
|
* than `maxLines`. Used to avoid rotating labels when wrapping suffices.
|
|
13
13
|
*/
|
|
14
14
|
declare function wrapLabel(label: string, maxWidthPx: number, maxLines?: number): string[] | null;
|
|
15
|
-
type AnyXScale = d3.ScaleBand<string> | d3.ScalePoint<string> | d3.ScaleLinear<number, number> | d3.ScaleSymLog<number, number> | d3.ScaleTime<number, number>;
|
|
15
|
+
type AnyXScale = d3.ScaleBand<string> | d3.ScalePoint<string> | d3.ScaleLinear<number, number> | d3.ScaleSymLog<number, number> | d3.ScaleLogarithmic<number, number> | d3.ScaleTime<number, number>;
|
|
16
16
|
declare function buildTickFormatter(fmt: string | null, labels: string[]): ((d: string | d3.NumberValue) => string) | null;
|
|
17
17
|
declare function thinLabels(domain: string[], availableWidth: number, formatter?: ((d: string | d3.NumberValue) => string) | null): string[];
|
|
18
18
|
/**
|
|
@@ -16,11 +16,18 @@ export declare function computeMarginDelta(priorMargin: Pick<Margin, 'top' | 'le
|
|
|
16
16
|
dx: number;
|
|
17
17
|
dy: number;
|
|
18
18
|
} | undefined;
|
|
19
|
+
export declare const DEFAULT_MARGIN: Margin;
|
|
20
|
+
export declare const DEFAULT_WIDTH = 600;
|
|
21
|
+
export declare const DEFAULT_HEIGHT = 400;
|
|
19
22
|
/**
|
|
20
23
|
* Estimate the pixel width of the widest tick label for a vertical axis.
|
|
21
24
|
* Uses an offscreen canvas for measurement, falling back to character-count estimation.
|
|
22
25
|
*/
|
|
23
26
|
export declare function estimateVerticalLabelWidth(values: number[], range?: AxisRange, numberFormat?: string | null, scaleType?: string): number;
|
|
27
|
+
export declare function estimateScaleLabelWidth(scale: {
|
|
28
|
+
ticks: (n?: number) => number[];
|
|
29
|
+
tickFormat: (n?: number) => (v: number) => string;
|
|
30
|
+
}, numberFormat?: string | null): number;
|
|
24
31
|
/**
|
|
25
32
|
* Estimate the pixel width of the widest string label (for band/category axes).
|
|
26
33
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AnnotationSnapshot } from './snapshots';
|
|
2
2
|
import type * as d3 from 'd3';
|
|
3
3
|
export interface AnnotationContext {
|
|
4
|
-
scaleX: d3.ScaleBand<string> | d3.ScalePoint<string> | d3.ScaleTime<number, number> | d3.ScaleLinear<number, number>;
|
|
5
|
-
scaleY: d3.ScaleLinear<number, number> | d3.ScaleSymLog<number, number>;
|
|
4
|
+
scaleX: d3.ScaleBand<string> | d3.ScalePoint<string> | d3.ScaleTime<number, number> | d3.ScaleLinear<number, number> | d3.ScaleLogarithmic<number, number> | d3.ScaleSymLog<number, number>;
|
|
5
|
+
scaleY: d3.ScaleLinear<number, number> | d3.ScaleSymLog<number, number> | d3.ScaleLogarithmic<number, number>;
|
|
6
6
|
data: {
|
|
7
7
|
label: string;
|
|
8
8
|
value: number;
|
|
@@ -8,7 +8,8 @@ export declare function scaleXValue(scale: AnnotationContext['scaleX'], label: s
|
|
|
8
8
|
export declare function computeAnchorPoint(datum: {
|
|
9
9
|
label: string;
|
|
10
10
|
value: number;
|
|
11
|
-
|
|
11
|
+
x?: number;
|
|
12
|
+
}, scaleX: AnnotationContext['scaleX'], scaleY: AnnotationContext['scaleY'], anchorDirection: CompassDirection, orientation?: 'horizontal'): {
|
|
12
13
|
x: number;
|
|
13
14
|
y: number;
|
|
14
15
|
};
|
|
@@ -6,12 +6,14 @@ export interface ProximityPoint {
|
|
|
6
6
|
value: number;
|
|
7
7
|
series?: string;
|
|
8
8
|
color: string;
|
|
9
|
+
r?: number;
|
|
9
10
|
}
|
|
10
11
|
export interface ProximityOptions {
|
|
11
12
|
width: number;
|
|
12
13
|
height: number;
|
|
13
14
|
points: ProximityPoint[];
|
|
14
15
|
tooltip?: boolean;
|
|
16
|
+
nearest?: 'x' | 'xy';
|
|
15
17
|
crosshair?: boolean;
|
|
16
18
|
crosshairDirection?: 'both' | 'vertical' | 'horizontal';
|
|
17
19
|
crosshairStyle?: 'solid' | 'dashed' | 'dotted';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ScatterPoint } from './points';
|
|
2
|
+
export declare function highlightedPointNames(points: ScatterPoint[], targets: string[]): Set<string>;
|
|
3
|
+
export declare function splitColorOverrides(points: ScatterPoint[], overrides: Map<string, string>): {
|
|
4
|
+
points: Map<string, string>;
|
|
5
|
+
groups: Map<string, string>;
|
|
6
|
+
};
|
|
7
|
+
export declare function resolvePointColor(point: ScatterPoint, overrides: Map<string, string>, groups: Map<string, string>, fallback: string): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AxisRange, ChartData } from '../../types';
|
|
2
|
+
import { ScaleType } from '../../../enums';
|
|
3
|
+
import { ScatterMapping } from './mapping';
|
|
4
|
+
export interface ScatterIssue {
|
|
5
|
+
code: string;
|
|
6
|
+
severity: 'error' | 'warning';
|
|
7
|
+
message: string;
|
|
8
|
+
key?: 'x' | 'y' | 'size' | 'group';
|
|
9
|
+
suggestion?: string;
|
|
10
|
+
}
|
|
11
|
+
type ScaleTypes = {
|
|
12
|
+
x?: ScaleType;
|
|
13
|
+
y?: ScaleType;
|
|
14
|
+
};
|
|
15
|
+
type Ranges = {
|
|
16
|
+
x?: AxisRange;
|
|
17
|
+
y?: AxisRange;
|
|
18
|
+
};
|
|
19
|
+
export declare function scatterIssues(data: ChartData, overrides: ScatterMapping, scaleTypes: ScaleTypes, ranges: Ranges, trend?: string): ScatterIssue[];
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface LabelCandidate {
|
|
2
|
+
key: string;
|
|
3
|
+
text: string;
|
|
4
|
+
cx: number;
|
|
5
|
+
cy: number;
|
|
6
|
+
r: number;
|
|
7
|
+
}
|
|
8
|
+
export interface PlacedLabel {
|
|
9
|
+
key: string;
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
anchor: 'start' | 'middle' | 'end';
|
|
13
|
+
}
|
|
14
|
+
export declare function placePointLabels(candidates: LabelCandidate[], bounds: {
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
}, fontPx: number): PlacedLabel[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ScatterPoint } from './points';
|
|
2
|
+
export declare function groupColors(points: ScatterPoint[], palette: string[]): Map<string, string>;
|
|
3
|
+
export declare function sizeLegendValues(maxSize: number): number[];
|
|
4
|
+
export interface KeyConfig {
|
|
5
|
+
sizeLabel?: string;
|
|
6
|
+
sizeValues: number[];
|
|
7
|
+
radius: (value: number) => number;
|
|
8
|
+
trend: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function scatterKeyWidth({ sizeLabel, sizeValues, radius, trend }: KeyConfig): number;
|
|
11
|
+
export declare function renderScatterKey(parent: SVGGElement, cfg: KeyConfig): SVGGElement | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ChartData } from '../../types';
|
|
2
|
+
export declare const MAPPING_NONE = "none";
|
|
3
|
+
export interface ScatterMapping {
|
|
4
|
+
x?: string;
|
|
5
|
+
y?: string;
|
|
6
|
+
size?: string;
|
|
7
|
+
group?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function numericColumns(data: ChartData): string[];
|
|
10
|
+
export declare function resolveScatterMapping(data: ChartData, overrides?: ScatterMapping): ScatterMapping;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ChartData } from '../../types';
|
|
2
|
+
import { ScaleType } from '../../../enums';
|
|
3
|
+
import { ScatterMapping } from './mapping';
|
|
4
|
+
export interface ScatterPoint {
|
|
5
|
+
name: string;
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
size?: number;
|
|
9
|
+
group?: string;
|
|
10
|
+
}
|
|
11
|
+
export type DropReason = 'missing-x' | 'missing-y' | 'invalid-size' | 'non-positive-log-x' | 'non-positive-log-y';
|
|
12
|
+
export interface DroppedRow {
|
|
13
|
+
name: string;
|
|
14
|
+
reason: DropReason;
|
|
15
|
+
}
|
|
16
|
+
type ScaleTypes = {
|
|
17
|
+
x?: ScaleType;
|
|
18
|
+
y?: ScaleType;
|
|
19
|
+
};
|
|
20
|
+
export declare function buildScatterPoints(data: ChartData, mapping: ScatterMapping, scaleTypes: ScaleTypes): {
|
|
21
|
+
points: ScatterPoint[];
|
|
22
|
+
dropped: DroppedRow[];
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ScaleType } from '../../../enums';
|
|
2
|
+
import { AxisRange } from '../../types';
|
|
3
|
+
import * as d3 from 'd3';
|
|
4
|
+
export type ScatterScale = d3.ScaleLinear<number, number> | d3.ScaleLogarithmic<number, number> | d3.ScaleSymLog<number, number>;
|
|
5
|
+
export declare function buildScatterScale(type: ScaleType | undefined, values: number[], range?: AxisRange): ScatterScale;
|
|
6
|
+
export declare function axisTransform(type: ScaleType | undefined): {
|
|
7
|
+
forward: (v: number) => number;
|
|
8
|
+
inverse: (t: number) => number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Widest `[start, end]` pixel range that keeps every bubble inside
|
|
12
|
+
* `[0, length]`, and both ends of the domain at least `edgePad` from the edges. Only the bubbles that reach an edge cost
|
|
13
|
+
* margin, so a large bubble in the middle of the cloud reserves none.
|
|
14
|
+
*/
|
|
15
|
+
export declare function fitRange(scale: ScatterScale, items: {
|
|
16
|
+
value: number;
|
|
17
|
+
r: number;
|
|
18
|
+
}[], length: number, edgePad?: number): [number, number];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ChartData, ChartOptions } from '../../types';
|
|
2
|
+
export declare const DEFAULT_COLOR = "#4e79a7";
|
|
3
|
+
export declare const DOT_RADIUS = 4.5;
|
|
4
|
+
export declare const FILL_OPACITY = 0.7;
|
|
5
|
+
export declare function maxBubbleRadius(width: number, height: number): number;
|
|
6
|
+
export declare function render(container: HTMLElement, data: ChartData, options?: ChartOptions, transition?: boolean): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ScatterMapping } from './mapping';
|
|
2
|
+
import { ScatterPoint } from './points';
|
|
3
|
+
type Formats = {
|
|
4
|
+
x?: string;
|
|
5
|
+
y?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function formatScatterTooltip(point: ScatterPoint, mapping: ScatterMapping, formats: Formats): string;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ScaleType } from '../../../enums';
|
|
2
|
+
import { ScatterPoint } from './points';
|
|
3
|
+
export declare const TREND_MODES: readonly ["overall", "per-group"];
|
|
4
|
+
export type TrendMode = typeof TREND_MODES[number];
|
|
5
|
+
export declare function isTrendMode(value: string | undefined): value is TrendMode;
|
|
6
|
+
export interface TrendSegment {
|
|
7
|
+
key: string;
|
|
8
|
+
group?: string;
|
|
9
|
+
x1: number;
|
|
10
|
+
y1: number;
|
|
11
|
+
x2: number;
|
|
12
|
+
y2: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function fitLeastSquares(xs: number[], ys: number[]): {
|
|
15
|
+
slope: number;
|
|
16
|
+
intercept: number;
|
|
17
|
+
} | null;
|
|
18
|
+
export declare function trendSegments(points: ScatterPoint[], mode: TrendMode, scaleTypes: {
|
|
19
|
+
x?: ScaleType;
|
|
20
|
+
y?: ScaleType;
|
|
21
|
+
}): {
|
|
22
|
+
segments: TrendSegment[];
|
|
23
|
+
skipped: string[];
|
|
24
|
+
};
|
package/dist/charts/types.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ export interface ChartData {
|
|
|
7
7
|
name: string;
|
|
8
8
|
values: number[];
|
|
9
9
|
}[];
|
|
10
|
+
textColumns?: {
|
|
11
|
+
name: string;
|
|
12
|
+
values: (string | undefined)[];
|
|
13
|
+
}[];
|
|
10
14
|
}
|
|
11
15
|
export interface ColorizeConfig {
|
|
12
16
|
target: string;
|
|
@@ -190,6 +194,11 @@ export interface ChartOptions {
|
|
|
190
194
|
waterfallTotal?: boolean;
|
|
191
195
|
sharedScale?: boolean;
|
|
192
196
|
categoryLabelLine?: boolean;
|
|
197
|
+
x?: string;
|
|
198
|
+
y?: string;
|
|
199
|
+
size?: string;
|
|
200
|
+
group?: string;
|
|
201
|
+
trend?: string;
|
|
193
202
|
}
|
|
194
203
|
export type ChartRenderer = (container: HTMLElement, data: ChartData, options: ChartOptions, transition?: boolean) => void;
|
|
195
204
|
export interface ChartOptionDef {
|
|
@@ -275,5 +284,10 @@ export interface ChartTypeOptions {
|
|
|
275
284
|
waterfallTotal: boolean;
|
|
276
285
|
sharedScale: boolean;
|
|
277
286
|
categoryLabelLine: boolean;
|
|
287
|
+
x: string;
|
|
288
|
+
y: string;
|
|
289
|
+
size: string;
|
|
290
|
+
group: string;
|
|
291
|
+
trend: string;
|
|
278
292
|
}
|
|
279
293
|
export type ChartTypeOptionKey = keyof ChartTypeOptions;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pick the nearest candidate to `value` by edit distance. Returns undefined
|
|
3
|
+
* when nothing is close enough (distance must be < half the value length, and
|
|
4
|
+
* at most 3 edits) to avoid noisy suggestions.
|
|
5
|
+
*/
|
|
6
|
+
export declare function nearest(value: string, candidates: Iterable<string>): string | undefined;
|
package/dist/enums.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare enum ChartType {
|
|
|
12
12
|
AreaStacked = "area-stacked",
|
|
13
13
|
Donut = "donut",
|
|
14
14
|
Pie = "pie",
|
|
15
|
+
Scatter = "scatter",
|
|
15
16
|
VerticalBar = "vertical-bar",
|
|
16
17
|
HorizontalBar = "horizontal-bar"
|
|
17
18
|
}
|
|
@@ -21,7 +22,8 @@ export declare enum AxisDirection {
|
|
|
21
22
|
}
|
|
22
23
|
export declare enum ScaleType {
|
|
23
24
|
Linear = "linear",
|
|
24
|
-
Log = "log"
|
|
25
|
+
Log = "log",
|
|
26
|
+
Symlog = "symlog"
|
|
25
27
|
}
|
|
26
28
|
export declare enum GridStyle {
|
|
27
29
|
Solid = "solid",
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export { renderLegend } from './charts/legend/legend';
|
|
|
11
11
|
export { registerChart, getChart, getChartOptions, listCharts } from './charts/registry';
|
|
12
12
|
export { parseData, buildChartOptions } from './charts/chart-helpers';
|
|
13
13
|
export { stripDigitGroupSpaces } from './charts/number-parse';
|
|
14
|
+
export { resolveScatterMapping, numericColumns, MAPPING_NONE, type ScatterMapping } from './charts/types/scatter/mapping';
|
|
14
15
|
export { recommendCharts } from './recommendations/recommend';
|
|
15
16
|
export { classifyIntent } from './recommendations/intent';
|
|
16
17
|
export { shapeOf } from './recommendations/shape';
|