@samizdata/mozaic 0.11.0 → 0.12.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.
Files changed (42) hide show
  1. package/dist/flags/index.d.ts +16 -0
  2. package/dist/flags/index.js +16 -0
  3. package/dist/flags/svgs.d.ts +261 -0
  4. package/dist/flags/svgs.js +265 -0
  5. package/dist/guides/AxisX.svelte +18 -3
  6. package/dist/guides/AxisX.svelte.d.ts +4 -0
  7. package/dist/interactive/Tooltip.svelte +10 -3
  8. package/dist/locale/index.d.ts +8 -0
  9. package/dist/locale/index.js +10 -0
  10. package/dist/marks/Beeswarm.svelte +31 -12
  11. package/dist/marks/Beeswarm.svelte.d.ts +3 -0
  12. package/dist/marks/Flag.svelte +65 -0
  13. package/dist/marks/Flag.svelte.d.ts +27 -0
  14. package/dist/marks/Flags.svelte +69 -0
  15. package/dist/marks/Flags.svelte.d.ts +45 -0
  16. package/dist/marks/index.d.ts +2 -0
  17. package/dist/marks/index.js +2 -0
  18. package/dist/recipes/ArrowChart.svelte +4 -1
  19. package/dist/recipes/ArrowChart.svelte.d.ts +2 -0
  20. package/dist/recipes/BarChart.svelte +101 -17
  21. package/dist/recipes/BarChart.svelte.d.ts +20 -2
  22. package/dist/recipes/BarDotChart.svelte +4 -1
  23. package/dist/recipes/BarDotChart.svelte.d.ts +2 -0
  24. package/dist/recipes/ColumnChart.svelte +5 -2
  25. package/dist/recipes/ColumnChart.svelte.d.ts +2 -0
  26. package/dist/recipes/LineChart.svelte +8 -2
  27. package/dist/recipes/LineChart.svelte.d.ts +2 -0
  28. package/dist/recipes/ScatterChart.svelte +177 -17
  29. package/dist/recipes/ScatterChart.svelte.d.ts +40 -1
  30. package/dist/recipes/StripChart.svelte +301 -0
  31. package/dist/recipes/StripChart.svelte.d.ts +89 -0
  32. package/dist/recipes/index.d.ts +2 -1
  33. package/dist/recipes/index.js +3 -1
  34. package/package.json +174 -170
  35. package/src/lib/recipes/ArrowChart.svelte +4 -1
  36. package/src/lib/recipes/BarChart.svelte +101 -17
  37. package/src/lib/recipes/BarDotChart.svelte +4 -1
  38. package/src/lib/recipes/ColumnChart.svelte +5 -2
  39. package/src/lib/recipes/LineChart.svelte +8 -2
  40. package/src/lib/recipes/ScatterChart.svelte +177 -17
  41. package/src/lib/recipes/StripChart.svelte +301 -0
  42. package/src/lib/recipes/index.ts +3 -1
@@ -3,6 +3,8 @@
3
3
  Horizontal axis for the plot's x scale. Tick labels use the chart's locale
4
4
  unless you pass `format`. On a continuous scale, labels that would overlap are
5
5
  thinned to every other tick (or every third, and so on); the tick marks stay.
6
+ `unit` names the unit once, after the last labelled tick ("20 c/kWh"), kept
7
+ inside the chart.
6
8
  -->
7
9
  <script lang="ts">
8
10
  import { useChart, usePlot } from '../core/context.js';
@@ -23,6 +25,8 @@ thinned to every other tick (or every third, and so on); the tick marks stay.
23
25
  baseline?: boolean;
24
26
  /** Axis title, drawn at the end of the axis. */
25
27
  label?: string;
28
+ /** Unit written after the last labelled tick, e.g. "lei/m³" or "euro a year". */
29
+ unit?: string;
26
30
  class?: string;
27
31
  }
28
32
 
@@ -38,6 +42,7 @@ thinned to every other tick (or every third, and so on); the tick marks stay.
38
42
  tickPadding: tickPaddingInput,
