@dou-ui/chart 0.0.0-stage → 0.1.0-alpha.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/LICENSE +21 -0
- package/README.md +10 -2
- package/dist/chart.js +6 -0
- package/dist/chart.js.map +1 -0
- package/dist/chart.vue_vue_type_script_setup_true_lang.js +4245 -0
- package/dist/chart.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/area.js +6 -0
- package/dist/components/area.js.map +1 -0
- package/dist/components/area.vue_vue_type_script_setup_true_lang.js +55 -0
- package/dist/components/area.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/axis.js +6 -0
- package/dist/components/axis.js.map +1 -0
- package/dist/components/axis.vue_vue_type_script_setup_true_lang.js +46 -0
- package/dist/components/axis.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/bar.js +6 -0
- package/dist/components/bar.js.map +1 -0
- package/dist/components/bar.vue_vue_type_script_setup_true_lang.js +46 -0
- package/dist/components/bar.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/boxplot.js +6 -0
- package/dist/components/boxplot.js.map +1 -0
- package/dist/components/boxplot.vue_vue_type_script_setup_true_lang.js +42 -0
- package/dist/components/boxplot.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/brush.js +6 -0
- package/dist/components/brush.js.map +1 -0
- package/dist/components/brush.vue_vue_type_script_setup_true_lang.js +42 -0
- package/dist/components/brush.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/funnel.js +6 -0
- package/dist/components/funnel.js.map +1 -0
- package/dist/components/funnel.vue_vue_type_script_setup_true_lang.js +41 -0
- package/dist/components/funnel.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/gauge.js +6 -0
- package/dist/components/gauge.js.map +1 -0
- package/dist/components/gauge.vue_vue_type_script_setup_true_lang.js +91 -0
- package/dist/components/gauge.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/heatmap.js +6 -0
- package/dist/components/heatmap.js.map +1 -0
- package/dist/components/heatmap.vue_vue_type_script_setup_true_lang.js +45 -0
- package/dist/components/heatmap.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/histogram.js +6 -0
- package/dist/components/histogram.js.map +1 -0
- package/dist/components/histogram.vue_vue_type_script_setup_true_lang.js +61 -0
- package/dist/components/histogram.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/line.js +6 -0
- package/dist/components/line.js.map +1 -0
- package/dist/components/line.vue_vue_type_script_setup_true_lang.js +52 -0
- package/dist/components/line.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/marker.js +6 -0
- package/dist/components/marker.js.map +1 -0
- package/dist/components/marker.vue_vue_type_script_setup_true_lang.js +31 -0
- package/dist/components/marker.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/pie.js +6 -0
- package/dist/components/pie.js.map +1 -0
- package/dist/components/pie.vue_vue_type_script_setup_true_lang.js +42 -0
- package/dist/components/pie.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/radar.js +6 -0
- package/dist/components/radar.js.map +1 -0
- package/dist/components/radar.vue_vue_type_script_setup_true_lang.js +45 -0
- package/dist/components/radar.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/range.js +6 -0
- package/dist/components/range.js.map +1 -0
- package/dist/components/range.vue_vue_type_script_setup_true_lang.js +27 -0
- package/dist/components/range.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/scatter.js +6 -0
- package/dist/components/scatter.js.map +1 -0
- package/dist/components/scatter.vue_vue_type_script_setup_true_lang.js +45 -0
- package/dist/components/scatter.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/sunburst.js +6 -0
- package/dist/components/sunburst.js.map +1 -0
- package/dist/components/sunburst.vue_vue_type_script_setup_true_lang.js +36 -0
- package/dist/components/sunburst.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/tooltip.js +6 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/components/tooltip.vue_vue_type_script_setup_true_lang.js +31 -0
- package/dist/components/tooltip.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/treemap.js +6 -0
- package/dist/components/treemap.js.map +1 -0
- package/dist/components/treemap.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/components/treemap.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/waterfall.js +6 -0
- package/dist/components/waterfall.js.map +1 -0
- package/dist/components/waterfall.vue_vue_type_script_setup_true_lang.js +49 -0
- package/dist/components/waterfall.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/zoom.js +6 -0
- package/dist/components/zoom.js.map +1 -0
- package/dist/components/zoom.vue_vue_type_script_setup_true_lang.js +37 -0
- package/dist/components/zoom.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/context.js +30 -0
- package/dist/context.js.map +1 -0
- package/dist/core/bar.js +223 -0
- package/dist/core/bar.js.map +1 -0
- package/dist/core/box.js +150 -0
- package/dist/core/box.js.map +1 -0
- package/dist/core/colors.js +58 -0
- package/dist/core/colors.js.map +1 -0
- package/dist/core/data.js +257 -0
- package/dist/core/data.js.map +1 -0
- package/dist/core/decimate.js +211 -0
- package/dist/core/decimate.js.map +1 -0
- package/dist/core/format.js +151 -0
- package/dist/core/format.js.map +1 -0
- package/dist/core/funnel.js +68 -0
- package/dist/core/funnel.js.map +1 -0
- package/dist/core/grid.js +87 -0
- package/dist/core/grid.js.map +1 -0
- package/dist/core/heatmap.js +187 -0
- package/dist/core/heatmap.js.map +1 -0
- package/dist/core/histogram.js +81 -0
- package/dist/core/histogram.js.map +1 -0
- package/dist/core/hit.js +115 -0
- package/dist/core/hit.js.map +1 -0
- package/dist/core/labels.js +141 -0
- package/dist/core/labels.js.map +1 -0
- package/dist/core/layout.js +1002 -0
- package/dist/core/layout.js.map +1 -0
- package/dist/core/line.js +230 -0
- package/dist/core/line.js.map +1 -0
- package/dist/core/marker.js +205 -0
- package/dist/core/marker.js.map +1 -0
- package/dist/core/model.js +391 -0
- package/dist/core/model.js.map +1 -0
- package/dist/core/painter.js +79 -0
- package/dist/core/painter.js.map +1 -0
- package/dist/core/pattern.js +102 -0
- package/dist/core/pattern.js.map +1 -0
- package/dist/core/pie.js +119 -0
- package/dist/core/pie.js.map +1 -0
- package/dist/core/radar.js +83 -0
- package/dist/core/radar.js.map +1 -0
- package/dist/core/scale.js +149 -0
- package/dist/core/scale.js.map +1 -0
- package/dist/core/scatter.js +263 -0
- package/dist/core/scatter.js.map +1 -0
- package/dist/core/svg.js +209 -0
- package/dist/core/svg.js.map +1 -0
- package/dist/core/sync.js +21 -0
- package/dist/core/sync.js.map +1 -0
- package/dist/core/time.js +217 -0
- package/dist/core/time.js.map +1 -0
- package/dist/core/tree.js +348 -0
- package/dist/core/tree.js.map +1 -0
- package/dist/core/warn.js +11 -0
- package/dist/core/warn.js.map +1 -0
- package/dist/core/waterfall.js +134 -0
- package/dist/core/waterfall.js.map +1 -0
- package/dist/core/window.js +94 -0
- package/dist/core/window.js.map +1 -0
- package/dist/define.js +62 -0
- package/dist/define.js.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/locale.js +170 -0
- package/dist/locale.js.map +1 -0
- package/dist/overlay.js +6 -0
- package/dist/overlay.js.map +1 -0
- package/dist/overlay.vue_vue_type_script_setup_true_lang.js +207 -0
- package/dist/overlay.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/pointer.js +6 -0
- package/dist/pointer.js.map +1 -0
- package/dist/pointer.vue_vue_type_script_setup_true_lang.js +136 -0
- package/dist/pointer.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/static.js +6 -0
- package/dist/static.js.map +1 -0
- package/dist/static.vue_vue_type_script_setup_true_lang.js +34 -0
- package/dist/static.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/style.css +1 -0
- package/dist/style.d.ts +1 -0
- package/dist/style.js +3 -0
- package/dist/table.js +6 -0
- package/dist/table.js.map +1 -0
- package/dist/table.vue_vue_type_script_setup_true_lang.js +52 -0
- package/dist/table.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/types/chart.vue.d.ts +24 -0
- package/dist/types/components/area.vue.d.ts +16 -0
- package/dist/types/components/axis.vue.d.ts +8 -0
- package/dist/types/components/bar.vue.d.ts +14 -0
- package/dist/types/components/boxplot.vue.d.ts +14 -0
- package/dist/types/components/brush.vue.d.ts +22 -0
- package/dist/types/components/funnel.vue.d.ts +14 -0
- package/dist/types/components/gauge.vue.d.ts +17 -0
- package/dist/types/components/heatmap.vue.d.ts +14 -0
- package/dist/types/components/histogram.vue.d.ts +14 -0
- package/dist/types/components/line.vue.d.ts +16 -0
- package/dist/types/components/marker.vue.d.ts +6 -0
- package/dist/types/components/pie.vue.d.ts +23 -0
- package/dist/types/components/radar.vue.d.ts +16 -0
- package/dist/types/components/range.vue.d.ts +12 -0
- package/dist/types/components/scatter.vue.d.ts +14 -0
- package/dist/types/components/sunburst.vue.d.ts +17 -0
- package/dist/types/components/tooltip.vue.d.ts +13 -0
- package/dist/types/components/treemap.vue.d.ts +8 -0
- package/dist/types/components/waterfall.vue.d.ts +16 -0
- package/dist/types/components/zoom.vue.d.ts +18 -0
- package/dist/types/context.d.ts +87 -0
- package/dist/types/core/bar.d.ts +38 -0
- package/dist/types/core/box.d.ts +25 -0
- package/dist/types/core/colors.d.ts +16 -0
- package/dist/types/core/data.d.ts +72 -0
- package/dist/types/core/decimate.d.ts +39 -0
- package/dist/types/core/format.d.ts +33 -0
- package/dist/types/core/funnel.d.ts +15 -0
- package/dist/types/core/grid.d.ts +18 -0
- package/dist/types/core/heatmap.d.ts +17 -0
- package/dist/types/core/histogram.d.ts +23 -0
- package/dist/types/core/hit.d.ts +31 -0
- package/dist/types/core/labels.d.ts +45 -0
- package/dist/types/core/layout.d.ts +259 -0
- package/dist/types/core/line.d.ts +36 -0
- package/dist/types/core/marker.d.ts +67 -0
- package/dist/types/core/model.d.ts +86 -0
- package/dist/types/core/painter.d.ts +34 -0
- package/dist/types/core/pattern.d.ts +14 -0
- package/dist/types/core/pie.d.ts +66 -0
- package/dist/types/core/radar.d.ts +12 -0
- package/dist/types/core/scale.d.ts +60 -0
- package/dist/types/core/scatter.d.ts +16 -0
- package/dist/types/core/series.d.ts +228 -0
- package/dist/types/core/svg.d.ts +63 -0
- package/dist/types/core/sync.d.ts +8 -0
- package/dist/types/core/time.d.ts +20 -0
- package/dist/types/core/tree.d.ts +84 -0
- package/dist/types/core/warn.d.ts +4 -0
- package/dist/types/core/waterfall.d.ts +24 -0
- package/dist/types/core/window.d.ts +36 -0
- package/dist/types/define.d.ts +115 -0
- package/dist/types/index.d.ts +363 -0
- package/dist/types/locale.d.ts +100 -0
- package/dist/types/overlay.vue.d.ts +95 -0
- package/dist/types/pointer.vue.d.ts +53 -0
- package/dist/types/static.vue.d.ts +24 -0
- package/dist/types/table.vue.d.ts +19 -0
- package/dist/types/types.d.ts +555 -0
- package/dist/types/zoom-layer.vue.d.ts +41 -0
- package/dist/zoom-layer.js +6 -0
- package/dist/zoom-layer.js.map +1 -0
- package/dist/zoom-layer.vue_vue_type_script_setup_true_lang.js +210 -0
- package/dist/zoom-layer.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/package.json +53 -4
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Painter, Rect } from './painter';
|
|
2
|
+
export type ChartPattern = 'diagonal' | 'dots' | 'crosshatch' | 'horizontal' | 'backslash' | 'grid' | 'vertical';
|
|
3
|
+
/** The patterns in the order series and slices take them. */
|
|
4
|
+
export declare const CHART_PATTERNS: readonly ChartPattern[];
|
|
5
|
+
/**
|
|
6
|
+
* Draws `pattern` over `box` in `ink`, clipped to the current path: call
|
|
7
|
+
* it right after filling a shape, while its path is still the current one.
|
|
8
|
+
*/
|
|
9
|
+
export declare function fillPattern(painter: Painter, pattern: ChartPattern, box: Rect, ink: string, alpha?: number): void;
|
|
10
|
+
/** The same pattern for a legend swatch, as a CSS background image and its size. */
|
|
11
|
+
export declare function patternCss(pattern: ChartPattern, ink: string): {
|
|
12
|
+
image: string;
|
|
13
|
+
size?: string;
|
|
14
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type ChartAccessor, type ChartData } from './data';
|
|
2
|
+
import type { Painter } from './painter';
|
|
3
|
+
import { type ChartPattern } from './pattern';
|
|
4
|
+
/** A slice of a pie, with its angles in radians clockwise from 12 o'clock. */
|
|
5
|
+
export interface PieSlice {
|
|
6
|
+
/** The row's index. */
|
|
7
|
+
index: number;
|
|
8
|
+
label: string;
|
|
9
|
+
value: number;
|
|
10
|
+
/** Its own color, if the pie reads one. */
|
|
11
|
+
color?: string;
|
|
12
|
+
/** Its part of the whole, 0 to 1; 0 when hidden. */
|
|
13
|
+
share: number;
|
|
14
|
+
/** Turned off in the legend: it keeps its color, but takes no room. */
|
|
15
|
+
hidden: boolean;
|
|
16
|
+
start: number;
|
|
17
|
+
end: number;
|
|
18
|
+
/**
|
|
19
|
+
* How much of its ring it fills, 0 to 1: 1, but for a rose, whose
|
|
20
|
+
* slices share the turn evenly and fill out by their values.
|
|
21
|
+
*/
|
|
22
|
+
reach: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* How far out a slice reaches, from a hole of `inner` px to `radius` px:
|
|
26
|
+
* a rose's slice by area, so twice the value covers twice the ink.
|
|
27
|
+
*/
|
|
28
|
+
export declare function sliceOuter(slice: Pick<PieSlice, 'reach'>, inner: number, radius: number): number;
|
|
29
|
+
/** The part of the turn a pie takes, and whether it is a rose. */
|
|
30
|
+
export interface PieShape {
|
|
31
|
+
/** Where the slices start and end, in radians clockwise from 12 o'clock. */
|
|
32
|
+
start?: number;
|
|
33
|
+
end?: number;
|
|
34
|
+
/** Each slice the same angle, its area (not its angle) by its value. */
|
|
35
|
+
rose?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The slices of `rows`: one per row with a value above 0, in the order
|
|
39
|
+
* given, going round clockwise from the top. Slices named in `hidden`
|
|
40
|
+
* are kept, with no room, so they keep their place and color.
|
|
41
|
+
*/
|
|
42
|
+
export declare function pieSlices(rows: ChartData, value: ChartAccessor, label: ChartAccessor | undefined, color?: ChartAccessor, hidden?: readonly string[], shape?: PieShape): PieSlice[];
|
|
43
|
+
/** How much of a series or slice shows while another is brought forward. */
|
|
44
|
+
export declare const FADED = 0.24;
|
|
45
|
+
/**
|
|
46
|
+
* Draws the slices around `cx, cy`, from `inner` (0 for a pie) to
|
|
47
|
+
* `radius`, with a gap of the chart's surface color between them. With
|
|
48
|
+
* `focus`, the other slices are faded; `sweep` (0 to 1) draws only that
|
|
49
|
+
* much of the way round, for the pie to come in.
|
|
50
|
+
*/
|
|
51
|
+
export declare function drawPie(painter: Painter, slices: PieSlice[], colors: string[], { cx, cy, radius, inner, surface, focus, fade, sweep, from, patterns, }: {
|
|
52
|
+
cx: number;
|
|
53
|
+
cy: number;
|
|
54
|
+
radius: number;
|
|
55
|
+
inner: number;
|
|
56
|
+
surface: string;
|
|
57
|
+
/** The `index` of the slice to bring forward. */
|
|
58
|
+
focus?: number;
|
|
59
|
+
/** How much the other slices show. */
|
|
60
|
+
fade?: number;
|
|
61
|
+
sweep?: number;
|
|
62
|
+
/** Where the slices start: coming in, they sweep round from there. */
|
|
63
|
+
from?: number;
|
|
64
|
+
/** The pattern over each slice, by its `index`. */
|
|
65
|
+
patterns?: Array<ChartPattern | null>;
|
|
66
|
+
}): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ChartSeriesKind } from './series';
|
|
2
|
+
export interface RadarStyle {
|
|
3
|
+
/** Dots on the corners: `true`, `false`, or (the default) when there are few. */
|
|
4
|
+
dots?: boolean;
|
|
5
|
+
/** The width of the outline, in px. */
|
|
6
|
+
lineWidth?: number;
|
|
7
|
+
}
|
|
8
|
+
/** The angle of spoke `index` of `count`, clockwise from 12 o'clock. */
|
|
9
|
+
export declare function spokeAngle(index: number, count: number): number;
|
|
10
|
+
/** The spoke nearest the angle `angle` (clockwise from 12 o'clock), of `count`. */
|
|
11
|
+
export declare function nearestSpoke(angle: number, count: number): number;
|
|
12
|
+
export declare const radarKind: ChartSeriesKind<RadarStyle>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scales turn data values into pixels and back. They are plain objects
|
|
3
|
+
* with the mapping folded into two numbers, so `map` costs a multiply and
|
|
4
|
+
* an add: it runs once per drawn point.
|
|
5
|
+
*/
|
|
6
|
+
export type ScaleKind = 'linear' | 'log' | 'time' | 'category';
|
|
7
|
+
export interface Scale {
|
|
8
|
+
kind: ScaleKind;
|
|
9
|
+
/** The values at the two ends, after rounding to nice numbers. */
|
|
10
|
+
domain: [number, number];
|
|
11
|
+
/** The pixels the two ends of `domain` land on. */
|
|
12
|
+
range: [number, number];
|
|
13
|
+
map(value: number): number;
|
|
14
|
+
invert(pixel: number): number;
|
|
15
|
+
/** For `category`: the room each category gets, in px. 0 otherwise. */
|
|
16
|
+
step: number;
|
|
17
|
+
/** For `category`: the categories. */
|
|
18
|
+
categories: string[];
|
|
19
|
+
/** For all but `log`: `map(v)` is `v * k + b`, for loops that can't afford a call per point. */
|
|
20
|
+
k: number;
|
|
21
|
+
b: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The step of 1, 2 or 5 times a power of ten that gives closest to
|
|
25
|
+
* `count` steps across `span` (rounding on a log scale, so it may give a
|
|
26
|
+
* few more or fewer).
|
|
27
|
+
*/
|
|
28
|
+
export declare function niceStep(span: number, count: number): number;
|
|
29
|
+
/** The next nice step up: 1 → 2 → 5 → 10. */
|
|
30
|
+
export declare function nextNiceStep(step: number): number;
|
|
31
|
+
/** How many decimals tell the ticks of `step` apart. */
|
|
32
|
+
export declare function stepDecimals(step: number): number;
|
|
33
|
+
/**
|
|
34
|
+
* A domain wide enough to show `[min, max]`: an empty span is widened, and
|
|
35
|
+
* with `nice` the ends are rounded out to the tick step for about `count` ticks.
|
|
36
|
+
*/
|
|
37
|
+
export declare function linearDomain(min: number, max: number, { count, nice }?: {
|
|
38
|
+
count?: number;
|
|
39
|
+
nice?: boolean;
|
|
40
|
+
}): [number, number];
|
|
41
|
+
/** Ticks at the multiples of a nice step inside `[lo, hi]`, about `count` of them. */
|
|
42
|
+
export declare function linearTicks(lo: number, hi: number, count: number): number[];
|
|
43
|
+
export declare function linearScale(domain: [number, number], range: [number, number], kind?: 'linear' | 'time'): Scale;
|
|
44
|
+
/** Rounds out to whole powers of ten; values at or below 0 can't be shown and are left out. */
|
|
45
|
+
export declare function logDomain(min: number, max: number): [number, number];
|
|
46
|
+
export declare function logTicks(lo: number, hi: number, count: number): number[];
|
|
47
|
+
export declare function logScale(domain: [number, number], range: [number, number]): Scale;
|
|
48
|
+
/**
|
|
49
|
+
* Categories side by side, each in the middle of its own step. `map(i)` is
|
|
50
|
+
* the middle of category `i`; `domain` is `[-0.5, n - 0.5]` so that a
|
|
51
|
+
* category's step runs from `map(i - 0.5)` to `map(i + 0.5)`.
|
|
52
|
+
*/
|
|
53
|
+
export declare function categoryScale(categories: string[], range: [number, number]): Scale;
|
|
54
|
+
/** Every `every`-th category index, starting from the first. */
|
|
55
|
+
export declare function categoryTicks(count: number, every?: number): number[];
|
|
56
|
+
/**
|
|
57
|
+
* The pixel that areas and bars grow from: 0, or the nearer end when 0 is
|
|
58
|
+
* off the axis (always the start on a log axis).
|
|
59
|
+
*/
|
|
60
|
+
export declare function baseline(scale: Scale): number;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ChartAccessor } from './data';
|
|
2
|
+
import type { Painter } from './painter';
|
|
3
|
+
import type { ChartHit, ChartSeries, ChartSeriesKind, ChartView } from './series';
|
|
4
|
+
export interface ScatterStyle {
|
|
5
|
+
/** The bubble size of each row; the area of a bubble grows with it. */
|
|
6
|
+
size?: ChartAccessor;
|
|
7
|
+
/** Dot radius in px; with `size`, the radius of the largest bubble. */
|
|
8
|
+
radius?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function drawScatter(painter: Painter, series: ChartSeries<ScatterStyle>, view: ChartView): void;
|
|
11
|
+
/**
|
|
12
|
+
* The point under `(px, py)`: the bubble it is inside (the smallest, which
|
|
13
|
+
* is drawn on top), or the dot nearest to it within a finger's reach.
|
|
14
|
+
*/
|
|
15
|
+
export declare function hitScatter(series: ChartSeries<ScatterStyle>, view: ChartView, px: number, py: number): ChartHit | null;
|
|
16
|
+
export declare const scatterKind: ChartSeriesKind<ScatterStyle>;
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import type { Tone } from 'dou-ui';
|
|
2
|
+
import type { ChartAccessor, ChartData, XColumn } from './data';
|
|
3
|
+
import type { ChartPattern } from './pattern';
|
|
4
|
+
import type { Painter, Rect } from './painter';
|
|
5
|
+
import type { Scale } from './scale';
|
|
6
|
+
/** The y axis a series is measured on. */
|
|
7
|
+
/** The value axis a series is measured on: `y`, or `y2` for a second kind of values. */
|
|
8
|
+
export type ChartValueAxis = 'y' | 'y2';
|
|
9
|
+
/** What every series accepts. */
|
|
10
|
+
export interface ChartSeriesProps {
|
|
11
|
+
/** The value of each row: a key of the row or a function of it. */
|
|
12
|
+
y: ChartAccessor;
|
|
13
|
+
/** Shown in the legend and the tooltip. Defaults to `y` when that is a key. */
|
|
14
|
+
name?: string;
|
|
15
|
+
/** Rows of this series alone; defaults to the chart's `data`. */
|
|
16
|
+
data?: ChartData;
|
|
17
|
+
/** The x of each row of this series' own `data`; defaults to the chart's `x`. */
|
|
18
|
+
x?: ChartAccessor;
|
|
19
|
+
/**
|
|
20
|
+
* Any CSS color. Defaults to the next color of the chart palette. Kinds
|
|
21
|
+
* that draw each point on its own (bars, scatter) also take a function of
|
|
22
|
+
* the row giving that point's color: a CSS color or a tone, `undefined`
|
|
23
|
+
* for the series' color. Its results are in `series.colors`.
|
|
24
|
+
*/
|
|
25
|
+
color?: string | ((row: any, index: number) => string | undefined);
|
|
26
|
+
/** A tone, for when the color means something (`danger` for errors). */
|
|
27
|
+
tone?: Tone;
|
|
28
|
+
/** The value axis to measure on: `y2` is a second one, on the right (on the top when horizontal). */
|
|
29
|
+
axis?: ChartValueAxis;
|
|
30
|
+
}
|
|
31
|
+
/** A series as it is drawn: its data read into columns and its color worked out. */
|
|
32
|
+
export interface ChartSeries<P = Record<string, unknown>> {
|
|
33
|
+
/** Stable for the series' lifetime: its place among all series, hidden or not. */
|
|
34
|
+
index: number;
|
|
35
|
+
kind: ChartSeriesKind<any>;
|
|
36
|
+
props: ChartSeriesProps & P;
|
|
37
|
+
name: string;
|
|
38
|
+
/** The rows the series reads: its own `data`, or the chart's. */
|
|
39
|
+
rows: ChartData;
|
|
40
|
+
/** The color as a CSS color the canvas understands. */
|
|
41
|
+
color: string;
|
|
42
|
+
/**
|
|
43
|
+
* Colors of single points or bars, by row, for a series whose `color`
|
|
44
|
+
* is a function (bars, scatter); `undefined` where the row takes `color`.
|
|
45
|
+
*/
|
|
46
|
+
colors?: Array<string | undefined> | null;
|
|
47
|
+
axis: ChartValueAxis;
|
|
48
|
+
x: XColumn;
|
|
49
|
+
/** The values as given. */
|
|
50
|
+
y: Float64Array;
|
|
51
|
+
/** Where the series is drawn: `y`, or the top of its slice of a stack. */
|
|
52
|
+
top: Float64Array;
|
|
53
|
+
/** The bottom of its slice of a stack; `null` when not stacked. */
|
|
54
|
+
base: Float64Array | null;
|
|
55
|
+
/**
|
|
56
|
+
* For a stacked series: how far the whole stack reaches at each x, up
|
|
57
|
+
* (positives) and down (negatives). A slice whose `top` is there is the
|
|
58
|
+
* outermost one.
|
|
59
|
+
*/
|
|
60
|
+
stackEnds: {
|
|
61
|
+
up: Float64Array;
|
|
62
|
+
down: Float64Array;
|
|
63
|
+
} | null;
|
|
64
|
+
/** For series that share the room of each x (bars): which part is theirs. */
|
|
65
|
+
slot: {
|
|
66
|
+
index: number;
|
|
67
|
+
count: number;
|
|
68
|
+
} | null;
|
|
69
|
+
/** The pattern drawn over its fill, if any (the chart's `patterns`, or its own `pattern`). */
|
|
70
|
+
pattern?: ChartPattern | null;
|
|
71
|
+
/**
|
|
72
|
+
* What the kind's `prepare` gave back for this data; `undefined` until
|
|
73
|
+
* it has run, so `draw` and `hit` must work without it.
|
|
74
|
+
*/
|
|
75
|
+
prepared?: unknown;
|
|
76
|
+
}
|
|
77
|
+
/** What a series draws with. */
|
|
78
|
+
export interface ChartView {
|
|
79
|
+
/** The x scale. With `horizontal`, it runs down the left side. */
|
|
80
|
+
x: Scale;
|
|
81
|
+
/** The value scale. With `horizontal`, it runs along the bottom. */
|
|
82
|
+
y: Scale;
|
|
83
|
+
/** Whether x runs down and values run across: `map` of `x` gives a top, of `y` a left. */
|
|
84
|
+
horizontal: boolean;
|
|
85
|
+
/** The room each x value gets along the x axis, in px: a category's width, or the closest two x apart. */
|
|
86
|
+
band: number;
|
|
87
|
+
/** Where a value at `x` lands, as `[left, top]` in CSS px, whichever way the chart runs. */
|
|
88
|
+
point(x: number, value: number): [number, number];
|
|
89
|
+
/** The plot area, in CSS px. */
|
|
90
|
+
plot: Rect;
|
|
91
|
+
/** Device pixels per CSS px. */
|
|
92
|
+
dpr: number;
|
|
93
|
+
/**
|
|
94
|
+
* Drawing into an SVG (an export, the server's image): shapes only, no
|
|
95
|
+
* images of another canvas.
|
|
96
|
+
*/
|
|
97
|
+
vector?: boolean;
|
|
98
|
+
/** The resolved colors of the chart. */
|
|
99
|
+
colors: ChartColors;
|
|
100
|
+
/**
|
|
101
|
+
* For a radar: its center and radius, and how many spokes. `point`
|
|
102
|
+
* then takes a spoke (the category's index) and a value.
|
|
103
|
+
*/
|
|
104
|
+
polar?: {
|
|
105
|
+
cx: number;
|
|
106
|
+
cy: number;
|
|
107
|
+
radius: number;
|
|
108
|
+
count: number;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export interface ChartColors {
|
|
112
|
+
/** What the chart sits on; rings around dots, gaps between slices. */
|
|
113
|
+
surface: string;
|
|
114
|
+
grid: string;
|
|
115
|
+
baseline: string;
|
|
116
|
+
}
|
|
117
|
+
/** A kind of series: how it widens the axes and how it draws. */
|
|
118
|
+
export interface ChartSeriesKind<P = Record<string, unknown>> {
|
|
119
|
+
/** What kind of series it is, in class names (`is-bar`): the legend draws its swatch from it. */
|
|
120
|
+
type: string;
|
|
121
|
+
/** Whether the value axis must reach 0 (areas and bars grow from it). */
|
|
122
|
+
zero?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Whether the series places its rows by category on the value axis too
|
|
125
|
+
* (a heatmap): `y` names a category, `value` gives each cell's value.
|
|
126
|
+
* The value axis then lists the categories, the first at the top; `y`
|
|
127
|
+
* holds the values and `top` the categories' places.
|
|
128
|
+
*/
|
|
129
|
+
categoryY?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Whether the series is drawn round a center (a radar): a spoke for each
|
|
132
|
+
* category, values out from the center. It can't share a chart with
|
|
133
|
+
* series drawn on axes.
|
|
134
|
+
*/
|
|
135
|
+
polar?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Whether the series is a funnel: its rows are stages, one bar under
|
|
138
|
+
* another, without axes. It is drawn alone, as a pie is.
|
|
139
|
+
*/
|
|
140
|
+
funnel?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Whether the series is a waterfall: each value a change, drawn from the
|
|
143
|
+
* running total before it (`base`) to the one after (`top`); rows its
|
|
144
|
+
* `total` marks are drawn from 0 to the running total.
|
|
145
|
+
*/
|
|
146
|
+
waterfall?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Whether the series is a box plot: `y` gives each row a group of values,
|
|
149
|
+
* summed up in a box; `y` holds the medians, and `base` and `top` the
|
|
150
|
+
* smallest and largest values, so the axis reaches them.
|
|
151
|
+
*/
|
|
152
|
+
box?: boolean;
|
|
153
|
+
/** Whether series of this kind can stack (`stack` prop). */
|
|
154
|
+
stackable?: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Whether series of this kind share the room of each x side by side
|
|
157
|
+
* (bars): each gets a `slot`, and the x axis leaves half a band of room
|
|
158
|
+
* at both ends.
|
|
159
|
+
*/
|
|
160
|
+
band?: boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Room the series needs around each point, in px, for marks larger than
|
|
163
|
+
* a dot (bubbles): the axes are widened so they fit inside the plot.
|
|
164
|
+
*/
|
|
165
|
+
inset?(series: Pick<ChartSeries<P>, 'props' | 'rows' | 'x' | 'y'>): number;
|
|
166
|
+
draw(painter: Painter, series: ChartSeries<P>, view: ChartView): void;
|
|
167
|
+
/**
|
|
168
|
+
* What the tooltip shows by default: every series at the x under the
|
|
169
|
+
* pointer (`axis`, the default), or the one point under it (`item`,
|
|
170
|
+
* for scatters).
|
|
171
|
+
*/
|
|
172
|
+
tooltip?: 'axis' | 'item';
|
|
173
|
+
/**
|
|
174
|
+
* The point under `(px, py)` for an `item` tooltip, and the radius of its
|
|
175
|
+
* mark. By default, the nearest point within 12px.
|
|
176
|
+
*/
|
|
177
|
+
hit?(series: ChartSeries<P>, view: ChartView, px: number, py: number): ChartHit | null;
|
|
178
|
+
/**
|
|
179
|
+
* Work done ahead, once the data has stayed the same a moment and the
|
|
180
|
+
* page is idle, so `hit` (or `draw`) can be quicker: building an index,
|
|
181
|
+
* say. What it gives back is kept as `series.prepared`. Not run for data
|
|
182
|
+
* replaced many times a second (live data).
|
|
183
|
+
*/
|
|
184
|
+
prepare?(series: ChartSeries<P>): unknown;
|
|
185
|
+
/**
|
|
186
|
+
* The tooltip's title for row `row`, in place of its x as the axis
|
|
187
|
+
* writes it (`text`): a histogram's bin, from its start to its end.
|
|
188
|
+
*/
|
|
189
|
+
xTitle?(series: ChartSeries<P>, row: number, text: (x: number) => string): string;
|
|
190
|
+
/**
|
|
191
|
+
* For a `band` series, how wide one band is in x's units, in place of
|
|
192
|
+
* the smallest gap between its x values: a histogram's bin width, which
|
|
193
|
+
* holds with only one bin.
|
|
194
|
+
*/
|
|
195
|
+
xStep?(series: ChartSeries<P>): number;
|
|
196
|
+
/**
|
|
197
|
+
* Where the series' data labels go (`labels` prop): a point and the side
|
|
198
|
+
* of it the text takes, for each row on screen worth a label. The chart
|
|
199
|
+
* writes the text, and leaves out labels that cover others.
|
|
200
|
+
*/
|
|
201
|
+
labels?(series: ChartSeries<P>, view: ChartView): ChartLabelAnchor[];
|
|
202
|
+
}
|
|
203
|
+
/** Where a data label goes. */
|
|
204
|
+
export interface ChartLabelAnchor {
|
|
205
|
+
/** The row's index in the series' rows. */
|
|
206
|
+
index: number;
|
|
207
|
+
/** The point the label is beside, in CSS px. */
|
|
208
|
+
at: [number, number];
|
|
209
|
+
/** Which side of `at` the text goes; `center` puts it on `at`, inside `box`. */
|
|
210
|
+
side: 'top' | 'bottom' | 'left' | 'right' | 'center';
|
|
211
|
+
/** For `center`: the shape the text must fit in (a bar), and its color. */
|
|
212
|
+
box?: Rect & {
|
|
213
|
+
color: string;
|
|
214
|
+
};
|
|
215
|
+
/**
|
|
216
|
+
* The most room the label may take across its side, in px: its width
|
|
217
|
+
* above or below the point, its height beside it. A bar's label stays
|
|
218
|
+
* within the room of its bar.
|
|
219
|
+
*/
|
|
220
|
+
room?: number;
|
|
221
|
+
}
|
|
222
|
+
/** A point found under the pointer. */
|
|
223
|
+
export interface ChartHit {
|
|
224
|
+
/** The row's index in the series' rows. */
|
|
225
|
+
index: number;
|
|
226
|
+
/** The radius of its mark in px, for the ring that shows it. */
|
|
227
|
+
radius: number;
|
|
228
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Painter } from './painter';
|
|
2
|
+
/** A number with at most two decimals, short in the markup. */
|
|
3
|
+
export declare const num: (value: number) => string;
|
|
4
|
+
/** Text made safe to put in markup, as content or in an attribute. */
|
|
5
|
+
export declare const escapeXml: (text: string) => string;
|
|
6
|
+
/** `name="value"` for a color, or a style when SVG attributes can't take it (`var(…)`, `color-mix(…)`). */
|
|
7
|
+
export declare function paintAttribute(name: 'fill' | 'stroke' | 'stop-color', color: string): string;
|
|
8
|
+
export declare class SvgPainter implements Painter {
|
|
9
|
+
private prefix;
|
|
10
|
+
private color;
|
|
11
|
+
fillStyle: string | CanvasGradient | CanvasPattern;
|
|
12
|
+
strokeStyle: string | CanvasGradient | CanvasPattern;
|
|
13
|
+
lineWidth: number;
|
|
14
|
+
lineJoin: CanvasLineJoin;
|
|
15
|
+
lineCap: CanvasLineCap;
|
|
16
|
+
globalAlpha: number;
|
|
17
|
+
private dash;
|
|
18
|
+
private clipId;
|
|
19
|
+
private states;
|
|
20
|
+
private path;
|
|
21
|
+
/** The current point, and where the current subpath starts; `NaN` when there is none. */
|
|
22
|
+
private cx;
|
|
23
|
+
private cy;
|
|
24
|
+
private sx;
|
|
25
|
+
private sy;
|
|
26
|
+
private body;
|
|
27
|
+
private defs;
|
|
28
|
+
private clips;
|
|
29
|
+
private ids;
|
|
30
|
+
/**
|
|
31
|
+
* `prefix` starts every id the markup gives, so two SVGs in one page
|
|
32
|
+
* don't share them; `color` turns a color into one the SVG's reader
|
|
33
|
+
* understands.
|
|
34
|
+
*/
|
|
35
|
+
constructor(prefix: string, color?: (css: string) => string);
|
|
36
|
+
/** An id of its own in this SVG, for something drawn as raw markup (a gradient). */
|
|
37
|
+
id(name: string): string;
|
|
38
|
+
save(): void;
|
|
39
|
+
restore(): void;
|
|
40
|
+
beginPath(): void;
|
|
41
|
+
closePath(): void;
|
|
42
|
+
moveTo(x: number, y: number): void;
|
|
43
|
+
lineTo(x: number, y: number): void;
|
|
44
|
+
bezierCurveTo(c1x: number, c1y: number, c2x: number, c2y: number, x: number, y: number): void;
|
|
45
|
+
rect(x: number, y: number, width: number, height: number): void;
|
|
46
|
+
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
|
|
47
|
+
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
|
|
48
|
+
setLineDash(segments: Iterable<number>): void;
|
|
49
|
+
fill(rule?: CanvasFillRule | Path2D): void;
|
|
50
|
+
stroke(): void;
|
|
51
|
+
clip(): void;
|
|
52
|
+
drawImage(image: CanvasImageSource, ...args: number[]): void;
|
|
53
|
+
/** Draws what `draw` paints as one layer, `alpha` see-through as a whole. */
|
|
54
|
+
layer(alpha: number, draw: () => void): void;
|
|
55
|
+
/** Adds markup as it is, for what the painter can't draw (text). */
|
|
56
|
+
raw(markup: string): void;
|
|
57
|
+
/** The clip and see-through every shape takes from the state. */
|
|
58
|
+
private common;
|
|
59
|
+
/** What was drawn, as the inside of an `<svg>`. */
|
|
60
|
+
markup(): string;
|
|
61
|
+
}
|
|
62
|
+
/** Whether a painter writes SVG: it then draws layers and text itself. */
|
|
63
|
+
export declare const isSvg: (painter: unknown) => painter is SvgPainter;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** An x as charts of a group share it; `null` when the pointer left. */
|
|
2
|
+
export type SharedX = string | number | null;
|
|
3
|
+
type Listener = (x: SharedX) => void;
|
|
4
|
+
/** Listens to the x shown in `group`; gives back how to stop. */
|
|
5
|
+
export declare function joinGroup(group: string, listener: Listener): () => void;
|
|
6
|
+
/** Shows `x` in every chart of `group` but the one telling (`from`). */
|
|
7
|
+
export declare function tellGroup(group: string, x: SharedX, from: Listener): void;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ticks on a time axis, at round points of local time: whole minutes,
|
|
3
|
+
* midnights, the first of a month. The step is the smallest one that
|
|
4
|
+
* gives no more than the wanted number of ticks.
|
|
5
|
+
*/
|
|
6
|
+
export type TimeUnit = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
|
|
7
|
+
export interface TimeInterval {
|
|
8
|
+
unit: TimeUnit;
|
|
9
|
+
every: number;
|
|
10
|
+
}
|
|
11
|
+
/** The smallest interval that gives at most `count` ticks across `span` ms. */
|
|
12
|
+
export declare function timeInterval(span: number, count: number): TimeInterval;
|
|
13
|
+
/** The start of the `unit` that `time` falls in (weeks start on Monday). */
|
|
14
|
+
export declare function floorTime(time: number, unit: TimeUnit): Date;
|
|
15
|
+
/** The ticks of `interval` from `lo` to `hi` (ms), both ends included when they fall on one. */
|
|
16
|
+
export declare function timeTicks(lo: number, hi: number, interval: TimeInterval): number[];
|
|
17
|
+
/** The next unit up, whose boundaries a tick label marks with more context. */
|
|
18
|
+
export declare function parentUnit(unit: TimeUnit): TimeUnit | null;
|
|
19
|
+
/** Whether `time` is the very start of a `unit`. */
|
|
20
|
+
export declare function startsUnit(time: number, unit: TimeUnit): boolean;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { type ChartAccessor, type ChartRow } from './data';
|
|
2
|
+
import type { Painter, Rect } from './painter';
|
|
3
|
+
export interface TreeNode {
|
|
4
|
+
/** Its place in `nodes`, in the order the tree is walked (parents first). */
|
|
5
|
+
index: number;
|
|
6
|
+
name: string;
|
|
7
|
+
/** Its own value (a leaf's), or the sum of its children's. */
|
|
8
|
+
value: number;
|
|
9
|
+
/** 1 for the top level: the root, which holds the whole, is 0. */
|
|
10
|
+
depth: number;
|
|
11
|
+
parent: TreeNode | null;
|
|
12
|
+
children: TreeNode[];
|
|
13
|
+
/** The row it was read from; the root has none. */
|
|
14
|
+
row: ChartRow | null;
|
|
15
|
+
/** Its row's place among its siblings' rows, as accessors are given it. */
|
|
16
|
+
place: number;
|
|
17
|
+
/** The place of its top-level node among the top level, which picks its color. */
|
|
18
|
+
group: number;
|
|
19
|
+
/** A treemap's rectangle, or a sunburst's arc (angles and radii). */
|
|
20
|
+
x0: number;
|
|
21
|
+
y0: number;
|
|
22
|
+
x1: number;
|
|
23
|
+
y1: number;
|
|
24
|
+
}
|
|
25
|
+
export interface TreeAccessors {
|
|
26
|
+
label: ChartAccessor;
|
|
27
|
+
value: ChartAccessor;
|
|
28
|
+
children: ChartAccessor;
|
|
29
|
+
}
|
|
30
|
+
/** The tree read from nested rows, and its nodes walked parents first; nodes without value are left out. */
|
|
31
|
+
export declare function buildTree(data: readonly ChartRow[] | undefined, { label, value, children }: TreeAccessors): {
|
|
32
|
+
root: TreeNode;
|
|
33
|
+
nodes: TreeNode[];
|
|
34
|
+
};
|
|
35
|
+
/** The names from the top level down to `node`. */
|
|
36
|
+
export declare function treePath(node: TreeNode): string[];
|
|
37
|
+
/** Room above a group's children for its name, in px. */
|
|
38
|
+
export declare const TREE_HEADER = 20;
|
|
39
|
+
/**
|
|
40
|
+
* Lays the treemap out in `rect`: each node's rectangle as near a square
|
|
41
|
+
* as can be (the squarified layout), largest first, children inside their
|
|
42
|
+
* group below its header.
|
|
43
|
+
*/
|
|
44
|
+
export declare function layoutTreemap(root: TreeNode, rect: Rect): void;
|
|
45
|
+
/** Whether a treemap group has room for its header (see `layoutTreemap`). */
|
|
46
|
+
export declare function hasHeader(node: TreeNode): boolean;
|
|
47
|
+
/** The deepest node of a treemap under `(px, py)`. */
|
|
48
|
+
export declare function treemapAt(root: TreeNode, px: number, py: number): TreeNode | null;
|
|
49
|
+
/**
|
|
50
|
+
* Draws a treemap: a leaf filled with its color, a group a light wash of
|
|
51
|
+
* it under its children. `focus` (a node's index) is ringed.
|
|
52
|
+
*/
|
|
53
|
+
export declare function drawTreemap(painter: Painter, nodes: TreeNode[], colors: string[], { surface, ring, focus, t, }: {
|
|
54
|
+
surface: string;
|
|
55
|
+
ring: string;
|
|
56
|
+
focus?: number;
|
|
57
|
+
t?: number;
|
|
58
|
+
}): void;
|
|
59
|
+
/** Rings a treemap's node: the one under the pointer or picked with the keys. */
|
|
60
|
+
export declare function ringTreemap(painter: Painter, node: TreeNode | undefined, ring: string): void;
|
|
61
|
+
/**
|
|
62
|
+
* Lays a sunburst out round `(cx, cy)`: the top level in the ring just out
|
|
63
|
+
* of the hole (`inner`), each level a ring further out to `radius`; each
|
|
64
|
+
* node's arc a share of its parent's as its value is of the parent's.
|
|
65
|
+
* Angles run clockwise from 12 o'clock.
|
|
66
|
+
*/
|
|
67
|
+
export declare function layoutSunburst(root: TreeNode, inner: number, radius: number): void;
|
|
68
|
+
/** The node of a sunburst under the angle `angle` (clockwise from 12 o'clock) and radius `r`. */
|
|
69
|
+
export declare function sunburstAt(root: TreeNode, angle: number, r: number): TreeNode | null;
|
|
70
|
+
/**
|
|
71
|
+
* Draws a sunburst round `(cx, cy)`, sweeping in with `sweep` (0 to 1).
|
|
72
|
+
* Nodes other than `focus`, its ancestors and its descendants are faded.
|
|
73
|
+
*/
|
|
74
|
+
/** How much of a sunburst shows off the branch pointed at. */
|
|
75
|
+
export declare const SUNBURST_FADE = 0.4;
|
|
76
|
+
/** A node with its ancestors and all its descendants: what stays lit when it is pointed at. */
|
|
77
|
+
export declare function sunburstBranch(node: TreeNode): TreeNode[];
|
|
78
|
+
export declare function drawSunburst(painter: Painter, nodes: TreeNode[], colors: string[], { cx, cy, surface, focus, sweep, }: {
|
|
79
|
+
cx: number;
|
|
80
|
+
cy: number;
|
|
81
|
+
surface: string;
|
|
82
|
+
focus?: number;
|
|
83
|
+
sweep?: number;
|
|
84
|
+
}): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ChartAccessor, type ChartData } from './data';
|
|
2
|
+
import type { ChartSeries, ChartSeriesKind } from './series';
|
|
3
|
+
export interface WaterfallStyle {
|
|
4
|
+
/** Whether a row is a total: a key of the row or a function of it. */
|
|
5
|
+
total?: ChartAccessor;
|
|
6
|
+
/** Corner radius of the bars, in px. */
|
|
7
|
+
radius?: number;
|
|
8
|
+
/** Lines from each bar to the next, at the total they share. */
|
|
9
|
+
connectors?: boolean;
|
|
10
|
+
labelPosition?: 'outside' | 'inside';
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The bars of a waterfall: where each starts (`base`) and ends (`top`), and
|
|
14
|
+
* its value (`y`): the change, or for a total row, the running total. A
|
|
15
|
+
* row without a value is left out and changes nothing.
|
|
16
|
+
*/
|
|
17
|
+
export declare function waterfallSteps(rows: ChartData, changes: Float64Array, total: ChartAccessor | undefined): {
|
|
18
|
+
y: Float64Array;
|
|
19
|
+
top: Float64Array;
|
|
20
|
+
base: Float64Array;
|
|
21
|
+
};
|
|
22
|
+
/** Whether row `i` of a waterfall is a total. */
|
|
23
|
+
export declare function isTotal(series: Pick<ChartSeries<WaterfallStyle>, 'props' | 'rows'>, i: number): boolean;
|
|
24
|
+
export declare const waterfallKind: ChartSeriesKind<WaterfallStyle>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type XKind } from './data';
|
|
2
|
+
import type { ChartTickValue } from './layout';
|
|
3
|
+
import type { Scale } from './scale';
|
|
4
|
+
export type Window = [number, number];
|
|
5
|
+
/** Turns a value as given (a category, a date, a number) into the scale's number; `NaN` if it can't be. */
|
|
6
|
+
export declare function valueToNumber(value: ChartTickValue, kind: XKind, categories: string[]): number;
|
|
7
|
+
/** The value as given for a scale number: the category, a `Date`, or the number. */
|
|
8
|
+
export declare function numberToValue(value: number, kind: XKind, categories: string[]): ChartTickValue;
|
|
9
|
+
/**
|
|
10
|
+
* The window of an interval as given; categories take their whole step,
|
|
11
|
+
* from half a step before the first to half after the last. `null` for
|
|
12
|
+
* none, or one that can't be read.
|
|
13
|
+
*/
|
|
14
|
+
export declare function intervalToWindow(interval: readonly [ChartTickValue, ChartTickValue] | null | undefined, kind: XKind, categories: string[]): Window | null;
|
|
15
|
+
/** The interval of a window: for categories, the first and last mostly in it. */
|
|
16
|
+
export declare function windowToInterval(window: Window, kind: XKind, categories: string[]): [ChartTickValue, ChartTickValue];
|
|
17
|
+
/** A window on categories moved to whole steps, keeping at least one. */
|
|
18
|
+
export declare function snapCategories([a, b]: Window): Window;
|
|
19
|
+
/** Numbers a scale is even in: the log of a log scale's values. */
|
|
20
|
+
export interface Units {
|
|
21
|
+
to: (value: number) => number;
|
|
22
|
+
from: (unit: number) => number;
|
|
23
|
+
}
|
|
24
|
+
export declare const unitsOf: (scale: Pick<Scale, "kind">) => Units;
|
|
25
|
+
/**
|
|
26
|
+
* `window` kept inside `full`, at least `least` wide (in units): a window
|
|
27
|
+
* that runs over an end is moved back, not cut. `null` when it covers
|
|
28
|
+
* all of `full`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function clampWindow(window: Window, full: Window, least: number, units?: Units): Window | null;
|
|
31
|
+
/** The window `scale` shows with its range moved `by` px: dragging the plot by `-by`. */
|
|
32
|
+
export declare function panWindow(scale: Scale, by: number): Window;
|
|
33
|
+
/** The window `scale` shows zoomed by `factor` (below 1 is in) about the pixel `at`. */
|
|
34
|
+
export declare function zoomWindow(scale: Scale, at: number, factor: number): Window;
|
|
35
|
+
/** Whether `value` is at or between the ends of `window`. */
|
|
36
|
+
export declare const within: (value: number, window: Window) => boolean;
|