lightview 1.8.2 → 2.0.1

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 (262) hide show
  1. package/.codacy/cli.sh +149 -0
  2. package/.codacy/codacy.yaml +15 -0
  3. package/.github/instructions/codacy.instructions.md +72 -0
  4. package/.wranglerignore +21 -0
  5. package/README.md +1330 -19
  6. package/_headers +4 -0
  7. package/build.js +70 -0
  8. package/components/actions/button.js +151 -0
  9. package/components/actions/dropdown.js +120 -0
  10. package/components/actions/modal.js +146 -0
  11. package/components/actions/swap.js +118 -0
  12. package/components/daisyui.js +288 -0
  13. package/components/data-display/accordion.js +128 -0
  14. package/components/data-display/alert.js +112 -0
  15. package/components/data-display/avatar.js +170 -0
  16. package/components/data-display/badge.js +82 -0
  17. package/components/data-display/card.js +151 -0
  18. package/components/data-display/carousel.js +94 -0
  19. package/components/data-display/chart.js +220 -0
  20. package/components/data-display/chat.js +128 -0
  21. package/components/data-display/collapse.js +103 -0
  22. package/components/data-display/countdown.js +69 -0
  23. package/components/data-display/diff.js +111 -0
  24. package/components/data-display/kbd.js +65 -0
  25. package/components/data-display/loading.js +75 -0
  26. package/components/data-display/progress.js +79 -0
  27. package/components/data-display/radial-progress.js +88 -0
  28. package/components/data-display/skeleton.js +66 -0
  29. package/components/data-display/stats.js +159 -0
  30. package/components/data-display/table.js +146 -0
  31. package/components/data-display/timeline.js +146 -0
  32. package/components/data-display/toast.js +72 -0
  33. package/components/data-display/tooltip.js +74 -0
  34. package/components/data-input/checkbox.js +253 -0
  35. package/components/data-input/file-input.js +224 -0
  36. package/components/data-input/input.js +264 -0
  37. package/components/data-input/radio.js +338 -0
  38. package/components/data-input/range.js +204 -0
  39. package/components/data-input/rating.js +219 -0
  40. package/components/data-input/select.js +287 -0
  41. package/components/data-input/textarea.js +287 -0
  42. package/components/data-input/toggle.js +201 -0
  43. package/components/index.js +137 -0
  44. package/components/layout/divider.js +72 -0
  45. package/components/layout/drawer.js +142 -0
  46. package/components/layout/footer.js +100 -0
  47. package/components/layout/hero.js +109 -0
  48. package/components/layout/indicator.js +90 -0
  49. package/components/layout/join.js +78 -0
  50. package/components/layout/navbar.js +110 -0
  51. package/components/navigation/breadcrumbs.js +91 -0
  52. package/components/navigation/dock.js +103 -0
  53. package/components/navigation/menu.js +126 -0
  54. package/components/navigation/pagination.js +105 -0
  55. package/components/navigation/steps.js +89 -0
  56. package/components/navigation/tabs.css +177 -0
  57. package/components/navigation/tabs.js +123 -0
  58. package/components/theme/theme-switch.css +65 -0
  59. package/components/theme/theme-switch.js +177 -0
  60. package/docs/about.html +164 -0
  61. package/docs/api/computed.html +184 -0
  62. package/docs/api/effects.html +173 -0
  63. package/docs/api/elements.html +180 -0
  64. package/docs/api/enhance.html +225 -0
  65. package/docs/api/hypermedia.html +165 -0
  66. package/docs/api/index.html +178 -0
  67. package/docs/api/nav.html +18 -0
  68. package/docs/api/signals.html +136 -0
  69. package/docs/api/state.html +217 -0
  70. package/docs/assets/images/logo-favicon.svg +42 -0
  71. package/docs/assets/images/logo-static.svg +40 -0
  72. package/docs/assets/images/logo.svg +66 -0
  73. package/docs/assets/js/examplify.js +395 -0
  74. package/docs/assets/styles/site.css +1102 -0
  75. package/docs/assets/styles/themes.css +236 -0
  76. package/docs/components/accordion.html +439 -0
  77. package/docs/components/alert.html +528 -0
  78. package/docs/components/avatar.html +586 -0
  79. package/docs/components/badge.html +531 -0
  80. package/docs/components/breadcrumbs.html +278 -0
  81. package/docs/components/button.html +579 -0
  82. package/docs/components/card.html +561 -0
  83. package/docs/components/carousel.html +286 -0
  84. package/docs/components/chart-area.html +702 -0
  85. package/docs/components/chart-bar.html +782 -0
  86. package/docs/components/chart-column.html +735 -0
  87. package/docs/components/chart-line.html +794 -0
  88. package/docs/components/chart-pie.html +823 -0
  89. package/docs/components/chart.html +610 -15
  90. package/docs/components/chat.html +547 -0
  91. package/docs/components/checkbox.html +641 -0
  92. package/docs/components/collapse.html +536 -0
  93. package/docs/components/component-nav.html +53 -0
  94. package/docs/components/countdown.html +470 -0
  95. package/docs/components/diff.html +245 -0
  96. package/docs/components/divider.html +240 -0
  97. package/docs/components/dock.html +277 -0
  98. package/docs/components/drawer.html +515 -0
  99. package/docs/components/dropdown.html +479 -0
  100. package/docs/components/file-input.html +591 -0
  101. package/docs/components/footer.html +301 -0
  102. package/docs/components/gallery.html +504 -0
  103. package/docs/components/hero.html +264 -0
  104. package/docs/components/index.css +840 -0
  105. package/docs/components/index.html +735 -0
  106. package/docs/components/indicator.html +342 -0
  107. package/docs/components/input.html +644 -0
  108. package/docs/components/join.html +285 -0
  109. package/docs/components/kbd.html +322 -0
  110. package/docs/components/loading.html +521 -0
  111. package/docs/components/menu.html +461 -0
  112. package/docs/components/modal.html +639 -0
  113. package/docs/components/navbar.html +321 -0
  114. package/docs/components/pagination.html +279 -0
  115. package/docs/components/progress.html +514 -0
  116. package/docs/components/radial-progress.html +434 -0
  117. package/docs/components/radio.html +655 -0
  118. package/docs/components/range.html +611 -0
  119. package/docs/components/rating.html +642 -0
  120. package/docs/components/select.html +696 -0
  121. package/docs/components/sidebar-setup.js +93 -0
  122. package/docs/components/skeleton.html +447 -0
  123. package/docs/components/spinner.html +68 -0
  124. package/docs/components/stats.html +486 -0
  125. package/docs/components/steps.html +356 -0
  126. package/docs/components/swap.html +517 -0
  127. package/docs/components/switch.html +68 -0
  128. package/docs/components/table.html +668 -0
  129. package/docs/components/tabs.html +506 -0
  130. package/docs/components/text-input.html +68 -0
  131. package/docs/components/textarea.html +603 -0
  132. package/docs/components/timeline.html +485 -42
  133. package/docs/components/toast.html +474 -0
  134. package/docs/components/toggle.html +564 -0
  135. package/docs/components/tooltip.html +423 -0
  136. package/docs/examples/getting-started-example.html +40 -0
  137. package/docs/examples/index.html +93 -0
  138. package/docs/getting-started/index.html +739 -0
  139. package/docs/getting-started/reviews.html +23 -0
  140. package/docs/getting-started/reviews.odom +108 -0
  141. package/docs/getting-started/reviews.vdom +84 -0
  142. package/docs/index.html +132 -42
  143. package/docs/playground.html +416 -0
  144. package/docs/router.html +285 -0
  145. package/docs/styles/index.html +190 -0
  146. package/functions/_middleware.js +32 -0
  147. package/index.html +309 -0
  148. package/lightview-router.js +364 -0
  149. package/lightview-x.js +1577 -0
  150. package/lightview.js +659 -1200
  151. package/middleware/locale.js +25 -0
  152. package/middleware/markdown.js +44 -0
  153. package/middleware/notFound.js +37 -0
  154. package/package.json +27 -41
  155. package/watch.js +92 -0
  156. package/wrangler.toml +12 -0
  157. package/.idea/lightview.iml +0 -12
  158. package/.idea/modules.xml +0 -8
  159. package/.idea/vcs.xml +0 -6
  160. package/LICENSE +0 -21
  161. package/codepen-no-tabs-embed.css +0 -2
  162. package/docs/CNAME +0 -1
  163. package/docs/api.html +0 -674
  164. package/docs/blank.html +0 -10
  165. package/docs/comparedto.html +0 -89
  166. package/docs/components/chart-repl.html +0 -69
  167. package/docs/components/components.js +0 -113
  168. package/docs/components/contents.html +0 -17
  169. package/docs/components/gantt-repl.html +0 -61
  170. package/docs/components/gantt.html +0 -42
  171. package/docs/components/gauge-repl.html +0 -66
  172. package/docs/components/gauge.html +0 -20
  173. package/docs/components/orgchart-repl.html +0 -64
  174. package/docs/components/orgchart.html +0 -41
  175. package/docs/components/repl-as-src.html +0 -17
  176. package/docs/components/repl-repl.html +0 -95
  177. package/docs/components/repl.html +0 -527
  178. package/docs/components/timeline-repl.html +0 -72
  179. package/docs/components.html +0 -14
  180. package/docs/css/highlightjs.min.css +0 -9
  181. package/docs/css/tutorial.css +0 -35
  182. package/docs/examples/anchor.html +0 -11
  183. package/docs/examples/chart.html +0 -34
  184. package/docs/examples/counter.html +0 -26
  185. package/docs/examples/counter.test.mjs +0 -47
  186. package/docs/examples/counter2.html +0 -26
  187. package/docs/examples/directives.html +0 -79
  188. package/docs/examples/foreign.html +0 -50
  189. package/docs/examples/forgeinform.html +0 -98
  190. package/docs/examples/form.html +0 -61
  191. package/docs/examples/gauge.html +0 -18
  192. package/docs/examples/invalid-template-literals.html +0 -44
  193. package/docs/examples/medium/remote.html +0 -60
  194. package/docs/examples/message.html +0 -18
  195. package/docs/examples/nested.html +0 -11
  196. package/docs/examples/object-bound-form.html +0 -34
  197. package/docs/examples/remote-server.js +0 -51
  198. package/docs/examples/remote.html +0 -34
  199. package/docs/examples/remote.json +0 -1
  200. package/docs/examples/scratch.html +0 -69
  201. package/docs/examples/sensors/index.html +0 -44
  202. package/docs/examples/sensors/sensor-server.js +0 -30
  203. package/docs/examples/shared.html +0 -41
  204. package/docs/examples/template.html +0 -33
  205. package/docs/examples/timeline.html +0 -21
  206. package/docs/examples/todo.html +0 -40
  207. package/docs/examples/top.html +0 -10
  208. package/docs/examples/types.html +0 -94
  209. package/docs/examples/xor.html +0 -62
  210. package/docs/examples.html +0 -25
  211. package/docs/javascript/codejar.min.js +0 -8
  212. package/docs/javascript/highlightjs.min.js +0 -1173
  213. package/docs/javascript/isomorphic-git.js +0 -9
  214. package/docs/javascript/json5.min.js +0 -1
  215. package/docs/javascript/lightning-fs.js +0 -1
  216. package/docs/javascript/lightview.js +0 -1285
  217. package/docs/javascript/marked.min.js +0 -6
  218. package/docs/javascript/peerjs.min.js +0 -70
  219. package/docs/javascript/turndown.js +0 -973
  220. package/docs/javascript/types.js +0 -606
  221. package/docs/javascript/utils.js +0 -45
  222. package/docs/lightview.html +0 -63
  223. package/docs/old_index.html +0 -965
  224. package/docs/old_index.md +0 -1132
  225. package/docs/slidein.html +0 -51
  226. package/docs/tutorial/0-getting-started.html +0 -67
  227. package/docs/tutorial/1-intro-to-variables.html +0 -103
  228. package/docs/tutorial/10-template-components.html +0 -80
  229. package/docs/tutorial/11-linked-components.html +0 -76
  230. package/docs/tutorial/12-imported-components.html +0 -67
  231. package/docs/tutorial/13-input-binding.html +0 -94
  232. package/docs/tutorial/14-automatic-variable-creation.html +0 -74
  233. package/docs/tutorial/15-form-binding.html +0 -110
  234. package/docs/tutorial/16-if-directive.html +0 -60
  235. package/docs/tutorial/17-loop-directives.html +0 -83
  236. package/docs/tutorial/18-sanitizing-and-escaping-input.html +0 -79
  237. package/docs/tutorial/2-imported-and-exported-variables.html +0 -80
  238. package/docs/tutorial/3-data-types.html +0 -89
  239. package/docs/tutorial/4-extended-data-types.html +0 -83
  240. package/docs/tutorial/5-extended-functional-types.html +0 -96
  241. package/docs/tutorial/5.1-extended-functional-types.html +0 -79
  242. package/docs/tutorial/5.2-extended-functional-types.html +0 -70
  243. package/docs/tutorial/6-conventional-javascript.html +0 -75
  244. package/docs/tutorial/7-monitoring-with-observers.html +0 -107
  245. package/docs/tutorial/8-event-listeners.html +0 -65
  246. package/docs/tutorial/9-intro-to-components.html +0 -91
  247. package/docs/tutorial/contents.html +0 -32
  248. package/docs/tutorial/my-component.html +0 -29
  249. package/docs/tutorial/remote-value.json +0 -4
  250. package/docs/websiterepl.html +0 -46
  251. package/jest-puppeteer.config.js +0 -5
  252. package/jest.config.json +0 -12
  253. package/lightview.min.js +0 -1
  254. package/lightview_good.js +0 -1267
  255. package/lightview_optimized.js +0 -1274
  256. package/repl_hold.html +0 -320
  257. package/test/basic.html +0 -104
  258. package/test/basic.test.mjs +0 -315
  259. package/test/extended.html +0 -29
  260. package/test/extended.test.mjs +0 -448
  261. package/types.js +0 -607
  262. package/unsplash.key +0 -1
