@fundar/data-chart-telling 0.0.25 → 0.0.26

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 (170) hide show
  1. package/dist/charts/bar/Chart.svelte +2 -0
  2. package/dist/charts/heatmap/Chart.svelte +3 -1
  3. package/dist/charts/heatmap/Chart.svelte.d.ts +1 -2
  4. package/dist/charts/line/Chart.svelte +2 -0
  5. package/dist/charts/pyramid/Chart.svelte +3 -1
  6. package/dist/charts/pyramid/Chart.svelte.d.ts +1 -2
  7. package/dist/charts/scatter/Chart.svelte +95 -0
  8. package/dist/charts/scatter/Chart.svelte.d.ts +28 -0
  9. package/dist/configuration/config.svelte.js +2 -0
  10. package/dist/configuration/themes/index.d.ts +48 -0
  11. package/dist/index.d.ts +20 -14
  12. package/dist/index.js +9 -3
  13. package/dist/layout/coordinates/CoordinatesLayout.svelte +95 -0
  14. package/dist/layout/{plot/RuleLayout.svelte.d.ts → coordinates/CoordinatesLayout.svelte.d.ts} +13 -16
  15. package/dist/layout/coordinates/margins.d.ts +16 -0
  16. package/dist/layout/coordinates/margins.js +11 -0
  17. package/dist/{plots/geo → layout/coordinates}/projections/argentina.d.ts +1 -1
  18. package/dist/layout/{geo → coordinates}/resolveProjection.d.ts +1 -1
  19. package/dist/layout/coordinates/resolveProjection.js +24 -0
  20. package/dist/{plots/geo → layout/coordinates}/zoom.svelte.d.ts +1 -1
  21. package/dist/layout/geometry/GeometryLayout.svelte +231 -0
  22. package/dist/layout/geometry/GeometryLayout.svelte.d.ts +62 -0
  23. package/dist/layout/plot/BasePlotLayout.svelte +142 -155
  24. package/dist/layout/plot/BasePlotLayout.svelte.d.ts +61 -51
  25. package/dist/layout/plot/margins.d.ts +0 -16
  26. package/dist/layout/plot/margins.js +0 -11
  27. package/dist/layout/{plot/AxisLayout.svelte → scales/ScalesLayout.svelte} +23 -16
  28. package/dist/layout/{plot/AxisLayout.svelte.d.ts → scales/ScalesLayout.svelte.d.ts} +4 -5
  29. package/dist/layout/scales/buildScale.d.ts +8 -0
  30. package/dist/layout/scales/buildScale.js +43 -0
  31. package/dist/layout/styles/StylesLayout.svelte +75 -0
  32. package/dist/layout/styles/StylesLayout.svelte.d.ts +15 -0
  33. package/dist/{plots/geo → layout/styles}/TileLayer.svelte +2 -2
  34. package/dist/{plots/geo → layout/styles}/TileLayer.svelte.d.ts +1 -1
  35. package/dist/layout/tooltip/Tooltip.svelte +16 -20
  36. package/dist/layout/tooltip/Tooltip.svelte.d.ts +5 -0
  37. package/dist/layout/tooltip/TooltipLayout.svelte +7 -1
  38. package/dist/layout/tooltip/TooltipLayout.svelte.d.ts +4 -0
  39. package/dist/layout/tooltip/controller.svelte.d.ts +4 -5
  40. package/dist/layout/tooltip/controller.svelte.js +28 -16
  41. package/dist/layout/tooltip/resolveTooltipPlacement.d.ts +24 -0
  42. package/dist/layout/tooltip/resolveTooltipPlacement.js +49 -0
  43. package/dist/layout/tooltip/utils.d.ts +27 -19
  44. package/dist/layout/tooltip/utils.js +16 -15
  45. package/dist/markers/BarMarker.svelte +92 -0
  46. package/dist/markers/BarMarker.svelte.d.ts +7 -0
  47. package/dist/markers/CellMarker.svelte +21 -0
  48. package/dist/markers/CellMarker.svelte.d.ts +7 -0
  49. package/dist/markers/ContourMarker.svelte +28 -0
  50. package/dist/markers/ContourMarker.svelte.d.ts +7 -0
  51. package/dist/markers/DeltaMarker.svelte +32 -39
  52. package/dist/markers/DeltaMarker.svelte.d.ts +4 -5
  53. package/dist/markers/DotMarker.svelte +35 -6
  54. package/dist/markers/DotMarker.svelte.d.ts +11 -2
  55. package/dist/markers/GeoFeaturesMarker.svelte +19 -0
  56. package/dist/markers/GeoFeaturesMarker.svelte.d.ts +7 -0
  57. package/dist/markers/GeoHoverMarker.svelte +25 -0
  58. package/dist/markers/GeoHoverMarker.svelte.d.ts +9 -0
  59. package/dist/markers/GraticuleMarker.svelte +18 -0
  60. package/dist/markers/GraticuleMarker.svelte.d.ts +7 -0
  61. package/dist/markers/HoverMarker.svelte +32 -33
  62. package/dist/markers/HoverMarker.svelte.d.ts +15 -9
  63. package/dist/markers/LineMarker.svelte +19 -0
  64. package/dist/markers/LineMarker.svelte.d.ts +7 -0
  65. package/dist/markers/LinkMarker.svelte +42 -0
  66. package/dist/markers/LinkMarker.svelte.d.ts +7 -0
  67. package/dist/markers/RuleMarker.svelte +24 -0
  68. package/dist/markers/RuleMarker.svelte.d.ts +10 -0
  69. package/dist/markers/SphereMarker.svelte +15 -0
  70. package/dist/markers/SphereMarker.svelte.d.ts +7 -0
  71. package/dist/markers/TextMarker.svelte +1 -1
  72. package/dist/markers/TextMarker.svelte.d.ts +1 -1
  73. package/dist/markers/VectorMarker.svelte +20 -0
  74. package/dist/markers/VectorMarker.svelte.d.ts +7 -0
  75. package/dist/markers/inset/InsetMarker.svelte +38 -45
  76. package/dist/markers/inset/InsetMarker.svelte.d.ts +6 -2
  77. package/dist/plots/bar/Plot.svelte +54 -84
  78. package/dist/plots/bar/Plot.svelte.d.ts +4 -5
  79. package/dist/plots/bar/ValueLabels.svelte +1 -1
  80. package/dist/plots/bar/ValueLabels.svelte.d.ts +1 -1
  81. package/dist/plots/bar/buildBarMarkers.d.ts +30 -0
  82. package/dist/plots/bar/buildBarMarkers.js +100 -0
  83. package/dist/plots/bar/layout.svelte.d.ts +1 -2
  84. package/dist/plots/bar/layout.svelte.js +1 -1
  85. package/dist/plots/geo/Plot.svelte +113 -387
  86. package/dist/plots/geo/Plot.svelte.d.ts +5 -4
  87. package/dist/plots/geo/buildGeoMarkers.d.ts +33 -0
  88. package/dist/plots/geo/buildGeoMarkers.js +47 -0
  89. package/dist/plots/heatmap/Plot.svelte +24 -49
  90. package/dist/plots/heatmap/Plot.svelte.d.ts +4 -5
  91. package/dist/plots/heatmap/ValueLabels.svelte +2 -2
  92. package/dist/plots/heatmap/ValueLabels.svelte.d.ts +2 -2
  93. package/dist/plots/heatmap/buildCellMarkers.d.ts +21 -0
  94. package/dist/plots/heatmap/buildCellMarkers.js +25 -0
  95. package/dist/plots/line/Plot.svelte +68 -141
  96. package/dist/plots/line/Plot.svelte.d.ts +4 -4
  97. package/dist/plots/line/ValueLabels.svelte +29 -52
  98. package/dist/plots/line/ValueLabels.svelte.d.ts +6 -1
  99. package/dist/plots/line/buildLineMarkers.d.ts +15 -0
  100. package/dist/plots/line/buildLineMarkers.js +57 -0
  101. package/dist/plots/pyramid/Plot.svelte +41 -117
  102. package/dist/plots/pyramid/Plot.svelte.d.ts +4 -5
  103. package/dist/plots/pyramid/ValueLabels.svelte +1 -1
  104. package/dist/plots/pyramid/ValueLabels.svelte.d.ts +1 -1
  105. package/dist/plots/pyramid/buildPyramidBarMarkers.d.ts +19 -0
  106. package/dist/plots/pyramid/buildPyramidBarMarkers.js +32 -0
  107. package/dist/plots/scatter/Plot.svelte +206 -0
  108. package/dist/plots/{bar/BarSegments.svelte.d.ts → scatter/Plot.svelte.d.ts} +9 -20
  109. package/dist/plots/scatter/ValueLabels.svelte +106 -0
  110. package/dist/{layout/plot/GridLayout.svelte.d.ts → plots/scatter/ValueLabels.svelte.d.ts} +11 -5
  111. package/dist/plots/scatter/buildScatterMarkers.d.ts +11 -0
  112. package/dist/plots/scatter/buildScatterMarkers.js +37 -0
  113. package/dist/plots/scatter/resolveRadiusPaddedDomain.d.ts +10 -0
  114. package/dist/plots/scatter/resolveRadiusPaddedDomain.js +23 -0
  115. package/dist/plots/utils/declutter.d.ts +55 -37
  116. package/dist/plots/utils/declutter.js +79 -64
  117. package/dist/plots/utils/geoAccessors.d.ts +1 -1
  118. package/dist/plots/utils/geoAccessors.js +1 -1
  119. package/dist/plots/utils/segments.d.ts +17 -10
  120. package/dist/plots/utils/segments.js +26 -16
  121. package/dist/types/charts/common.d.ts +1 -1
  122. package/dist/types/charts/props.d.ts +5 -6
  123. package/dist/types/configuration/styling.d.ts +7 -2
  124. package/dist/types/{plots/scales/geo.d.ts → layout/coordinates.d.ts} +33 -1
  125. package/dist/types/layout/geometry.d.ts +17 -0
  126. package/dist/types/{plots/axis.d.ts → layout/scales.d.ts} +11 -0
  127. package/dist/types/layout/styles.d.ts +126 -0
  128. package/dist/types/layout/tooltip.d.ts +20 -1
  129. package/dist/types/markers/all.d.ts +11 -0
  130. package/dist/types/markers/base.d.ts +45 -0
  131. package/dist/types/markers/base.js +1 -0
  132. package/dist/types/markers/common.d.ts +64 -16
  133. package/dist/types/markers/geo.d.ts +75 -100
  134. package/dist/types/markers/line.d.ts +34 -0
  135. package/dist/types/markers/line.js +1 -0
  136. package/dist/types/markers/props.d.ts +1 -1
  137. package/dist/types/plots/data/common.d.ts +1 -1
  138. package/dist/types/plots/data/scatter.d.ts +13 -0
  139. package/dist/types/plots/data/scatter.js +1 -0
  140. package/dist/types/plots/props.d.ts +46 -74
  141. package/dist/types/plots/segments/common.d.ts +6 -12
  142. package/dist/types/plots/segments/config.d.ts +1 -1
  143. package/dist/types/plots/styling.d.ts +10 -0
  144. package/dist/{plots/utils → utils}/delta.d.ts +2 -2
  145. package/dist/{plots/utils → utils}/delta.js +1 -1
  146. package/dist/utils/edgeAwareAnchor.d.ts +37 -0
  147. package/dist/utils/edgeAwareAnchor.js +65 -0
  148. package/dist/utils/grouping.d.ts +1 -1
  149. package/dist/utils/interpolate.d.ts +1 -1
  150. package/package.json +3 -1
  151. package/dist/layout/geo/GeoLayout.svelte +0 -51
  152. package/dist/layout/geo/GeoLayout.svelte.d.ts +0 -24
  153. package/dist/layout/geo/resolveProjection.js +0 -48
  154. package/dist/layout/plot/GridLayout.svelte +0 -30
  155. package/dist/layout/plot/RuleLayout.svelte +0 -111
  156. package/dist/plots/bar/BarSegments.svelte +0 -69
  157. package/dist/types/plots/delta.d.ts +0 -19
  158. package/dist/types/plots/styles/common.d.ts +0 -52
  159. package/dist/types/plots/styles/geo.d.ts +0 -42
  160. /package/dist/{plots/geo → layout/coordinates}/projections/argentina.js +0 -0
  161. /package/dist/{plots/geo → layout/coordinates}/projections/fit.d.ts +0 -0
  162. /package/dist/{plots/geo → layout/coordinates}/projections/fit.js +0 -0
  163. /package/dist/{plots/geo → layout/coordinates}/rotate.svelte.d.ts +0 -0
  164. /package/dist/{plots/geo → layout/coordinates}/rotate.svelte.js +0 -0
  165. /package/dist/{plots/geo → layout/coordinates}/zoom.svelte.js +0 -0
  166. /package/dist/types/{plots/axis.js → layout/coordinates.js} +0 -0
  167. /package/dist/types/{plots/delta.js → layout/geometry.js} +0 -0
  168. /package/dist/types/{plots/scales/geo.js → layout/scales.js} +0 -0
  169. /package/dist/types/{plots/styles/common.js → layout/styles.js} +0 -0
  170. /package/dist/types/{plots/styles/geo.js → markers/all.js} +0 -0
