@samizdata/mozaic 0.0.0-stage → 0.3.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 +674 -0
- package/README.md +44 -2
- package/dist/annotations/Arrow.svelte +50 -0
- package/dist/annotations/Arrow.svelte.d.ts +18 -0
- package/dist/annotations/Callout.svelte +87 -0
- package/dist/annotations/Callout.svelte.d.ts +22 -0
- package/dist/annotations/Label.svelte +55 -0
- package/dist/annotations/Label.svelte.d.ts +19 -0
- package/dist/annotations/RefBand.svelte +46 -0
- package/dist/annotations/RefBand.svelte.d.ts +18 -0
- package/dist/annotations/RefLine.svelte +107 -0
- package/dist/annotations/RefLine.svelte.d.ts +27 -0
- package/dist/annotations/callout-geometry.d.ts +23 -0
- package/dist/annotations/callout-geometry.js +45 -0
- package/dist/annotations/index.d.ts +6 -0
- package/dist/annotations/index.js +6 -0
- package/dist/core/Canvas.svelte +55 -0
- package/dist/core/Canvas.svelte.d.ts +19 -0
- package/dist/core/Facets.svelte +80 -0
- package/dist/core/Facets.svelte.d.ts +49 -0
- package/dist/core/Html.svelte +38 -0
- package/dist/core/Html.svelte.d.ts +13 -0
- package/dist/core/Plot.svelte +202 -0
- package/dist/core/Plot.svelte.d.ts +60 -0
- package/dist/core/Svg.svelte +58 -0
- package/dist/core/Svg.svelte.d.ts +17 -0
- package/dist/core/accessor.d.ts +5 -0
- package/dist/core/accessor.js +3 -0
- package/dist/core/context.d.ts +25 -0
- package/dist/core/context.js +69 -0
- package/dist/core/index.d.ts +10 -0
- package/dist/core/index.js +9 -0
- package/dist/core/scales.d.ts +16 -0
- package/dist/core/scales.js +32 -0
- package/dist/core/types.d.ts +78 -0
- package/dist/core/types.js +1 -0
- package/dist/core/units.d.ts +6 -0
- package/dist/core/units.js +10 -0
- package/dist/embed/Embed.svelte +50 -0
- package/dist/embed/Embed.svelte.d.ts +14 -0
- package/dist/embed/code.d.ts +18 -0
- package/dist/embed/code.js +9 -0
- package/dist/embed/host.d.ts +6 -0
- package/dist/embed/host.js +20 -0
- package/dist/embed/index.d.ts +6 -0
- package/dist/embed/index.js +5 -0
- package/dist/embed/manifest.d.ts +16 -0
- package/dist/embed/manifest.js +1 -0
- package/dist/embed/params.svelte.d.ts +10 -0
- package/dist/embed/params.svelte.js +27 -0
- package/dist/embed/resize.d.ts +13 -0
- package/dist/embed/resize.js +28 -0
- package/dist/export/download.d.ts +13 -0
- package/dist/export/download.js +52 -0
- package/dist/export/figure-to-svg.d.ts +21 -0
- package/dist/export/figure-to-svg.js +187 -0
- package/dist/export/fonts.d.ts +26 -0
- package/dist/export/fonts.js +112 -0
- package/dist/export/index.d.ts +2 -0
- package/dist/export/index.js +2 -0
- package/dist/frame/Byline.svelte +26 -0
- package/dist/frame/Byline.svelte.d.ts +8 -0
- package/dist/frame/Chart.svelte +144 -0
- package/dist/frame/Chart.svelte.d.ts +37 -0
- package/dist/frame/ChartTools.svelte +259 -0
- package/dist/frame/ChartTools.svelte.d.ts +17 -0
- package/dist/frame/DataDownload.svelte +34 -0
- package/dist/frame/DataDownload.svelte.d.ts +34 -0
- package/dist/frame/DataTable.svelte +49 -0
- package/dist/frame/DataTable.svelte.d.ts +34 -0
- package/dist/frame/Footer.svelte +39 -0
- package/dist/frame/Footer.svelte.d.ts +10 -0
- package/dist/frame/Header.svelte +21 -0
- package/dist/frame/Header.svelte.d.ts +9 -0
- package/dist/frame/Logo.svelte +57 -0
- package/dist/frame/Logo.svelte.d.ts +8 -0
- package/dist/frame/Notes.svelte +29 -0
- package/dist/frame/Notes.svelte.d.ts +9 -0
- package/dist/frame/Source.svelte +29 -0
- package/dist/frame/Source.svelte.d.ts +9 -0
- package/dist/frame/Subtitle.svelte +22 -0
- package/dist/frame/Subtitle.svelte.d.ts +9 -0
- package/dist/frame/Title.svelte +31 -0
- package/dist/frame/Title.svelte.d.ts +9 -0
- package/dist/frame/index.d.ts +12 -0
- package/dist/frame/index.js +12 -0
- package/dist/guides/AxisX.svelte +101 -0
- package/dist/guides/AxisX.svelte.d.ts +22 -0
- package/dist/guides/AxisY.svelte +107 -0
- package/dist/guides/AxisY.svelte.d.ts +25 -0
- package/dist/guides/ColorRamp.svelte +93 -0
- package/dist/guides/ColorRamp.svelte.d.ts +25 -0
- package/dist/guides/GridX.svelte +35 -0
- package/dist/guides/GridX.svelte.d.ts +9 -0
- package/dist/guides/GridY.svelte +35 -0
- package/dist/guides/GridY.svelte.d.ts +9 -0
- package/dist/guides/Key.svelte +48 -0
- package/dist/guides/Key.svelte.d.ts +14 -0
- package/dist/guides/Legend.svelte +112 -0
- package/dist/guides/Legend.svelte.d.ts +26 -0
- package/dist/guides/SizeLegend.svelte +62 -0
- package/dist/guides/SizeLegend.svelte.d.ts +15 -0
- package/dist/guides/index.d.ts +9 -0
- package/dist/guides/index.js +9 -0
- package/dist/guides/ticks.d.ts +6 -0
- package/dist/guides/ticks.js +15 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +14 -0
- package/dist/interactive/ButtonGroup.svelte +98 -0
- package/dist/interactive/ButtonGroup.svelte.d.ts +42 -0
- package/dist/interactive/PointerArea.svelte +49 -0
- package/dist/interactive/PointerArea.svelte.d.ts +18 -0
- package/dist/interactive/Scroller.svelte +147 -0
- package/dist/interactive/Scroller.svelte.d.ts +54 -0
- package/dist/interactive/Tooltip.svelte +116 -0
- package/dist/interactive/Tooltip.svelte.d.ts +34 -0
- package/dist/interactive/index.d.ts +4 -0
- package/dist/interactive/index.js +4 -0
- package/dist/interactive/tooltip-position.d.ts +12 -0
- package/dist/interactive/tooltip-position.js +16 -0
- package/dist/locale/definitions.d.ts +145 -0
- package/dist/locale/definitions.js +138 -0
- package/dist/locale/index.d.ts +23 -0
- package/dist/locale/index.js +34 -0
- package/dist/marks/Arcs.svelte +93 -0
- package/dist/marks/Arcs.svelte.d.ts +47 -0
- package/dist/marks/Area.svelte +44 -0
- package/dist/marks/Area.svelte.d.ts +43 -0
- package/dist/marks/Arrows.svelte +93 -0
- package/dist/marks/Arrows.svelte.d.ts +50 -0
- package/dist/marks/Bars.svelte +111 -0
- package/dist/marks/Bars.svelte.d.ts +61 -0
- package/dist/marks/Beeswarm.svelte +84 -0
- package/dist/marks/Beeswarm.svelte.d.ts +42 -0
- package/dist/marks/Dumbbell.svelte +71 -0
- package/dist/marks/Dumbbell.svelte.d.ts +42 -0
- package/dist/marks/GeoPath.svelte +56 -0
- package/dist/marks/GeoPath.svelte.d.ts +42 -0
- package/dist/marks/Hemicycle.svelte +182 -0
- package/dist/marks/Hemicycle.svelte.d.ts +78 -0
- package/dist/marks/Intervals.svelte +128 -0
- package/dist/marks/Intervals.svelte.d.ts +60 -0
- package/dist/marks/Line.svelte +64 -0
- package/dist/marks/Line.svelte.d.ts +43 -0
- package/dist/marks/LineEndLabels.svelte +70 -0
- package/dist/marks/LineEndLabels.svelte.d.ts +41 -0
- package/dist/marks/Points.svelte +70 -0
- package/dist/marks/Points.svelte.d.ts +46 -0
- package/dist/marks/Rects.svelte +92 -0
- package/dist/marks/Rects.svelte.d.ts +47 -0
- package/dist/marks/Rules.svelte +46 -0
- package/dist/marks/Rules.svelte.d.ts +15 -0
- package/dist/marks/Slope.svelte +112 -0
- package/dist/marks/Slope.svelte.d.ts +41 -0
- package/dist/marks/Text.svelte +75 -0
- package/dist/marks/Text.svelte.d.ts +47 -0
- package/dist/marks/Treemap.svelte +89 -0
- package/dist/marks/Treemap.svelte.d.ts +45 -0
- package/dist/marks/Voronoi.svelte +61 -0
- package/dist/marks/Voronoi.svelte.d.ts +39 -0
- package/dist/marks/Waffle.svelte +77 -0
- package/dist/marks/Waffle.svelte.d.ts +45 -0
- package/dist/marks/bar-path.d.ts +5 -0
- package/dist/marks/bar-path.js +15 -0
- package/dist/marks/index.d.ts +20 -0
- package/dist/marks/index.js +20 -0
- package/dist/recipes/ArrowChart.svelte +247 -0
- package/dist/recipes/ArrowChart.svelte.d.ts +73 -0
- package/dist/recipes/BarChart.svelte +122 -0
- package/dist/recipes/BarChart.svelte.d.ts +58 -0
- package/dist/recipes/BarDotChart.svelte +204 -0
- package/dist/recipes/BarDotChart.svelte.d.ts +75 -0
- package/dist/recipes/ColumnChart.svelte +119 -0
- package/dist/recipes/ColumnChart.svelte.d.ts +56 -0
- package/dist/recipes/LineChart.svelte +159 -0
- package/dist/recipes/LineChart.svelte.d.ts +61 -0
- package/dist/recipes/MosaicChart.svelte +256 -0
- package/dist/recipes/MosaicChart.svelte.d.ts +83 -0
- package/dist/recipes/ScatterChart.svelte +167 -0
- package/dist/recipes/ScatterChart.svelte.d.ts +63 -0
- package/dist/recipes/StackedBarChart.svelte +222 -0
- package/dist/recipes/StackedBarChart.svelte.d.ts +83 -0
- package/dist/recipes/index.d.ts +10 -0
- package/dist/recipes/index.js +19 -0
- package/dist/styles/base.d.ts +5 -0
- package/dist/styles/base.js +102 -0
- package/dist/styles/check.d.ts +8 -0
- package/dist/styles/check.js +32 -0
- package/dist/styles/color.d.ts +11 -0
- package/dist/styles/color.js +29 -0
- package/dist/styles/index.d.ts +9 -0
- package/dist/styles/index.js +17 -0
- package/dist/styles/types.d.ts +90 -0
- package/dist/styles/types.js +1 -0
- package/dist/table/Sparkline.svelte +59 -0
- package/dist/table/Sparkline.svelte.d.ts +16 -0
- package/dist/table/Table.svelte +287 -0
- package/dist/table/Table.svelte.d.ts +44 -0
- package/dist/table/csv.d.ts +3 -0
- package/dist/table/csv.js +12 -0
- package/dist/table/index.d.ts +4 -0
- package/dist/table/index.js +3 -0
- package/dist/table/types.d.ts +26 -0
- package/dist/table/types.js +1 -0
- package/dist/transforms/bin.d.ts +15 -0
- package/dist/transforms/bin.js +18 -0
- package/dist/transforms/dodge.d.ts +10 -0
- package/dist/transforms/dodge.js +35 -0
- package/dist/transforms/group.d.ts +14 -0
- package/dist/transforms/group.js +14 -0
- package/dist/transforms/hemicycle.d.ts +30 -0
- package/dist/transforms/hemicycle.js +51 -0
- package/dist/transforms/index.d.ts +8 -0
- package/dist/transforms/index.js +8 -0
- package/dist/transforms/labels.d.ts +6 -0
- package/dist/transforms/labels.js +20 -0
- package/dist/transforms/smooth.d.ts +61 -0
- package/dist/transforms/smooth.js +105 -0
- package/dist/transforms/stack.d.ts +25 -0
- package/dist/transforms/stack.js +61 -0
- package/dist/transforms/treemap.d.ts +21 -0
- package/dist/transforms/treemap.js +31 -0
- package/package.json +152 -3
- package/src/lib/recipes/ArrowChart.svelte +247 -0
- package/src/lib/recipes/BarChart.svelte +122 -0
- package/src/lib/recipes/BarDotChart.svelte +204 -0
- package/src/lib/recipes/ColumnChart.svelte +119 -0
- package/src/lib/recipes/LineChart.svelte +159 -0
- package/src/lib/recipes/MosaicChart.svelte +256 -0
- package/src/lib/recipes/ScatterChart.svelte +167 -0
- package/src/lib/recipes/StackedBarChart.svelte +222 -0
- package/src/lib/recipes/index.ts +20 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { base } from './base.js';
|
|
2
|
+
import { contrastRatio } from './color.js';
|
|
3
|
+
/**
|
|
4
|
+
* Problems with a house style, as sentences (empty when there are none): every
|
|
5
|
+
* base token defined, at least five categorical and sequential colours as
|
|
6
|
+
* `#rrggbb`, and text colours readable on the background (text 7:1, muted 4.5:1).
|
|
7
|
+
* Run it in a brand's or project's tests: `expect(checkTheme(theme)).toEqual([])`.
|
|
8
|
+
*/
|
|
9
|
+
export function checkTheme(theme) {
|
|
10
|
+
const issues = [];
|
|
11
|
+
const missing = Object.keys(base.tokens).filter((key) => !(key in theme.tokens));
|
|
12
|
+
if (missing.length)
|
|
13
|
+
issues.push(`Missing tokens: ${missing.join(', ')}.`);
|
|
14
|
+
for (const name of ['categorical', 'sequential']) {
|
|
15
|
+
const colors = theme.palettes[name];
|
|
16
|
+
if (colors.length < 5)
|
|
17
|
+
issues.push(`The ${name} palette has ${colors.length} colours; it needs at least 5.`);
|
|
18
|
+
const invalid = colors.filter((c) => !/^#[0-9a-f]{6}$/i.test(c));
|
|
19
|
+
if (invalid.length)
|
|
20
|
+
issues.push(`The ${name} palette has colours that are not #rrggbb: ${invalid.join(', ')}.`);
|
|
21
|
+
}
|
|
22
|
+
const bg = theme.tokens['--mz-color-bg'];
|
|
23
|
+
for (const [token, minimum] of [
|
|
24
|
+
['--mz-color-text', 7],
|
|
25
|
+
['--mz-color-muted', 4.5]
|
|
26
|
+
]) {
|
|
27
|
+
const ratio = contrastRatio(theme.tokens[token], bg);
|
|
28
|
+
if (!(ratio >= minimum))
|
|
29
|
+
issues.push(`${token} has ${ratio.toFixed(2)}:1 contrast on the background; it needs ${minimum}:1.`);
|
|
30
|
+
}
|
|
31
|
+
return issues;
|
|
32
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Relative luminance (WCAG 2) of a `#rrggbb` colour. */
|
|
2
|
+
export declare function luminance(hex: string): number;
|
|
3
|
+
/** WCAG contrast ratio between two `#rrggbb` colours (1–21). */
|
|
4
|
+
export declare function contrastRatio(a: string, b: string): number;
|
|
5
|
+
/**
|
|
6
|
+
* `n` colours from a light → dark ramp for binned data (choropleths, heat
|
|
7
|
+
* steps). Steps too pale to see against `background` (below `minContrast`)
|
|
8
|
+
* are skipped when the ramp has enough others; the rest are picked evenly,
|
|
9
|
+
* so the brand's exact colours are used and the darkest step is always kept.
|
|
10
|
+
*/
|
|
11
|
+
export declare function rampSteps(ramp: string[], n: number, background?: string, minContrast?: number): string[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Relative luminance (WCAG 2) of a `#rrggbb` colour. */
|
|
2
|
+
export function luminance(hex) {
|
|
3
|
+
const n = parseInt(hex.replace('#', ''), 16);
|
|
4
|
+
const [r, g, b] = [(n >> 16) & 255, (n >> 8) & 255, n & 255].map((c) => {
|
|
5
|
+
const s = c / 255;
|
|
6
|
+
return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
|
|
7
|
+
});
|
|
8
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
9
|
+
}
|
|
10
|
+
/** WCAG contrast ratio between two `#rrggbb` colours (1–21). */
|
|
11
|
+
export function contrastRatio(a, b) {
|
|
12
|
+
const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x);
|
|
13
|
+
return (hi + 0.05) / (lo + 0.05);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* `n` colours from a light → dark ramp for binned data (choropleths, heat
|
|
17
|
+
* steps). Steps too pale to see against `background` (below `minContrast`)
|
|
18
|
+
* are skipped when the ramp has enough others; the rest are picked evenly,
|
|
19
|
+
* so the brand's exact colours are used and the darkest step is always kept.
|
|
20
|
+
*/
|
|
21
|
+
export function rampSteps(ramp, n, background = '#ffffff', minContrast = 2) {
|
|
22
|
+
const visible = ramp.filter((c) => contrastRatio(c, background) >= minContrast);
|
|
23
|
+
const source = visible.length >= n ? visible : ramp;
|
|
24
|
+
if (n <= 1)
|
|
25
|
+
return [source[source.length - 1]];
|
|
26
|
+
if (n >= source.length)
|
|
27
|
+
return [...source];
|
|
28
|
+
return Array.from({ length: n }, (_, i) => source[Math.round((i * (source.length - 1)) / (n - 1))]);
|
|
29
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Breakpoint, Theme } from './types.js';
|
|
2
|
+
export type { Breakpoint, Medium, Padding, Theme, ThemeOverrides } from './types.js';
|
|
3
|
+
/** House styles live with each brand (e.g. `datavis/mozaic/` in a brand repo) and extend `base`. */
|
|
4
|
+
export { base, extendTheme } from './base.js';
|
|
5
|
+
export { contrastRatio, luminance, rampSteps } from './color.js';
|
|
6
|
+
export { checkTheme } from './check.js';
|
|
7
|
+
/** Serialise theme tokens into an inline `style` attribute value. */
|
|
8
|
+
export declare function tokensToStyle(tokens: Theme['tokens']): string;
|
|
9
|
+
export declare function breakpointFor(width: number, breakpoints: Theme['breakpoints']): Breakpoint;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** House styles live with each brand (e.g. `datavis/mozaic/` in a brand repo) and extend `base`. */
|
|
2
|
+
export { base, extendTheme } from './base.js';
|
|
3
|
+
export { contrastRatio, luminance, rampSteps } from './color.js';
|
|
4
|
+
export { checkTheme } from './check.js';
|
|
5
|
+
/** Serialise theme tokens into an inline `style` attribute value. */
|
|
6
|
+
export function tokensToStyle(tokens) {
|
|
7
|
+
return Object.entries(tokens)
|
|
8
|
+
.map(([key, value]) => `${key}: ${value}`)
|
|
9
|
+
.join('; ');
|
|
10
|
+
}
|
|
11
|
+
export function breakpointFor(width, breakpoints) {
|
|
12
|
+
if (width >= breakpoints.l)
|
|
13
|
+
return 'l';
|
|
14
|
+
if (width >= breakpoints.m)
|
|
15
|
+
return 'm';
|
|
16
|
+
return 's';
|
|
17
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { LocaleCode } from '../locale/index.js';
|
|
2
|
+
export type Breakpoint = 's' | 'm' | 'l';
|
|
3
|
+
export type Medium = 'web' | 'print';
|
|
4
|
+
export interface Padding {
|
|
5
|
+
top: number;
|
|
6
|
+
right: number;
|
|
7
|
+
bottom: number;
|
|
8
|
+
left: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A house style. Visual tokens become CSS custom properties on `<Chart>`;
|
|
12
|
+
* everything that scales, marks and formatters need as values lives in the
|
|
13
|
+
* other fields and is read with `useTheme()`.
|
|
14
|
+
*/
|
|
15
|
+
export interface Theme {
|
|
16
|
+
/** Machine name, set as `data-mz-style` on the chart. */
|
|
17
|
+
name: string;
|
|
18
|
+
/** Human-readable name. */
|
|
19
|
+
label: string;
|
|
20
|
+
/** CSS custom properties applied to `<Chart>`. Keys start with `--mz-`. */
|
|
21
|
+
tokens: Record<`--mz-${string}`, string>;
|
|
22
|
+
palettes: {
|
|
23
|
+
/** Fixed order; assign by entity, never cycle past the end. */
|
|
24
|
+
categorical: string[];
|
|
25
|
+
/** Single hue, light → dark. */
|
|
26
|
+
sequential: string[];
|
|
27
|
+
/** [negative pole, neutral midpoint, positive pole]. */
|
|
28
|
+
diverging: [string, string, string];
|
|
29
|
+
semantic: {
|
|
30
|
+
positive: string;
|
|
31
|
+
negative: string;
|
|
32
|
+
neutral: string;
|
|
33
|
+
highlight: string;
|
|
34
|
+
/** De-emphasised marks (the "everything else" grey). */
|
|
35
|
+
context: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
plot: {
|
|
39
|
+
/** Width used for server rendering, before the container is measured. */
|
|
40
|
+
initialWidth: number;
|
|
41
|
+
/** Default plot-area height when `<Plot>` gets no height or aspectRatio. */
|
|
42
|
+
height: number;
|
|
43
|
+
padding: Padding;
|
|
44
|
+
ticks: number;
|
|
45
|
+
tickSize: number;
|
|
46
|
+
tickPadding: number;
|
|
47
|
+
/** Draw the axis baseline. */
|
|
48
|
+
axisLine: boolean;
|
|
49
|
+
lineWidth: number;
|
|
50
|
+
/** Corner radius on the data end of bars. */
|
|
51
|
+
barRadius: number;
|
|
52
|
+
/** Bars never get thicker than this, whatever the band size. */
|
|
53
|
+
barMaxThickness: number;
|
|
54
|
+
/** Font size in px used by SVG text and text-width estimates. */
|
|
55
|
+
fontSize: number;
|
|
56
|
+
};
|
|
57
|
+
/** Minimum chart width (px) for each breakpoint. */
|
|
58
|
+
breakpoints: Record<Breakpoint, number>;
|
|
59
|
+
defaultLocale: LocaleCode;
|
|
60
|
+
/** Print medium: named widths in millimetres and token overrides (sizes in pt). */
|
|
61
|
+
print: {
|
|
62
|
+
widths: Record<string, number>;
|
|
63
|
+
tokens: Partial<Record<`--mz-${string}`, string>>;
|
|
64
|
+
};
|
|
65
|
+
/** Web fonts the style needs; `<Chart>` adds the stylesheet to the page head. */
|
|
66
|
+
fonts?: {
|
|
67
|
+
stylesheet: string;
|
|
68
|
+
};
|
|
69
|
+
/** House logo for the chart footer: an inline SVG mark, a text wordmark, or both. */
|
|
70
|
+
logo?: {
|
|
71
|
+
/** Accessible name, e.g. "SAMIZDATA". */
|
|
72
|
+
label: string;
|
|
73
|
+
/** Inline SVG markup (trusted, from the style file). */
|
|
74
|
+
svg?: string;
|
|
75
|
+
/** Wordmark text set in the label font, shown after the SVG. */
|
|
76
|
+
text?: string;
|
|
77
|
+
/** Rendered height of the SVG in px. */
|
|
78
|
+
height?: number;
|
|
79
|
+
/** Where the logo links to (opens in a new tab, so it works from embeds). */
|
|
80
|
+
href?: string;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
type DeepPartial<T> = {
|
|
84
|
+
[K in keyof T]?: T[K] extends unknown[] ? T[K] : T[K] extends object ? DeepPartial<T[K]> : T[K];
|
|
85
|
+
};
|
|
86
|
+
export type ThemeOverrides = DeepPartial<Theme> & {
|
|
87
|
+
name: string;
|
|
88
|
+
label: string;
|
|
89
|
+
};
|
|
90
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
A tiny inline line chart, e.g. in a table cell. Not a full chart: no axes.
|
|
4
|
+
The last point gets a dot.
|
|
5
|
+
-->
|
|
6
|
+
<script lang="ts">
|
|
7
|
+
import { extent } from 'd3-array';
|
|
8
|
+
import { scaleLinear } from 'd3-scale';
|
|
9
|
+
import { line } from 'd3-shape';
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
values: number[];
|
|
13
|
+
width?: number;
|
|
14
|
+
height?: number;
|
|
15
|
+
stroke?: string;
|
|
16
|
+
/** Shared y domain, so several sparklines are comparable. */
|
|
17
|
+
domain?: [number, number];
|
|
18
|
+
label?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let { values, width = 80, height = 20, stroke = 'var(--mz-color-text)', domain, label }: Props = $props();
|
|
22
|
+
|
|
23
|
+
const x = $derived(
|
|
24
|
+
scaleLinear()
|
|
25
|
+
.domain([0, Math.max(1, values.length - 1)])
|
|
26
|
+
.range([2, width - 3])
|
|
27
|
+
);
|
|
28
|
+
const y = $derived(
|
|
29
|
+
scaleLinear()
|
|
30
|
+
.domain(domain ?? (extent(values) as [number, number]))
|
|
31
|
+
.range([height - 3, 3])
|
|
32
|
+
);
|
|
33
|
+
const d = $derived(
|
|
34
|
+
line<number>()
|
|
35
|
+
.x((_, i) => x(i))
|
|
36
|
+
.y((v) => y(v))(values) ?? ''
|
|
37
|
+
);
|
|
38
|
+
const last = $derived(values.length - 1);
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<svg
|
|
42
|
+
class="mz-sparkline"
|
|
43
|
+
{width}
|
|
44
|
+
{height}
|
|
45
|
+
viewBox="0 0 {width} {height}"
|
|
46
|
+
role={label ? 'img' : 'presentation'}
|
|
47
|
+
aria-label={label}
|
|
48
|
+
>
|
|
49
|
+
<path {d} fill="none" style:stroke stroke-width="1.5" stroke-linejoin="round" stroke-linecap="round" />
|
|
50
|
+
{#if last >= 0}<circle cx={x(last)} cy={y(values[last])} r="2.25" style:fill={stroke} />{/if}
|
|
51
|
+
</svg>
|
|
52
|
+
|
|
53
|
+
<style>
|
|
54
|
+
.mz-sparkline {
|
|
55
|
+
display: inline-block;
|
|
56
|
+
vertical-align: middle;
|
|
57
|
+
overflow: visible;
|
|
58
|
+
}
|
|
59
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
values: number[];
|
|
3
|
+
width?: number;
|
|
4
|
+
height?: number;
|
|
5
|
+
stroke?: string;
|
|
6
|
+
/** Shared y domain, so several sparklines are comparable. */
|
|
7
|
+
domain?: [number, number];
|
|
8
|
+
label?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A tiny inline line chart, e.g. in a table cell. Not a full chart: no axes.
|
|
12
|
+
* The last point gets a dot.
|
|
13
|
+
*/
|
|
14
|
+
declare const Sparkline: import("svelte").Component<Props, {}, "">;
|
|
15
|
+
type Sparkline = ReturnType<typeof Sparkline>;
|
|
16
|
+
export default Sparkline;
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
A data table with sortable columns, locale-aware formatting, optional search
|
|
4
|
+
and a "show all" toggle, plus inline bar, heat and sparkline cells. Use it
|
|
5
|
+
on its own or inside `<Chart>`.
|
|
6
|
+
-->
|
|
7
|
+
<script lang="ts" generics="T">
|
|
8
|
+
import { untrack } from 'svelte';
|
|
9
|
+
import { ascending, descending, max as d3max } from 'd3-array';
|
|
10
|
+
import { useChart } from '../core/context.js';
|
|
11
|
+
import Sparkline from './Sparkline.svelte';
|
|
12
|
+
import type { Column } from './types.js';
|
|
13
|
+
|
|
14
|
+
interface Props {
|
|
15
|
+
data: T[];
|
|
16
|
+
columns: Column<T>[];
|
|
17
|
+
/** Initial sort column key. */
|
|
18
|
+
sortBy?: string;
|
|
19
|
+
sortDirection?: 'ascending' | 'descending';
|
|
20
|
+
/** Show a search box. */
|
|
21
|
+
search?: boolean;
|
|
22
|
+
/** Rows shown before "Show all". */
|
|
23
|
+
maxRows?: number;
|
|
24
|
+
/** Visible caption (also the accessible name). */
|
|
25
|
+
caption?: string;
|
|
26
|
+
stickyHeader?: boolean;
|
|
27
|
+
class?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let {
|
|
31
|
+
data,
|
|
32
|
+
columns,
|
|
33
|
+
sortBy,
|
|
34
|
+
sortDirection = 'descending',
|
|
35
|
+
search = false,
|
|
36
|
+
maxRows,
|
|
37
|
+
caption,
|
|
38
|
+
stickyHeader = false,
|
|
39
|
+
class: className = ''
|
|
40
|
+
}: Props = $props();
|
|
41
|
+
|
|
42
|
+
const chart = useChart();
|
|
43
|
+
const strings = $derived(chart.locale.strings);
|
|
44
|
+
|
|
45
|
+
// Sort state starts from the props, then follows the reader's clicks.
|
|
46
|
+
let sortKey = $state<string | undefined>(untrack(() => sortBy));
|
|
47
|
+
let direction = $state<'ascending' | 'descending'>(untrack(() => sortDirection));
|
|
48
|
+
let query = $state('');
|
|
49
|
+
let expanded = $state(false);
|
|
50
|
+
|
|
51
|
+
const isNumeric = (c: Column<T>) => data.some((d) => typeof c.value(d) === 'number');
|
|
52
|
+
// Bars and sparklines start at the left edge, so their headers do too.
|
|
53
|
+
const align = (c: Column<T>) =>
|
|
54
|
+
c.align ?? (isNumeric(c) && c.type !== 'sparkline' && c.type !== 'bar' ? 'right' : 'left');
|
|
55
|
+
const maxima = $derived(
|
|
56
|
+
Object.fromEntries(columns.map((c) => [c.key, c.max ?? (d3max(data, (d) => Math.abs(Number(c.value(d)))) || 1)]))
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const filtered = $derived.by(() => {
|
|
60
|
+
const q = query.trim().toLocaleLowerCase(chart.locale.lang);
|
|
61
|
+
if (!q) return data;
|
|
62
|
+
const searchable = columns.filter((c) => c.searchable ?? !isNumeric(c));
|
|
63
|
+
return data.filter((d) =>
|
|
64
|
+
searchable.some((c) =>
|
|
65
|
+
String(c.value(d) ?? '')
|
|
66
|
+
.toLocaleLowerCase(chart.locale.lang)
|
|
67
|
+
.includes(q)
|
|
68
|
+
)
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const sorted = $derived.by(() => {
|
|
73
|
+
const column = columns.find((c) => c.key === sortKey);
|
|
74
|
+
if (!column) return filtered;
|
|
75
|
+
const compare = direction === 'ascending' ? ascending : descending;
|
|
76
|
+
return filtered.toSorted((a, b) => {
|
|
77
|
+
const va = column.value(a);
|
|
78
|
+
const vb = column.value(b);
|
|
79
|
+
if (typeof va === 'string' && typeof vb === 'string')
|
|
80
|
+
return (direction === 'ascending' ? 1 : -1) * va.localeCompare(vb, chart.locale.lang);
|
|
81
|
+
return compare(va as number, vb as number);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const visible = $derived(maxRows && !expanded ? sorted.slice(0, maxRows) : sorted);
|
|
86
|
+
|
|
87
|
+
function toggleSort(column: Column<T>) {
|
|
88
|
+
if (sortKey === column.key) direction = direction === 'ascending' ? 'descending' : 'ascending';
|
|
89
|
+
else {
|
|
90
|
+
sortKey = column.key;
|
|
91
|
+
direction = isNumeric(column) ? 'descending' : 'ascending';
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function text(column: Column<T>, d: T): string {
|
|
96
|
+
const v = column.value(d);
|
|
97
|
+
if (column.format) return column.format(v, d);
|
|
98
|
+
if (typeof v === 'number') return chart.locale.number(v);
|
|
99
|
+
if (v instanceof Date) return chart.locale.timeFormat('%e %b %Y')(v);
|
|
100
|
+
return v == null ? '' : String(v);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function contrast(color: string): string {
|
|
104
|
+
// Near-black or white text on a heat cell: whichever has the higher WCAG contrast ratio.
|
|
105
|
+
const m = color.match(/^#([0-9a-f]{6})$/i);
|
|
106
|
+
if (!m) return 'inherit';
|
|
107
|
+
const n = parseInt(m[1], 16);
|
|
108
|
+
const [r, g, b] = [(n >> 16) & 255, (n >> 8) & 255, n & 255].map((c) => {
|
|
109
|
+
const s = c / 255;
|
|
110
|
+
return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
|
|
111
|
+
});
|
|
112
|
+
const luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
113
|
+
const dark = 0.0056; // luminance of #111111
|
|
114
|
+
return (luminance + 0.05) / (dark + 0.05) >= 1.05 / (luminance + 0.05) ? '#111111' : '#ffffff';
|
|
115
|
+
}
|
|
116
|
+
</script>
|
|
117
|
+
|
|
118
|
+
<div class="mz-table-wrap {className}">
|
|
119
|
+
{#if search && chart.medium !== 'print'}
|
|
120
|
+
<input
|
|
121
|
+
class="mz-table-search"
|
|
122
|
+
type="search"
|
|
123
|
+
placeholder={strings.search}
|
|
124
|
+
aria-label={strings.search}
|
|
125
|
+
bind:value={query}
|
|
126
|
+
/>
|
|
127
|
+
{/if}
|
|
128
|
+
<div class="mz-table-scroll">
|
|
129
|
+
<table class="mz-table" class:sticky={stickyHeader}>
|
|
130
|
+
{#if caption}<caption>{caption}</caption>{/if}
|
|
131
|
+
<thead>
|
|
132
|
+
<tr>
|
|
133
|
+
{#each columns as column (column.key)}
|
|
134
|
+
<th
|
|
135
|
+
scope="col"
|
|
136
|
+
style:width={column.width}
|
|
137
|
+
style:text-align={align(column)}
|
|
138
|
+
aria-sort={sortKey === column.key ? direction : undefined}
|
|
139
|
+
>
|
|
140
|
+
{#if column.sortable !== false && chart.medium !== 'print'}
|
|
141
|
+
<button type="button" onclick={() => toggleSort(column)}>
|
|
142
|
+
{column.label}<span class="mz-sort" aria-hidden="true"
|
|
143
|
+
>{sortKey === column.key ? (direction === 'ascending' ? '▲' : '▼') : ''}</span
|
|
144
|
+
>
|
|
145
|
+
</button>
|
|
146
|
+
{:else}
|
|
147
|
+
{column.label}
|
|
148
|
+
{/if}
|
|
149
|
+
</th>
|
|
150
|
+
{/each}
|
|
151
|
+
</tr>
|
|
152
|
+
</thead>
|
|
153
|
+
<tbody>
|
|
154
|
+
{#each visible as d}
|
|
155
|
+
<tr>
|
|
156
|
+
{#each columns as column, ci (column.key)}
|
|
157
|
+
{@const v = column.value(d)}
|
|
158
|
+
{#if column.type === 'heat' && column.color}
|
|
159
|
+
{@const bg = column.color(v, d)}
|
|
160
|
+
<td style:text-align={align(column)} style:background={bg} style:color={contrast(bg)}
|
|
161
|
+
>{text(column, d)}</td
|
|
162
|
+
>
|
|
163
|
+
{:else if column.type === 'bar'}
|
|
164
|
+
<td class="mz-bar-cell">
|
|
165
|
+
<span
|
|
166
|
+
class="mz-cell-bar"
|
|
167
|
+
style:width="{(Math.abs(Number(v)) / maxima[column.key]) * 100}%"
|
|
168
|
+
style:background={column.color?.(v, d) ?? chart.theme.palettes.categorical[0]}
|
|
169
|
+
></span>
|
|
170
|
+
<span class="mz-cell-value">{text(column, d)}</span>
|
|
171
|
+
</td>
|
|
172
|
+
{:else if column.type === 'sparkline' && column.series}
|
|
173
|
+
<td><Sparkline values={column.series(d)} /></td>
|
|
174
|
+
{:else if ci === 0}
|
|
175
|
+
<th scope="row" style:text-align={align(column)}>{text(column, d)}</th>
|
|
176
|
+
{:else}
|
|
177
|
+
<td style:text-align={align(column)}>{text(column, d)}</td>
|
|
178
|
+
{/if}
|
|
179
|
+
{/each}
|
|
180
|
+
</tr>
|
|
181
|
+
{/each}
|
|
182
|
+
{#if visible.length === 0}
|
|
183
|
+
<tr><td colspan={columns.length} class="mz-empty">{strings.noData}</td></tr>
|
|
184
|
+
{/if}
|
|
185
|
+
</tbody>
|
|
186
|
+
</table>
|
|
187
|
+
</div>
|
|
188
|
+
{#if maxRows && sorted.length > maxRows && chart.medium !== 'print'}
|
|
189
|
+
<button class="mz-table-more" type="button" onclick={() => (expanded = !expanded)}>
|
|
190
|
+
{expanded ? strings.showFewer : strings.showAll(sorted.length)}
|
|
191
|
+
</button>
|
|
192
|
+
{/if}
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
<style>
|
|
196
|
+
.mz-table-wrap {
|
|
197
|
+
font-family: var(--mz-font-body, system-ui, sans-serif);
|
|
198
|
+
font-size: var(--mz-size-small, 0.8125rem);
|
|
199
|
+
color: var(--mz-color-text, #1a1a1a);
|
|
200
|
+
}
|
|
201
|
+
.mz-table-scroll {
|
|
202
|
+
overflow-x: auto;
|
|
203
|
+
}
|
|
204
|
+
.mz-table {
|
|
205
|
+
width: 100%;
|
|
206
|
+
border-collapse: collapse;
|
|
207
|
+
font-variant-numeric: tabular-nums;
|
|
208
|
+
}
|
|
209
|
+
caption {
|
|
210
|
+
text-align: left;
|
|
211
|
+
font-weight: var(--mz-weight-strong, 700);
|
|
212
|
+
padding-bottom: 0.375rem;
|
|
213
|
+
}
|
|
214
|
+
th,
|
|
215
|
+
td {
|
|
216
|
+
padding: 0.375rem 0.5rem;
|
|
217
|
+
border-bottom: 1px solid var(--mz-color-grid, #e4e4e4);
|
|
218
|
+
vertical-align: middle;
|
|
219
|
+
}
|
|
220
|
+
thead th {
|
|
221
|
+
font-family: var(--mz-font-label, inherit);
|
|
222
|
+
font-weight: var(--mz-weight-label, 700);
|
|
223
|
+
text-transform: var(--mz-label-transform, none);
|
|
224
|
+
letter-spacing: var(--mz-label-tracking, normal);
|
|
225
|
+
color: var(--mz-color-muted, #5c5c5c);
|
|
226
|
+
border-bottom: 1px solid var(--mz-color-text, #1a1a1a);
|
|
227
|
+
white-space: nowrap;
|
|
228
|
+
}
|
|
229
|
+
tbody th {
|
|
230
|
+
font-weight: var(--mz-weight-strong, 600);
|
|
231
|
+
}
|
|
232
|
+
.sticky thead th {
|
|
233
|
+
position: sticky;
|
|
234
|
+
top: 0;
|
|
235
|
+
background: var(--mz-color-bg, #fff);
|
|
236
|
+
}
|
|
237
|
+
thead button {
|
|
238
|
+
all: unset;
|
|
239
|
+
cursor: pointer;
|
|
240
|
+
}
|
|
241
|
+
thead button:focus-visible {
|
|
242
|
+
outline: 2px solid var(--mz-color-accent, #2a78d6);
|
|
243
|
+
}
|
|
244
|
+
.mz-sort {
|
|
245
|
+
display: inline-block;
|
|
246
|
+
width: 1em;
|
|
247
|
+
font-size: 0.7em;
|
|
248
|
+
text-align: center;
|
|
249
|
+
}
|
|
250
|
+
.mz-bar-cell {
|
|
251
|
+
position: relative;
|
|
252
|
+
min-width: 6rem;
|
|
253
|
+
}
|
|
254
|
+
.mz-cell-bar {
|
|
255
|
+
position: absolute;
|
|
256
|
+
left: 0.5rem;
|
|
257
|
+
top: 25%;
|
|
258
|
+
height: 50%;
|
|
259
|
+
max-width: calc(100% - 1rem);
|
|
260
|
+
border-radius: 0 min(var(--mz-radius, 2px), 2px) min(var(--mz-radius, 2px), 2px) 0;
|
|
261
|
+
opacity: 0.35;
|
|
262
|
+
}
|
|
263
|
+
.mz-cell-value {
|
|
264
|
+
position: relative;
|
|
265
|
+
}
|
|
266
|
+
.mz-empty {
|
|
267
|
+
text-align: center;
|
|
268
|
+
color: var(--mz-color-muted, #5c5c5c);
|
|
269
|
+
}
|
|
270
|
+
.mz-table-search,
|
|
271
|
+
.mz-table-more {
|
|
272
|
+
margin: 0.5rem 0;
|
|
273
|
+
padding: 0.35rem 0.6rem;
|
|
274
|
+
border: 1px solid var(--mz-color-border, #e4e4e4);
|
|
275
|
+
border-radius: var(--mz-radius, 4px);
|
|
276
|
+
background: var(--mz-color-bg, #fff);
|
|
277
|
+
color: inherit;
|
|
278
|
+
font: inherit;
|
|
279
|
+
}
|
|
280
|
+
.mz-table-more {
|
|
281
|
+
cursor: pointer;
|
|
282
|
+
font-family: var(--mz-font-label, inherit);
|
|
283
|
+
font-weight: var(--mz-weight-label, 600);
|
|
284
|
+
text-transform: var(--mz-control-transform, none);
|
|
285
|
+
letter-spacing: var(--mz-control-tracking, normal);
|
|
286
|
+
}
|
|
287
|
+
</style>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Column } from './types.js';
|
|
2
|
+
declare function $$render<T>(): {
|
|
3
|
+
props: {
|
|
4
|
+
data: T[];
|
|
5
|
+
columns: Column<T>[];
|
|
6
|
+
/** Initial sort column key. */
|
|
7
|
+
sortBy?: string;
|
|
8
|
+
sortDirection?: "ascending" | "descending";
|
|
9
|
+
/** Show a search box. */
|
|
10
|
+
search?: boolean;
|
|
11
|
+
/** Rows shown before "Show all". */
|
|
12
|
+
maxRows?: number;
|
|
13
|
+
/** Visible caption (also the accessible name). */
|
|
14
|
+
caption?: string;
|
|
15
|
+
stickyHeader?: boolean;
|
|
16
|
+
class?: string;
|
|
17
|
+
};
|
|
18
|
+
exports: {};
|
|
19
|
+
bindings: "";
|
|
20
|
+
slots: {};
|
|
21
|
+
events: {};
|
|
22
|
+
};
|
|
23
|
+
declare class __sveltets_Render<T> {
|
|
24
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
25
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
26
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
27
|
+
bindings(): "";
|
|
28
|
+
exports(): {};
|
|
29
|
+
}
|
|
30
|
+
interface $$IsomorphicComponent {
|
|
31
|
+
new <T>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
32
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
33
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
34
|
+
<T>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
35
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A data table with sortable columns, locale-aware formatting, optional search
|
|
39
|
+
* and a "show all" toggle, plus inline bar, heat and sparkline cells. Use it
|
|
40
|
+
* on its own or inside `<Chart>`.
|
|
41
|
+
*/
|
|
42
|
+
declare const Table: $$IsomorphicComponent;
|
|
43
|
+
type Table<T> = InstanceType<typeof Table<T>>;
|
|
44
|
+
export default Table;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function escape(value) {
|
|
2
|
+
if (value == null)
|
|
3
|
+
return '';
|
|
4
|
+
const text = value instanceof Date ? value.toISOString().slice(0, 10) : String(value);
|
|
5
|
+
return /[",\n\r]/.test(text) ? `"${text.replace(/"/g, '""')}"` : text;
|
|
6
|
+
}
|
|
7
|
+
/** CSV text from rows and columns (raw values, not formatted). */
|
|
8
|
+
export function toCSV(rows, columns) {
|
|
9
|
+
const header = columns.map((c) => escape(c.label)).join(',');
|
|
10
|
+
const body = rows.map((d) => columns.map((c) => escape(c.value(d))).join(','));
|
|
11
|
+
return [header, ...body].join('\n') + '\n';
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface Column<T> {
|
|
2
|
+
/** Unique id for the column. */
|
|
3
|
+
key: string;
|
|
4
|
+
label: string;
|
|
5
|
+
value: (d: T) => unknown;
|
|
6
|
+
/** Text shown in the cell; defaults to locale number formatting for numbers. */
|
|
7
|
+
format?: (value: any, d: T) => string;
|
|
8
|
+
/** Defaults to right for numbers, left otherwise. */
|
|
9
|
+
align?: 'left' | 'right' | 'center';
|
|
10
|
+
sortable?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Cell display: plain text, an inline bar (numbers), a heat cell coloured by
|
|
13
|
+
* `color`, or a sparkline from `series`.
|
|
14
|
+
*/
|
|
15
|
+
type?: 'text' | 'bar' | 'heat' | 'sparkline';
|
|
16
|
+
/** For `bar`: the value that fills the cell; defaults to the column maximum. */
|
|
17
|
+
max?: number;
|
|
18
|
+
/** For `heat` (and optionally `bar`): value → CSS colour. */
|
|
19
|
+
color?: (value: any, d: T) => string;
|
|
20
|
+
/** For `sparkline`: the values to plot. */
|
|
21
|
+
series?: (d: T) => number[];
|
|
22
|
+
/** CSS width, e.g. "30%". */
|
|
23
|
+
width?: string;
|
|
24
|
+
/** Include in the search filter (text columns by default). */
|
|
25
|
+
searchable?: boolean;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|