derive-dashboards 0.5.1 → 0.7.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 (342) hide show
  1. package/README.md +4 -2
  2. package/dist/body.mjs +2 -2
  3. package/dist/charts/data/buckets.d.mts +11 -0
  4. package/dist/charts/data/buckets.mjs +66 -0
  5. package/dist/charts/data/clean.mjs +55 -0
  6. package/dist/charts/data/format.d.mts +19 -0
  7. package/dist/charts/data/format.mjs +174 -0
  8. package/dist/charts/data/input-error.d.mts +5 -0
  9. package/dist/charts/data/input-error.mjs +11 -0
  10. package/dist/charts/data/range.mjs +14 -0
  11. package/dist/charts/data/rows.d.mts +13 -0
  12. package/dist/charts/data/rows.mjs +31 -0
  13. package/dist/charts/data/shares.mjs +55 -0
  14. package/dist/charts/data/types.d.mts +106 -0
  15. package/dist/charts/data/words.d.mts +44 -0
  16. package/dist/charts/data/words.mjs +31 -0
  17. package/dist/charts/describe.mjs +110 -0
  18. package/dist/charts/index.d.mts +34 -0
  19. package/dist/charts/index.mjs +24 -0
  20. package/dist/charts/kinds/area-marks.mjs +120 -0
  21. package/dist/charts/kinds/area.d.mts +23 -0
  22. package/dist/charts/kinds/area.mjs +71 -0
  23. package/dist/charts/kinds/bars-data.d.mts +11 -0
  24. package/dist/charts/kinds/bars-data.mjs +30 -0
  25. package/dist/charts/kinds/bars-layout.mjs +30 -0
  26. package/dist/charts/kinds/bars-marks.mjs +93 -0
  27. package/dist/charts/kinds/bars-words.mjs +56 -0
  28. package/dist/charts/kinds/bars.d.mts +17 -0
  29. package/dist/charts/kinds/bars.mjs +68 -0
  30. package/dist/charts/kinds/columns-data.mjs +116 -0
  31. package/dist/charts/kinds/columns-layout.mjs +29 -0
  32. package/dist/charts/kinds/columns-marks.mjs +200 -0
  33. package/dist/charts/kinds/columns-words.mjs +26 -0
  34. package/dist/charts/kinds/columns.d.mts +13 -0
  35. package/dist/charts/kinds/columns.mjs +80 -0
  36. package/dist/charts/kinds/dumbbell-data.d.mts +22 -0
  37. package/dist/charts/kinds/dumbbell-data.mjs +59 -0
  38. package/dist/charts/kinds/dumbbell-layout.mjs +113 -0
  39. package/dist/charts/kinds/dumbbell-marks.mjs +119 -0
  40. package/dist/charts/kinds/dumbbell-words.d.mts +7 -0
  41. package/dist/charts/kinds/dumbbell-words.mjs +94 -0
  42. package/dist/charts/kinds/dumbbell.d.mts +14 -0
  43. package/dist/charts/kinds/dumbbell.mjs +67 -0
  44. package/dist/charts/kinds/funnel-data.d.mts +11 -0
  45. package/dist/charts/kinds/funnel-data.mjs +70 -0
  46. package/dist/charts/kinds/funnel-layout.mjs +32 -0
  47. package/dist/charts/kinds/funnel-marks.mjs +204 -0
  48. package/dist/charts/kinds/funnel-words.mjs +77 -0
  49. package/dist/charts/kinds/funnel.d.mts +11 -0
  50. package/dist/charts/kinds/funnel.mjs +75 -0
  51. package/dist/charts/kinds/grid-data.d.mts +18 -0
  52. package/dist/charts/kinds/grid-data.mjs +35 -0
  53. package/dist/charts/kinds/grid-layout.mjs +77 -0
  54. package/dist/charts/kinds/grid-marks.mjs +140 -0
  55. package/dist/charts/kinds/grid-time.mjs +41 -0
  56. package/dist/charts/kinds/grid-words.mjs +86 -0
  57. package/dist/charts/kinds/grid.d.mts +22 -0
  58. package/dist/charts/kinds/grid.mjs +55 -0
  59. package/dist/charts/kinds/histogram-data.mjs +142 -0
  60. package/dist/charts/kinds/histogram-layout.mjs +144 -0
  61. package/dist/charts/kinds/histogram-marks.mjs +110 -0
  62. package/dist/charts/kinds/histogram-words.mjs +104 -0
  63. package/dist/charts/kinds/histogram.d.mts +15 -0
  64. package/dist/charts/kinds/histogram.mjs +47 -0
  65. package/dist/charts/kinds/line-marks.mjs +36 -0
  66. package/dist/charts/kinds/line.d.mts +17 -0
  67. package/dist/charts/kinds/line.mjs +52 -0
  68. package/dist/charts/kinds/multiples-grid.mjs +107 -0
  69. package/dist/charts/kinds/multiples-head.mjs +44 -0
  70. package/dist/charts/kinds/multiples-layout.mjs +159 -0
  71. package/dist/charts/kinds/multiples-marks.mjs +95 -0
  72. package/dist/charts/kinds/multiples-words.mjs +110 -0
  73. package/dist/charts/kinds/multiples.d.mts +26 -0
  74. package/dist/charts/kinds/multiples.mjs +42 -0
  75. package/dist/charts/kinds/row-chart.mjs +112 -0
  76. package/dist/charts/kinds/row-marks.mjs +121 -0
  77. package/dist/charts/kinds/scatter-data.d.mts +18 -0
  78. package/dist/charts/kinds/scatter-data.mjs +123 -0
  79. package/dist/charts/kinds/scatter-layout.mjs +189 -0
  80. package/dist/charts/kinds/scatter-marks.mjs +149 -0
  81. package/dist/charts/kinds/scatter-words.mjs +80 -0
  82. package/dist/charts/kinds/scatter.d.mts +21 -0
  83. package/dist/charts/kinds/scatter.mjs +72 -0
  84. package/dist/charts/kinds/stat-data.mjs +91 -0
  85. package/dist/charts/kinds/stat-layout.mjs +108 -0
  86. package/dist/charts/kinds/stat-marks.mjs +85 -0
  87. package/dist/charts/kinds/stat-words.mjs +57 -0
  88. package/dist/charts/kinds/stat.d.mts +28 -0
  89. package/dist/charts/kinds/stat.mjs +35 -0
  90. package/dist/charts/kinds/time-chart.mjs +74 -0
  91. package/dist/charts/kinds/time-frame.mjs +113 -0
  92. package/dist/charts/kinds/time-notes.mjs +36 -0
  93. package/dist/charts/kinds/time-plan.d.mts +8 -0
  94. package/dist/charts/kinds/time-plan.mjs +57 -0
  95. package/dist/charts/kinds/time-plot.mjs +56 -0
  96. package/dist/charts/kinds/time-stops.mjs +56 -0
  97. package/dist/charts/kinds/value-plot.mjs +33 -0
  98. package/dist/charts/kinds/waterfall-data.d.mts +7 -0
  99. package/dist/charts/kinds/waterfall-data.mjs +71 -0
  100. package/dist/charts/kinds/waterfall-layout.mjs +38 -0
  101. package/dist/charts/kinds/waterfall-marks.mjs +82 -0
  102. package/dist/charts/kinds/waterfall-words.mjs +118 -0
  103. package/dist/charts/kinds/waterfall.d.mts +17 -0
  104. package/dist/charts/kinds/waterfall.mjs +66 -0
  105. package/dist/charts/layout/boxes.mjs +28 -0
  106. package/dist/charts/layout/dodge.mjs +75 -0
  107. package/dist/charts/layout/extent.mjs +25 -0
  108. package/dist/charts/layout/frame.mjs +97 -0
  109. package/dist/charts/layout/place-labels.mjs +101 -0
  110. package/dist/charts/layout/stack.mjs +31 -0
  111. package/dist/charts/marks/axes.mjs +137 -0
  112. package/dist/charts/marks/dot.mjs +31 -0
  113. package/dist/charts/marks/end-labels.mjs +124 -0
  114. package/dist/charts/marks/legend.mjs +141 -0
  115. package/dist/charts/marks/lines.d.mts +2 -0
  116. package/dist/charts/marks/lines.mjs +38 -0
  117. package/dist/charts/marks/lit.d.mts +3 -0
  118. package/dist/charts/marks/lit.mjs +63 -0
  119. package/dist/charts/marks/more.mjs +18 -0
  120. package/dist/charts/marks/notes.mjs +253 -0
  121. package/dist/charts/marks/series-line.mjs +110 -0
  122. package/dist/charts/marks/thin.mjs +138 -0
  123. package/dist/charts/marks/x-axis.mjs +32 -0
  124. package/dist/charts/scale/calendar.mjs +174 -0
  125. package/dist/charts/scale/time-ticks.mjs +154 -0
  126. package/dist/charts/scale/time.mjs +33 -0
  127. package/dist/charts/scale/value.mjs +161 -0
  128. package/dist/charts/scene/defs.mjs +33 -0
  129. package/dist/charts/scene/markup.mjs +35 -0
  130. package/dist/charts/scene/nearest.d.mts +11 -0
  131. package/dist/charts/scene/nearest.mjs +49 -0
  132. package/dist/charts/scene/paint.d.mts +12 -0
  133. package/dist/charts/scene/paint.mjs +13 -0
  134. package/dist/charts/scene/svg.d.mts +18 -0
  135. package/dist/charts/scene/svg.mjs +185 -0
  136. package/dist/charts/scene/types.d.mts +177 -0
  137. package/dist/charts/text/measure.d.mts +9 -0
  138. package/dist/charts/text/measure.mjs +123 -0
  139. package/dist/charts/theme.d.mts +47 -0
  140. package/dist/charts/theme.mjs +239 -0
  141. package/dist/charts-react/Chart.d.mts +91 -0
  142. package/dist/charts-react/Chart.mjs +166 -0
  143. package/dist/charts-react/Overlay.mjs +171 -0
  144. package/dist/charts-react/Picture.mjs +22 -0
  145. package/dist/charts-react/Reader.mjs +147 -0
  146. package/dist/charts-react/bucket-names.mjs +29 -0
  147. package/dist/charts-react/chart-unlayered.css +1 -0
  148. package/dist/charts-react/chart-unlayered.css.d.ts +1 -0
  149. package/dist/charts-react/chart.css +1 -0
  150. package/dist/charts-react/chart.css.d.ts +1 -0
  151. package/dist/charts-react/events.mjs +72 -0
  152. package/dist/charts-react/exact-sum.mjs +24 -0
  153. package/dist/charts-react/from-answer.mjs +185 -0
  154. package/dist/charts-react/index.d.mts +3 -0
  155. package/dist/charts-react/index.mjs +4 -0
  156. package/dist/charts-react/keys.mjs +117 -0
  157. package/dist/charts-react/opens.mjs +28 -0
  158. package/dist/charts-react/plan-bars.mjs +95 -0
  159. package/dist/charts-react/plan-funnel.mjs +120 -0
  160. package/dist/charts-react/plan-grid.mjs +121 -0
  161. package/dist/charts-react/plan-parts.d.mts +2 -0
  162. package/dist/charts-react/plan-parts.mjs +30 -0
  163. package/dist/charts-react/plan-time.mjs +84 -0
  164. package/dist/charts-react/plan.d.mts +3 -0
  165. package/dist/charts-react/plan.mjs +37 -0
  166. package/dist/charts-react/point-keys.mjs +22 -0
  167. package/dist/charts-react/pointer.mjs +99 -0
  168. package/dist/charts-react/reader-page.d.mts +8 -0
  169. package/dist/charts-react/reader-page.mjs +116 -0
  170. package/dist/charts-react/tiles.d.mts +24 -0
  171. package/dist/charts-react/tiles.mjs +142 -0
  172. package/dist/charts-react/tip-place.mjs +107 -0
  173. package/dist/charts-react/tip-room.mjs +31 -0
  174. package/dist/charts-react/useClientLayoutEffect.mjs +8 -0
  175. package/dist/charts-react/useScene.mjs +76 -0
  176. package/dist/charts-react/useSize.mjs +44 -0
  177. package/dist/charts-react/useStop.mjs +68 -0
  178. package/dist/core/conformance/memory/aggregate.mjs +2 -1
  179. package/dist/core/conformance/memory/rows.mjs +1 -1
  180. package/dist/core/conformance/memory/source.mjs +3 -2
  181. package/dist/core/document/display-comparisons.mjs +49 -0
  182. package/dist/core/document/display-entries.mjs +2 -1
  183. package/dist/core/document/display-validation.d.mts +12 -0
  184. package/dist/core/document/display-validation.mjs +56 -0
  185. package/dist/core/document/display.d.mts +27 -12
  186. package/dist/core/document/display.mjs +40 -49
  187. package/dist/core/document/view-layout.mjs +16 -0
  188. package/dist/core/engine/access.mjs +4 -2
  189. package/dist/core/engine/context.mjs +5 -7
  190. package/dist/core/engine/custom/cells.mjs +1 -1
  191. package/dist/core/engine/custom/records.mjs +2 -1
  192. package/dist/core/engine/dialect.d.mts +2 -0
  193. package/dist/core/engine/index.mjs +1 -1
  194. package/dist/core/engine/levels.mjs +33 -1
  195. package/dist/core/engine/plan.d.mts +2 -0
  196. package/dist/core/engine/postgres.mjs +1 -0
  197. package/dist/core/engine/rank.mjs +1 -1
  198. package/dist/core/engine/reader.d.mts +4 -0
  199. package/dist/core/engine/sql-partition.mjs +45 -0
  200. package/dist/core/engine/sql-reads.mjs +4 -1
  201. package/dist/core/engine/statement.mjs +4 -4
  202. package/dist/core/engine/version.d.mts +1 -1
  203. package/dist/core/engine/version.mjs +1 -1
  204. package/dist/core/error/codes.d.mts +1 -1
  205. package/dist/core/error/codes.mjs +1 -1
  206. package/dist/core/exact/decimal.d.mts +1 -4
  207. package/dist/core/exact/decimal.mjs +1 -14
  208. package/dist/core/exact/text.d.mts +5 -0
  209. package/dist/core/exact/text.mjs +19 -0
  210. package/dist/core/index.d.mts +9 -6
  211. package/dist/core/index.mjs +11 -8
  212. package/dist/core/model/types.d.mts +2 -0
  213. package/dist/core/model/validate/fields.mjs +1 -1
  214. package/dist/core/model/validate/known-members.mjs +2 -0
  215. package/dist/core/model/validate/shape.mjs +5 -1
  216. package/dist/core/oracle/visibility.mjs +2 -2
  217. package/dist/core/policy/bind.mjs +29 -1
  218. package/dist/core/query/drill/compose.d.mts +2 -0
  219. package/dist/core/query/drill/compose.mjs +1 -1
  220. package/dist/core/query/drill/synthetic.mjs +2 -1
  221. package/dist/core/query/drill/types.d.mts +7 -0
  222. package/dist/core/query/drill/types.mjs +3 -1
  223. package/dist/core/result/number.mjs +2 -1
  224. package/dist/core/result/time-axis.mjs +2 -1
  225. package/dist/core/schema/answers.d.mts +1176 -362
  226. package/dist/core/schema/commands.mjs +2 -1
  227. package/dist/core/schema/document.mjs +27 -2
  228. package/dist/core/schema/drill-answers.mjs +19 -1
  229. package/dist/core/schema/drill.d.mts +21 -6
  230. package/dist/core/schema/drill.mjs +7 -1
  231. package/dist/core/schema/index.d.mts +2 -1
  232. package/dist/core/schema/index.mjs +2 -1
  233. package/dist/core/schema/null-ops.d.mts +6 -0
  234. package/dist/core/schema/null-ops.mjs +18 -0
  235. package/dist/core/schema/query.mjs +30 -4
  236. package/dist/core/schema/tools.mjs +13 -0
  237. package/dist/core/schema/union-error.mjs +38 -0
  238. package/dist/core/time/bucket.mjs +2 -1
  239. package/dist/core/time/index.d.mts +3 -2
  240. package/dist/core/time/instant.d.mts +1 -2
  241. package/dist/core/time/instant.mjs +2 -30
  242. package/dist/core/time/range.mjs +2 -1
  243. package/dist/core/time/stored.mjs +2 -1
  244. package/dist/core/time/text-time.d.mts +10 -0
  245. package/dist/core/time/text-time.mjs +80 -0
  246. package/dist/core/types/api.d.mts +1 -1
  247. package/dist/core/types/api.mjs +1 -1
  248. package/dist/core/types/drill-api.d.mts +22 -2
  249. package/dist/dashboard-documents.d.mts +8 -0
  250. package/dist/dashboard-documents.mjs +52 -0
  251. package/dist/drill-access.mjs +40 -3
  252. package/dist/drill-comparison.mjs +71 -0
  253. package/dist/drill-crumbs.mjs +21 -2
  254. package/dist/drill-group-seal.mjs +13 -0
  255. package/dist/drill-open.mjs +7 -1
  256. package/dist/drill-seal.mjs +4 -6
  257. package/dist/drill-views.mjs +5 -13
  258. package/dist/drill.mjs +28 -58
  259. package/dist/editing.mjs +1 -1
  260. package/dist/endpoints/drill.mjs +2 -3
  261. package/dist/endpoints/index.d.mts +20 -0
  262. package/dist/index.d.mts +2 -1
  263. package/dist/index.mjs +6 -27
  264. package/dist/llms.txt +1 -1
  265. package/dist/react/Cell.mjs +2 -2
  266. package/dist/react/DashboardList.mjs +3 -3
  267. package/dist/react/Editing.mjs +3 -3
  268. package/dist/react/Header.mjs +2 -2
  269. package/dist/react/History.mjs +3 -3
  270. package/dist/react/Parts.mjs +2 -2
  271. package/dist/react/RowBody.d.mts +2 -4
  272. package/dist/react/RowBody.mjs +14 -39
  273. package/dist/react/Tile.mjs +4 -5
  274. package/dist/react/builder/FilterEditor.mjs +2 -2
  275. package/dist/react/builder/Picker.mjs +3 -3
  276. package/dist/react/builder/RangeEditor.mjs +3 -3
  277. package/dist/react/builder/Time.mjs +3 -3
  278. package/dist/react/builder/Values.mjs +2 -2
  279. package/dist/react/builder/WidgetBuilder.mjs +2 -2
  280. package/dist/react/digits.mjs +1 -1
  281. package/dist/react/drill/Bars.mjs +34 -38
  282. package/dist/react/drill/Comparison.mjs +204 -0
  283. package/dist/react/drill/Controls.mjs +8 -12
  284. package/dist/react/drill/DrillDrawer.mjs +42 -0
  285. package/dist/react/drill/DrillPanel.mjs +61 -41
  286. package/dist/react/drill/Header.mjs +65 -35
  287. package/dist/react/drill/ItemLink.mjs +40 -0
  288. package/dist/react/drill/Items.d.mts +2 -1
  289. package/dist/react/drill/Items.mjs +126 -99
  290. package/dist/react/drill/ItemsBody.mjs +38 -0
  291. package/dist/react/drill/ItemsFoot.mjs +24 -19
  292. package/dist/react/drill/Notes.mjs +23 -13
  293. package/dist/react/drill/PanelBody.mjs +7 -25
  294. package/dist/react/drill/RecordRow.mjs +47 -0
  295. package/dist/react/drill/Trend.mjs +186 -0
  296. package/dist/react/drill/board.mjs +21 -11
  297. package/dist/react/drill/drawer-context.mjs +5 -0
  298. package/dist/react/drill/item-parts.mjs +53 -35
  299. package/dist/react/drill/item-type.d.mts +2 -2
  300. package/dist/react/drill/lazy.d.mts +1 -4
  301. package/dist/react/drill/lazy.mjs +29 -11
  302. package/dist/react/drill/panel-focus.mjs +18 -7
  303. package/dist/react/drill/props.d.mts +7 -1
  304. package/dist/react/drill/props.mjs +39 -8
  305. package/dist/react/drill/record-page.mjs +61 -0
  306. package/dist/react/drill/state.mjs +17 -2
  307. package/dist/react/drill/trend-touch.mjs +33 -0
  308. package/dist/react/drill/useDrill.d.mts +3 -3
  309. package/dist/react/drill/useDrill.mjs +35 -15
  310. package/dist/react/drill/words.d.mts +14 -0
  311. package/dist/react/drill/words.mjs +20 -8
  312. package/dist/react/english.d.mts +4 -1
  313. package/dist/react/english.mjs +17 -2
  314. package/dist/react/filters/chip.mjs +2 -2
  315. package/dist/react/filters/menu-search.mjs +5 -5
  316. package/dist/react/filters/menu.mjs +2 -2
  317. package/dist/react/filters/number.mjs +2 -2
  318. package/dist/react/filters/operator.mjs +2 -2
  319. package/dist/react/filters/phone.mjs +2 -2
  320. package/dist/react/filters/values.mjs +4 -4
  321. package/dist/react/format-time.d.mts +2 -1
  322. package/dist/react/format-time.mjs +42 -34
  323. package/dist/react/format.mjs +15 -3
  324. package/dist/react/index.d.mts +4 -3
  325. package/dist/react/index.mjs +4 -3
  326. package/dist/react/messages.d.mts +23 -2
  327. package/dist/react/renderers/entries.d.mts +11 -0
  328. package/dist/react/renderers/list.mjs +8 -10
  329. package/dist/react/renderers/table-cells.mjs +38 -9
  330. package/dist/react/renderers/table-measure.mjs +2 -0
  331. package/dist/react/renderers/table-row.mjs +64 -7
  332. package/dist/react/renderers/table-sort.mjs +2 -8
  333. package/dist/react/renderers/table.mjs +16 -15
  334. package/dist/react/series.mjs +8 -3
  335. package/dist/react/theme-unlayered.css +1 -3144
  336. package/dist/react/theme.css +1 -3146
  337. package/dist/recharts/parts.mjs +1 -1
  338. package/dist/skills/derive-dashboards/SKILL.md +10 -5
  339. package/dist/store/apply.mjs +2 -2
  340. package/dist/store/editor.mjs +2 -2
  341. package/dist/store/writer.mjs +2 -2
  342. package/package.json +27 -2