39
43
  baseline: baselineInput,
40
44
  label,
45
+ unit,
41
46
  class: className = ''
42
47
  }: Props = $props();
43
48
 
@@ -49,16 +54,26 @@ thinned to every other tick (or every third, and so on); the tick marks stay.
49
54
  const fmt = $derived(format ?? defaultTickFormat(values, chart.locale));
50
55
  const dir = $derived(position === 'bottom' ? 1 : -1);
51
56
  const measure = useTextWidth();
52
- const items = $derived(values.map((value, i) => ({ value, px: scaled(plot.x, value), label: fmt(value, i) })));
57
+ const raw = $derived(values.map((value, i) => ({ value, px: scaled(plot.x, value), label: fmt(value, i) })));
58
+ // The unit makes the last label longer, so the thinning takes it into account.
59
+ const withUnit = (list: typeof raw) =>
60
+ unit && list.length
61
+ ? list.map((t, i) => (i === list.length - 1 ? { ...t, label: `${t.label} ${unit}` } : t))
62
+ : list;
53
63
  // Band and point scales name every category, so only continuous scales are thinned.
54
64
  const stride = $derived(
55
65
  plot.x.bandwidth
56
66
  ? 1
57
67
  : tickStride(
58
- items.map((t) => t.px),
59
- items.map((t) => measure(t.label, chart.theme.plot.fontSize, chart.theme.tokens['--mz-font-body']))
68
+ raw.map((t) => t.px),
69
+ withUnit(raw).map((t) => measure(t.label, chart.theme.plot.fontSize, chart.theme.tokens['--mz-font-body']))
60
70
  )
61
71
  );
72
+ /** Index of the last tick that gets a label: the one that carries the unit. */
73
+ const lastShown = $derived(raw.length ? raw.length - 1 - ((raw.length - 1) % stride) : -1);
74
+ const items = $derived(
75
+ raw.map((t, i) => (unit && i === lastShown && !plot.x.bandwidth ? { ...t, label: `${t.label} ${unit}` } : t))
76
+ );
62
77
 
63
78
  // Labels that would spill past the chart edge are anchored inwards instead of centred.
