@zsherman/charts 0.0.0-stage → 0.1.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 (180) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +373 -0
  3. package/README.md +13 -2
  4. package/THIRD_PARTY_NOTICES.md +33 -0
  5. package/dist/dom/bar-list/bar-list.js +386 -0
  6. package/dist/dom/bar-list/bar-list.styles.js +171 -0
  7. package/dist/dom/bar-list/index.js +1 -0
  8. package/dist/dom/chart/chart.js +716 -0
  9. package/dist/dom/chart/chart.styles.js +165 -0
  10. package/dist/dom/chart/index.js +1 -0
  11. package/dist/dom/chart-grid/chart-grid.js +67 -0
  12. package/dist/dom/chart-grid/index.js +1 -0
  13. package/dist/dom/donut/donut.js +565 -0
  14. package/dist/dom/donut/donut.styles.js +111 -0
  15. package/dist/dom/donut/index.js +1 -0
  16. package/dist/dom/heat-graph/calendar.js +118 -0
  17. package/dist/dom/heat-graph/heat-graph.js +423 -0
  18. package/dist/dom/heat-graph/heat-graph.styles.js +168 -0
  19. package/dist/dom/heat-graph/index.js +1 -0
  20. package/dist/dom/heat-matrix/heat-matrix.js +346 -0
  21. package/dist/dom/heat-matrix/heat-matrix.styles.js +155 -0
  22. package/dist/dom/heat-matrix/index.js +1 -0
  23. package/dist/dom/heat-matrix/model.js +41 -0
  24. package/dist/dom/index.js +13 -0
  25. package/dist/dom/internal/colors.js +44 -0
  26. package/dist/dom/internal/floating-tip.js +83 -0
  27. package/dist/dom/internal/format.js +43 -0
  28. package/dist/dom/internal/grid-context.js +5 -0
  29. package/dist/dom/internal/hidden.styles.js +16 -0
  30. package/dist/dom/internal/legend.js +112 -0
  31. package/dist/dom/internal/legend.styles.js +108 -0
  32. package/dist/dom/internal/markers.js +101 -0
  33. package/dist/dom/internal/options.js +300 -0
  34. package/dist/dom/internal/place.js +27 -0
  35. package/dist/dom/internal/scheme-watch.js +73 -0
  36. package/dist/dom/internal/share.js +28 -0
  37. package/dist/dom/internal/types.js +0 -0
  38. package/dist/dom/row-chart/index.js +1 -0
  39. package/dist/dom/row-chart/model.js +59 -0
  40. package/dist/dom/row-chart/row-chart.js +691 -0
  41. package/dist/dom/row-chart/row-chart.styles.js +242 -0
  42. package/dist/dom/segmented-bar/index.js +1 -0
  43. package/dist/dom/segmented-bar/segmented-bar.js +280 -0
  44. package/dist/dom/segmented-bar/segmented-bar.styles.js +88 -0
  45. package/dist/dom/sparkline/index.js +1 -0
  46. package/dist/dom/sparkline/sparkline.js +145 -0
  47. package/dist/dom/stacked-histogram/histogram.js +137 -0
  48. package/dist/dom/stacked-histogram/index.js +1 -0
  49. package/dist/dom/stacked-histogram/stacked-histogram.js +761 -0
  50. package/dist/dom/stacked-histogram/stacked-histogram.styles.js +211 -0
  51. package/dist/dom/state-timeline/index.js +1 -0
  52. package/dist/dom/state-timeline/model.js +166 -0
  53. package/dist/dom/state-timeline/state-timeline.js +729 -0
  54. package/dist/dom/state-timeline/state-timeline.styles.js +171 -0
  55. package/dist/dom/status-history/index.js +1 -0
  56. package/dist/dom/status-history/status-history.js +542 -0
  57. package/dist/dom/status-history/status-history.styles.js +171 -0
  58. package/dist/solid/bar-list/bar-list.jsx +139 -0
  59. package/dist/solid/bar-list/bar-list.styles.jsx +171 -0
  60. package/dist/solid/bar-list/index.jsx +1 -0
  61. package/dist/solid/chart/chart.jsx +454 -0
  62. package/dist/solid/chart/chart.styles.jsx +165 -0
  63. package/dist/solid/chart/index.jsx +1 -0
  64. package/dist/solid/chart-grid/chart-grid.jsx +46 -0
  65. package/dist/solid/chart-grid/index.jsx +1 -0
  66. package/dist/solid/donut/donut.jsx +291 -0
  67. package/dist/solid/donut/donut.styles.jsx +111 -0
  68. package/dist/solid/donut/index.jsx +1 -0
  69. package/dist/solid/heat-graph/calendar.jsx +118 -0
  70. package/dist/solid/heat-graph/heat-graph.jsx +228 -0
  71. package/dist/solid/heat-graph/heat-graph.styles.jsx +168 -0
  72. package/dist/solid/heat-graph/index.jsx +1 -0
  73. package/dist/solid/heat-matrix/heat-matrix.jsx +165 -0
  74. package/dist/solid/heat-matrix/heat-matrix.styles.jsx +155 -0
  75. package/dist/solid/heat-matrix/index.jsx +1 -0
  76. package/dist/solid/heat-matrix/model.jsx +41 -0
  77. package/dist/solid/index.jsx +13 -0
  78. package/dist/solid/internal/colors.jsx +44 -0
  79. package/dist/solid/internal/floating-tip.jsx +68 -0
  80. package/dist/solid/internal/format.jsx +43 -0
  81. package/dist/solid/internal/grid-context.jsx +5 -0
  82. package/dist/solid/internal/hidden.styles.jsx +16 -0
  83. package/dist/solid/internal/legend.jsx +35 -0
  84. package/dist/solid/internal/legend.styles.jsx +108 -0
  85. package/dist/solid/internal/markers.jsx +101 -0
  86. package/dist/solid/internal/options.jsx +300 -0
  87. package/dist/solid/internal/place.jsx +27 -0
  88. package/dist/solid/internal/scheme-watch.jsx +73 -0
  89. package/dist/solid/internal/share.jsx +28 -0
  90. package/dist/solid/internal/types.jsx +0 -0
  91. package/dist/solid/row-chart/index.jsx +1 -0
  92. package/dist/solid/row-chart/model.jsx +59 -0
  93. package/dist/solid/row-chart/row-chart.jsx +312 -0
  94. package/dist/solid/row-chart/row-chart.styles.jsx +242 -0
  95. package/dist/solid/segmented-bar/index.jsx +1 -0
  96. package/dist/solid/segmented-bar/segmented-bar.jsx +125 -0
  97. package/dist/solid/segmented-bar/segmented-bar.styles.jsx +88 -0
  98. package/dist/solid/sparkline/index.jsx +1 -0
  99. package/dist/solid/sparkline/sparkline.jsx +88 -0
  100. package/dist/solid/stacked-histogram/histogram.jsx +137 -0
  101. package/dist/solid/stacked-histogram/index.jsx +1 -0
  102. package/dist/solid/stacked-histogram/stacked-histogram.jsx +381 -0
  103. package/dist/solid/stacked-histogram/stacked-histogram.styles.jsx +211 -0
  104. package/dist/solid/state-timeline/index.jsx +1 -0
  105. package/dist/solid/state-timeline/model.jsx +166 -0
  106. package/dist/solid/state-timeline/state-timeline.jsx +387 -0
  107. package/dist/solid/state-timeline/state-timeline.styles.jsx +171 -0
  108. package/dist/solid/status-history/index.jsx +1 -0
  109. package/dist/solid/status-history/status-history.jsx +279 -0
  110. package/dist/solid/status-history/status-history.styles.jsx +171 -0
  111. package/dist/styles.css +1 -0
  112. package/dist/types/bar-list/bar-list.d.ts +91 -0
  113. package/dist/types/bar-list/bar-list.styles.d.ts +148 -0
  114. package/dist/types/bar-list/index.d.ts +3 -0
  115. package/dist/types/chart/chart.d.ts +98 -0
  116. package/dist/types/chart/chart.styles.d.ts +145 -0
  117. package/dist/types/chart/index.d.ts +3 -0
  118. package/dist/types/chart-grid/chart-grid.d.ts +35 -0
  119. package/dist/types/chart-grid/index.d.ts +2 -0
  120. package/dist/types/donut/donut.d.ts +124 -0
  121. package/dist/types/donut/donut.styles.d.ts +96 -0
  122. package/dist/types/donut/index.d.ts +3 -0
  123. package/dist/types/heat-graph/calendar.d.ts +61 -0
  124. package/dist/types/heat-graph/heat-graph.d.ts +82 -0
  125. package/dist/types/heat-graph/heat-graph.styles.d.ts +141 -0
  126. package/dist/types/heat-graph/index.d.ts +4 -0
  127. package/dist/types/heat-matrix/heat-matrix.d.ts +65 -0
  128. package/dist/types/heat-matrix/heat-matrix.styles.d.ts +135 -0
  129. package/dist/types/heat-matrix/index.d.ts +3 -0
  130. package/dist/types/heat-matrix/model.d.ts +15 -0
  131. package/dist/types/index.d.ts +12 -0
  132. package/dist/types/internal/colors.d.ts +22 -0
  133. package/dist/types/internal/floating-tip.d.ts +15 -0
  134. package/dist/types/internal/format.d.ts +7 -0
  135. package/dist/types/internal/grid-context.d.ts +9 -0
  136. package/dist/types/internal/hidden.styles.d.ts +15 -0
  137. package/dist/types/internal/legend.d.ts +18 -0
  138. package/dist/types/internal/legend.styles.d.ts +96 -0
  139. package/dist/types/internal/markers.d.ts +16 -0
  140. package/dist/types/internal/options.d.ts +59 -0
  141. package/dist/types/internal/place.d.ts +20 -0
  142. package/dist/types/internal/scheme-watch.d.ts +12 -0
  143. package/dist/types/internal/share.d.ts +19 -0
  144. package/dist/types/internal/types.d.ts +163 -0
  145. package/dist/types/row-chart/index.d.ts +4 -0
  146. package/dist/types/row-chart/model.d.ts +50 -0
  147. package/dist/types/row-chart/row-chart.d.ts +148 -0
  148. package/dist/types/row-chart/row-chart.styles.d.ts +216 -0
  149. package/dist/types/segmented-bar/index.d.ts +3 -0
  150. package/dist/types/segmented-bar/segmented-bar.d.ts +65 -0
  151. package/dist/types/segmented-bar/segmented-bar.styles.d.ts +75 -0
  152. package/dist/types/sparkline/index.d.ts +3 -0
  153. package/dist/types/sparkline/sparkline.d.ts +38 -0
  154. package/dist/types/stacked-histogram/histogram.d.ts +48 -0
  155. package/dist/types/stacked-histogram/index.d.ts +4 -0
  156. package/dist/types/stacked-histogram/stacked-histogram.d.ts +73 -0
  157. package/dist/types/stacked-histogram/stacked-histogram.styles.d.ts +187 -0
  158. package/dist/types/state-timeline/index.d.ts +3 -0
  159. package/dist/types/state-timeline/model.d.ts +63 -0
  160. package/dist/types/state-timeline/state-timeline.d.ts +108 -0
  161. package/dist/types/state-timeline/state-timeline.styles.d.ts +151 -0
  162. package/dist/types/status-history/index.d.ts +3 -0
  163. package/dist/types/status-history/status-history.d.ts +72 -0
  164. package/dist/types/status-history/status-history.styles.d.ts +150 -0
  165. package/docs/api.json +1346 -0
  166. package/docs/bar-list.md +190 -0
  167. package/docs/chart-grid.md +77 -0
  168. package/docs/chart.md +355 -0
  169. package/docs/donut.md +182 -0
  170. package/docs/heat-graph.md +121 -0
  171. package/docs/heat-matrix.md +108 -0
  172. package/docs/llms.txt +68 -0
  173. package/docs/row-chart.md +193 -0
  174. package/docs/search-index.json +291 -0
  175. package/docs/segmented-bar.md +128 -0
  176. package/docs/sparkline.md +82 -0
  177. package/docs/stacked-histogram.md +123 -0
  178. package/docs/state-timeline.md +141 -0
  179. package/docs/status-history.md +121 -0
  180. package/package.json +104 -4
