poetry-charts 0.0.2

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 (124) hide show
  1. checksums.yaml +7 -0
  2. data/.gitattributes +6 -0
  3. data/CHANGELOG.md +3 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +94 -0
  6. data/THIRD_PARTY_NOTICES.md +39 -0
  7. data/app/assets/stylesheets/poetry-charts.css +117 -0
  8. data/app/components/poetry/charts/adapter_chart/component.html.erb +6 -0
  9. data/app/components/poetry/charts/adapter_chart/component.rb +99 -0
  10. data/app/components/poetry/charts/adapter_chart/preview.rb +37 -0
  11. data/app/components/poetry/charts/adapter_chart/style.rb +16 -0
  12. data/app/components/poetry/charts/area_chart/component.html.erb +75 -0
  13. data/app/components/poetry/charts/area_chart/component.rb +251 -0
  14. data/app/components/poetry/charts/area_chart/preview.rb +95 -0
  15. data/app/components/poetry/charts/area_chart/style.rb +29 -0
  16. data/app/components/poetry/charts/bar_chart/component.html.erb +95 -0
  17. data/app/components/poetry/charts/bar_chart/component.rb +318 -0
  18. data/app/components/poetry/charts/bar_chart/preview.rb +115 -0
  19. data/app/components/poetry/charts/bar_chart/style.rb +28 -0
  20. data/app/components/poetry/charts/bar_math.rb +95 -0
  21. data/app/components/poetry/charts/cartesian_family.rb +105 -0
  22. data/app/components/poetry/charts/chart_family.rb +58 -0
  23. data/app/components/poetry/charts/composed_chart/component.html.erb +95 -0
  24. data/app/components/poetry/charts/composed_chart/component.rb +309 -0
  25. data/app/components/poetry/charts/composed_chart/preview.rb +62 -0
  26. data/app/components/poetry/charts/composed_chart/style.rb +24 -0
  27. data/app/components/poetry/charts/container/component.html.erb +4 -0
  28. data/app/components/poetry/charts/container/component.rb +80 -0
  29. data/app/components/poetry/charts/container/preview.rb +45 -0
  30. data/app/components/poetry/charts/container/style.rb +22 -0
  31. data/app/components/poetry/charts/error_bars.rb +35 -0
  32. data/app/components/poetry/charts/legend_content/component.html.erb +10 -0
  33. data/app/components/poetry/charts/legend_content/component.rb +122 -0
  34. data/app/components/poetry/charts/legend_content/preview.rb +23 -0
  35. data/app/components/poetry/charts/legend_content/style.rb +26 -0
  36. data/app/components/poetry/charts/line_chart/component.html.erb +85 -0
  37. data/app/components/poetry/charts/line_chart/component.rb +252 -0
  38. data/app/components/poetry/charts/line_chart/preview.rb +115 -0
  39. data/app/components/poetry/charts/line_chart/style.rb +28 -0
  40. data/app/components/poetry/charts/live.rb +296 -0
  41. data/app/components/poetry/charts/motion.rb +98 -0
  42. data/app/components/poetry/charts/pie_chart/component.html.erb +36 -0
  43. data/app/components/poetry/charts/pie_chart/component.rb +256 -0
  44. data/app/components/poetry/charts/pie_chart/preview.rb +100 -0
  45. data/app/components/poetry/charts/pie_chart/style.rb +19 -0
  46. data/app/components/poetry/charts/polar_family.rb +95 -0
  47. data/app/components/poetry/charts/radar_chart/component.html.erb +73 -0
  48. data/app/components/poetry/charts/radar_chart/component.rb +329 -0
  49. data/app/components/poetry/charts/radar_chart/preview.rb +97 -0
  50. data/app/components/poetry/charts/radar_chart/style.rb +21 -0
  51. data/app/components/poetry/charts/radial_bar_chart/component.html.erb +65 -0
  52. data/app/components/poetry/charts/radial_bar_chart/component.rb +424 -0
  53. data/app/components/poetry/charts/radial_bar_chart/preview.rb +99 -0
  54. data/app/components/poetry/charts/radial_bar_chart/style.rb +27 -0
  55. data/app/components/poetry/charts/reference_marks.rb +156 -0
  56. data/app/components/poetry/charts/scatter_chart/component.html.erb +55 -0
  57. data/app/components/poetry/charts/scatter_chart/component.rb +396 -0
  58. data/app/components/poetry/charts/scatter_chart/preview.rb +93 -0
  59. data/app/components/poetry/charts/scatter_chart/style.rb +22 -0
  60. data/app/components/poetry/charts/tooltip_content/component.html.erb +19 -0
  61. data/app/components/poetry/charts/tooltip_content/component.rb +168 -0
  62. data/app/components/poetry/charts/tooltip_content/preview.rb +39 -0
  63. data/app/components/poetry/charts/tooltip_content/style.rb +31 -0
  64. data/app/components/poetry/charts/tooltip_layer/component.html.erb +6 -0
  65. data/app/components/poetry/charts/tooltip_layer/component.rb +61 -0
  66. data/app/components/poetry/charts/tooltip_layer/style.rb +13 -0
  67. data/app/components/poetry/charts/tooltip_wiring.rb +167 -0
  68. data/app/helpers/poetry/charts/components_helper.rb +125 -0
  69. data/app/javascript/poetry/charts/adapter_controller.js +75 -0
  70. data/app/javascript/poetry/charts/adapter_registry.js +52 -0
  71. data/app/javascript/poetry/charts/adapters/chartjs.js +86 -0
  72. data/app/javascript/poetry/charts/d3.js +14 -0
  73. data/app/javascript/poetry/charts/index.js +67 -0
  74. data/app/javascript/poetry/charts/live/renderer.js +456 -0
  75. data/app/javascript/poetry/charts/live_controller.js +195 -0
  76. data/app/javascript/poetry/charts/motion/flip.js +169 -0
  77. data/app/javascript/poetry/charts/motion/sector.js +62 -0
  78. data/app/javascript/poetry/charts/motion/tween.js +105 -0
  79. data/app/javascript/poetry/charts/motion_controller.js +230 -0
  80. data/app/javascript/poetry/charts/tooltip_controller.js +331 -0
  81. data/app/javascript/poetry/charts/window_controller.js +195 -0
  82. data/config/component_descriptions.yml +14 -0
  83. data/config/component_registry.yml +3055 -0
  84. data/config/controllers_manifest.json +100 -0
  85. data/config/importmap.rb +10 -0
  86. data/lib/poetry/charts/cartesian.rb +277 -0
  87. data/lib/poetry/charts/config.rb +149 -0
  88. data/lib/poetry/charts/engine.rb +76 -0
  89. data/lib/poetry/charts/geometry/area.rb +68 -0
  90. data/lib/poetry/charts/geometry/curve.rb +327 -0
  91. data/lib/poetry/charts/geometry/line.rb +64 -0
  92. data/lib/poetry/charts/geometry/nice_ticks.rb +220 -0
  93. data/lib/poetry/charts/geometry/path.rb +96 -0
  94. data/lib/poetry/charts/geometry/scale/band.rb +81 -0
  95. data/lib/poetry/charts/geometry/scale/linear.rb +127 -0
  96. data/lib/poetry/charts/geometry/stack.rb +129 -0
  97. data/lib/poetry/charts/geometry/ticks.rb +103 -0
  98. data/lib/poetry/charts/geometry.rb +66 -0
  99. data/lib/poetry/charts/polar.rb +179 -0
  100. data/lib/poetry/charts/spec.rb +108 -0
  101. data/lib/poetry/charts/theme_style.rb +53 -0
  102. data/lib/poetry/charts/version.rb +8 -0
  103. data/lib/poetry/charts.rb +114 -0
  104. data/lib/poetry-charts.rb +4 -0
  105. data/themes/default.css +146 -0
  106. data/themes/luma.css +139 -0
  107. data/themes/lyra.css +140 -0
  108. data/themes/maia.css +139 -0
  109. data/themes/mira.css +139 -0
  110. data/themes/nova.css +139 -0
  111. data/themes/rhea.css +139 -0
  112. data/themes/sera.css +140 -0
  113. data/themes/vega.css +144 -0
  114. data/vendor/d3-kernel/LICENSE-d3.txt +17 -0
  115. data/vendor/d3-kernel/LICENSE-decimal.js-light.txt +25 -0
  116. data/vendor/d3-kernel/LICENSE-recharts.txt +26 -0
  117. data/vendor/d3-kernel/README.md +30 -0
  118. data/vendor/d3-kernel/build.mjs +66 -0
  119. data/vendor/d3-kernel/entry.js +27 -0
  120. data/vendor/d3-kernel/recharts/state/cartesianAxisSlice.ts +6 -0
  121. data/vendor/d3-kernel/recharts/util/scale/getNiceTickValues.ts +310 -0
  122. data/vendor/d3-kernel/recharts/util/scale/util/arithmetic.ts +54 -0
  123. data/vendor/d3-kernel/recharts/util/types.ts +5 -0
  124. metadata +186 -0