@@ -0,0 +1,253 @@
1
+ import { MUTED } from "../scene/paint.mjs";
2
+ import { firstFree } from "../layout/boxes.mjs";
3
+ import { fitOrNone, fitText } from "../text/measure.mjs";
4
+ import { LINE, MARK, TEXT } from "../theme.mjs";
5
+ // src/marks/notes.ts
6
+ /**
7
+ * Room between a line and its name, and between a name and the plot's edge: four pixels, so the
8
+ * words sit by their line without touching its dashes.
9
+ */
10
+ const OFF = 4;
11
+ /** The height of a line of names, and how many lines down a name may move to clear another. */
12
+ const NOTE_LINE = LINE.tick;
13
+ const LINES = 4;
14
+ /**
15
+ * How far apart a line is traced, along its own length (a steep stretch as closely as a level
16
+ * one), so no name fits between two places on it.
17
+ */
18
+ const TRACE = 6;
19
+ /**
20
+ * The places along a line through some points, in order, broken where a point is missing:
21
+ * each point, and the stretch from it to the next. What a level's name keeps clear of where
22
+ * it can (`NoteRoom.lines`), so it does not sit on the data.
23
+ */
24
+ function alongLine(points) {
25
+ return points.flatMap((here, i) => {
26
+ const next = points[i + 1];
27
+ if (here === void 0) return [];
28
+ if (next === void 0) return [{
29
+ x: here.x,
30
+ y: here.y,
31
+ r: MARK.line
32
+ }];
33
+ const steps = Math.max(1, Math.ceil(Math.hypot(next.x - here.x, next.y - here.y) / TRACE));
34
+ return Array.from({ length: steps }, (_step, k) => ({
35
+ x: here.x + (next.x - here.x) * k / steps,
36
+ y: here.y + (next.y - here.y) * k / steps,
37
+ r: MARK.line
38
+ }));
39
+ });
40
+ }
41
+ /** Where names may go: the plot, grown up by its lane and out to its sides. */
42
+ function boundsOf(room) {
43
+ const { plot } = room;
44
+ const lane = room.lane ?? 0;
45
+ const min = room.sides?.min ?? plot.x;
46
+ const max = room.sides?.max ?? plot.x + plot.width;
47
+ return {
48
+ x: min,
49
+ y: plot.y - lane,
50
+ width: max - min,
51
+ height: plot.height + lane
52
+ };
53
+ }
54
+ /** The least room a name is worth cutting to: two letters and an ellipsis. */
55
+ const LEAST_NAME = 20;
56
+ /**
57
+ * A line's words for a width. A level's value is never cut (a number cut short reads as another
58
+ * number): its name is cut to the room the value leaves, and left out when that is too little to
59
+ * say anything, so the value stands alone; a value with no room is not written. A moment has
60
+ * a name alone, cut to the width.
61
+ */
62
+ function wordsFor({ name, value }, width, { measure }) {
63
+ if (value === void 0) return fitText(name, width, TEXT.tick, measure);
64
+ const whole = `${name} ${value}`;
65
+ if (measure(whole, TEXT.tick) <= width) return whole;
66
+ if (measure(value, TEXT.tick) > width) return "";
67
+ const after = ` ${value}`;
68
+ const left = width - measure(after, TEXT.tick);
69
+ const kept = fitOrNone(name, {
70
+ width: left,
71
+ least: LEAST_NAME,
72
+ font: TEXT.tick,
73
+ measure
74
+ });
75
+ return kept === void 0 ? value : `${kept}${after}`;
76
+ }
77
+ /** A line's words cut to a width, and how wide they then are. */
78
+ function cut(words, width, room) {
79
+ const text = wordsFor(words, width, room);
80
+ return {
81
+ text,
82
+ width: room.measure(text, TEXT.tick)
83
+ };
84
+ }
85
+ /** The places a name may take: none when there is nothing to write, so its line stands unnamed. */
86
+ const spotsFor = (text, spots) => text === "" ? [] : spots;
87
+ /** A spot for a name of a width, its left edge at `left`, set from its left or its right end. */
88
+ const spot = (left, top, at) => ({
89
+ box: {
90
+ x: left,
91
+ y: top,
92
+ width: at.width,
93
+ height: TEXT.tick.size
94
+ },
95
+ x: at.end ? left + at.width : left,
96
+ anchor: at.end ? "end" : "start"
97
+ });
98
+ /** Whether a place is on the plot's stretch; a place that is not a number is nowhere. */
99
+ const within = (place, from, length) => place >= from && place <= from + length;
100
+ /** A dashed level line for each reference value on the axis, named above or below either end. */
101
+ function levelNotes(references, at, room) {
102
+ const { plot } = room;
103
+ return references.flatMap((reference) => {
104
+ const y = at.place(reference.value);
105
+ if (!within(y, plot.y, plot.height)) return [];
106
+ const { text, width } = cut({
107
+ name: reference.label,
108
+ value: at.text(reference.value)
109
+ }, plot.width - 8, room);
110
+ const above = y - OFF - TEXT.tick.size;
111
+ const below = y + OFF;
112
+ const left = plot.x + OFF;
113
+ const right = plot.x + plot.width - OFF - width;
114
+ const spots = spotsFor(text, [
115
+ spot(left, above, {
116
+ width,
117
+ end: false
118
+ }),
119
+ spot(left, below, {
120
+ width,
121
+ end: false
122
+ }),
123
+ spot(right, above, {
124
+ width,
125
+ end: true
126
+ }),
127
+ spot(right, below, {
128
+ width,
129
+ end: true
130
+ })
131
+ ]);
132
+ return [{
133
+ part: "reference",
134
+ dash: MARK.dash,
135
+ upright: false,
136
+ at: y,
137
+ text,
138
+ spots
139
+ }];
140
+ });
141
+ }
142
+ /** An upright line at `x`: named at its top, on the side with more room, moving down to clear. */
143
+ function upright(mark, room) {
144
+ const { plot } = room;
145
+ if (!within(mark.x, plot.x, plot.width)) return [];
146
+ const bounds = boundsOf(room);
147
+ const rightward = mark.x <= bounds.x + bounds.width / 2;
148
+ const space = rightward ? bounds.x + bounds.width - mark.x - OFF : mark.x - OFF - bounds.x;
149
+ const { text, width } = cut(mark.words, space, room);
150
+ const top = room.lane === void 0 ? plot.y + OFF / 2 : plot.y - room.lane;
151
+ const after = (line) => spot(mark.x + OFF, top + line * NOTE_LINE, {
152
+ width,
153
+ end: false
154
+ });
155
+ const before = (line) => spot(mark.x - OFF - width, top + line * NOTE_LINE, {
156
+ width,
157
+ end: true
158
+ });
159
+ const spots = Array.from({ length: LINES }, (_v, line) => rightward ? [after(line), before(line)] : [before(line), after(line)]).flat();
160
+ const dash = mark.part === "event" ? MARK.moment : MARK.dash;
161
+ return [{
162
+ part: mark.part,
163
+ dash,
164
+ upright: true,
165
+ at: mark.x,
166
+ text,
167
+ spots: spotsFor(text, spots)
168
+ }];
169
+ }
170
+ /** A dashed upright line for each reference value on an axis along the bottom. */
171
+ function uprightNotes(references, at, room) {
172
+ return references.flatMap((reference) => {
173
+ const words = {
174
+ name: reference.label,
175
+ value: at.text(reference.value)
176
+ };
177
+ return upright({
178
+ x: at.place(reference.value),
179
+ words,
180
+ part: "reference"
181
+ }, room);
182
+ });
183
+ }
184
+ /** A dotted upright hairline at each moment inside the plot. */
185
+ function eventNotes(events, at, room) {
186
+ return events.flatMap((event) => upright({
187
+ x: at.x(event.at),
188
+ words: { name: event.label },
189
+ part: "event"
190
+ }, room));
191
+ }
192
+ /** A note's line: across the plot, an upright one reaching up to its name when that sits above. */
193
+ function lineOf(note, plot, name) {
194
+ const top = name === void 0 ? plot.y : Math.min(plot.y, name.box.y);
195
+ const ends = note.upright ? {
196
+ x1: note.at,
197
+ x2: note.at,
198
+ y1: top,
199
+ y2: plot.y + plot.height
200
+ } : {
201
+ x1: plot.x,
202
+ x2: plot.x + plot.width,
203
+ y1: note.at,
204
+ y2: note.at
205
+ };
206
+ return {
207
+ kind: "line",
208
+ part: note.part,
209
+ ...ends,
210
+ stroke: MUTED,
211
+ dash: note.dash
212
+ };
213
+ }
214
+ /** The notes drawn: every line, and each name in the first of its places that touches nothing. */
215
+ function marked(notes, room) {
216
+ const bounds = boundsOf(room);
217
+ const taken = [...room.taken ?? []];
218
+ const dots = room.dots ?? [];
219
+ const along = room.lines ?? [];
220
+ const lines = [];
221
+ const names = [];
222
+ for (const note of notes) {
223
+ const found = firstFree(note.spots, (s) => s.box, {
224
+ bounds,
225
+ taken,
226
+ dots: [...dots, ...along]
227
+ }) ?? firstFree(note.spots, (s) => s.box, {
228
+ bounds,
229
+ taken,
230
+ dots
231
+ });
232
+ lines.push(lineOf(note, room.plot, found));
233
+ if (found === void 0) continue;
234
+ taken.push(found.box);
235
+ names.push({
236
+ kind: "text",
237
+ part: note.part,
238
+ x: found.x,
239
+ y: found.box.y + TEXT.tick.size / 2,
240
+ text: note.text,
241
+ ...TEXT.tick,
242
+ anchor: found.anchor,
243
+ baseline: "middle",
244
+ halo: true
245
+ });
246
+ }
247
+ return {
248
+ lines,
249
+ names,
250
+ taken
251
+ };
252
+ }
253
+ export { NOTE_LINE, alongLine, eventNotes, levelNotes, marked, uprightNotes };
@@ -0,0 +1,110 @@
1
+ import { follows, running, starting } from "../data/buckets.mjs";
2
+ import { MARK } from "../theme.mjs";
3
+ import { dot, widestReach } from "./dot.mjs";
4
+ import { alone, areaPath, broken, lastOf, linePath } from "./lines.mjs";
5
+ import { thinned } from "./thin.mjs";
6
+ // src/marks/series-line.ts
7
+ /** The radius of the dot at a line's end. */
8
+ const END = 3.5;
9
+ /** How far the dot at a line's end reaches past the line's last point, filled or hollow. */
10
+ const END_REACH = widestReach(END);
11
+ /** The radius of a point that stands alone between two gaps: a little less than a line's end, which it is not. */
12
+ const LONE = 3;
13
+ /** Each value's point, by its bucket's place; nothing where there is no value. */
14
+ function pointsOf(values, at) {
15
+ return at.buckets.map((_bucket, i) => {
16
+ const value = values[i] ?? null;
17
+ return value === null ? void 0 : {
18
+ x: at.center(i),
19
+ y: at.place(value)
20
+ };
21
+ });
22
+ }
23
+ /** The line in its parts: what is final, and the dotted steps at an end that is not whole. */
24
+ function parted(points, buckets) {
25
+ const first = points.findIndex((p) => p !== void 0);
26
+ const last = points.findLastIndex((p) => p !== void 0);
27
+ const open = last !== -1 && running(buckets[last]);
28
+ const stepsIn = first !== -1 && first !== last && starting(buckets[first]) && follows(buckets, first + 1) && points[first + 1] !== void 0;
29
+ const whole = points.map((p, i) => open && i === last || stepsIn && i === first ? void 0 : p);
30
+ return {
31
+ settled: thinned(broken(whole, buckets)),
32
+ open,
33
+ head: stepsIn ? [points[first], points[first + 1]] : [],
34
+ tail: open && follows(buckets, last) ? [points[last - 1], points[last]] : []
35
+ };
36
+ }
37
+ /** The marks of one series' line. */
38
+ function seriesLine(series, at, look) {
39
+ const points = pointsOf(series.values, at);
40
+ const parts = parted(points, at.buckets);
41
+ const quiet = look.quiet === true;
42
+ const path = (d, dash) => d === "" ? [] : [{
43
+ kind: "path",
44
+ part: "line",
45
+ d,
46
+ stroke: look.color,
47
+ strokeWidth: quiet ? MARK.context : MARK.line,
48
+ ...dash === void 0 ? {} : { dash }
49
+ }];
50
+ return [
51
+ ...wash(thinned(broken(points, at.buckets)), look),
52
+ ...ghost(series, at, look),
53
+ ...path(linePath(parts.settled, look.curve)),
54
+ ...path(linePath(parts.head, "straight"), MARK.step),
55
+ ...path(linePath(parts.tail, "straight"), MARK.step),
56
+ ...dots(quiet ? [] : alone(parts.settled), look.color),
57
+ ...endDot(quiet ? void 0 : lastOf(points)?.at, {
58
+ color: look.color,
59
+ open: parts.open
60
+ })
61
+ ];
62
+ }
63
+ function wash(points, look) {
64
+ if (look.washTo === void 0) return [];
65
+ const d = areaPath(points, look.washTo, look.curve);
66
+ return d === "" ? [] : [{
67
+ kind: "path",
68
+ part: "wash",
69
+ d,
70
+ fill: {
71
+ fade: look.color,
72
+ from: MARK.wash,
73
+ to: 0
74
+ }
75
+ }];
76
+ }
77
+ /** The comparison period, place for place, behind the line. */
78
+ function ghost(series, at, look) {
79
+ if (series.previous === void 0) return [];
80
+ const before = thinned(broken(pointsOf(series.previous, at), at.buckets));
81
+ const d = linePath(before, look.curve);
82
+ return d === "" ? [] : [{
83
+ kind: "path",
84
+ part: "before",
85
+ d,
86
+ stroke: look.color,
87
+ strokeWidth: MARK.context,
88
+ dash: MARK.before,
89
+ opacity: MARK.faint
90
+ }];
91
+ }
92
+ /** A point with no neighbour to join to: a small dot, so one value between two gaps still shows. */
93
+ const dots = (points, color) => points.map((p) => dot({
94
+ ...p,
95
+ r: LONE,
96
+ color,
97
+ part: "dot"
98
+ }));
99
+ /** The dot at the line's end: filled when its value is final, hollow while its period runs. */
100
+ function endDot(at, look) {
101
+ if (at === void 0) return [];
102
+ return [dot({
103
+ ...at,
104
+ r: END,
105
+ color: look.color,
106
+ hollow: look.open,
107
+ part: "end"
108
+ })];
109
+ }
110
+ export { END_REACH, pointsOf, seriesLine };
@@ -0,0 +1,138 @@
1
+ // src/marks/thin.ts
2
+ /** The pixel column a thing stands in. */
3
+ const columnOf = (item, read) => Math.floor(read.x(item));
4
+ /** The runs of things between breaks, in order. */
5
+ function runsIn(items) {
6
+ const runs = [];
7
+ let run = [];
8
+ for (const item of items) if (item !== void 0) run.push(item);
9
+ else if (run.length > 0) {
10
+ runs.push(run);
11
+ run = [];
12
+ }
13
+ return run.length > 0 ? [...runs, run] : runs;
14
+ }
15
+ /** The places of the least and the most of one height, among a run's things from one place to another. */
16
+ function reach(run, span, y) {
17
+ let low = span.from;
18
+ let high = span.from;
19
+ let [least, most] = [Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY];
20
+ for (let i = span.from; i < span.to; i++) {
21
+ const item = run[i];
22
+ const at = item === void 0 ? NaN : y(item);
23
+ if (at < least) [low, least] = [i, at];
24
+ if (at > most) [high, most] = [i, at];
25
+ }
26
+ return [low, high];
27
+ }
28
+ /** The first and the last of a run's things from one place to another, and the least and the most of each height, in their order. */
29
+ function extremes(run, span, read) {
30
+ if (span.to - span.from <= 2) return run.slice(span.from, span.to);
31
+ const picks = [span.from, span.to - 1];
32
+ for (const y of read.ys) picks.push(...reach(run, span, y));
33
+ picks.sort((a, b) => a - b);
34
+ const kept = [];
35
+ let previous = -1;
36
+ for (const at of picks) {
37
+ if (at === previous) continue;
38
+ previous = at;
39
+ const item = run[at];
40
+ if (item !== void 0) kept.push(item);
41
+ }
42
+ return kept;
43
+ }
44
+ /** A run with each pixel column's things thinned to its first, least, most and last. */
45
+ function thinnedRun(run, read) {
46
+ const out = [];
47
+ let from = 0;
48
+ for (let to = 1; to <= run.length; to++) {
49
+ const [first, next] = [run[from], run[to]];
50
+ if (first !== void 0 && next !== void 0 && columnOf(next, read) === columnOf(first, read)) continue;
51
+ out.push(...extremes(run, {
52
+ from,
53
+ to
54
+ }, read));
55
+ from = to;
56
+ }
57
+ return out;
58
+ }
59
+ /** The pixel column a run begins and ends in; none for a run that goes from one column to another. */
60
+ function within(run, read) {
61
+ const [first, last] = [run[0], run.at(-1)];
62
+ if (first === void 0 || last === void 0) return void 0;
63
+ const column = columnOf(first, read);
64
+ return column === columnOf(last, read) ? column : void 0;
65
+ }
66
+ /**
67
+ * Of some runs inside one pixel column, those that reach lowest and highest at each height (a
68
+ * line's one, a band's two edges), in their order.
69
+ */
70
+ function reaching(runs, read) {
71
+ if (runs.length <= 2) return [...runs];
72
+ const kept = /* @__PURE__ */ new Set();
73
+ for (const y of read.ys) {
74
+ const least = (run) => Math.min(...run.map((item) => y(item)));
75
+ const most = (run) => Math.max(...run.map((item) => y(item)));
76
+ kept.add(runs.reduce((best, run) => least(run) < least(best) ? run : best));
77
+ kept.add(runs.reduce((best, run) => most(run) > most(best) ? run : best));
78
+ }
79
+ return runs.filter((run) => kept.has(run));
80
+ }
81
+ /**
82
+ * The runs a picture can show. Only a series with two gaps inside one pixel has runs that begin
83
+ * and end in one column: of those, the ones reaching lowest and highest are kept, so the column
84
+ * still shows how far its values reach and holds no more than a few marks.
85
+ */
86
+ function shown(runs, read) {
87
+ const out = [];
88
+ let inside = [];
89
+ let column;
90
+ for (const run of runs) {
91
+ const own = within(run, read);
92
+ if (own === void 0 || own !== column) {
93
+ out.push(...reaching(inside, read));
94
+ inside = [];
95
+ }
96
+ column = own;
97
+ if (own === void 0) out.push(run);
98
+ else inside.push(run);
99
+ }
100
+ return [...out, ...reaching(inside, read)];
101
+ }
102
+ /** Things in their order across, a break (nothing) between two runs, thinned to what the pixels can show. */
103
+ function thin(items, read) {
104
+ return shown(runsIn(items).map((run) => thinnedRun(run, read)), read).flatMap((run, i) => i === 0 ? run : [void 0, ...run]);
105
+ }
106
+ const POINT = {
107
+ x: (point) => point.x,
108
+ ys: [(point) => point.y]
109
+ };
110
+ /**
111
+ * The points a path is drawn through, for points in their order across with a break (nothing)
112
+ * wherever a line stops: in each pixel column each unbroken piece keeps its first, least, most
113
+ * and last points. A line with no more than two points to a pixel column comes back whole.
114
+ */
115
+ const thinned = (points) => thin(points, POINT);
116
+ const EDGES = {
117
+ x: (place) => place.top.x,
118
+ ys: [(place) => place.top.y, (place) => place.bottom.y]
119
+ };
120
+ /**
121
+ * A band's two edges, place for place, thinned together so they still pair: in each pixel
122
+ * column each unbroken piece keeps its first and last places and the least and the most of
123
+ * each edge. A place where either edge is missing is a break.
124
+ */
125
+ function thinnedBand(top, bottom) {
126
+ const kept = thin(top.map((upper, i) => {
127
+ const lower = bottom[i];
128
+ return upper === void 0 || lower === void 0 ? void 0 : {
129
+ top: upper,
130
+ bottom: lower
131
+ };
132
+ }), EDGES);
133
+ return {
134
+ top: kept.map((place) => place?.top),
135
+ bottom: kept.map((place) => place?.bottom)
136
+ };
137
+ }
138
+ export { thinned, thinnedBand };
@@ -0,0 +1,32 @@
1
+ import { RULE } from "../scene/paint.mjs";
2
+ import { TEXT } from "../theme.mjs";
3
+ import { tickTexts, tickUnder, writtenOf } from "./axes.mjs";
4
+ // src/marks/x-axis.ts
5
+ /** The ticks whose numbers are written, left to right, by the rule of every value axis (`writtenOf`). */
6
+ function writtenTicks(axis, at) {
7
+ const tick = tickTexts(axis, at.reads);
8
+ const named = axis.ticks.map((value) => ({
9
+ x: at.place(value),
10
+ text: tick(value)
11
+ }));
12
+ return writtenOf(named, {
13
+ place: (one) => one.x,
14
+ half: (one) => at.measure(one.text, TEXT.tick) / 2,
15
+ min: at.min,
16
+ max: at.max
17
+ });
18
+ }
19
+ /** An upright hairline at each tick, and the numbers that fit under the plot. */
20
+ function xGrid(axis, at) {
21
+ const { plot, place } = at;
22
+ return [...axis.ticks.map((value) => ({
23
+ kind: "line",
24
+ part: "grid",
25
+ x1: place(value),
26
+ x2: place(value),
27
+ y1: plot.y,
28
+ y2: plot.y + plot.height,
29
+ stroke: RULE
30
+ })), ...writtenTicks(axis, at).map((tick) => tickUnder(tick, plot))];
31
+ }
32
+ export { xGrid };
@@ -0,0 +1,174 @@
1
+ import { said } from "../data/format.mjs";
2
+ // src/scale/calendar.ts
3
+ const DATE = /^(\d{4})-(\d{2})-(\d{2})$/u;
4
+ /** The calendar parts of each bucket, in the buckets' order. */
5
+ function partsOf(x) {
6
+ let zoned;
7
+ return x.buckets.map((bucket) => {
8
+ const date = dateParts(bucket.label);
9
+ if (date !== void 0) return date;
10
+ zoned ??= zonedParts(x.zone);
11
+ return zoned(bucket.from);
12
+ });
13
+ }
14
+ function dateParts(label) {
15
+ const found = DATE.exec(label);
16
+ if (found === null) return void 0;
17
+ const [year, month, day] = [
18
+ Number(found[1]),
19
+ Number(found[2]),
20
+ Number(found[3])
21
+ ];
22
+ return {
23
+ year,
24
+ month,
25
+ day,
26
+ hour: 0,
27
+ weekday: asDate({
28
+ year,
29
+ month,
30
+ day,
31
+ hour: 0
32
+ }).getUTCDay()
33
+ };
34
+ }
35
+ /** Reads an instant's parts in a zone (UTC when none is given). */
36
+ function zonedParts(zone) {
37
+ const format = new Intl.DateTimeFormat("en-US", {
38
+ timeZone: zone ?? "UTC",
39
+ year: "numeric",
40
+ month: "numeric",
41
+ day: "numeric",
42
+ hour: "numeric",
43
+ hourCycle: "h23",
44
+ weekday: "short"
45
+ });
46
+ const days = [
47
+ "Sun",
48
+ "Mon",
49
+ "Tue",
50
+ "Wed",
51
+ "Thu",
52
+ "Fri",
53
+ "Sat"
54
+ ];
55
+ return (ms) => {
56
+ const parts = new Map(format.formatToParts(new Date(ms)).map((p) => [p.type, p.value]));
57
+ const number = (type) => Number(parts.get(type) ?? 0);
58
+ return {
59
+ year: number("year"),
60
+ month: number("month"),
61
+ day: number("day"),
62
+ hour: number("hour"),
63
+ weekday: days.indexOf(parts.get("weekday") ?? "Sun")
64
+ };
65
+ };
66
+ }
67
+ /** The parts as a date Intl can format: the wall time, held as if it were UTC. */
68
+ function asDate(p) {
69
+ const date = /* @__PURE__ */ new Date(0);
70
+ date.setUTCFullYear(p.year, p.month - 1, p.day);
71
+ date.setUTCHours(p.hour);
72
+ return date;
73
+ }
74
+ /** A writer of calendar parts in a locale; the runtime's own when left out. */
75
+ function dateWriter(locale) {
76
+ const made = /* @__PURE__ */ new Map();
77
+ const formatOf = (options) => {
78
+ const key = JSON.stringify(options);
79
+ const kept = made.get(key);
80
+ if (kept !== void 0) return kept;
81
+ const format = new Intl.DateTimeFormat(locale, {
82
+ ...options,
83
+ timeZone: "UTC"
84
+ });
85
+ made.set(key, format);
86
+ return format;
87
+ };
88
+ return {
89
+ text: (parts, options) => formatOf(options).format(asDate(parts)),
90
+ range: (from, to, options) => formatOf(options).formatRange(asDate(from), to)
91
+ };
92
+ }
93
+ /**
94
+ * A tick's label, as short as its neighbours allow: a day reads "4" after "Nov 3", a month
95
+ * "Feb" after "Jan 2026". `before` is the tick before it, when there is one.
96
+ */
97
+ function tickText(kind, at, write) {
98
+ const { parts, before } = at;
99
+ const newYear = before === void 0 || before.year !== parts.year;
100
+ const newMonth = newYear || before.month !== parts.month;
101
+ if (kind === "year") return write.text(parts, { year: "numeric" });
102
+ if (kind === "month") return write.text(parts, newYear ? {
103
+ month: "short",
104
+ year: "numeric"
105
+ } : { month: "short" });
106
+ if (kind === "day") return write.text(parts, newMonth ? {
107
+ month: "short",
108
+ day: "numeric"
109
+ } : { day: "numeric" });
110
+ return parts.hour === 0 ? write.text(parts, {
111
+ month: "short",
112
+ day: "numeric"
113
+ }) : write.text(parts, { hour: "numeric" });
114
+ }
115
+ const DAY = 864e5;
116
+ const TITLES = {
117
+ hour: {
118
+ month: "short",
119
+ day: "numeric",
120
+ hour: "numeric"
121
+ },
122
+ day: {
123
+ weekday: "short",
124
+ month: "short",
125
+ day: "numeric",
126
+ year: "numeric"
127
+ },
128
+ month: {
129
+ month: "long",
130
+ year: "numeric"
131
+ },
132
+ year: { year: "numeric" }
133
+ };
134
+ /**
135
+ * A bucket's whole name, for a tooltip: "Tue, Nov 3, 2026", "Nov 2 – 8, 2026" for a week,
136
+ * "Oct – Dec 2026" for a quarter.
137
+ */
138
+ function bucketTitle(bucket, at, write) {
139
+ const { parts, grain } = at;
140
+ if (grain !== "week" && grain !== "quarter") return write.text(parts, TITLES[grain]);
141
+ const end = grain === "week" ? new Date(asDate(parts).getTime() + 6 * DAY) : asDate({
142
+ ...parts,
143
+ month: parts.month + 2,
144
+ day: 1
145
+ });
146
+ const options = grain === "week" ? {
147
+ month: "short",
148
+ day: "numeric",
149
+ year: "numeric"
150
+ } : {
151
+ month: "short",
152
+ year: "numeric"
153
+ };
154
+ return bucket.to > bucket.from ? write.range(parts, end, options) : write.text(parts, options);
155
+ }
156
+ /**
157
+ * Every bucket's whole name, for a tooltip and a summary: the host's own for it when it gave
158
+ * one, else the calendar's, read from the bucket's label when that is a date and from its first
159
+ * instant when it is not.
160
+ */
161
+ function bucketTitles(x, locale) {
162
+ const parts = partsOf(x);
163
+ const write = dateWriter(locale);
164
+ return x.buckets.map((bucket, i) => {
165
+ const given = said(x.titles?.[i]);
166
+ if (given !== void 0) return given;
167
+ const own = parts[i];
168
+ return own === void 0 ? bucket.label : bucketTitle(bucket, {
169
+ parts: own,
170
+ grain: x.grain
171
+ }, write);
172
+ });
173
+ }
174
+ export { bucketTitles, dateWriter, partsOf, tickText };