@@ -0,0 +1,155 @@
1
+ import "@stylexjs/stylex";
2
+ // src/heat-matrix/heat-matrix.styles.ts
3
+ const styles = {
4
+ root: {
5
+ kB7OPa: "x9f619",
6
+ k1xSpc: "xrvj5dj",
7
+ kOIVth: "xgtrjx6",
8
+ k7Eaqz: "xeuugli",
9
+ kMv6JI: "x13rcfk",
10
+ kGuDYH: "x409pna",
11
+ kLWn49: "xau0z5x",
12
+ kMwMTN: "x1yjpjgc",
13
+ $$css: true
14
+ },
15
+ scroller: {
16
+ k7Eaqz: "xeuugli",
17
+ kXHlph: "xw2csxc",
18
+ kaIpWk: "x1b6xorz",
19
+ k3XXqK: "x1t137rt x9v5kkp",
20
+ kMeerF: "x1de99jn",
21
+ kInvED: "x1hl8ikr",
22
+ kjBf7l: "xi1ptex x1x84bn5",
23
+ $$css: true
24
+ },
25
+ table: {
26
+ kzqmXN: "xh8yej3",
27
+ kPzzVL: "x140o2bo",
28
+ kLvRdT: "x1vathgz",
29
+ kheTzg: "x1jkpq5q",
30
+ kUOVxO: "x1iyyiug",
31
+ kcqcaj: "xss6m8b",
32
+ $$css: true
33
+ },
34
+ headerColumn: {
35
+ kzqmXN: "x83mle0",
36
+ $$css: true
37
+ },
38
+ corner: {
39
+ kg3NbH: "x1d6xsf",
40
+ k9WMMc: "x1yc453h",
41
+ kGuDYH: "xb5fjo1",
42
+ k63SB2: "x1lyc3gu",
43
+ kMwMTN: "xarme7a",
44
+ khDVqt: "xuxw1ft",
45
+ kVQacm: "xb3r6kr",
46
+ kg5iWk: "xlyipyv",
47
+ $$css: true
48
+ },
49
+ columnHeader: {
50
+ kg3NbH: "x1d6xsf",
51
+ k8WAf4: "x1ucdaca",
52
+ kGuDYH: "xb5fjo1",
53
+ k63SB2: "x1lyc3gu xfbqhvr",
54
+ kMwMTN: "xe2mk2a x1qjambr",
55
+ k9WMMc: "x2b8uid",
56
+ kXLuUW: "x3ajldb",
57
+ kHjlTd: "xj0a0fe",
58
+ $$css: true
59
+ },
60
+ rowHeader: {
61
+ kg3NbH: "x1d6xsf",
62
+ kGuDYH: "xb5fjo1",
63
+ k63SB2: "x1lyc3gu xfbqhvr",
64
+ kMwMTN: "xe2mk2a x1qjambr",
65
+ k9WMMc: "x1yc453h",
66
+ khDVqt: "xuxw1ft",
67
+ kVQacm: "xb3r6kr",
68
+ kg5iWk: "xlyipyv",
69
+ $$css: true
70
+ },
71
+ cell: {
72
+ kB7OPa: "x9f619",
73
+ kZKoxP: "xqcgfsk",
74
+ kg3NbH: "xloswcj",
75
+ kaIpWk: "x1cum3z5",
76
+ k9WMMc: "x2b8uid",
77
+ kGuDYH: "xb5fjo1",
78
+ khDVqt: "xuxw1ft",
79
+ kVQacm: "xb3r6kr",
80
+ kg5iWk: "xlyipyv",
81
+ kAXs8y: "x1kzknox",
82
+ kGVxlE: "x1gnnqk1 x1ymmt2b",
83
+ $$css: true
84
+ },
85
+ empty: {
86
+ kWkggS: "x1rjxnwd",
87
+ kMwMTN: "xe2mk2a",
88
+ kAXs8y: "x1tzjh5l",
89
+ $$css: true
90
+ },
91
+ legend: {
92
+ k1xSpc: "x78zum5",
93
+ kwnvtZ: "x1a02dak",
94
+ kGNEyG: "x6s0dn4",
95
+ k1C7PZ: "xa2zc0e",
96
+ khm7nJ: "x1xpjfrv",
97
+ kogj98: "x1ghz6dp",
98
+ kmVPX3: "x1717udv",
99
+ kB88ic: "xe8uvvx",
100
+ kGuDYH: "xb5fjo1",
101
+ kMwMTN: "xe2mk2a",
102
+ kcqcaj: "xss6m8b",
103
+ $$css: true
104
+ },
105
+ legendItem: {
106
+ k1xSpc: "x3nfvp2",
107
+ kGNEyG: "x6s0dn4",
108
+ kOIVth: "x1xuqxfr",
109
+ kQ0QjF: "xa7awgv",
110
+ $$css: true
111
+ },
112
+ legendSwatch: {
113
+ kmuXW: "x2lah0s",
114
+ kzqmXN: "x1jw3ynk",
115
+ kZKoxP: "xvle69y",
116
+ kaIpWk: "x1cum3z5",
117
+ kAXs8y: "x1kzknox",
118
+ $$css: true
119
+ },
120
+ emptyText: {
121
+ kogj98: "x1ghz6dp",
122
+ k8WAf4: "x5eapc7",
123
+ kMwMTN: "xe2mk2a",
124
+ $$css: true
125
+ }
126
+ };
127
+ /** Each step's fill and text: steps 1–4 dark text, step 5 light (tokens chosen and checked for it). */
128
+ const steps = {
129
+ s1: {
130
+ kWkggS: "xozx054",
131
+ kMwMTN: "xxqkoqo",
132
+ $$css: true
133
+ },
134
+ s2: {
135
+ kWkggS: "xpydojf",
136
+ kMwMTN: "xxqkoqo",
137
+ $$css: true
138
+ },
139
+ s3: {
140
+ kWkggS: "x19ppr2v",
141
+ kMwMTN: "xxqkoqo",
142
+ $$css: true
143
+ },
144
+ s4: {
145
+ kWkggS: "x324701",
146
+ kMwMTN: "xxqkoqo",
147
+ $$css: true
148
+ },
149
+ s5: {
150
+ kWkggS: "xbzkzya",
151
+ kMwMTN: "x1bhb14y",
152
+ $$css: true
153
+ }
154
+ };
155
+ export { steps, styles };
@@ -0,0 +1 @@
1
+ export { HeatMatrix } from "./heat-matrix.jsx";
@@ -0,0 +1,41 @@
1
+ // src/heat-matrix/model.ts
2
+ /**
3
+ * Even steps between the smallest and largest value: the bounds of steps 2–5. Cells left out of the scale
4
+ * (missing, muted) don't count. All equal (or none): every value is step 1.
5
+ */
6
+ function defaultThresholds(values) {
7
+ let min = Infinity;
8
+ let max = -Infinity;
9
+ for (const v of values) {
10
+ if (!Number.isFinite(v)) continue;
11
+ min = Math.min(min, v);
12
+ max = Math.max(max, v);
13
+ }
14
+ if (!Number.isFinite(min) || max <= min) return [
15
+ Infinity,
16
+ Infinity,
17
+ Infinity,
18
+ Infinity
19
+ ];
20
+ const step = (max - min) / 5;
21
+ return [
22
+ min + step,
23
+ min + 2 * step,
24
+ min + 3 * step,
25
+ min + 4 * step
26
+ ];
27
+ }
28
+ /** A value's step: 1 below the first bound, up to 5 at or above the last; 0 for no value. */
29
+ function stepOf(value, thresholds) {
30
+ if (value == null || !Number.isFinite(value)) return 0;
31
+ let step = 1;
32
+ for (const bound of thresholds) if (value >= bound) step++;
33
+ return step;
34
+ }
35
+ /** Bounds as given, if they're four finite numbers in order; else `undefined` (use the default). */
36
+ function validThresholds(t) {
37
+ if (!t || t.length !== 4 || !t.every(Number.isFinite)) return void 0;
38
+ for (let i = 1; i < 4; i++) if (t[i] < t[i - 1]) return void 0;
39
+ return t;
40
+ }
41
+ export { defaultThresholds, stepOf, validThresholds };
@@ -0,0 +1,13 @@
1
+ import { BarList } from "./bar-list/bar-list.jsx";
2
+ import { Chart } from "./chart/chart.jsx";
3
+ import { ChartGrid } from "./chart-grid/chart-grid.jsx";
4
+ import { Donut, DonutLegend } from "./donut/donut.jsx";
5
+ import { HeatGraph } from "./heat-graph/heat-graph.jsx";
6
+ import { HeatMatrix } from "./heat-matrix/heat-matrix.jsx";
7
+ import { RowChart } from "./row-chart/row-chart.jsx";
8
+ import { SegmentedBar } from "./segmented-bar/segmented-bar.jsx";
9
+ import { Sparkline } from "./sparkline/sparkline.jsx";
10
+ import { StackedHistogram } from "./stacked-histogram/stacked-histogram.jsx";
11
+ import { StateTimeline } from "./state-timeline/state-timeline.jsx";
12
+ import { StatusHistory } from "./status-history/status-history.jsx";
13
+ export { BarList, Chart, ChartGrid, Donut, DonutLegend, HeatGraph, HeatMatrix, RowChart, SegmentedBar, Sparkline, StackedHistogram, StateTimeline, StatusHistory };
@@ -0,0 +1,44 @@
1
+ // src/internal/colors.ts
2
+ const TOKEN = /^chart-[1-8]$/;
3
+ /** A series color as CSS: a chart token name becomes its custom property. */
4
+ function cssColor(color, index) {
5
+ const c = color ?? `chart-${index % 8 + 1}`;
6
+ return TOKEN.test(c) ? `var(--sui-${c})` : c;
7
+ }
8
+ /**
9
+ * Canvas can't read custom properties or `light-dark()`, so colors are resolved through a hidden
10
+ * element inside the chart: its computed `color` is a concrete color in the chart's own scheme (a
11
+ * `<Theme scheme="dark">` subtree included), which canvas accepts.
12
+ */
13
+ function createResolver(probe) {
14
+ const cache = /* @__PURE__ */ new Map();
15
+ return (css) => {
16
+ let out = cache.get(css);
17
+ if (out === void 0) {
18
+ probe.style.color = "";
19
+ probe.style.color = css;
20
+ out = getComputedStyle(probe).color;
21
+ cache.set(css, out);
22
+ }
23
+ return out;
24
+ };
25
+ }
26
+ /** A translucent wash of a color (area fills, the brush). */
27
+ const wash = (css, percent) => `color-mix(in oklab, ${css} ${percent}%, transparent)`;
28
+ /**
29
+ * The color behind an element: the first ancestor's opaque background (a card's surface, the page). What
30
+ * the gaps between stacked bars and the rings around points are painted in, so they read as background
31
+ * whatever the chart sits on.
32
+ */
33
+ function backdrop(el) {
34
+ for (let node = el; node; node = node.parentElement) {
35
+ const bg = getComputedStyle(node).backgroundColor;
36
+ if (bg && bg !== "transparent" && !/^rgba\([^)]*,\s*0\)$|\/\s*0\)$/.test(bg)) return bg;
37
+ }
38
+ }
39
+ /**
40
+ * A status tone's color: the kit's status tokens, as Badge's dot uses them, and a neutral gray. For marks
41
+ * whose color means a state (passed, failed, skipped), not a series.
42
+ */
43
+ const toneColor = (tone) => tone === "neutral" ? "var(--sui-text-subtle)" : `var(--sui-${tone})`;
44
+ export { backdrop, createResolver, cssColor, toneColor, wash };
@@ -0,0 +1,68 @@
1
+ import { placeTip } from "./place.jsx";
2
+ import * as stylex from "@stylexjs/stylex";
3
+ import { createEffect, omit, onSettled } from "solid-js";
4
+ // src/internal/floating-tip.tsx
5
+ function FloatingTip(props) {
6
+ const rest = omit(props, "origin", "left", "top", "before", "xstyle", "children");
7
+ let el;
8
+ let anchor;
9
+ const place = () => {
10
+ const origin = anchor?.origin;
11
+ if (!anchor || !el?.isConnected || !origin) return;
12
+ const box = origin.getBoundingClientRect();
13
+ const at = placeTip({
14
+ x: box.left + anchor.left,
15
+ y: box.top + anchor.top
16
+ }, {
17
+ width: el.offsetWidth,
18
+ height: el.offsetHeight
19
+ }, {
20
+ width: document.documentElement.clientWidth,
21
+ height: document.documentElement.clientHeight
22
+ }, anchor.before);
23
+ el.style.translate = `${at.x}px ${at.y}px`;
24
+ };
25
+ createEffect(() => ({
26
+ origin: props.origin(),
27
+ left: props.left,
28
+ top: props.top,
29
+ before: props.before === true
30
+ }), (next) => {
31
+ anchor = next;
32
+ place();
33
+ });
34
+ onSettled(() => {
35
+ try {
36
+ el.showPopover();
37
+ } catch {}
38
+ place();
39
+ const resize = new ResizeObserver(() => place());
40
+ resize.observe(el);
41
+ const onScroll = () => place();
42
+ window.addEventListener("scroll", onScroll, {
43
+ capture: true,
44
+ passive: true
45
+ });
46
+ window.addEventListener("resize", onScroll, { passive: true });
47
+ return () => {
48
+ resize.disconnect();
49
+ window.removeEventListener("scroll", onScroll, { capture: true });
50
+ window.removeEventListener("resize", onScroll);
51
+ };
52
+ });
53
+ return <div {...rest} ref={(node) => el = node} popover="manual" {...stylex.attrs(props.xstyle, layer.root)}>
54
+ {props.children}
55
+ </div>;
56
+ }
57
+ const layer = { root: {
58
+ kVAEAm: "xixxii4",
59
+ k87sOh: "x13vifvy",
60
+ kbCHJM: "xu96u03",
61
+ kCIrl2: "xwukr4l",
62
+ krVfgx: "xdd4er5",
63
+ kogj98: "x1ghz6dp",
64
+ kVQacm: "x1rea2x4",
65
+ kfzvcC: "x47corl",
66
+ $$css: true
67
+ } };
68
+ export { FloatingTip };
@@ -0,0 +1,43 @@
1
+ // src/internal/format.ts
2
+ /** Default number format: full under 10,000, compact above (12.9K), in the reader's locale. */
3
+ function numberFormat(locale, max = 0) {
4
+ const full = new Intl.NumberFormat(locale, { maximumFractionDigits: 2 });
5
+ const compact = new Intl.NumberFormat(locale, {
6
+ notation: "compact",
7
+ maximumFractionDigits: 1
8
+ });
9
+ return (value) => (Math.abs(max) >= 1e4 ? compact : full).format(value);
10
+ }
11
+ /** Default x format for the tooltip heading and readout. */
12
+ function xFormat(x, locale, span) {
13
+ if (x?.format) return x.format;
14
+ const categories = x?.categories;
15
+ if (categories) return (value) => categories[Math.round(value)] ?? String(value);
16
+ if (x?.time ?? true) {
17
+ const options = span < 3600 ? {
18
+ hour: "numeric",
19
+ minute: "2-digit",
20
+ second: "2-digit"
21
+ } : span < 86400 ? {
22
+ hour: "numeric",
23
+ minute: "2-digit"
24
+ } : span < 5184e3 ? {
25
+ month: "short",
26
+ day: "numeric",
27
+ hour: "numeric",
28
+ minute: "2-digit"
29
+ } : {
30
+ year: "numeric",
31
+ month: "short",
32
+ day: "numeric"
33
+ };
34
+ const date = new Intl.DateTimeFormat(locale, options);
35
+ return (value) => date.format(/* @__PURE__ */ new Date(value * 1e3));
36
+ }
37
+ return numberFormat(locale);
38
+ }
39
+ /** The formatter for one series' values. */
40
+ function valueFormat(series, y, fallback) {
41
+ return series?.format ?? y?.format ?? fallback;
42
+ }
43
+ export { numberFormat, valueFormat, xFormat };
@@ -0,0 +1,5 @@
1
+ import { createContext, useContext } from "solid-js";
2
+ // src/internal/grid-context.ts
3
+ const ChartGridContext = createContext(null);
4
+ const useChartGrid = () => useContext(ChartGridContext);
5
+ export { ChartGridContext, useChartGrid };
@@ -0,0 +1,16 @@
1
+ import "@stylexjs/stylex";
2
+ // src/internal/hidden.styles.ts
3
+ /** Text for assistive technology only: a row's full name, the values behind a chart drawn without its legend. */
4
+ const hidden = { visually: {
5
+ kVAEAm: "x10l6tqk",
6
+ kzqmXN: "x1i1rx1s",
7
+ kZKoxP: "xjm9jq1",
8
+ kogj98: "xkdpibf",
9
+ kmVPX3: "x1717udv",
10
+ kVQacm: "xb3r6kr",
11
+ kMcinP: "xeh89do",
12
+ khDVqt: "xuxw1ft",
13
+ kMzoRj: "xc342km",
14
+ $$css: true
15
+ } };
16
+ export { hidden };
@@ -0,0 +1,35 @@
1
+ import { legend } from "./legend.styles.jsx";
2
+ import * as stylex from "@stylexjs/stylex";
3
+ import { Show } from "solid-js";
4
+ // src/internal/legend.tsx
5
+ /** A category's color mark: decorative, the label beside it names the category. */
6
+ function Swatch(props) {
7
+ return <span aria-hidden="true" data-slot="chart-swatch" {...stylex.attrs(legend.swatch)} style={{ "--swatch": props.color }} />;
8
+ }
9
+ /**
10
+ * The inside of a legend row: swatch, label (and a note under it), value and share. The row itself (an
11
+ * `li`, or a button inside one) is the caller's. `hidden` keeps the text from assistive technology, for a
12
+ * row that names itself in words.
13
+ */
14
+ function LegendEntry(props) {
15
+ return <>
16
+ <Swatch color={props.color} />
17
+ <span aria-hidden={props.hidden ? "true" : void 0} data-slot="chart-legend-label" {...stylex.attrs(legend.label)}>
18
+ {props.label}
19
+ <Show when={props.note}>
20
+ <span data-slot="chart-legend-note" {...stylex.attrs(legend.note)}>
21
+ {props.note}
22
+ </span>
23
+ </Show>
24
+ </span>
25
+ <span aria-hidden={props.hidden ? "true" : void 0} data-slot="chart-legend-value" {...stylex.attrs(legend.value)}>
26
+ {props.value}
27
+ </span>
28
+ <Show when={props.share !== void 0}>
29
+ <span aria-hidden={props.hidden ? "true" : void 0} data-slot="chart-legend-share" {...stylex.attrs(legend.share)}>
30
+ {props.share}
31
+ </span>
32
+ </Show>
33
+ </>;
34
+ }
35
+ export { LegendEntry, Swatch };
@@ -0,0 +1,108 @@
1
+ import "@stylexjs/stylex";
2
+ // src/internal/legend.styles.ts
3
+ /**
4
+ * The legend list Donut and Segmented bar share: one row per category with its swatch, label, value and
5
+ * share. Values and shares sit in fixed columns at the end, in tabular figures, so they line up row to row.
6
+ */
7
+ const legend = {
8
+ list: {
9
+ k1xSpc: "xrvj5dj",
10
+ kfiyM8: "x10ukxgv",
11
+ kOIVth: "xpowot6",
12
+ k7Eaqz: "xeuugli",
13
+ kogj98: "x1ghz6dp",
14
+ kmVPX3: "x1717udv",
15
+ kB88ic: "xe8uvvx",
16
+ kMv6JI: "x13rcfk",
17
+ kGuDYH: "x409pna",
18
+ kLWn49: "xau0z5x",
19
+ kMwMTN: "x1yjpjgc",
20
+ $$css: true
21
+ },
22
+ row: {
23
+ kB7OPa: "x9f619",
24
+ k1xSpc: "x78zum5",
25
+ kGNEyG: "x1cy8zhl",
26
+ kOIVth: "x8rwxmg",
27
+ kzqmXN: "xh8yej3",
28
+ k7Eaqz: "xeuugli",
29
+ kAzted: "x1pw4g4d",
30
+ k8WAf4: "x1ucdaca",
31
+ kg3NbH: "x1d6xsf",
32
+ kaIpWk: "x1b6xorz",
33
+ k9WMMc: "x1yc453h",
34
+ $$css: true
35
+ },
36
+ interactive: {
37
+ kWkggS: "xjbqb8w x1duwuep",
38
+ k1ekBW: "x15406qy",
39
+ kIyJzY: "xctwqe3 x12w9bfk",
40
+ $$css: true
41
+ },
42
+ button: {
43
+ kVAEAm: "x1n2onr6",
44
+ kogj98: "x1ghz6dp",
45
+ kMzoRj: "xc342km",
46
+ kMv6JI: "xjb2p0i",
47
+ kGuDYH: "x1qlqyl8",
48
+ kLWn49: "x15bjb6t",
49
+ kMwMTN: "x1heor9g",
50
+ kkrTdU: "x1ypdohk",
51
+ k3XXqK: "x1t137rt x9v5kkp",
52
+ kMeerF: "x1de99jn",
53
+ kInvED: "x2ssjo2",
54
+ kjBf7l: "xi1ptex x1x84bn5",
55
+ $$css: true
56
+ },
57
+ selected: {
58
+ k63SB2: "x1vmg6u2",
59
+ kWkggS: "x3yl11l",
60
+ k3XXqK: "x815t2r",
61
+ kMeerF: "xcthrzx",
62
+ kjBf7l: "x1x84bn5",
63
+ $$css: true
64
+ },
65
+ swatch: {
66
+ kmuXW: "x2lah0s",
67
+ k1xSpc: "x1rg5ohu",
68
+ kzqmXN: "x1e7hgle",
69
+ kZKoxP: "x1qa65zt",
70
+ keoZOQ: "x1mlafj8",
71
+ kaIpWk: "x1cum3z5",
72
+ kWkggS: "xrmkqiu",
73
+ kAXs8y: "x1kzknox",
74
+ $$css: true
75
+ },
76
+ label: {
77
+ kUk6DE: "x12lumcd",
78
+ k7Eaqz: "xeuugli",
79
+ kHjlTd: "x1mzt3pk",
80
+ $$css: true
81
+ },
82
+ note: {
83
+ k1xSpc: "x1lliihq",
84
+ keoZOQ: "x14c0qtv",
85
+ kGuDYH: "xb5fjo1",
86
+ kMwMTN: "xe2mk2a",
87
+ $$css: true
88
+ },
89
+ value: {
90
+ kmuXW: "x2lah0s",
91
+ kcqcaj: "xss6m8b",
92
+ k63SB2: "x1vmg6u2",
93
+ khDVqt: "xuxw1ft",
94
+ kQ0QjF: "xa7awgv",
95
+ $$css: true
96
+ },
97
+ share: {
98
+ kmuXW: "x2lah0s",
99
+ k7Eaqz: "x1k8l6nd",
100
+ k9WMMc: "xp4054r",
101
+ kcqcaj: "xss6m8b",
102
+ kMwMTN: "xe2mk2a",
103
+ khDVqt: "xuxw1ft",
104
+ kQ0QjF: "xa7awgv",
105
+ $$css: true
106
+ }
107
+ };
108
+ export { legend };
@@ -0,0 +1,101 @@
1
+ import { wash } from "./colors.jsx";
2
+ // src/internal/markers.ts
3
+ const TONES = {
4
+ neutral: "var(--sui-text-muted)",
5
+ accent: "var(--sui-accent)",
6
+ success: "var(--sui-success)",
7
+ warning: "var(--sui-warning)",
8
+ danger: "var(--sui-danger)"
9
+ };
10
+ const isBand = (m) => typeof m.value !== "number";
11
+ /** A marker's two ends (the same value twice for a line). */
12
+ const ends = (m) => typeof m.value === "number" ? [m.value, m.value] : m.value;
13
+ /** The y values markers need in view: the y scale's range takes them in. */
14
+ function markerExtent(markers) {
15
+ return (markers ?? []).filter((m) => m.axis === "y").flatMap(ends);
16
+ }
17
+ function markersPlugin(markers, theme) {
18
+ const colored = markers.map((m) => {
19
+ const css = TONES[m.tone ?? "neutral"];
20
+ return {
21
+ marker: m,
22
+ line: theme.resolve(css),
23
+ band: theme.resolve(wash(css, m.tone && m.tone !== "neutral" ? 12 : 8))
24
+ };
25
+ });
26
+ /** A marker's span in canvas pixels along its axis, clamped to the plot. */
27
+ const span = (u, m) => {
28
+ const [a, b] = ends(m);
29
+ const p1 = u.valToPos(a, m.axis, true);
30
+ const p2 = u.valToPos(b, m.axis, true);
31
+ return [Math.min(p1, p2), Math.max(p1, p2)];
32
+ };
33
+ /** Labels drawn this frame (bands first, then lines), so later ones step around them. */
34
+ let placed = [];
35
+ const draw = (u, bands) => {
36
+ if (bands) placed = [];
37
+ const { ctx } = u;
38
+ const { left, top, width, height } = u.bbox;
39
+ const ratio = devicePixelRatio || 1;
40
+ ctx.save();
41
+ ctx.beginPath();
42
+ ctx.rect(left, top, width, height);
43
+ ctx.clip();
44
+ for (const { marker: m, line, band } of colored) {
45
+ if (isBand(m) !== bands) continue;
46
+ const [from, to] = span(u, m);
47
+ if (bands) {
48
+ ctx.fillStyle = band;
49
+ if (m.axis === "y") ctx.fillRect(left, from, width, to - from);
50
+ else ctx.fillRect(from, top, to - from, height);
51
+ } else {
52
+ ctx.strokeStyle = line;
53
+ ctx.lineWidth = 1.5 * ratio;
54
+ ctx.setLineDash((m.dash ?? [6, 4]).map((d) => d * ratio));
55
+ ctx.beginPath();
56
+ if (m.axis === "y") {
57
+ ctx.moveTo(left, from);
58
+ ctx.lineTo(left + width, from);
59
+ } else {
60
+ ctx.moveTo(from, top);
61
+ ctx.lineTo(from, top + height);
62
+ }
63
+ ctx.stroke();
64
+ ctx.setLineDash([]);
65
+ }
66
+ if (!m.label) continue;
67
+ const [size, ...family] = theme.font.split(" ");
68
+ const fontPx = parseFloat(size ?? "12") * ratio;
69
+ ctx.font = `500 ${fontPx}px ${family.join(" ")}`;
70
+ ctx.fillStyle = theme.text;
71
+ const pad = 4 * ratio;
72
+ const w = ctx.measureText(m.label).width;
73
+ const h = fontPx * 1.25;
74
+ let x;
75
+ let y;
76
+ if (m.axis === "y") {
77
+ x = left + width - pad - w;
78
+ y = from - pad - h;
79
+ } else {
80
+ x = bands || from - pad - w < left ? from + pad : from - pad - w;
81
+ y = top + pad;
82
+ }
83
+ while (placed.some((r) => x < r.x + r.w && x + w > r.x && y < r.y + r.h && y + h > r.y)) y += h;
84
+ placed.push({
85
+ x,
86
+ y,
87
+ w,
88
+ h
89
+ });
90
+ ctx.textAlign = "left";
91
+ ctx.textBaseline = "top";
92
+ ctx.fillText(m.label, x, y);
93
+ }
94
+ ctx.restore();
95
+ };
96
+ return { hooks: {
97
+ drawAxes: [(u) => draw(u, true)],
98
+ draw: [(u) => draw(u, false)]
99
+ } };
100
+ }
101
+ export { markerExtent, markersPlugin };