data/themes/sera.css ADDED
@@ -0,0 +1,140 @@
1
+ /* poetry-charts sera theme - chart chrome under upstream
2
+ * style-sera.css (pinned clone 1773ecfe, the shadcn@4.19.0 release). Upstream ships ONE chart rule (cn-chart-tooltip) and sera reskins it (bg-popover ring-1 ring-foreground/10 shadow-sm, radius absent = square); everything else carries the default treatment.
3
+ * Same contract as default.css: imported layer(base) by the host entry;
4
+ * POETRY_THEME=sera drives the gates and golden set. */
5
+
6
+ /* MARK: Tooltip */
7
+ .cn-chart-tooltip {
8
+ @apply bg-popover text-popover-foreground ring-foreground/10 gap-1.5 px-2.5 py-1.5 text-xs shadow-sm ring-1;
9
+ }
10
+
11
+ .cn-chart-tooltip-label {
12
+ @apply font-medium;
13
+ }
14
+
15
+ .cn-chart-tooltip-row {
16
+ @apply gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground;
17
+ }
18
+
19
+ .cn-chart-tooltip-name {
20
+ @apply text-muted-foreground;
21
+ }
22
+
23
+ .cn-chart-tooltip-value {
24
+ @apply font-mono font-medium text-foreground tabular-nums;
25
+ }
26
+
27
+ /* MARK: Legend */
28
+ .cn-chart-legend {
29
+ @apply gap-4;
30
+ }
31
+
32
+ .cn-chart-legend-align-top {
33
+ @apply pb-3;
34
+ }
35
+
36
+ .cn-chart-legend-align-bottom {
37
+ @apply pt-3;
38
+ }
39
+
40
+ .cn-chart-legend-item {
41
+ @apply gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground;
42
+ }
43
+
44
+ .cn-chart-legend-swatch {
45
+ @apply h-2 w-2 rounded-[2px];
46
+ }
47
+
48
+ /* MARK: Cartesian chrome (shared across families) */
49
+ .cn-chart-grid-line {
50
+ @apply stroke-border/50;
51
+ }
52
+
53
+ .cn-chart-tick {
54
+ @apply fill-muted-foreground;
55
+ }
56
+
57
+ .cn-chart-cursor-line {
58
+ @apply stroke-border;
59
+ }
60
+
61
+ .cn-chart-cursor-band {
62
+ @apply fill-muted;
63
+ }
64
+
65
+ .cn-chart-reference-line {
66
+ @apply stroke-muted-foreground;
67
+ }
68
+
69
+ .cn-chart-reference-area {
70
+ @apply fill-muted-foreground;
71
+ }
72
+
73
+ .cn-chart-reference-dot {
74
+ @apply fill-background stroke-muted-foreground;
75
+ }
76
+
77
+ .cn-chart-error-bar {
78
+ @apply stroke-foreground;
79
+ }
80
+
81
+ .cn-chart-brush-track {
82
+ @apply fill-muted;
83
+ }
84
+
85
+ .cn-chart-brush-window {
86
+ @apply fill-foreground/10 stroke-border;
87
+ }
88
+
89
+ .cn-chart-brush-handle {
90
+ @apply fill-muted-foreground;
91
+ }
92
+
93
+ .cn-chart-label {
94
+ @apply fill-foreground;
95
+ }
96
+
97
+ /* MARK: Polar chrome */
98
+ .cn-chart-polar-grid-line {
99
+ @apply fill-none stroke-border;
100
+ }
101
+
102
+ .cn-chart-polar-grid-circle {
103
+ @apply fill-none stroke-border/50;
104
+ }
105
+
106
+ .cn-chart-radial-track {
107
+ @apply fill-muted;
108
+ }
109
+
110
+ .cn-chart-radial-disc-muted {
111
+ @apply fill-muted;
112
+ }
113
+
114
+ .cn-chart-radial-disc-background {
115
+ @apply fill-background;
116
+ }
117
+
118
+ .cn-chart-inside-label {
119
+ @apply fill-background text-xs;
120
+ }
121
+
122
+ .cn-chart-radial-inside-label {
123
+ @apply fill-white capitalize mix-blend-luminosity text-[11px];
124
+ }
125
+
126
+ .cn-chart-center-title {
127
+ @apply fill-foreground text-3xl font-bold;
128
+ }
129
+
130
+ .cn-chart-center-title-radial {
131
+ @apply fill-foreground text-4xl font-bold;
132
+ }
133
+
134
+ .cn-chart-center-title-compact {
135
+ @apply fill-foreground text-2xl font-bold;
136
+ }
137
+
138
+ .cn-chart-center-subtitle {
139
+ @apply fill-muted-foreground;
140
+ }
data/themes/vega.css ADDED
@@ -0,0 +1,144 @@
1
+ /* poetry-charts vega theme - same contract as default.css
2
+ * (layer(base), shared chrome names). Upstream style-vega.css touches a
3
+ * single chart surface (.cn-chart-tooltip) and its body is byte-identical
4
+ * to poetry defaults; every other chart treatment is poetry-own and
5
+ * carries the default look (a deliberate, recorded choice). The file
6
+ * exists so every poetry gem ships every theme (install --theme vega
7
+ * fails fast otherwise) and diverges when a later theme restyles charts.
8
+ */
9
+
10
+ /* MARK: Tooltip */
11
+ .cn-chart-tooltip {
12
+ @apply gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl;
13
+ }
14
+
15
+ .cn-chart-tooltip-label {
16
+ @apply font-medium;
17
+ }
18
+
19
+ .cn-chart-tooltip-row {
20
+ @apply gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground;
21
+ }
22
+
23
+ .cn-chart-tooltip-name {
24
+ @apply text-muted-foreground;
25
+ }
26
+
27
+ .cn-chart-tooltip-value {
28
+ @apply font-mono font-medium text-foreground tabular-nums;
29
+ }
30
+
31
+ /* MARK: Legend */
32
+ .cn-chart-legend {
33
+ @apply gap-4;
34
+ }
35
+
36
+ .cn-chart-legend-align-top {
37
+ @apply pb-3;
38
+ }
39
+
40
+ .cn-chart-legend-align-bottom {
41
+ @apply pt-3;
42
+ }
43
+
44
+ .cn-chart-legend-item {
45
+ @apply gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground;
46
+ }
47
+
48
+ .cn-chart-legend-swatch {
49
+ @apply h-2 w-2 rounded-[2px];
50
+ }
51
+
52
+ /* MARK: Cartesian chrome (shared across families) */
53
+ .cn-chart-grid-line {
54
+ @apply stroke-border/50;
55
+ }
56
+
57
+ .cn-chart-tick {
58
+ @apply fill-muted-foreground;
59
+ }
60
+
61
+ .cn-chart-cursor-line {
62
+ @apply stroke-border;
63
+ }
64
+
65
+ .cn-chart-cursor-band {
66
+ @apply fill-muted;
67
+ }
68
+
69
+ .cn-chart-reference-line {
70
+ @apply stroke-muted-foreground;
71
+ }
72
+
73
+ .cn-chart-reference-area {
74
+ @apply fill-muted-foreground;
75
+ }
76
+
77
+ .cn-chart-reference-dot {
78
+ @apply fill-background stroke-muted-foreground;
79
+ }
80
+
81
+ .cn-chart-error-bar {
82
+ @apply stroke-foreground;
83
+ }
84
+
85
+ .cn-chart-brush-track {
86
+ @apply fill-muted;
87
+ }
88
+
89
+ .cn-chart-brush-window {
90
+ @apply fill-foreground/10 stroke-border;
91
+ }
92
+
93
+ .cn-chart-brush-handle {
94
+ @apply fill-muted-foreground;
95
+ }
96
+
97
+ .cn-chart-label {
98
+ @apply fill-foreground;
99
+ }
100
+
101
+ /* MARK: Polar chrome */
102
+ .cn-chart-polar-grid-line {
103
+ @apply fill-none stroke-border;
104
+ }
105
+
106
+ .cn-chart-polar-grid-circle {
107
+ @apply fill-none stroke-border/50;
108
+ }
109
+
110
+ .cn-chart-radial-track {
111
+ @apply fill-muted;
112
+ }
113
+
114
+ .cn-chart-radial-disc-muted {
115
+ @apply fill-muted;
116
+ }
117
+
118
+ .cn-chart-radial-disc-background {
119
+ @apply fill-background;
120
+ }
121
+
122
+ .cn-chart-inside-label {
123
+ @apply fill-background text-xs;
124
+ }
125
+
126
+ .cn-chart-radial-inside-label {
127
+ @apply fill-white capitalize mix-blend-luminosity text-[11px];
128
+ }
129
+
130
+ .cn-chart-center-title {
131
+ @apply fill-foreground text-3xl font-bold;
132
+ }
133
+
134
+ .cn-chart-center-title-radial {
135
+ @apply fill-foreground text-4xl font-bold;
136
+ }
137
+
138
+ .cn-chart-center-title-compact {
139
+ @apply fill-foreground text-2xl font-bold;
140
+ }
141
+
142
+ .cn-chart-center-subtitle {
143
+ @apply fill-muted-foreground;
144
+ }
@@ -0,0 +1,17 @@
1
+ Applies to the d3-array, d3-scale, d3-shape, d3-interpolate, d3-format,
2
+ d3-time, and d3-time-format modules bundled (unmodified) into
3
+ app/javascript/poetry/charts/d3.js.
4
+
5
+ Copyright 2010-2023 Mike Bostock
6
+
7
+ Permission to use, copy, modify, and/or distribute this software for any purpose
8
+ with or without fee is hereby granted, provided that the above copyright notice
9
+ and this permission notice appear in all copies.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
13
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
15
+ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16
+ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
17
+ THIS SOFTWARE.
@@ -0,0 +1,25 @@
1
+ Applies to decimal.js-light, bundled (unmodified) into
2
+ app/javascript/poetry/charts/d3.js.
3
+
4
+ The MIT Expat Licence.
5
+
6
+ Copyright (c) 2020 Michael Mclaughlin
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining
9
+ a copy of this software and associated documentation files (the
10
+ 'Software'), to deal in the Software without restriction, including
11
+ without limitation the rights to use, copy, modify, merge, publish,
12
+ distribute, sublicense, and/or sell copies of the Software, and to
13
+ permit persons to whom the Software is furnished to do so, subject to
14
+ the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be
17
+ included in all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
20
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,26 @@
1
+ Applies to getNiceTickValues.ts and util/arithmetic.ts under recharts/,
2
+ copied verbatim from recharts v3.9.2 and bundled into
3
+ app/javascript/poetry/charts/d3.js, and to the BigDecimal transcription
4
+ of the same algorithm in lib/ (Poetry::Charts::Geometry::NiceTicks).
5
+
6
+ The MIT License (MIT)
7
+
8
+ Copyright (c) 2015-present recharts
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
@@ -0,0 +1,30 @@
1
+ # The @poetry/charts/d3 kernel
2
+
3
+ The DOM-free geometry kernel poetry-charts' live tier computes with,
4
+ bundled into the committed `app/javascript/poetry/charts/d3.js` (ESM,
5
+ ~26 KB gzip) behind the host-remappable `@poetry/charts/d3` importmap pin.
6
+ It is an implementation detail of live mode, not a public d3 distribution
7
+ (no poetry-d3 gem unless raw-d3 demand appears — the remappable pin
8
+ keeps that extraction non-breaking).
9
+
10
+ Contents, unmodified:
11
+
12
+ - **d3**: d3-array, d3-scale, d3-shape, d3-interpolate, d3-format,
13
+ d3-time, d3-time-format (ISC, Mike Bostock) — the EXACT packages that
14
+ generate `test/fixtures/geometry_fixtures.json`, so this kernel and the
15
+ Ruby geometry port answer to one oracle.
16
+ - **decimal.js-light** (MIT, Michael Mclaughlin) — recharts' arbitrary-precision
17
+ dependency.
18
+ - **recharts/** — `getNiceTickValues.ts` + `util/arithmetic.ts` copied
19
+ VERBATIM from recharts v3.9.2 `src/util/scale/` (MIT, Recharts Group);
20
+ the two sibling `.ts` files here are type-only shims at the original
21
+ import paths so the copies bundle unmodified. This is the same algorithm
22
+ `Poetry::Charts::Geometry::NiceTicks` transcribes to BigDecimal.
23
+
24
+ Rebuild: `npm run vendor:d3`. Drift gates: `npm run vendor:d3:verify`
25
+ (byte compare, part of `npm test`) and the KERNEL_VERSIONS check +
26
+ fixture-parity suite in `test/javascript/d3_kernel.test.js`.
27
+
28
+ License texts for everything bundled here: `LICENSE-d3.txt`,
29
+ `LICENSE-decimal.js-light.txt`, `LICENSE-recharts.txt` (this directory;
30
+ see also the repo-root `THIRD_PARTY_NOTICES.md`).
@@ -0,0 +1,66 @@
1
+ // Builds the committed @poetry/charts/d3 kernel bundle from
2
+ // vendor/d3-kernel/entry.js (the vendoring pattern).
3
+ //
4
+ // npm run vendor:d3 rebuild app/javascript/poetry/charts/d3.js
5
+ // npm run vendor:d3:verify rebuild in memory and fail on drift
6
+ //
7
+ // The build is deterministic for a given dependency set; KERNEL_VERSIONS
8
+ // is injected so the vitest gate can prove the committed bundle matches
9
+ // the installed packages.
10
+ import { build } from "esbuild"
11
+ import { readFileSync, writeFileSync } from "node:fs"
12
+ import { fileURLToPath } from "node:url"
13
+ import path from "node:path"
14
+
15
+ const ROOT = path.dirname(path.dirname(path.dirname(fileURLToPath(import.meta.url))))
16
+ const OUTFILE = path.join(ROOT, "app/javascript/poetry/charts/d3.js")
17
+
18
+ const PACKAGES = [
19
+ "d3-array", "d3-scale", "d3-shape", "d3-interpolate", "d3-format",
20
+ "d3-time", "d3-time-format", "decimal.js-light",
21
+ ]
22
+ const versions = Object.fromEntries(
23
+ PACKAGES.map((name) => [
24
+ name,
25
+ JSON.parse(readFileSync(path.join(ROOT, "node_modules", name, "package.json"), "utf8")).version,
26
+ ])
27
+ )
28
+
29
+ const banner = `/*!
30
+ * @poetry/charts/d3 - the vendored DOM-free geometry kernel (the opt-in live mode).
31
+ * Bundles, unmodified:
32
+ * d3-array ${versions["d3-array"]}, d3-scale ${versions["d3-scale"]}, d3-shape ${versions["d3-shape"]},
33
+ * d3-interpolate ${versions["d3-interpolate"]}, d3-format ${versions["d3-format"]},
34
+ * d3-time ${versions["d3-time"]}, d3-time-format ${versions["d3-time-format"]}
35
+ * - Copyright 2010-2023 Mike Bostock, ISC license (https://github.com/d3)
36
+ * decimal.js-light ${versions["decimal.js-light"]}
37
+ * - Copyright Michael Mclaughlin, MIT license
38
+ * getNiceTickValues from recharts v3.9.2 (verbatim)
39
+ * - Copyright (c) Recharts Group, MIT license (https://github.com/recharts/recharts)
40
+ * Rebuild: npm run vendor:d3 (source: vendor/d3-kernel/).
41
+ */`
42
+
43
+ const result = await build({
44
+ entryPoints: [path.join(ROOT, "vendor/d3-kernel/entry.js")],
45
+ bundle: true,
46
+ format: "esm",
47
+ minify: true,
48
+ legalComments: "none",
49
+ banner: { js: banner },
50
+ define: { __KERNEL_VERSIONS__: JSON.stringify(versions) },
51
+ write: false,
52
+ })
53
+
54
+ const fresh = result.outputFiles[0].text
55
+
56
+ if (process.argv.includes("--verify")) {
57
+ const committed = readFileSync(OUTFILE, "utf8")
58
+ if (committed !== fresh) {
59
+ console.error("DRIFT: app/javascript/poetry/charts/d3.js does not match a fresh build - run `npm run vendor:d3` and commit.")
60
+ process.exit(1)
61
+ }
62
+ console.log(`vendor:d3 verified (${(fresh.length / 1024).toFixed(1)} KB, ${Object.entries(versions).map(([k, v]) => `${k}@${v}`).join(", ")})`)
63
+ } else {
64
+ writeFileSync(OUTFILE, fresh)
65
+ console.log(`vendored ${OUTFILE} (${(fresh.length / 1024).toFixed(1)} KB)`)
66
+ }
@@ -0,0 +1,27 @@
1
+ // The @poetry/charts/d3 kernel surface: the DOM-free d3
2
+ // modules the live tier computes geometry with - the EXACT packages that
3
+ // generated test/fixtures/geometry_fixtures.json, so the client kernel and
4
+ // the Ruby geometry port share one ground truth - plus recharts' own
5
+ // getNiceTickValues (copied verbatim; v3 keeps it internal) so client
6
+ // ticks match Geometry::NiceTicks decimal-for-decimal.
7
+ //
8
+ // Not a public d3 distribution: this is an implementation detail of live
9
+ // mode behind a host-remappable importmap pin (the vendoring pattern).
10
+ // Rebuild with `npm run vendor:d3`; CI drift-gates the committed bundle.
11
+
12
+ export { ticks, tickIncrement, tickStep, bisector, extent, max, min, range } from "d3-array"
13
+ export { scaleLinear, scaleBand, scalePoint, scaleTime } from "d3-scale"
14
+ export {
15
+ line, area, stack, arc, pie,
16
+ curveLinear, curveNatural, curveStep, curveStepBefore, curveStepAfter, curveMonotoneX,
17
+ stackOffsetNone, stackOffsetExpand, stackOffsetDiverging, stackOrderNone,
18
+ } from "d3-shape"
19
+ export { interpolate, interpolateNumber, interpolateArray } from "d3-interpolate"
20
+ export { format } from "d3-format"
21
+ export { timeFormat, timeParse } from "d3-time-format"
22
+ export { getNiceTickValues, getTickValuesFixedDomain } from "./recharts/util/scale/getNiceTickValues"
23
+
24
+ // Injected at bundle time (vendor/d3-kernel/build.mjs): the exact package
25
+ // versions inside this bundle - the vitest drift gate compares them to
26
+ // package.json so a dependency bump can never outrun a rebuild.
27
+ export const KERNEL_VERSIONS = __KERNEL_VERSIONS__
@@ -0,0 +1,6 @@
1
+ // Type shim for the verbatim recharts copies in this vendor tree: the
2
+ // original `src/util/scale/getNiceTickValues.ts` imports
3
+ // NiceTicksAlgorithm from `../../state/cartesianAxisSlice`; this file
4
+ // provides ONLY that type (from recharts v3.9.2) so the copies bundle
5
+ // without modification.
6
+ export type NiceTicksAlgorithm = 'none' | 'auto' | 'adaptive' | 'snap125';