64
79
  function anchor(px: number, label: string): 'start' | 'middle' | 'end' {
@@ -11,12 +11,16 @@ interface Props {
11
11
  baseline?: boolean;
12
12
  /** Axis title, drawn at the end of the axis. */
13
13
  label?: string;
14
+ /** Unit written after the last labelled tick, e.g. "lei/m³" or "euro a year". */
15
+ unit?: string;
14
16
  class?: string;
15
17
  }
16
18
  /**
17
19
  * Horizontal axis for the plot's x scale. Tick labels use the chart's locale
18
20
  * unless you pass `format`. On a continuous scale, labels that would overlap are
19
21
  * thinned to every other tick (or every third, and so on); the tick marks stay.
22
+ * `unit` names the unit once, after the last labelled tick ("20 c/kWh"), kept
23
+ * inside the chart.
20
24
  */
21
25
  declare const AxisX: import("svelte").Component<Props, {}, "">;
22
26
  type AxisX = ReturnType<typeof AxisX>;
@@ -39,6 +39,7 @@ values aligned in a column. `children` follow the rows.
39
39
  let { title, items = [], x, y, visible = true, offset = 12, class: className = '', children }: Props = $props();
40
40
 
41
41
  const plot = usePlot();
42
+ const swatches = $derived(items.some((item) => item.color));
42
43
  const flip = $derived(x > plot.width * 0.6);
43
44
  const top = $derived(Math.max(0, Math.min(plot.height, y)));
44
45
  // Once measured, the tooltip is placed so it stays inside the chart (see tooltipLeft).
@@ -61,10 +62,13 @@ values aligned in a column. `children` follow the rows.
61
62
  >
62
63
  {#if title}<strong class="mz-tooltip-title">{title}</strong>{/if}
63
64
  {#if items.length}
64
- <div class="mz-tooltip-items">
65
+ <!-- The swatch column only when some row has a colour; otherwise it would indent every row. -->
66
+ <div class="mz-tooltip-items" class:plain={!swatches}>
65
67
  {#each items as item, i (i)}
66
- <span class="mz-tooltip-swatch {item.shape ?? 'square'}" style:background={item.color ?? 'transparent'}
67
- ></span>
68
+ {#if swatches}
69
+ <span class="mz-tooltip-swatch {item.shape ?? 'square'}" style:background={item.color ?? 'transparent'}
70
+ ></span>
71
+ {/if}
68
72
  <span class="mz-tooltip-label">{item.label}</span>
69
73
  <strong class="mz-tooltip-value">{item.value}</strong>
70
74
  {/each}
@@ -104,6 +108,9 @@ values aligned in a column. `children` follow the rows.
104
108
  column-gap: 0.4rem;
105
109
  row-gap: 0.15rem;
106
110
  }
111
+ .mz-tooltip-items.plain {
112
+ grid-template-columns: 1fr auto;
113
+ }
107
114
  .mz-tooltip-swatch {
108
115
  width: 0.7rem;
109
116
  height: 0.7rem;
@@ -13,6 +13,14 @@ export interface Locale {
13
13
  timeFormat(specifier: string): (d: Date) => string;
14
14
  /** 1234.5 → "1,234.5" (en) / "1.234,5" (ro) / "1 234,5" (ru). Trailing zeros removed. */
15
15
  number: (n: number) => string;
16
+ /**
17
+ * Exactly `digits` decimals, except that a value which rounds to a whole number at that
18
+ * precision has none: `decimals(1)` gives 8.46 → "8.5" and 11.03 → "11" (not "11.0").
19
+ * Use it for one rounding level across a chart without "26.0" or "26.00".
20
+ */
21
+ decimals(digits: number): (n: number) => string;
22
+ /** Money: two decimals, or none when the value is a whole number (26.14 → "26.14", 26 → "26", 12.3 → "12.30"). */
23
+ money: (n: number) => string;
16
24
  /** 0.123 → "12%". */
17
25
  percent: (n: number) => string;
18
26
  /** 0.123 → "+12%"; −0.05 → "−5%". */
@@ -12,6 +12,14 @@ export function createLocale(code) {
12
12
  throw new Error(`Unknown mozaic locale "${code}". Known locales: ${Object.keys(definitions).join(', ')}`);
13
13
  const numbers = formatLocale(def.number);
14
14
  const times = timeFormatLocale(def.time);
15
+ const decimals = (digits) => {
16
+ const withDecimals = numbers.format(`,.${digits}f`);
17
+ const whole = numbers.format(',.0f');
18
+ return (n) => {
19
+ const rounded = Number(n.toFixed(digits));
20
+ return Number.isInteger(rounded) ? whole(rounded) : withDecimals(n);
21
+ };
22
+ };
15
23
  const locale = {
16
24
  code,
17
25
  lang: def.lang,
@@ -19,6 +27,8 @@ export function createLocale(code) {
19
27
  format: (specifier) => numbers.format(specifier),
20
28
  timeFormat: (specifier) => times.format(specifier),
21
29
  number: numbers.format(',~f'),
30
+ decimals,
31
+ money: decimals(2),
22
32
  percent: numbers.format('.0%'),
23
33
  signedPercent: numbers.format('+.0%')
24
34
  };
@@ -2,12 +2,14 @@
2
2
  @component
3
3
  A beeswarm: one dot per datum along the x scale, nudged vertically so dots
4
4
  do not overlap. With a band y scale, each category gets its own swarm.
5
+ Pass `flag` to draw countries as circular flags instead of dots.
5
6
  -->
6
7
  <script lang="ts" generics="T">
7
8
  import { useChart, usePlot } from '../core/context.js';
8
9
  import { scaled } from '../core/scales.js';
9
10
  import { access, type Accessor } from '../core/accessor.js';
10
11
  import { dodge } from '../transforms/dodge.js';
12
+ import Flag from './Flag.svelte';
11
13
 
12
14
  interface Props {
13
15
  data: T[];
@@ -18,6 +20,8 @@ do not overlap. With a band y scale, each category gets its own swarm.
18
20
  padding?: number;
19
21
  fill?: Accessor<T, string>;
20
22
  opacity?: Accessor<T, number>;
23
+ /** The datum's flag from `@samizdata/mozaic/flags`, drawn as a circle of radius `r` instead of a dot. */
24
+ flag?: (d: T) => string | null | undefined;
21
25
  title?: (d: T) => string;
22
26
  onpointerenter?: (d: T, event: PointerEvent) => void;
23
27
  onpointerleave?: (d: T, event: PointerEvent) => void;
@@ -31,6 +35,7 @@ do not overlap. With a band y scale, each category gets its own swarm.
31
35
  r = 4,
32
36
  padding = 1,
33
37
  fill,
38
+ flag,
34
39
  opacity = 1,
35
40
  title,
36
41
  onpointerenter,
@@ -62,22 +67,36 @@ do not overlap. With a band y scale, each category gets its own swarm.
62
67
 
63
68
  <g class="mz-beeswarm {className}">
64
69
  {#each dots as dot, i}
65
- <!-- svelte-ignore a11y_no_static_element_interactions -->
66
- <circle
67
- cx={dot.cx}
68
- cy={dot.cy}
69
- {r}
70
- fill={fill ? access(fill, dot.d, i) : chart.theme.palettes.categorical[0]}
71
- fill-opacity={access(opacity, dot.d, i)}
72
- onpointerenter={onpointerenter ? (e) => onpointerenter(dot.d, e) : undefined}
73
- onpointerleave={onpointerleave ? (e) => onpointerleave(dot.d, e) : undefined}
74
- >{#if title}<title>{title(dot.d)}</title>{/if}</circle
75
- >
70
+ {@const svg = flag?.(dot.d)}
71
+ {#if svg}
72
+ <Flag
73
+ {svg}
74
+ cx={dot.cx}
75
+ cy={dot.cy}
76
+ {r}
77
+ opacity={access(opacity, dot.d, i)}
78
+ title={title?.(dot.d)}
79
+ onpointerenter={onpointerenter ? (e) => onpointerenter(dot.d, e) : undefined}
80
+ onpointerleave={onpointerleave ? (e) => onpointerleave(dot.d, e) : undefined}
81
+ />
82
+ {:else}
83
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
84
+ <circle
85
+ cx={dot.cx}
86
+ cy={dot.cy}
87
+ {r}
88
+ fill={fill ? access(fill, dot.d, i) : chart.theme.palettes.categorical[0]}
89
+ fill-opacity={access(opacity, dot.d, i)}
90
+ onpointerenter={onpointerenter ? (e) => onpointerenter(dot.d, e) : undefined}
91
+ onpointerleave={onpointerleave ? (e) => onpointerleave(dot.d, e) : undefined}
92
+ >{#if title}<title>{title(dot.d)}</title>{/if}</circle
93
+ >
94
+ {/if}
76
95
  {/each}
77
96
  </g>
78
97
 
79
98
  <style>
80
- circle {
99
+ .mz-beeswarm > circle {
81
100
  stroke: var(--mz-color-bg);
82
101
  stroke-width: 1;
83
102
  }
@@ -9,6 +9,8 @@ declare function $$render<T>(): {
9
9
  padding?: number;
10
10
  fill?: Accessor<T, string>;
11
11
  opacity?: Accessor<T, number>;
12
+ /** The datum's flag from `@samizdata/mozaic/flags`, drawn as a circle of radius `r` instead of a dot. */
13
+ flag?: (d: T) => string | null | undefined;
12
14
  title?: (d: T) => string;
13
15
  onpointerenter?: (d: T, event: PointerEvent) => void;
14
16
  onpointerleave?: (d: T, event: PointerEvent) => void;
@@ -36,6 +38,7 @@ interface $$IsomorphicComponent {
36
38
  /**
37
39
  * A beeswarm: one dot per datum along the x scale, nudged vertically so dots
38
40
  * do not overlap. With a band y scale, each category gets its own swarm.
41
+ * Pass `flag` to draw countries as circular flags instead of dots.
39
42
  */
40
43
  declare const Beeswarm: $$IsomorphicComponent;
41
44
  type Beeswarm<T> = InstanceType<typeof Beeswarm<T>>;
@@ -0,0 +1,65 @@
1
+ <!--
2
+ @component
3
+ One flag drawn as a circle at a pixel position, as in ggflags. Pass a flag
4
+ from `@samizdata/mozaic/flags`. A hairline ring keeps white and pale flags
5
+ visible on the background. Used by `Flags`, `Beeswarm`, `BarChart` and
6
+ `StripChart`; use it directly to put a flag beside a label or annotation.
7
+ -->
8
+ <script lang="ts">
9
+ interface Props {
10
+ /** A flag from `@samizdata/mozaic/flags` (inner SVG markup on a 512 × 512 viewBox). */
11
+ svg: string;
12
+ /** Centre in px. */
13
+ cx: number;
14
+ cy: number;
15
+ /** Radius in px. */
16
+ r?: number;
17
+ /** Ring colour; defaults to the border token. Use `none` for no ring. */
18
+ stroke?: string;
19
+ strokeWidth?: number;
20
+ /** Accessible name (adds a <title>), usually the country's name. */
21
+ title?: string;
22
+ opacity?: number;
23
+ onpointerenter?: (event: PointerEvent) => void;
24
+ onpointerleave?: (event: PointerEvent) => void;
25
+ class?: string;
26
+ }
27
+
28
+ let {
29
+ svg,
30
+ cx,
31
+ cy,
32
+ r = 8,
33
+ stroke = 'var(--mz-color-border)',
34
+ strokeWidth = 1,
35
+ title,
36
+ opacity = 1,
37
+ onpointerenter,
38
+ onpointerleave,
39
+ class: className = ''
40
+ }: Props = $props();
41
+
42
+ const uid = $props.id();
43
+ </script>
44
+
45
+ <g
46
+ class="mz-flag {className}"
47
+ transform="translate({cx - r} {cy - r})"
48
+ {opacity}
49
+ role={title ? 'img' : undefined}
50
+ aria-label={title}
51
+ {onpointerenter}
52
+ {onpointerleave}
53
+ >
54
+ {#if title}<title>{title}</title>{/if}
55
+ <clipPath id="{uid}-clip"><circle cx={r} cy={r} {r} /></clipPath>
56
+ <g clip-path="url(#{uid}-clip)">
57
+ <svg width={r * 2} height={r * 2} viewBox="0 0 512 512" preserveAspectRatio="xMidYMid slice" aria-hidden="true">
58
+ <!-- eslint-disable-next-line svelte/no-at-html-tags -- trusted markup generated from flag-icons -->
59
+ {@html svg}
60
+ </svg>
61
+ </g>
62
+ {#if stroke !== 'none'}
63
+ <circle cx={r} cy={r} r={r - strokeWidth / 2} fill="none" {stroke} stroke-width={strokeWidth} />
64
+ {/if}
65
+ </g>
@@ -0,0 +1,27 @@
1
+ interface Props {
2
+ /** A flag from `@samizdata/mozaic/flags` (inner SVG markup on a 512 × 512 viewBox). */
3
+ svg: string;
4
+ /** Centre in px. */
5
+ cx: number;
6
+ cy: number;
7
+ /** Radius in px. */
8
+ r?: number;
9
+ /** Ring colour; defaults to the border token. Use `none` for no ring. */
10
+ stroke?: string;
11
+ strokeWidth?: number;
12
+ /** Accessible name (adds a <title>), usually the country's name. */
13
+ title?: string;
14
+ opacity?: number;
15
+ onpointerenter?: (event: PointerEvent) => void;
16
+ onpointerleave?: (event: PointerEvent) => void;
17
+ class?: string;
18
+ }
19
+ /**
20
+ * One flag drawn as a circle at a pixel position, as in ggflags. Pass a flag
21
+ * from `@samizdata/mozaic/flags`. A hairline ring keeps white and pale flags
22
+ * visible on the background. Used by `Flags`, `Beeswarm`, `BarChart` and
23
+ * `StripChart`; use it directly to put a flag beside a label or annotation.
24
+ */
25
+ declare const Flag: import("svelte").Component<Props, {}, "">;
26
+ type Flag = ReturnType<typeof Flag>;
27
+ export default Flag;
@@ -0,0 +1,69 @@
1
+ <!--
2
+ @component
3
+ Flags as points, as in ggflags: one circular flag per datum at its x/y
4
+ position (scatter plots, dot plots, maps with a projection). Pass the flag for
5
+ each datum from `@samizdata/mozaic/flags`; rows without one are skipped. For a
6
+ one-axis strip of flags that do not overlap, use `Beeswarm` with `flag`.
7
+ -->
8
+ <script lang="ts" generics="T">
9
+ import { usePlot } from '../core/context.js';
10
+ import { position } from '../core/scales.js';
11
+ import type { Accessor, Value } from '../core/accessor.js';
12
+ import { access } from '../core/accessor.js';
13
+ import Flag from './Flag.svelte';
14
+
15
+ interface Props {
16
+ data: T[];
17
+ x: Accessor<T, Value>;
18
+ y: Accessor<T, Value>;
19
+ /** The datum's flag from `@samizdata/mozaic/flags`, or nothing to skip it. */
20
+ flag: (d: T) => string | null | undefined;
21
+ /** Radius in px. */
22
+ r?: Accessor<T, number>;
23
+ opacity?: Accessor<T, number>;
24
+ /** Accessible name per flag, usually the country's name. */
25
+ title?: (d: T) => string;
26
+ onpointerenter?: (d: T, event: PointerEvent) => void;
27
+ onpointerleave?: (d: T, event: PointerEvent) => void;
28
+ class?: string;
29
+ }
30
+
31
+ let {
32
+ data,
33
+ x,
34
+ y,
35
+ flag,
36
+ r = 8,
37
+ opacity = 1,
38
+ title,
39
+ onpointerenter,
40
+ onpointerleave,
41
+ class: className = ''
42
+ }: Props = $props();
43
+
44
+ const plot = usePlot();
45
+
46
+ const items = $derived(
47
+ data.flatMap((d, i) => {
48
+ const svg = flag(d);
49
+ if (!svg) return [];
50
+ const [cx, cy] = position(plot, access(x, d, i), access(y, d, i));
51
+ return Number.isFinite(cx) && Number.isFinite(cy) ? [{ d, i, svg, cx, cy }] : [];
52
+ })
53
+ );
54
+ </script>
55
+
56
+ <g class="mz-flags {className}">
57
+ {#each items as item (item.i)}
58
+ <Flag
59
+ svg={item.svg}
60
+ cx={item.cx}
61
+ cy={item.cy}
62
+ r={access(r, item.d, item.i)}
63
+ opacity={access(opacity, item.d, item.i)}
64
+ title={title?.(item.d)}
65
+ onpointerenter={onpointerenter ? (e) => onpointerenter(item.d, e) : undefined}
66
+ onpointerleave={onpointerleave ? (e) => onpointerleave(item.d, e) : undefined}
67
+ />
68
+ {/each}
69
+ </g>
@@ -0,0 +1,45 @@
1
+ import type { Accessor, Value } from '../core/accessor.js';
2
+ declare function $$render<T>(): {
3
+ props: {
4
+ data: T[];
5
+ x: Accessor<T, Value>;
6
+ y: Accessor<T, Value>;
7
+ /** The datum's flag from `@samizdata/mozaic/flags`, or nothing to skip it. */
8
+ flag: (d: T) => string | null | undefined;
9
+ /** Radius in px. */
10
+ r?: Accessor<T, number>;
11
+ opacity?: Accessor<T, number>;
12
+ /** Accessible name per flag, usually the country's name. */
13
+ title?: (d: T) => string;
14
+ onpointerenter?: (d: T, event: PointerEvent) => void;
15
+ onpointerleave?: (d: T, event: PointerEvent) => void;
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
+ * Flags as points, as in ggflags: one circular flag per datum at its x/y
39
+ * position (scatter plots, dot plots, maps with a projection). Pass the flag for
40
+ * each datum from `@samizdata/mozaic/flags`; rows without one are skipped. For a
41
+ * one-axis strip of flags that do not overlap, use `Beeswarm` with `flag`.
42
+ */
43
+ declare const Flags: $$IsomorphicComponent;
44
+ type Flags<T> = InstanceType<typeof Flags<T>>;
45
+ export default Flags;
@@ -15,6 +15,8 @@ export { default as Dumbbell } from './Dumbbell.svelte';
15
15
  export { default as Arrows } from './Arrows.svelte';
16
16
  export { default as Slope } from './Slope.svelte';
17
17
  export { default as Beeswarm } from './Beeswarm.svelte';
18
+ export { default as Flag } from './Flag.svelte';
19
+ export { default as Flags } from './Flags.svelte';
18
20
  export { default as Hemicycle } from './Hemicycle.svelte';
19
21
  export { default as Intervals } from './Intervals.svelte';
20
22
  export { barPath } from './bar-path.js';
@@ -15,6 +15,8 @@ export { default as Dumbbell } from './Dumbbell.svelte';
15
15
  export { default as Arrows } from './Arrows.svelte';
16
16
  export { default as Slope } from './Slope.svelte';
17
17
  export { default as Beeswarm } from './Beeswarm.svelte';
18
+ export { default as Flag } from './Flag.svelte';
19
+ export { default as Flags } from './Flags.svelte';
18
20
  export { default as Hemicycle } from './Hemicycle.svelte';
19
21
  export { default as Intervals } from './Intervals.svelte';
20
22
  export { barPath } from './bar-path.js';
@@ -44,6 +44,8 @@ project and change anything.
44
44
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
45
45
  embed?: ChartEmbed;
46
46
  /** Value label format; defaults to locale numbers. */
47
+ /** Unit after the last value-axis tick label and the tooltip values, e.g. "lei/m³". */
48
+ unit?: string;
47
49
  format?: (n: number) => string;
48
50
  /** Axis tick format; defaults to `format`. */
49
51
  tickFormat?: (n: number) => string;
@@ -77,6 +79,7 @@ project and change anything.
77
79
  source,
78
80
  alt,
79
81
  embed,
82
+ unit,
80
83
  format,
81
84
  tickFormat,
82
85
  color,
@@ -165,7 +168,7 @@ project and change anything.
165
168
  {#snippet children(plot)}
166
169
  <Svg>
167
170
  <GridX ticks={4} />
168
- <AxisX ticks={4} format={tickFormat ?? fmt} />
171
+ <AxisX ticks={4} format={tickFormat ?? fmt} {unit} />
169
172
  <AxisY />
170
173
  <Arrows
171
174
  data={both}
@@ -28,6 +28,8 @@ declare function $$render<T>(): {
28
28
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
29
29
  embed?: ChartEmbed;
30
30
  /** Value label format; defaults to locale numbers. */
31
+ /** Unit after the last value-axis tick label and the tooltip values, e.g. "lei/m³". */
32
+ unit?: string;
31
33
  format?: (n: number) => string;
32
34
  /** Axis tick format; defaults to `format`. */
33
35
  tickFormat?: (n: number) => string;