@@ -0,0 +1,823 @@
1
+ <!-- SEO-friendly SPA Shim -->
2
+ <script src="/lightview-router.js"></script>
3
+ <script>
4
+ if (window.LightviewRouter) {
5
+ LightviewRouter.base('/index.html');
6
+ }
7
+ </script>
8
+ <script type="module" src="../../components/data-display/chart.js"></script>
9
+
10
+ <!-- Load the page-specific stylesheet -->
11
+ <link rel="stylesheet" href="./index.css">
12
+
13
+ <!-- Gallery Structure -->
14
+ <div class="gallery-page">
15
+ <div class="gallery-layout">
16
+ <!-- Sidebar Overlay -->
17
+ <div id="sidebar-overlay" class="sidebar-overlay"></div>
18
+
19
+ <!-- Sidebar -->
20
+ <div id="gallery-sidebar" class="gallery-sidebar" style="visibility: hidden" src="./component-nav.html"></div>
21
+
22
+ <!-- Main Content -->
23
+ <div id="gallery-main" class="gallery-main">
24
+ <!-- Header Container -->
25
+ <div
26
+ style="position: sticky; top: 0; z-index: 30; background: var(--gallery-surface); border-bottom: 1px solid var(--gallery-border); backdrop-filter: blur(8px);">
27
+ <!-- Breadcrumbs Row -->
28
+ <div style="padding: 0.75rem 1.5rem 0;">
29
+ <script>
30
+ (() => {
31
+ const { Breadcrumbs } = Lightview.tags;
32
+ const breadcrumbs = Breadcrumbs({
33
+ id: 'page-breadcrumbs',
34
+ items: [
35
+ { label: 'Components', href: '/docs/components' },
36
+ { label: 'Chart Pie' }
37
+ ]
38
+ });
39
+ document.currentScript.replaceWith(breadcrumbs.domEl);
40
+ })();
41
+ </script>
42
+ </div>
43
+ <!-- Title Row -->
44
+ <div class="gallery-header"
45
+ style="border-bottom: none; height: auto; padding-top: 0.5rem; padding-bottom: 0.75rem;">
46
+ <button id="toggle-btn" class="toggle-btn" aria-label="Toggle Sidebar">
47
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="toggle-icon"
48
+ style="stroke: currentColor; stroke-width: 2;">
49
+ <path stroke-linecap="round" stroke-linejoin="round" d="M15 19l-7-7 7-7" />
50
+ <path stroke-linecap="round" stroke-linejoin="round" d="M11 19l-7-7 7-7" />
51
+ </svg>
52
+ </button>
53
+ <h1 class="gallery-title">Chart Pie</h1>
54
+ </div>
55
+ </div>
56
+
57
+ <!-- Content -->
58
+ <div class="gallery-content">
59
+ <div class="section-content" style="max-width: 1000px;">
60
+ <p class="text-lg" style="opacity: 0.7; margin-bottom: 1.5rem;">
61
+ Pie charts display data as slices of a circular pie, ideal for showing proportions
62
+ and percentages that add up to 100%.
63
+ </p>
64
+
65
+ <!-- Basic Usage -->
66
+ <div class="card bg-base-200" style="margin-bottom: 2rem;">
67
+ <div class="card-body">
68
+ <h2 class="card-title">Basic Usage</h2>
69
+ <p class="text-sm" style="opacity: 0.7; margin-bottom: 1rem;">
70
+ To create a pie chart, use <code>type: 'pie'</code> and specify
71
+ <code>start</code> and
72
+ <code>end</code> for each segment.
73
+ </p>
74
+
75
+ <!-- Tabs -->
76
+ <script>
77
+ window.switchBasicPieTab = (tabId) => {
78
+ const tabs = ['tagged', 'vdom', 'object'];
79
+ tabs.forEach(t => {
80
+ const tabEl = document.getElementById(`basic-pie-tab-btn-${t}`);
81
+ const contentEl = document.getElementById(`basic-pie-syntax-${t}`);
82
+ if (t === tabId) {
83
+ tabEl.classList.add('syntax-tab-active');
84
+ contentEl.style.display = 'block';
85
+ } else {
86
+ tabEl.classList.remove('syntax-tab-active');
87
+ contentEl.style.display = 'none';
88
+ }
89
+ });
90
+ };
91
+ </script>
92
+ <div role="tablist" class="syntax-tabs" style="margin-bottom: 1rem;">
93
+ <button id="basic-pie-tab-btn-tagged" role="tab" class="syntax-tab syntax-tab-active"
94
+ onclick="switchBasicPieTab('tagged')">Tagged</button>
95
+ <button id="basic-pie-tab-btn-vdom" role="tab" class="syntax-tab"
96
+ onclick="switchBasicPieTab('vdom')">vDOM</button>
97
+ <button id="basic-pie-tab-btn-object" role="tab" class="syntax-tab"
98
+ onclick="switchBasicPieTab('object')">Object DOM</button>
99
+ </div>
100
+
101
+ <!-- Tagged Syntax -->
102
+ <div id="basic-pie-syntax-tagged">
103
+ <pre><script>
104
+ examplify(document.currentScript.nextElementSibling, {
105
+ at: document.currentScript.parentElement,
106
+ scripts: ['/lightview.js', '/lightview-x.js'],
107
+ styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
108
+ type: 'module',
109
+ minHeight: 300,
110
+ autoRun: true
111
+ });
112
+ </script><code contenteditable="true">await import('/components/data-display/chart.js');
113
+ const { tags, $ } = Lightview;
114
+ const { Chart } = tags;
115
+
116
+ const chart = Chart({
117
+ type: 'pie',
118
+ style: 'width: 100%; max-width: 300px; margin: 0 auto; aspect-ratio: 1;'
119
+ },
120
+ Chart.Body({},
121
+ Chart.Row({},
122
+ Chart.Data({ start: 0.0, end: 0.5, color: '#4CAF50' }) // 50%
123
+ ),
124
+ Chart.Row({},
125
+ Chart.Data({ start: 0.5, end: 0.8, color: '#2196F3' }) // 30%
126
+ ),
127
+ Chart.Row({},
128
+ Chart.Data({ start: 0.8, end: 1.0, color: '#FF9800' }) // 20%
129
+ )
130
+ )
131
+ );
132
+
133
+ $('#example').content(chart);</code></pre>
134
+ </div>
135
+
136
+ <!-- vDOM Syntax -->
137
+ <div id="basic-pie-syntax-vdom" style="display: none;">
138
+ <pre><script>
139
+ examplify(document.currentScript.nextElementSibling, {
140
+ at: document.currentScript.parentElement,
141
+ scripts: ['/lightview.js', '/lightview-x.js'],
142
+ styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
143
+ type: 'module',
144
+ minHeight: 300
145
+ });
146
+ </script><code contenteditable="true">await import('/components/data-display/chart.js');
147
+ const { tags, $ } = Lightview;
148
+ const { Chart } = tags;
149
+
150
+ const segments = [
151
+ { start: 0.0, end: 0.5, color: '#4CAF50' },
152
+ { start: 0.5, end: 0.8, color: '#2196F3' },
153
+ { start: 0.8, end: 1.0, color: '#FF9800' }
154
+ ];
155
+
156
+ const chart = {
157
+ tag: Chart,
158
+ attributes: {
159
+ type: 'pie',
160
+ style: 'width: 100%; max-width: 300px; margin: 0 auto; aspect-ratio: 1;'
161
+ },
162
+ children: [
163
+ {
164
+ tag: Chart.Body,
165
+ children: segments.map(seg => ({
166
+ tag: Chart.Row,
167
+ children: [
168
+ { tag: Chart.Data, attributes: seg }
169
+ ]
170
+ }))
171
+ }
172
+ ]
173
+ };
174
+
175
+ $('#example').content(chart);</code></pre>
176
+ </div>
177
+
178
+ <!-- Object DOM Syntax -->
179
+ <div id="basic-pie-syntax-object" style="display: none;">
180
+ <pre><script>
181
+ examplify(document.currentScript.nextElementSibling, {
182
+ at: document.currentScript.parentElement,
183
+ scripts: ['/lightview.js', '/lightview-x.js'],
184
+ styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
185
+ type: 'module',
186
+ minHeight: 300
187
+ });
188
+ </script><code contenteditable="true">await import('/components/data-display/chart.js');
189
+ const { $ } = Lightview;
190
+
191
+ const chart = {
192
+ Chart: {
193
+ type: 'pie',
194
+ style: 'width: 100%; max-width: 300px; margin: 0 auto; aspect-ratio: 1;',
195
+ children: [
196
+ {
197
+ 'Chart.Body': {
198
+ children: [
199
+ { 'Chart.Row': { children: [{ 'Chart.Data': { start: 0.0, end: 0.5, color: '#4CAF50' } }] } },
200
+ { 'Chart.Row': { children: [{ 'Chart.Data': { start: 0.5, end: 0.8, color: '#2196F3' } }] } },
201
+ { 'Chart.Row': { children: [{ 'Chart.Data': { start: 0.8, end: 1.0, color: '#FF9800' } }] } }
202
+ ]
203
+ }
204
+ }
205
+ ]
206
+ }
207
+ };
208
+
209
+ $('#example').content(chart);</code></pre>
210
+ </div>
211
+ </div>
212
+ </div>
213
+
214
+ <!-- With Labels -->
215
+ <div class="card bg-base-200" style="margin-bottom: 2rem;">
216
+ <div class="card-body">
217
+ <h2 class="card-title">With Labels</h2>
218
+ <p class="text-sm" style="opacity: 0.7; margin-bottom: 1rem;">
219
+ Add data labels with <code>labels: true</code> and include a
220
+ <code>&lt;span class="data"&gt;</code>.
221
+ </p>
222
+
223
+ <!-- Tabs -->
224
+ <script>
225
+ window.switchLabelsPieTab = (tabId) => {
226
+ const tabs = ['tagged', 'vdom', 'object'];
227
+ tabs.forEach(t => {
228
+ const tabEl = document.getElementById(`labels-pie-tab-btn-${t}`);
229
+ const contentEl = document.getElementById(`labels-pie-syntax-${t}`);
230
+ if (t === tabId) {
231
+ tabEl.classList.add('syntax-tab-active');
232
+ contentEl.style.display = 'block';
233
+ } else {
234
+ tabEl.classList.remove('syntax-tab-active');
235
+ contentEl.style.display = 'none';
236
+ }
237
+ });
238
+ };
239
+ </script>
240
+ <div role="tablist" class="syntax-tabs" style="margin-bottom: 1rem;">
241
+ <button id="labels-pie-tab-btn-tagged" role="tab" class="syntax-tab syntax-tab-active"
242
+ onclick="switchLabelsPieTab('tagged')">Tagged</button>
243
+ <button id="labels-pie-tab-btn-vdom" role="tab" class="syntax-tab"
244
+ onclick="switchLabelsPieTab('vdom')">vDOM</button>
245
+ <button id="labels-pie-tab-btn-object" role="tab" class="syntax-tab"
246
+ onclick="switchLabelsPieTab('object')">Object DOM</button>
247
+ </div>
248
+
249
+ <!-- Tagged Syntax -->
250
+ <div id="labels-pie-syntax-tagged">
251
+ <pre><script>
252
+ examplify(document.currentScript.nextElementSibling, {
253
+ at: document.currentScript.parentElement,
254
+ scripts: ['/lightview.js', '/lightview-x.js'],
255
+ styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
256
+ type: 'module',
257
+ minHeight: 300,
258
+ autoRun: true
259
+ });
260
+ </script><code contenteditable="true">await import('/components/data-display/chart.js');
261
+ const { tags, $ } = Lightview;
262
+ const { Chart, span } = tags;
263
+
264
+ const chart = Chart({
265
+ type: 'pie',
266
+ labels: true,
267
+ style: 'width: 100%; max-width: 300px; margin: 0 auto; aspect-ratio: 1;'
268
+ },
269
+ Chart.Body({},
270
+ Chart.Row({},
271
+ Chart.Label({}, 'Chrome'),
272
+ Chart.Data({ start: 0.0, end: 0.6, color: '#4CAF50' },
273
+ span({ class: 'data' }, '60%'))
274
+ ),
275
+ Chart.Row({},
276
+ Chart.Label({}, 'Firefox'),
277
+ Chart.Data({ start: 0.6, end: 0.85, color: '#F44336' },
278
+ span({ class: 'data' }, '25%'))
279
+ ),
280
+ Chart.Row({},
281
+ Chart.Label({}, 'Safari'),
282
+ Chart.Data({ start: 0.85, end: 1.0, color: '#2196F3' },
283
+ span({ class: 'data' }, '15%'))
284
+ )
285
+ )
286
+ );
287
+
288
+ $('#example').content(chart);</code></pre>
289
+ </div>
290
+
291
+ <!-- vDOM Syntax -->
292
+ <div id="labels-pie-syntax-vdom" style="display: none;">
293
+ <pre><script>
294
+ examplify(document.currentScript.nextElementSibling, {
295
+ at: document.currentScript.parentElement,
296
+ scripts: ['/lightview.js', '/lightview-x.js'],
297
+ styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
298
+ type: 'module',
299
+ minHeight: 300
300
+ });
301
+ </script><code contenteditable="true">await import('/components/data-display/chart.js');
302
+ const { tags, $ } = Lightview;
303
+ const { Chart, span } = tags;
304
+
305
+ const browsers = [
306
+ { name: 'Chrome', start: 0.0, end: 0.6, color: '#4CAF50', text: '60%' },
307
+ { name: 'Firefox', start: 0.6, end: 0.85, color: '#F44336', text: '25%' },
308
+ { name: 'Safari', start: 0.85, end: 1.0, color: '#2196F3', text: '15%' }
309
+ ];
310
+
311
+ const chart = {
312
+ tag: Chart,
313
+ attributes: {
314
+ type: 'pie',
315
+ labels: true,
316
+ style: 'width: 100%; max-width: 300px; margin: 0 auto; aspect-ratio: 1;'
317
+ },
318
+ children: [
319
+ {
320
+ tag: Chart.Body,
321
+ children: browsers.map(b => ({
322
+ tag: Chart.Row,
323
+ children: [
324
+ { tag: Chart.Label, children: [b.name] },
325
+ {
326
+ tag: Chart.Data,
327
+ attributes: { start: b.start, end: b.end, color: b.color },
328
+ children: [{ tag: span, attributes: { class: 'data' }, children: [b.text] }]
329
+ }
330
+ ]
331
+ }))
332
+ }
333
+ ]
334
+ };
335
+
336
+ $('#example').content(chart);</code></pre>
337
+ </div>
338
+
339
+ <!-- Object DOM Syntax -->
340
+ <div id="labels-pie-syntax-object" style="display: none;">
341
+ <pre><script>
342
+ examplify(document.currentScript.nextElementSibling, {
343
+ at: document.currentScript.parentElement,
344
+ scripts: ['/lightview.js', '/lightview-x.js'],
345
+ styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
346
+ type: 'module',
347
+ minHeight: 300
348
+ });
349
+ </script><code contenteditable="true">await import('/components/data-display/chart.js');
350
+ const { $ } = Lightview;
351
+
352
+ const chart = {
353
+ Chart: {
354
+ type: 'pie',
355
+ labels: true,
356
+ style: 'width: 100%; max-width: 300px; margin: 0 auto; aspect-ratio: 1;',
357
+ children: [
358
+ {
359
+ 'Chart.Body': {
360
+ children: [
361
+ {
362
+ 'Chart.Row': {
363
+ children: [
364
+ { 'Chart.Label': { children: ['Chrome'] } },
365
+ { 'Chart.Data': { start: 0.0, end: 0.6, color: '#4CAF50', children: [{ span: { class: 'data', children: ['60%'] } }] } }
366
+ ]
367
+ }
368
+ },
369
+ {
370
+ 'Chart.Row': {
371
+ children: [
372
+ { 'Chart.Label': { children: ['Firefox'] } },
373
+ { 'Chart.Data': { start: 0.6, end: 0.85, color: '#F44336', children: [{ span: { class: 'data', children: ['25%'] } }] } }
374
+ ]
375
+ }
376
+ },
377
+ {
378
+ 'Chart.Row': {
379
+ children: [
380
+ { 'Chart.Label': { children: ['Safari'] } },
381
+ { 'Chart.Data': { start: 0.85, end: 1.0, color: '#2196F3', children: [{ span: { class: 'data', children: ['15%'] } }] } }
382
+ ]
383
+ }
384
+ }
385
+ ]
386
+ }
387
+ }
388
+ ]
389
+ }
390
+ };
391
+
392
+ $('#example').content(chart);</code></pre>
393
+ </div>
394
+ </div>
395
+ </div>
396
+
397
+ <!-- Spacing -->
398
+ <div class="card bg-base-200" style="margin-bottom: 2rem;">
399
+ <div class="card-body">
400
+ <h2 class="card-title">Spacing</h2>
401
+ <p class="text-sm" style="opacity: 0.7; margin-bottom: 1rem;">
402
+ Add gaps between slices with the <code>spacing</code> prop.
403
+ </p>
404
+
405
+ <!-- Tabs -->
406
+ <script>
407
+ window.switchSpacingPieTab = (tabId) => {
408
+ const tabs = ['tagged', 'vdom', 'object'];
409
+ tabs.forEach(t => {
410
+ const tabEl = document.getElementById(`spacing-pie-tab-btn-${t}`);
411
+ const contentEl = document.getElementById(`spacing-pie-syntax-${t}`);
412
+ if (t === tabId) {
413
+ tabEl.classList.add('syntax-tab-active');
414
+ contentEl.style.display = 'block';
415
+ } else {
416
+ tabEl.classList.remove('syntax-tab-active');
417
+ contentEl.style.display = 'none';
418
+ }
419
+ });
420
+ };
421
+ </script>
422
+ <div role="tablist" class="syntax-tabs" style="margin-bottom: 1rem;">
423
+ <button id="spacing-pie-tab-btn-tagged" role="tab" class="syntax-tab syntax-tab-active"
424
+ onclick="switchSpacingPieTab('tagged')">Tagged</button>
425
+ <button id="spacing-pie-tab-btn-vdom" role="tab" class="syntax-tab"
426
+ onclick="switchSpacingPieTab('vdom')">vDOM</button>
427
+ <button id="spacing-pie-tab-btn-object" role="tab" class="syntax-tab"
428
+ onclick="switchSpacingPieTab('object')">Object DOM</button>
429
+ </div>
430
+
431
+ <!-- Tagged Syntax -->
432
+ <div id="spacing-pie-syntax-tagged">
433
+ <pre><script>
434
+ examplify(document.currentScript.nextElementSibling, {
435
+ at: document.currentScript.parentElement,
436
+ scripts: ['/lightview.js', '/lightview-x.js'],
437
+ styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
438
+ type: 'module',
439
+ minHeight: 300,
440
+ autoRun: true
441
+ });
442
+ </script><code contenteditable="true">await import('/components/data-display/chart.js');
443
+ const { tags, $ } = Lightview;
444
+ const { Chart, div } = tags;
445
+
446
+ const charts = div({ style: 'display: flex; gap: 2rem; flex-wrap: wrap;' },
447
+ div({ style: 'flex: 1; min-width: 200px;' },
448
+ div({ style: 'font-weight: bold; margin-bottom: 0.5rem; text-align: center;' }, 'No spacing'),
449
+ Chart({
450
+ type: 'pie',
451
+ style: 'width: 100%; max-width: 200px; margin: 0 auto; aspect-ratio: 1;'
452
+ },
453
+ Chart.Body({},
454
+ Chart.Row({}, Chart.Data({ start: 0.0, end: 0.4, color: '#E91E63' })),
455
+ Chart.Row({}, Chart.Data({ start: 0.4, end: 0.7, color: '#9C27B0' })),
456
+ Chart.Row({}, Chart.Data({ start: 0.7, end: 1.0, color: '#673AB7' }))
457
+ )
458
+ )
459
+ ),
460
+ div({ style: 'flex: 1; min-width: 200px;' },
461
+ div({ style: 'font-weight: bold; margin-bottom: 0.5rem; text-align: center;' }, 'spacing: 5'),
462
+ Chart({
463
+ type: 'pie',
464
+ spacing: 5,
465
+ style: 'width: 100%; max-width: 200px; margin: 0 auto; aspect-ratio: 1;'
466
+ },
467
+ Chart.Body({},
468
+ Chart.Row({}, Chart.Data({ start: 0.0, end: 0.4, color: '#E91E63' })),
469
+ Chart.Row({}, Chart.Data({ start: 0.4, end: 0.7, color: '#9C27B0' })),
470
+ Chart.Row({}, Chart.Data({ start: 0.7, end: 1.0, color: '#673AB7' }))
471
+ )
472
+ )
473
+ )
474
+ );
475
+
476
+ $('#example').content(charts);</code></pre>
477
+ </div>
478
+
479
+ <!-- vDOM Syntax -->
480
+ <div id="spacing-pie-syntax-vdom" style="display: none;">
481
+ <pre><script>
482
+ examplify(document.currentScript.nextElementSibling, {
483
+ at: document.currentScript.parentElement,
484
+ scripts: ['/lightview.js', '/lightview-x.js'],
485
+ styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
486
+ type: 'module',
487
+ minHeight: 300
488
+ });
489
+ </script><code contenteditable="true">await import('/components/data-display/chart.js');
490
+ const { tags, $ } = Lightview;
491
+ const { Chart, div } = tags;
492
+
493
+ const segments = [
494
+ { start: 0.0, end: 0.4, color: '#E91E63' },
495
+ { start: 0.4, end: 0.7, color: '#9C27B0' },
496
+ { start: 0.7, end: 1.0, color: '#673AB7' }
497
+ ];
498
+
499
+ const createChart = (spacing, label) => ({
500
+ tag: div,
501
+ attributes: { style: 'flex: 1; min-width: 200px;' },
502
+ children: [
503
+ { tag: div, attributes: { style: 'font-weight: bold; margin-bottom: 0.5rem; text-align: center;' }, children: [label] },
504
+ {
505
+ tag: Chart,
506
+ attributes: {
507
+ type: 'pie',
508
+ spacing,
509
+ style: 'width: 100%; max-width: 200px; margin: 0 auto; aspect-ratio: 1;'
510
+ },
511
+ children: [
512
+ {
513
+ tag: Chart.Body,
514
+ children: segments.map(s => ({
515
+ tag: Chart.Row,
516
+ children: [{ tag: Chart.Data, attributes: s }]
517
+ }))
518
+ }
519
+ ]
520
+ }
521
+ ]
522
+ });
523
+
524
+ const charts = {
525
+ tag: div,
526
+ attributes: { style: 'display: flex; gap: 2rem; flex-wrap: wrap;' },
527
+ children: [
528
+ createChart(undefined, 'No spacing'),
529
+ createChart(5, 'spacing: 5')
530
+ ]
531
+ };
532
+
533
+ $('#example').content(charts);</code></pre>
534
+ </div>
535
+
536
+ <!-- Object DOM Syntax -->
537
+ <div id="spacing-pie-syntax-object" style="display: none;">
538
+ <pre><script>
539
+ examplify(document.currentScript.nextElementSibling, {
540
+ at: document.currentScript.parentElement,
541
+ scripts: ['/lightview.js', '/lightview-x.js'],
542
+ styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
543
+ type: 'module',
544
+ minHeight: 300
545
+ });
546
+ </script><code contenteditable="true">await import('/components/data-display/chart.js');
547
+ const { $ } = Lightview;
548
+
549
+ const chartData = [
550
+ { 'Chart.Row': { children: [{ 'Chart.Data': { start: 0.0, end: 0.4, color: '#E91E63' } }] } },
551
+ { 'Chart.Row': { children: [{ 'Chart.Data': { start: 0.4, end: 0.7, color: '#9C27B0' } }] } },
552
+ { 'Chart.Row': { children: [{ 'Chart.Data': { start: 0.7, end: 1.0, color: '#673AB7' } }] } }
553
+ ];
554
+
555
+ const charts = {
556
+ div: {
557
+ style: 'display: flex; gap: 2rem; flex-wrap: wrap;',
558
+ children: [
559
+ {
560
+ div: {
561
+ style: 'flex: 1; min-width: 200px;',
562
+ children: [
563
+ { div: { style: 'font-weight: bold; margin-bottom: 0.5rem; text-align: center;', children: ['No spacing'] } },
564
+ { Chart: { type: 'pie', style: 'width: 100%; max-width: 200px; margin: 0 auto; aspect-ratio: 1;', children: [{ 'Chart.Body': { children: chartData } }] } }
565
+ ]
566
+ }
567
+ },
568
+ {
569
+ div: {
570
+ style: 'flex: 1; min-width: 200px;',
571
+ children: [
572
+ { div: { style: 'font-weight: bold; margin-bottom: 0.5rem; text-align: center;', children: ['spacing: 5'] } },
573
+ { Chart: { type: 'pie', spacing: 5, style: 'width: 100%; max-width: 200px; margin: 0 auto; aspect-ratio: 1;', children: [{ 'Chart.Body': { children: chartData } }] } }
574
+ ]
575
+ }
576
+ }
577
+ ]
578
+ }
579
+ };
580
+
581
+ $('#example').content(charts);</code></pre>
582
+ </div>
583
+ </div>
584
+ </div>
585
+
586
+ <!-- Color Schemes -->
587
+ <div class="card bg-base-200" style="margin-bottom: 2rem;">
588
+ <div class="card-body">
589
+ <h2 class="card-title">Color Schemes</h2>
590
+ <p class="text-sm" style="opacity: 0.7; margin-bottom: 1rem;">
591
+ Use custom colors for each slice via the <code>color</code> prop.
592
+ </p>
593
+
594
+ <!-- Tabs -->
595
+ <script>
596
+ window.switchColorPieTab = (tabId) => {
597
+ const tabs = ['tagged', 'vdom', 'object'];
598
+ tabs.forEach(t => {
599
+ const tabEl = document.getElementById(`color-pie-tab-btn-${t}`);
600
+ const contentEl = document.getElementById(`color-pie-syntax-${t}`);
601
+ if (t === tabId) {
602
+ tabEl.classList.add('syntax-tab-active');
603
+ contentEl.style.display = 'block';
604
+ } else {
605
+ tabEl.classList.remove('syntax-tab-active');
606
+ contentEl.style.display = 'none';
607
+ }
608
+ });
609
+ };
610
+ </script>
611
+ <div role="tablist" class="syntax-tabs" style="margin-bottom: 1rem;">
612
+ <button id="color-pie-tab-btn-tagged" role="tab" class="syntax-tab syntax-tab-active"
613
+ onclick="switchColorPieTab('tagged')">Tagged</button>
614
+ <button id="color-pie-tab-btn-vdom" role="tab" class="syntax-tab"
615
+ onclick="switchColorPieTab('vdom')">vDOM</button>
616
+ <button id="color-pie-tab-btn-object" role="tab" class="syntax-tab"
617
+ onclick="switchColorPieTab('object')">Object DOM</button>
618
+ </div>
619
+
620
+ <!-- Tagged Syntax -->
621
+ <div id="color-pie-syntax-tagged">
622
+ <pre><script>
623
+ examplify(document.currentScript.nextElementSibling, {
624
+ at: document.currentScript.parentElement,
625
+ scripts: ['/lightview.js', '/lightview-x.js'],
626
+ styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
627
+ type: 'module',
628
+ minHeight: 300,
629
+ autoRun: true
630
+ });
631
+ </script><code contenteditable="true">await import('/components/data-display/chart.js');
632
+ const { tags, $ } = Lightview;
633
+ const { Chart, span } = tags;
634
+
635
+ const chart = Chart({
636
+ type: 'pie',
637
+ labels: true,
638
+ spacing: 2,
639
+ style: 'width: 100%; max-width: 300px; margin: 0 auto; aspect-ratio: 1;'
640
+ },
641
+ Chart.Body({},
642
+ Chart.Row({},
643
+ Chart.Label({}, 'Desktop'),
644
+ Chart.Data({ start: 0.0, end: 0.45, color: '#00BCD4' },
645
+ span({ class: 'data' }, '45%'))
646
+ ),
647
+ Chart.Row({},
648
+ Chart.Label({}, 'Mobile'),
649
+ Chart.Data({ start: 0.45, end: 0.80, color: '#8BC34A' },
650
+ span({ class: 'data' }, '35%'))
651
+ ),
652
+ Chart.Row({},
653
+ Chart.Label({}, 'Tablet'),
654
+ Chart.Data({ start: 0.80, end: 0.95, color: '#FFC107' },
655
+ span({ class: 'data' }, '15%'))
656
+ ),
657
+ Chart.Row({},
658
+ Chart.Label({}, 'Other'),
659
+ Chart.Data({ start: 0.95, end: 1.0, color: '#607D8B' },
660
+ span({ class: 'data' }, '5%'))
661
+ )
662
+ )
663
+ );
664
+
665
+ $('#example').content(chart);</code></pre>
666
+ </div>
667
+
668
+ <!-- vDOM Syntax -->
669
+ <div id="color-pie-syntax-vdom" style="display: none;">
670
+ <pre><script>
671
+ examplify(document.currentScript.nextElementSibling, {
672
+ at: document.currentScript.parentElement,
673
+ scripts: ['/lightview.js', '/lightview-x.js'],
674
+ styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
675
+ type: 'module',
676
+ minHeight: 300
677
+ });
678
+ </script><code contenteditable="true">await import('/components/data-display/chart.js');
679
+ const { tags, $ } = Lightview;
680
+ const { Chart, span } = tags;
681
+
682
+ const devices = [
683
+ { name: 'Desktop', start: 0.0, end: 0.45, color: '#00BCD4', text: '45%' },
684
+ { name: 'Mobile', start: 0.45, end: 0.80, color: '#8BC34A', text: '35%' },
685
+ { name: 'Tablet', start: 0.80, end: 0.95, color: '#FFC107', text: '15%' },
686
+ { name: 'Other', start: 0.95, end: 1.0, color: '#607D8B', text: '5%' }
687
+ ];
688
+
689
+ const chart = {
690
+ tag: Chart,
691
+ attributes: {
692
+ type: 'pie',
693
+ labels: true,
694
+ spacing: 2,
695
+ style: 'width: 100%; max-width: 300px; margin: 0 auto; aspect-ratio: 1;'
696
+ },
697
+ children: [
698
+ {
699
+ tag: Chart.Body,
700
+ children: devices.map(d => ({
701
+ tag: Chart.Row,
702
+ children: [
703
+ { tag: Chart.Label, children: [d.name] },
704
+ {
705
+ tag: Chart.Data,
706
+ attributes: { start: d.start, end: d.end, color: d.color },
707
+ children: [{ tag: span, attributes: { class: 'data' }, children: [d.text] }]
708
+ }
709
+ ]
710
+ }))
711
+ }
712
+ ]
713
+ };
714
+
715
+ $('#example').content(chart);</code></pre>
716
+ </div>
717
+
718
+ <!-- Object DOM Syntax -->
719
+ <div id="color-pie-syntax-object" style="display: none;">
720
+ <pre><script>
721
+ examplify(document.currentScript.nextElementSibling, {
722
+ at: document.currentScript.parentElement,
723
+ scripts: ['/lightview.js', '/lightview-x.js'],
724
+ styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'],
725
+ type: 'module',
726
+ minHeight: 300
727
+ });
728
+ </script><code contenteditable="true">await import('/components/data-display/chart.js');
729
+ const { $ } = Lightview;
730
+
731
+ const chart = {
732
+ Chart: {
733
+ type: 'pie',
734
+ labels: true,
735
+ spacing: 2,
736
+ style: 'width: 100%; max-width: 300px; margin: 0 auto; aspect-ratio: 1;',
737
+ children: [
738
+ {
739
+ 'Chart.Body': {
740
+ children: [
741
+ { 'Chart.Row': { children: [{ 'Chart.Label': { children: ['Desktop'] } }, { 'Chart.Data': { start: 0.0, end: 0.45, color: '#00BCD4', children: [{ span: { class: 'data', children: ['45%'] } }] } }] } },
742
+ { 'Chart.Row': { children: [{ 'Chart.Label': { children: ['Mobile'] } }, { 'Chart.Data': { start: 0.45, end: 0.80, color: '#8BC34A', children: [{ span: { class: 'data', children: ['35%'] } }] } }] } },
743
+ { 'Chart.Row': { children: [{ 'Chart.Label': { children: ['Tablet'] } }, { 'Chart.Data': { start: 0.80, end: 0.95, color: '#FFC107', children: [{ span: { class: 'data', children: ['15%'] } }] } }] } },
744
+ { 'Chart.Row': { children: [{ 'Chart.Label': { children: ['Other'] } }, { 'Chart.Data': { start: 0.95, end: 1.0, color: '#607D8B', children: [{ span: { class: 'data', children: ['5%'] } }] } }] } }
745
+ ]
746
+ }
747
+ }
748
+ ]
749
+ }
750
+ };
751
+
752
+ $('#example').content(chart);</code></pre>
753
+ </div>
754
+ </div>
755
+ </div>
756
+
757
+ <!-- Calculating Values -->
758
+ <h2 class="text-xl font-bold mb-4">Calculating Values</h2>
759
+ <div class="card bg-base-100 shadow-sm mb-8">
760
+ <div class="card-body">
761
+ <p class="mb-4">Here's how to calculate <code>--start</code> and <code>--end</code> from
762
+ percentages:
763
+ </p>
764
+ <div class="overflow-x-auto">
765
+ <table class="table table-zebra">
766
+ <thead>
767
+ <tr>
768
+ <th>Segment</th>
769
+ <th>Percentage</th>
770
+ <th>--start</th>
771
+ <th>--end</th>
772
+ </tr>
773
+ </thead>
774
+ <tbody>
775
+ <tr>
776
+ <td>First</td>
777
+ <td>50%</td>
778
+ <td>0.0</td>
779
+ <td>0.5 (0 + 0.5)</td>
780
+ </tr>
781
+ <tr>
782
+ <td>Second</td>
783
+ <td>30%</td>
784
+ <td>0.5 (prev end)</td>
785
+ <td>0.8 (0.5 + 0.3)</td>
786
+ </tr>
787
+ <tr>
788
+ <td>Third</td>
789
+ <td>20%</td>
790
+ <td>0.8 (prev end)</td>
791
+ <td>1.0 (0.8 + 0.2)</td>
792
+ </tr>
793
+ </tbody>
794
+ </table>
795
+ </div>
796
+ <div class="mt-4">
797
+ <pre class="bg-base-300 p-4 rounded-lg text-sm overflow-x-auto"><code>// Helper function to convert percentages to pie chart values
798
+ function percentagesToPie(percentages) {
799
+ let cumulative = 0;
800
+ return percentages.map(pct => {
801
+ const start = cumulative;
802
+ cumulative += pct / 100;
803
+ return { start, end: cumulative };
804
+ });
805
+ }
806
+
807
+ // Example:
808
+ const slices = percentagesToPie([50, 30, 20]);
809
+ // Returns: [
810
+ // { start: 0, end: 0.5 },
811
+ // { start: 0.5, end: 0.8 },
812
+ // { start: 0.8, end: 1.0 }
813
+ // ]</code></pre>
814
+ </div>
815
+ </div>
816
+ </div>
817
+
818
+
819
+ </div>
820
+ </div>
821
+ </div>
822
+ </div>
823
+ </div>