@@ -1,69 +0,0 @@
1
- <script lang="ts" generics="TData extends Record<string, unknown>">
2
- import { BarX, BarY } from 'svelteplot';
3
- import { resolveAccessor } from '../utils/accessors';
4
- import type { Series } from '../../types/plots/data/common';
5
- import type { BarSegmentStyle } from '../../types/plots/segments/common';
6
- import type { VisualGroup } from '../../types/plots/segments/config';
7
- import type { BarLayout } from './layout.svelte';
8
-
9
- /**
10
- * Renders one series' bars — the `'stacked'` branch (cumulative baseline
11
- * from {@link BarLayout.stackedBaseline}) or the `'grouped'`/`'overlap'`
12
- * branch (per-segment insets from {@link BarLayout.seriesStep}/`seriesGap`).
13
- */
14
- let {
15
- group,
16
- seriesIndex,
17
- barLayout,
18
- isHorizontal,
19
- BarMark,
20
- defaultColor,
21
- disabledFill,
22
- }: {
23
- group: VisualGroup<Series<TData>, BarSegmentStyle>;
24
- seriesIndex: number;
25
- barLayout: BarLayout<TData>;
26
- isHorizontal: boolean;
27
- BarMark: typeof BarX | typeof BarY;
28
- defaultColor: string;
29
- disabledFill?: { fill?: string; fillOpacity?: number };
30
- } = $props();
31
-
32
- const xFn = $derived(resolveAccessor(group.series.x));
33
- const yFn = $derived(resolveAccessor(group.series.y));
34
- </script>
35
-
36
- {#if barLayout.layout === 'stacked'}
37
- {@const stackedBaselineFn = (d: TData) => barLayout.stackedBaseline(xFn(d), seriesIndex)}
38
- {@const stackedTopFn = (d: TData) => barLayout.stackedBaseline(xFn(d), seriesIndex) + Number(yFn(d))}
39
- <BarMark
40
- data={group.series.data}
41
- {...isHorizontal
42
- ? { y: xFn, x1: stackedBaselineFn, x2: stackedTopFn }
43
- : { x: xFn, y1: stackedBaselineFn, y2: stackedTopFn }}
44
- fill={disabledFill?.fill ?? defaultColor}
45
- fillOpacity={disabledFill?.fillOpacity ?? 1}
46
- />
47
- {:else}
48
- {#each group.visualSegments as seg, i (`${group.series.name}-${i}`)}
49
- <BarMark
50
- data={seg.data}
51
- {...isHorizontal
52
- ? { y: xFn, x1: barLayout.valueBaseline, x2: yFn }
53
- : { x: xFn, y1: barLayout.valueBaseline, y2: yFn }}
54
- fill={disabledFill?.fill ?? seg.style.fill ?? defaultColor}
55
- fillOpacity={disabledFill?.fillOpacity ?? seg.style.fillOpacity ?? 1}
56
- {...barLayout.layout === 'grouped'
57
- ? isHorizontal
58
- ? {
59
- insetTop: seriesIndex * barLayout.seriesStep + barLayout.seriesGap / 2,
60
- insetBottom: (barLayout.seriesCount - 1 - seriesIndex) * barLayout.seriesStep + barLayout.seriesGap / 2,
61
- }
62
- : {
63
- insetLeft: seriesIndex * barLayout.seriesStep + barLayout.seriesGap / 2,
64
- insetRight: (barLayout.seriesCount - 1 - seriesIndex) * barLayout.seriesStep + barLayout.seriesGap / 2,
65
- }
66
- : {}}
67
- />
68
- {/each}
69
- {/if}
@@ -1,19 +0,0 @@
1
- import type { AxisValue } from './axis';
2
- import type { StrokeStyle, FontStyle, DotStyle } from './styling';
3
- export type DeltaTarget = {
4
- type: 'series';
5
- series: string;
6
- } | {
7
- type: 'axis';
8
- value?: number;
9
- };
10
- export type DeltaConfig = {
11
- axis: 'x' | 'y';
12
- at: AxisValue;
13
- from: DeltaTarget;
14
- to?: DeltaTarget;
15
- formatDiff?: (diff: number) => string;
16
- strokeStyle?: StrokeStyle;
17
- fontStyle?: FontStyle;
18
- dotStyle?: DotStyle;
19
- };
@@ -1,52 +0,0 @@
1
- import type { ValueAnchor } from '../constants';
2
- import type { FontStyle, StrokeStyle } from '../styling';
3
- /**
4
- * Controls if and how value labels are rendered on a plot. The high-level
5
- * `anchor` sets sensible defaults for placement; `fontStyle` (`dx`, `dy`,
6
- * `textAnchor`, `lineAnchor`, `lineHeight`, `rotate`, `class`, `textClass`,
7
- * `fill`, …) overrides those defaults field-by-field when provided — mirrors
8
- * {@link DeltaConfig}'s `fontStyle`/`strokeStyle` split, so label text and
9
- * connector-line styling never mix into one flat bag of props.
10
- */
11
- export type ValuesStyle = {
12
- show?: boolean;
13
- anchor?: ValueAnchor;
14
- /** Called with the numeric value and the series name. Return a string to render. */
15
- format?: (value: number, seriesName: string) => string;
16
- /** Text styling for the label itself. */
17
- fontStyle?: FontStyle;
18
- /**
19
- * Style for the leader line drawn from a label displaced to clear an
20
- * overlap with another series' label, back to its real data point.
21
- * Labels only ever move when they'd otherwise collide — this is a no-op
22
- * style until that happens. Falls back to a neutral grey, thin, solid
23
- * stroke — deliberately not the series' own colour or stroke width, since
24
- * matching the data line reads as more data rather than as a leader,
25
- * right where several lines are already converging. Unset fields keep
26
- * that fallback.
27
- */
28
- strokeStyle?: StrokeStyle;
29
- };
30
- /**
31
- * Color overrides for plots that derive their palette from data.
32
- * Each plot uses only the fields relevant to its kind; unused fields are
33
- * silently ignored.
34
- *
35
- * - `min` / `max` — sequential colour ramp endpoints (heatmap).
36
- * - `left` / `right` — diverging bar sides (pyramid).
37
- */
38
- export type ColorsStyle = {
39
- min?: string;
40
- max?: string;
41
- left?: string;
42
- right?: string;
43
- };
44
- /**
45
- * Top-level rendering style overrides shared by the non-geo plot kinds.
46
- * Passed as the `styles` prop. Each plot reads only the fields it cares
47
- * about.
48
- */
49
- export type BasePlotStyles = {
50
- values?: ValuesStyle;
51
- colors?: ColorsStyle;
52
- };
@@ -1,42 +0,0 @@
1
- import type { ColorsStyle } from './common';
2
- import type { GeoFeature } from '../data/geo';
3
- export type GeoTileLayerConfig = {
4
- /** XYZ tile URL template, e.g. `'https://tile.openstreetmap.org/{z}/{x}/{y}.png'`. */
5
- url: string;
6
- attribution?: string;
7
- opacity?: number;
8
- minZoom?: number;
9
- maxZoom?: number;
10
- /** Tile edge length in pixels. Defaults to `256`. */
11
- tileSize?: number;
12
- };
13
- export type GeoZoomConfig = {
14
- min?: number;
15
- max?: number;
16
- initial?: {
17
- x?: number;
18
- y?: number;
19
- k?: number;
20
- };
21
- };
22
- /**
23
- * `styles` prop for GeoPlot — the geo analog of `BasePlotStyles`. Unlike the
24
- * other plot kinds, GeoPlot's styling needs (base map, choropleth ramp, tile
25
- * background, zoom, click handling) are unlike anything x/y plots need, so
26
- * this is its own type rather than a reuse of `BasePlotStyles`.
27
- */
28
- export type GeoStyles<TProps extends Record<string, unknown> = Record<string, unknown>> = {
29
- /** Base map fill, used when a feature isn't styled by `segments` or the choropleth ramp. */
30
- fill?: string;
31
- fillOpacity?: number;
32
- stroke?: string;
33
- strokeWidth?: number;
34
- /** Continuous choropleth ramp endpoints — used when `value` is provided on data. Mirrors heatmap's `styles.colors`. */
35
- colors?: ColorsStyle;
36
- /** Raster XYZ tile basemap under the vector geometry. Mercator-family projections only. */
37
- tileLayer?: GeoTileLayerConfig;
38
- /** `true`/config enables drag-pan + scroll-zoom. Omitted/`false` = static map. */
39
- zoom?: boolean | GeoZoomConfig;
40
- /** Fired when a base-map feature is clicked. */
41
- onFeatureClick?: (feature: GeoFeature<TProps>, event: Event) => void;
42
- };