semiotic 3.1.2 → 3.2.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 (133) hide show
  1. package/CLAUDE.md +173 -213
  2. package/LICENSE +197 -10
  3. package/README.md +12 -11
  4. package/ai/dist/componentRegistry.js +6 -0
  5. package/ai/dist/mcp-server.js +115 -5
  6. package/ai/examples.md +184 -0
  7. package/ai/schema.json +4140 -888
  8. package/ai/system-prompt.md +36 -1
  9. package/dist/components/ChartContainer.d.ts +2 -0
  10. package/dist/components/DataSummaryContext.d.ts +12 -0
  11. package/dist/components/ThemeProvider.d.ts +5 -3
  12. package/dist/components/Tooltip/FlippingTooltip.d.ts +34 -0
  13. package/dist/components/charts/geo/ChoroplethMap.d.ts +1 -1
  14. package/dist/components/charts/index.d.ts +12 -1
  15. package/dist/components/charts/ordinal/BarChart.d.ts +4 -1
  16. package/dist/components/charts/ordinal/BoxPlot.d.ts +4 -1
  17. package/dist/components/charts/ordinal/DonutChart.d.ts +1 -1
  18. package/dist/components/charts/ordinal/DotPlot.d.ts +4 -1
  19. package/dist/components/charts/ordinal/FunnelChart.d.ts +57 -0
  20. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +4 -1
  21. package/dist/components/charts/ordinal/Histogram.d.ts +17 -2
  22. package/dist/components/charts/ordinal/LikertChart.d.ts +94 -0
  23. package/dist/components/charts/ordinal/PieChart.d.ts +1 -1
  24. package/dist/components/charts/ordinal/RidgelinePlot.d.ts +12 -7
  25. package/dist/components/charts/ordinal/StackedBarChart.d.ts +4 -1
  26. package/dist/components/charts/ordinal/SwarmPlot.d.ts +15 -1
  27. package/dist/components/charts/ordinal/SwimlaneChart.d.ts +65 -0
  28. package/dist/components/charts/ordinal/ViolinPlot.d.ts +17 -2
  29. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +20 -0
  30. package/dist/components/charts/shared/annotationResolvers.d.ts +28 -0
  31. package/dist/components/charts/shared/colorManipulation.d.ts +15 -0
  32. package/dist/components/charts/shared/formatUtils.d.ts +28 -0
  33. package/dist/components/charts/shared/hatchPattern.d.ts +35 -0
  34. package/dist/components/charts/shared/hooks.d.ts +39 -3
  35. package/dist/components/charts/shared/legendUtils.d.ts +2 -1
  36. package/dist/components/charts/shared/selectionUtils.d.ts +16 -1
  37. package/dist/components/charts/shared/statisticalOverlays.d.ts +49 -5
  38. package/dist/components/charts/shared/statsTooltip.d.ts +11 -0
  39. package/dist/components/charts/shared/types.d.ts +26 -2
  40. package/dist/components/charts/shared/useChartSetup.d.ts +12 -2
  41. package/dist/components/charts/shared/useLikertAggregation.d.ts +51 -0
  42. package/dist/components/charts/shared/useOrdinalBrush.d.ts +28 -0
  43. package/dist/components/charts/shared/useOrdinalStreaming.d.ts +54 -0
  44. package/dist/components/charts/shared/useStreamingLegend.d.ts +2 -2
  45. package/dist/components/charts/shared/validateProps.d.ts +2 -2
  46. package/dist/components/charts/shared/validationMap.d.ts +12 -0
  47. package/dist/components/charts/xy/AreaChart.d.ts +11 -0
  48. package/dist/components/charts/xy/Heatmap.d.ts +1 -1
  49. package/dist/components/charts/xy/MinimapChart.d.ts +1 -1
  50. package/dist/components/charts/xy/MultiAxisLineChart.d.ts +71 -0
  51. package/dist/components/charts/xy/StackedAreaChart.d.ts +11 -0
  52. package/dist/components/realtime/types.d.ts +6 -0
  53. package/dist/components/semiotic-ai.d.ts +4 -0
  54. package/dist/components/semiotic-ordinal.d.ts +5 -0
  55. package/dist/components/semiotic-themes.d.ts +80 -0
  56. package/dist/components/semiotic-utils.d.ts +30 -0
  57. package/dist/components/semiotic-xy.d.ts +1 -0
  58. package/dist/components/semiotic.d.ts +11 -5
  59. package/dist/components/store/LinkedCrosshairStore.d.ts +11 -0
  60. package/dist/components/store/ThemeStore.d.ts +22 -2
  61. package/dist/components/store/useSelection.d.ts +1 -0
  62. package/dist/components/stream/AccessibleDataTable.d.ts +28 -6
  63. package/dist/components/stream/FocusRing.d.ts +33 -0
  64. package/dist/components/stream/OrdinalBrushOverlay.d.ts +43 -0
  65. package/dist/components/stream/OrdinalPipelineStore.d.ts +16 -0
  66. package/dist/components/stream/OrdinalSVGOverlay.d.ts +2 -1
  67. package/dist/components/stream/PipelineStore.d.ts +7 -47
  68. package/dist/components/stream/SVGOverlay.d.ts +9 -3
  69. package/dist/components/stream/SceneGraph.d.ts +6 -1
  70. package/dist/components/stream/XYBrushOverlay.d.ts +47 -0
  71. package/dist/components/stream/accessorUtils.d.ts +14 -0
  72. package/dist/components/stream/geoTypes.d.ts +5 -1
  73. package/dist/components/stream/keyboardNav.d.ts +85 -9
  74. package/dist/components/stream/layouts/hierarchySceneBuilders.d.ts +35 -0
  75. package/dist/components/stream/layouts/hierarchyUtils.d.ts +25 -0
  76. package/dist/components/stream/networkTypes.d.ts +7 -1
  77. package/dist/components/stream/ordinalSceneBuilders/barFunnelScene.d.ts +27 -0
  78. package/dist/components/stream/ordinalSceneBuilders/funnelScene.d.ts +26 -0
  79. package/dist/components/stream/ordinalSceneBuilders/swimlaneScene.d.ts +12 -0
  80. package/dist/components/stream/ordinalTypes.d.ts +30 -4
  81. package/dist/components/stream/pipelineDecay.d.ts +20 -0
  82. package/dist/components/stream/pipelinePulse.d.ts +24 -0
  83. package/dist/components/stream/pipelineTransitions.d.ts +59 -0
  84. package/dist/components/stream/renderers/barFunnelCanvasRenderer.d.ts +12 -0
  85. package/dist/components/stream/renderers/pointCanvasRenderer.d.ts +2 -1
  86. package/dist/components/stream/renderers/trapezoidCanvasRenderer.d.ts +15 -0
  87. package/dist/components/stream/sceneUtils.d.ts +10 -0
  88. package/dist/components/stream/types.d.ts +29 -4
  89. package/dist/components/stream/useMediaPreferences.d.ts +11 -0
  90. package/dist/components/stream/xySceneBuilders/areaScene.d.ts +13 -0
  91. package/dist/components/stream/xySceneBuilders/barScene.d.ts +18 -0
  92. package/dist/components/stream/xySceneBuilders/boundsScene.d.ts +8 -0
  93. package/dist/components/stream/xySceneBuilders/candlestickScene.d.ts +10 -0
  94. package/dist/components/stream/xySceneBuilders/emitPointNodes.d.ts +13 -0
  95. package/dist/components/stream/xySceneBuilders/heatmapScene.d.ts +3 -0
  96. package/dist/components/stream/xySceneBuilders/lineScene.d.ts +12 -0
  97. package/dist/components/stream/xySceneBuilders/pointScene.d.ts +12 -0
  98. package/dist/components/stream/xySceneBuilders/swarmScene.d.ts +10 -0
  99. package/dist/components/stream/xySceneBuilders/types.d.ts +93 -0
  100. package/dist/components/stream/xySceneBuilders/waterfallScene.d.ts +12 -0
  101. package/dist/geo.min.js +1 -1
  102. package/dist/geo.module.min.js +1 -1
  103. package/dist/network.min.js +1 -1
  104. package/dist/network.module.min.js +1 -1
  105. package/dist/ordinal.min.js +1 -1
  106. package/dist/ordinal.module.min.js +1 -1
  107. package/dist/realtime.min.js +1 -1
  108. package/dist/realtime.module.min.js +1 -1
  109. package/dist/semiotic-ai-statisticalOverlays-C2PPlmXv.js +1 -0
  110. package/dist/semiotic-ai.d.ts +4 -0
  111. package/dist/semiotic-ai.min.js +1 -1
  112. package/dist/semiotic-ai.module.min.js +1 -1
  113. package/dist/semiotic-ordinal.d.ts +5 -0
  114. package/dist/semiotic-statisticalOverlays-DGX_WWc5.js +1 -0
  115. package/dist/semiotic-themes.d.ts +80 -0
  116. package/dist/semiotic-themes.min.js +1 -0
  117. package/dist/semiotic-themes.module.min.js +1 -0
  118. package/dist/semiotic-utils.d.ts +30 -0
  119. package/dist/semiotic-utils.min.js +1 -0
  120. package/dist/semiotic-utils.module.min.js +1 -0
  121. package/dist/semiotic-xy.d.ts +1 -0
  122. package/dist/semiotic.d.ts +11 -5
  123. package/dist/semiotic.min.js +1 -1
  124. package/dist/semiotic.module.min.js +1 -1
  125. package/dist/server.min.js +1 -1
  126. package/dist/server.module.min.js +1 -1
  127. package/dist/xy-statisticalOverlays-C2PPlmXv.js +1 -0
  128. package/dist/xy.min.js +1 -1
  129. package/dist/xy.module.min.js +1 -1
  130. package/package.json +38 -12
  131. package/dist/semiotic-ai-statisticalOverlays-C1f7TYyD.js +0 -1
  132. package/dist/semiotic-statisticalOverlays-C1f7TYyD.js +0 -1
  133. package/dist/xy-statisticalOverlays-C1f7TYyD.js +0 -1
package/LICENSE CHANGED
@@ -1,13 +1,200 @@
1
- Copyright 2017 Elijah Meeks
2
1
 
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
6
5
 
7
- http://www.apache.org/licenses/LICENSE-2.0
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
7
 
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
13
- limitations under the License.
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to the Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by the Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding any notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. Please also get an approval
186
+ for your intended use from the project maintainers.
187
+
188
+ Copyright 2017 Elijah Meeks
189
+
190
+ Licensed under the Apache License, Version 2.0 (the "License");
191
+ you may not use this file except in compliance with the License.
192
+ You may obtain a copy of the License at
193
+
194
+ http://www.apache.org/licenses/LICENSE-2.0
195
+
196
+ Unless required by applicable law or agreed to in writing, software
197
+ distributed under the License is distributed on an "AS IS" BASIS,
198
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
199
+ See the License for the specific language governing permissions and
200
+ limitations under the License.
package/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  [![CI](https://github.com/nteract/semiotic/actions/workflows/node.js.yml/badge.svg?branch=main)](https://github.com/nteract/semiotic/actions/workflows/node.js.yml)
4
4
  [![npm version](https://img.shields.io/npm/v/semiotic.svg)](https://www.npmjs.com/package/semiotic)
5
5
  [![TypeScript](https://img.shields.io/badge/TypeScript-built--in-blue.svg)](https://www.typescriptlang.org/)
6
+ [![semiotic MCP server](https://glama.ai/mcp/servers/nteract/semiotic/badges/card.svg)](https://glama.ai/mcp/servers/nteract/semiotic)
6
7
 
7
8
  A React data visualization library designed for AI-assisted development.
8
9
 
@@ -33,7 +34,7 @@ generate correct code without examples.
33
34
  Semiotic ships with everything an AI coding assistant needs to generate
34
35
  correct visualizations without trial and error:
35
36
 
36
- - **`semiotic/ai`** — a single import with all 37 chart components, optimized for LLM code generation
37
+ - **`semiotic/ai`** — a single import with all 38 chart components, optimized for LLM code generation
37
38
  - **`ai/schema.json`** — machine-readable prop schemas for every component
38
39
  - **`npx semiotic-mcp`** — an MCP server for tool-based chart rendering in any MCP client
39
40
  - **`npx semiotic-ai --doctor`** — validate component + props JSON from the command line with typo suggestions and anti-pattern detection
@@ -58,8 +59,8 @@ ref-based push API. Built-in decay, pulse, and staleness encoding for
58
59
  monitoring dashboards.
59
60
 
60
61
  **Coordinated views.** `LinkedCharts` provides hover cross-highlighting,
61
- brush cross-filtering, and selection synchronization across any combination
62
- of chart types — zero wiring.
62
+ brush cross-filtering, coordinate-based linked crosshairs, and selection
63
+ synchronization across any combination of chart types — zero wiring.
63
64
 
64
65
  **Geographic visualization.** Choropleth maps, proportional symbol maps, flow
65
66
  maps with animated particles, and distance cartograms — all canvas-rendered
@@ -238,8 +239,8 @@ import { LineChart, BarChart } from "semiotic"
238
239
 
239
240
  | Category | Components |
240
241
  |---|---|
241
- | **XY** | `LineChart` `AreaChart` `StackedAreaChart` `Scatterplot` `ConnectedScatterplot` `BubbleChart` `Heatmap` `QuadrantChart` `MinimapChart` |
242
- | **Categorical** | `BarChart` `StackedBarChart` `GroupedBarChart` `SwarmPlot` `BoxPlot` `Histogram` `ViolinPlot` `RidgelinePlot` `DotPlot` `PieChart` `DonutChart` |
242
+ | **XY** | `LineChart` `AreaChart` `StackedAreaChart` `Scatterplot` `ConnectedScatterplot` `BubbleChart` `Heatmap` `QuadrantChart` `MultiAxisLineChart` `MinimapChart` |
243
+ | **Categorical** | `BarChart` `StackedBarChart` `GroupedBarChart` `LikertChart` `SwimlaneChart` `FunnelChart` `SwarmPlot` `BoxPlot` `Histogram` `ViolinPlot` `RidgelinePlot` `DotPlot` `PieChart` `DonutChart` |
243
244
  | **Network** | `ForceDirectedGraph` `ChordDiagram` `SankeyDiagram` `TreeDiagram` `Treemap` `CirclePack` `OrbitDiagram` |
244
245
  | **Geo** | `ChoroplethMap` `ProportionalSymbolMap` `FlowMap` `DistanceCartogram` |
245
246
  | **Realtime** | `RealtimeLineChart` `RealtimeHistogram` `RealtimeSwarmChart` `RealtimeWaterfallChart` `RealtimeHeatmap` |
@@ -281,11 +282,11 @@ for color, size, aggregation, and binning.
281
282
  Import only what you need:
282
283
 
283
284
  ```jsx
284
- import { LineChart } from "semiotic/xy" // ~156 KB
285
- import { BarChart } from "semiotic/ordinal" // ~124 KB
286
- import { ForceDirectedGraph } from "semiotic/network" // ~123 KB
287
- import { ChoroplethMap } from "semiotic/geo" // ~102 KB (+ d3-geo peer)
288
- import { LineChart } from "semiotic/ai" // ~397 KB (all HOCs)
285
+ import { LineChart } from "semiotic/xy" // ~123 KB gzip
286
+ import { BarChart } from "semiotic/ordinal" // ~88 KB gzip
287
+ import { ForceDirectedGraph } from "semiotic/network" // ~89 KB gzip
288
+ import { ChoroplethMap } from "semiotic/geo" // ~82 KB gzip
289
+ import { LineChart } from "semiotic/ai" // ~236 KB gzip (all HOCs)
289
290
  ```
290
291
 
291
292
  Granular entry points export only v3 Stream Frames and HOC charts — no legacy
@@ -442,7 +443,7 @@ npx semiotic-ai --compact # compact schema (fewer tokens)
442
443
  [Interactive docs and examples](https://semiotic.nteract.io)
443
444
 
444
445
  - [Getting Started](https://semiotic.nteract.io/getting-started)
445
- - [Charts](https://semiotic.nteract.io/charts) — all 37 chart types with live examples
446
+ - [Charts](https://semiotic.nteract.io/charts) — all 38 chart types with live examples
446
447
  - [Frames](https://semiotic.nteract.io/frames) — full Frame API reference
447
448
  - [Features](https://semiotic.nteract.io/features) — axes, annotations, tooltips, styling, Vega-Lite translator
448
449
  - [Cookbook](https://semiotic.nteract.io/cookbook) — advanced patterns and recipes
@@ -11,14 +11,20 @@ exports.COMPONENT_REGISTRY = {
11
11
  BubbleChart: { component: ai_1.BubbleChart, category: "xy" },
12
12
  Heatmap: { component: ai_1.Heatmap, category: "xy" },
13
13
  ConnectedScatterplot: { component: ai_1.ConnectedScatterplot, category: "xy" },
14
+ QuadrantChart: { component: ai_1.QuadrantChart, category: "xy" },
15
+ MultiAxisLineChart: { component: ai_1.MultiAxisLineChart, category: "xy" },
14
16
  BarChart: { component: ai_1.BarChart, category: "ordinal" },
15
17
  StackedBarChart: { component: ai_1.StackedBarChart, category: "ordinal" },
16
18
  GroupedBarChart: { component: ai_1.GroupedBarChart, category: "ordinal" },
17
19
  SwarmPlot: { component: ai_1.SwarmPlot, category: "ordinal" },
18
20
  BoxPlot: { component: ai_1.BoxPlot, category: "ordinal" },
19
21
  DotPlot: { component: ai_1.DotPlot, category: "ordinal" },
22
+ Histogram: { component: ai_1.Histogram, category: "ordinal" },
23
+ ViolinPlot: { component: ai_1.ViolinPlot, category: "ordinal" },
24
+ RidgelinePlot: { component: ai_1.RidgelinePlot, category: "ordinal" },
20
25
  PieChart: { component: ai_1.PieChart, category: "ordinal" },
21
26
  DonutChart: { component: ai_1.DonutChart, category: "ordinal" },
27
+ FunnelChart: { component: ai_1.FunnelChart, category: "ordinal" },
22
28
  ForceDirectedGraph: { component: ai_1.ForceDirectedGraph, category: "network" },
23
29
  ChordDiagram: { component: ai_1.ChordDiagram, category: "network" },
24
30
  SankeyDiagram: { component: ai_1.SankeyDiagram, category: "network" },
@@ -84,7 +84,7 @@ async function getSchemaHandler(args) {
84
84
  const renderable = new Set(Object.keys(componentRegistry_1.COMPONENT_REGISTRY));
85
85
  const list = all.map(name => renderable.has(name) ? `${name} [renderable]` : name);
86
86
  return {
87
- content: [{ type: "text", text: `Available components (${all.length}):\n${list.join(", ")}\n\nComponents marked [renderable] can be rendered to SVG via renderChart. Others (Realtime*) require a browser environment.\n\nPass { component: '<name>' } to get the prop schema for a specific component.` }],
87
+ content: [{ type: "text", text: `Available components (${all.length}):\n${list.join(", ")}\n\nComponents marked [renderable] can be rendered to SVG via renderChart (pass theme parameter for styled output). Others (Realtime*) require a browser environment.\n\nAll charts support CSS custom properties for theming (--semiotic-bg, --semiotic-text, --semiotic-grid, etc.) and <ThemeProvider>. Use COLOR_BLIND_SAFE_CATEGORICAL (import from semiotic) for accessible color palettes.\n\nPass { component: '<name>' } to get the prop schema for a specific component.` }],
88
88
  };
89
89
  }
90
90
  const entry = schemaByComponent[component];
@@ -305,13 +305,17 @@ async function suggestChartHandler(args) {
305
305
  const propsStr = Object.entries(s.props).map(([k, v]) => `${k}=${v}`).join(" ");
306
306
  return `${i + 1}. **${s.component}** (${s.confidence} confidence)\n ${s.reason}\n \`<${s.component} ${propsStr} />\``;
307
307
  });
308
+ // Theming guidance appended to every recommendation
309
+ const themingTip = `\n---\n**Styling**: All charts respond to CSS custom properties on any ancestor element:\n\`\`\`css\n.my-theme {\n --semiotic-bg: #fff; /* chart background */\n --semiotic-text: #333; /* primary text */\n --semiotic-text-secondary: #666; /* tick labels */\n --semiotic-grid: #e0e0e0; /* grid lines */\n --semiotic-border: #e0e0e0; /* axis lines, borders */\n --semiotic-font-family: sans-serif;\n --semiotic-tooltip-bg: rgba(0,0,0,0.85);\n --semiotic-tooltip-text: white;\n --semiotic-tooltip-radius: 6px;\n}\n\`\`\`\nOr use \`<ThemeProvider theme="dark">\` / \`<ThemeProvider theme={{ colors: {...}, typography: {...} }}>\`.\nFor accessibility, use \`colorScheme={COLOR_BLIND_SAFE_CATEGORICAL}\` (import from \`semiotic\`) — 8-color palette safe for all forms of color blindness.`;
308
310
  return {
309
- content: [{ type: "text", text: lines.join("\n\n") }],
311
+ content: [{ type: "text", text: lines.join("\n\n") + themingTip }],
310
312
  };
311
313
  }
312
314
  async function renderChartHandler(args) {
313
315
  const component = args.component;
314
316
  const props = args.props ?? {};
317
+ const theme = args.theme;
318
+ const format = args.format || "svg";
315
319
  if (!component) {
316
320
  return {
317
321
  content: [{ type: "text", text: `Missing 'component' field. Provide { component: '<name>', props: { ... } }. Available: ${componentNames.join(", ")}` }],
@@ -331,8 +335,46 @@ async function renderChartHandler(args) {
331
335
  isError: true,
332
336
  };
333
337
  }
338
+ let svg = result.svg;
339
+ // Inject theme CSS custom properties into the SVG root element.
340
+ // We add a <style> block inside the SVG rather than wrapping in a <div>,
341
+ // because sharp requires pure SVG input for PNG rasterization.
342
+ if (theme && Object.keys(theme).length > 0) {
343
+ const validVars = Object.entries(theme)
344
+ .filter(([k]) => k.startsWith("--semiotic-"))
345
+ .map(([k, v]) => `${k}: ${v}`)
346
+ .join("; ");
347
+ if (validVars) {
348
+ svg = svg.replace(/<svg([^>]*)>/, `<svg$1><style>:root { ${validVars} }</style>`);
349
+ }
350
+ }
351
+ // PNG rasterization via sharp (optional dependency)
352
+ if (format === "png") {
353
+ try {
354
+ // Dynamic import — sharp is an optional dependency
355
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
356
+ const sharpMod = await Function('return import("sharp")')();
357
+ const sharpFn = sharpMod.default || sharpMod;
358
+ const pngBuffer = await sharpFn(Buffer.from(svg)).png().toBuffer();
359
+ const base64 = pngBuffer.toString("base64");
360
+ return {
361
+ content: [{ type: "text", text: `data:image/png;base64,${base64}` }],
362
+ };
363
+ }
364
+ catch (err) {
365
+ if (err.code === "MODULE_NOT_FOUND" || err.code === "ERR_MODULE_NOT_FOUND") {
366
+ return {
367
+ content: [{ type: "text", text: `PNG output requires the 'sharp' package. Install it with: npm install sharp\n\nFalling back to SVG output:\n\n${svg}` }],
368
+ };
369
+ }
370
+ return {
371
+ content: [{ type: "text", text: `PNG conversion failed: ${err.message}\n\nSVG output:\n\n${svg}` }],
372
+ isError: true,
373
+ };
374
+ }
375
+ }
334
376
  return {
335
- content: [{ type: "text", text: result.svg }],
377
+ content: [{ type: "text", text: svg }],
336
378
  };
337
379
  }
338
380
  async function diagnoseConfigHandler(args) {
@@ -385,6 +427,69 @@ async function reportIssueHandler(args) {
385
427
  content: [{ type: "text", text: `Open this URL to submit the issue:\n\n${url}` }],
386
428
  };
387
429
  }
430
+ // Named theme presets (inlined to avoid runtime dependency on semiotic-themes bundle)
431
+ const THEME_PRESET_NAMES = [
432
+ "light", "dark", "high-contrast",
433
+ "pastels", "pastels-dark",
434
+ "bi-tool", "bi-tool-dark",
435
+ "italian", "italian-dark",
436
+ "tufte", "tufte-dark",
437
+ "journalist", "journalist-dark",
438
+ "playful", "playful-dark",
439
+ ];
440
+ async function applyThemeHandler(args) {
441
+ const name = args.name;
442
+ if (!name) {
443
+ return {
444
+ content: [{ type: "text", text: `Available theme presets:\n${THEME_PRESET_NAMES.join(", ")}\n\nPass { name: "tufte" } to get the CSS custom properties and ThemeProvider usage for that theme.\n\nLight-mode presets: ${THEME_PRESET_NAMES.filter(n => !n.includes("dark")).join(", ")}\nDark-mode presets: ${THEME_PRESET_NAMES.filter(n => n.includes("dark")).join(", ")}` }],
445
+ };
446
+ }
447
+ if (!THEME_PRESET_NAMES.includes(name)) {
448
+ return {
449
+ content: [{ type: "text", text: `Unknown theme "${name}". Available: ${THEME_PRESET_NAMES.join(", ")}` }],
450
+ isError: true,
451
+ };
452
+ }
453
+ const usage = [
454
+ `## Theme: "${name}"`,
455
+ "",
456
+ "### Option 1: ThemeProvider (recommended)",
457
+ "```jsx",
458
+ `import { ThemeProvider } from "semiotic"`,
459
+ `<ThemeProvider theme="${name}">`,
460
+ ` <LineChart ... />`,
461
+ `</ThemeProvider>`,
462
+ "```",
463
+ "",
464
+ "### Option 2: Import the theme object",
465
+ "```jsx",
466
+ `import { ${name.replace(/-./g, c => c[1].toUpperCase()).replace(/^./, c => c.toUpperCase()).replace(/Dark$/, '_DARK').replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase()} } from "semiotic/themes"`,
467
+ `<ThemeProvider theme={themeObject}>`,
468
+ ` <BarChart ... />`,
469
+ `</ThemeProvider>`,
470
+ "```",
471
+ "",
472
+ "### Option 3: CSS custom properties (no React required)",
473
+ "```jsx",
474
+ `import { themeToCSS } from "semiotic/themes"`,
475
+ `import { ${name.replace(/-./g, c => c[1].toUpperCase()).replace(/^./, c => c.toUpperCase()).replace(/Dark$/, '_DARK').replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase()} } from "semiotic/themes"`,
476
+ `const css = themeToCSS(themeObject, ".my-charts")`,
477
+ "// Outputs CSS custom properties string for embedding in a stylesheet",
478
+ "```",
479
+ "",
480
+ "### Option 4: Design tokens JSON",
481
+ "```jsx",
482
+ `import { themeToTokens } from "semiotic/themes"`,
483
+ `const tokens = themeToTokens(themeObject)`,
484
+ "// Style Dictionary / DTCG-compatible token format",
485
+ "```",
486
+ "",
487
+ "For accessibility, consider `\"high-contrast\"` which uses `COLOR_BLIND_SAFE_CATEGORICAL` (Wong 2011 palette).",
488
+ ];
489
+ return {
490
+ content: [{ type: "text", text: usage.join("\n") }],
491
+ };
492
+ }
388
493
  // ── Server factory ───────────────────────────────────────────────────────
389
494
  // Creates a fresh McpServer with all tools registered.
390
495
  // HTTP mode needs one instance per session (McpServer can only connect to one transport).
@@ -399,11 +504,13 @@ function createServer() {
399
504
  data: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.unknown())).min(1).max(5).describe("1-5 sample data objects"),
400
505
  intent: zod_1.z.enum(["comparison", "trend", "distribution", "relationship", "composition", "geographic", "network", "hierarchy"]).optional().describe("Visualization intent to narrow suggestions"),
401
506
  }, suggestChartHandler);
402
- srv.tool("renderChart", `Render a Semiotic chart to static SVG. Returns SVG string or validation errors. Available components: ${componentNames.join(", ")}.`, {
507
+ srv.tool("renderChart", `Render a Semiotic chart to static SVG or PNG. Returns SVG string (default) or Base64-encoded PNG image. Optionally pass theme CSS custom properties (--semiotic-bg, --semiotic-text, etc.) to style the output. PNG requires the 'sharp' package to be installed. Available components: ${componentNames.join(", ")}.`, {
403
508
  component: zod_1.z.string().describe("Chart component name, e.g. 'LineChart', 'BarChart'"),
404
509
  props: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional().describe("Chart props object, e.g. { data: [...], xAccessor: 'x' }."),
510
+ theme: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional().describe("CSS custom properties for theming, e.g. { '--semiotic-bg': '#1a1a2e', '--semiotic-text': '#ededed' }. Only --semiotic-* variables are applied."),
511
+ format: zod_1.z.enum(["svg", "png"]).optional().describe("Output format: 'svg' (default) returns SVG markup, 'png' returns a Base64-encoded PNG image. PNG requires the 'sharp' package."),
405
512
  }, renderChartHandler);
406
- srv.tool("diagnoseConfig", "Diagnose a Semiotic chart configuration for common problems (empty data, bad dimensions, missing accessors, wrong data shape, etc). Returns a human-readable diagnostic report with actionable fixes.", {
513
+ srv.tool("diagnoseConfig", "Diagnose a Semiotic chart configuration for common problems (empty data, bad dimensions, missing accessors, wrong data shape, color contrast issues, etc). Checks WCAG color contrast ratios and suggests COLOR_BLIND_SAFE_CATEGORICAL for accessibility. Returns a human-readable diagnostic report with actionable fixes.", {
407
514
  component: zod_1.z.string().describe("Chart component name, e.g. 'LineChart'"),
408
515
  props: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional().describe("Chart props object, e.g. { data: [...], xAccessor: 'x' }."),
409
516
  }, diagnoseConfigHandler);
@@ -412,6 +519,9 @@ function createServer() {
412
519
  body: zod_1.z.string().optional().describe("Issue body with details, reproduction steps, diagnoseConfig output"),
413
520
  labels: zod_1.z.union([zod_1.z.array(zod_1.z.string()), zod_1.z.string()]).optional().describe("GitHub labels, e.g. ['bug'] or 'bug'"),
414
521
  }, reportIssueHandler);
522
+ srv.tool("applyTheme", `Get usage instructions for a named Semiotic theme preset. Returns ThemeProvider examples, CSS custom properties, and design token export patterns. Available themes: ${THEME_PRESET_NAMES.join(", ")}.`, {
523
+ name: zod_1.z.string().optional().describe("Theme preset name, e.g. 'tufte', 'pastels-dark', 'bi-tool'. Omit to list all available themes."),
524
+ }, applyThemeHandler);
415
525
  return srv;
416
526
  }
417
527
  // ── Startup ──────────────────────────────────────────────────────────────
package/ai/examples.md CHANGED
@@ -902,3 +902,187 @@ const containerRef = useRef<HTMLDivElement>(null)
902
902
  ```
903
903
 
904
904
  Key: `exportChart(wrapperDiv, { format, filename, scale, background })`. It queries the wrapper for canvas and SVG elements internally. Default format: PNG with 2x scale.
905
+
906
+ ---
907
+
908
+ ## Theming & Brand Styling
909
+
910
+ ### CSS Custom Properties (no React context needed)
911
+
912
+ ```jsx
913
+ // Dark theme via CSS custom properties on a wrapper div
914
+ <div style={{
915
+ "--semiotic-bg": "#1a1a2e",
916
+ "--semiotic-text": "#ededed",
917
+ "--semiotic-text-secondary": "#aaa",
918
+ "--semiotic-grid": "#333",
919
+ "--semiotic-border": "#555",
920
+ "--semiotic-font-family": "'Georgia', serif",
921
+ "--semiotic-tooltip-bg": "#1a1a2e",
922
+ "--semiotic-tooltip-text": "#ededed",
923
+ "--semiotic-tooltip-radius": "8px",
924
+ "--semiotic-tooltip-shadow": "0 4px 12px rgba(0,0,0,0.4)",
925
+ "--semiotic-primary": "#ff6b6b",
926
+ "--semiotic-focus": "#ff6b6b",
927
+ }}>
928
+ <LineChart
929
+ data={[{ x: 1, y: 10 }, { x: 2, y: 20 }, { x: 3, y: 15 }]}
930
+ xAccessor="x" yAccessor="y"
931
+ showGrid
932
+ annotations={[{ type: "y-threshold", value: 18, label: "Target" }]}
933
+ />
934
+ </div>
935
+ ```
936
+
937
+ ### ThemeProvider (React context)
938
+
939
+ ```jsx
940
+ import { ThemeProvider, DARK_THEME, COLOR_BLIND_SAFE_CATEGORICAL } from "semiotic"
941
+
942
+ // Preset dark theme
943
+ <ThemeProvider theme="dark">
944
+ <BarChart data={data} categoryAccessor="name" valueAccessor="value" />
945
+ </ThemeProvider>
946
+
947
+ // Custom brand theme (partial merge with defaults)
948
+ <ThemeProvider theme={{
949
+ mode: "light",
950
+ colors: {
951
+ primary: "#cc0000",
952
+ categorical: ["#cc0000", "#333333", "#c8a415", "#4682b4"],
953
+ background: "#fafafa",
954
+ text: "#1a1a1a",
955
+ textSecondary: "#666",
956
+ grid: "#e0e0e0",
957
+ border: "#e0e0e0",
958
+ },
959
+ typography: {
960
+ fontFamily: "'Helvetica Neue', Helvetica, Arial, sans-serif",
961
+ titleSize: 16, labelSize: 12, tickSize: 10,
962
+ },
963
+ tooltip: {
964
+ background: "#fafafa",
965
+ text: "#1a1a1a",
966
+ borderRadius: "4px",
967
+ },
968
+ }}>
969
+ <GroupedBarChart data={data} categoryAccessor="quarter" valueAccessor="revenue"
970
+ groupBy="region" colorBy="region" showGrid showLegend />
971
+ </ThemeProvider>
972
+
973
+ // Color-blind safe palette (Wong 2011 — 8 colors)
974
+ <Scatterplot data={data} xAccessor="x" yAccessor="y"
975
+ colorBy="category" colorScheme={COLOR_BLIND_SAFE_CATEGORICAL} />
976
+ ```
977
+
978
+ ### Annotations with Theme Colors
979
+
980
+ ```jsx
981
+ // Annotations inherit --semiotic-primary and --semiotic-text-secondary from theme
982
+ <LineChart
983
+ data={salesData}
984
+ xAccessor="month" yAccessor="revenue"
985
+ annotations={[
986
+ // Threshold line — defaults to --semiotic-primary if no color set
987
+ { type: "y-threshold", value: 50000, label: "Q3 Target" },
988
+ // Widget annotation at specific data point
989
+ { type: "widget", month: "Jul", revenue: 72000, dy: -15, content: (
990
+ <span style={{ fontSize: 11, fontWeight: 700 }}>Record month</span>
991
+ )},
992
+ // Enclose a cluster of outliers
993
+ { type: "enclose", coordinates: outlierPoints, label: "Outlier cluster", padding: 15 },
994
+ ]}
995
+ showGrid
996
+ />
997
+ ```
998
+
999
+ ---
1000
+
1001
+ ## Click Handlers
1002
+
1003
+ ### onClick on BarChart
1004
+
1005
+ ```jsx
1006
+ import { BarChart } from "semiotic/ai"
1007
+
1008
+ <BarChart
1009
+ data={salesData}
1010
+ categoryAccessor="region"
1011
+ valueAccessor="revenue"
1012
+ onClick={(datum, { x, y }) => {
1013
+ console.log(`Clicked ${datum.region}: $${datum.revenue}`)
1014
+ setSelectedRegion(datum.region)
1015
+ }}
1016
+ />
1017
+ ```
1018
+
1019
+ Key props: `onClick` receives the original datum and pixel coordinates. Works on all chart types.
1020
+
1021
+ ---
1022
+
1023
+ ## Linked Crosshair (Multi-chart Hover Sync)
1024
+
1025
+ ### Synced crosshair across time-series charts
1026
+
1027
+ ```jsx
1028
+ import { LineChart, LinkedCharts } from "semiotic/ai"
1029
+
1030
+ <LinkedCharts>
1031
+ <LineChart
1032
+ data={cpuData}
1033
+ xAccessor="time" yAccessor="cpu"
1034
+ linkedHover={{ name: "metrics", mode: "x-position", xField: "time" }}
1035
+ selection={{ name: "metrics" }}
1036
+ />
1037
+ <LineChart
1038
+ data={memoryData}
1039
+ xAccessor="time" yAccessor="memory"
1040
+ linkedHover={{ name: "metrics", mode: "x-position", xField: "time" }}
1041
+ selection={{ name: "metrics" }}
1042
+ />
1043
+ </LinkedCharts>
1044
+ ```
1045
+
1046
+ Key props: `linkedHover` with `mode: "x-position"` broadcasts the hovered X value. Each chart shows its own tooltip with its own Y values. Use for multi-metric dashboards.
1047
+
1048
+ ---
1049
+
1050
+ ## Category Format (Custom Tick Labels)
1051
+
1052
+ ### Truncated category labels
1053
+
1054
+ ```jsx
1055
+ import { BarChart } from "semiotic/ai"
1056
+
1057
+ <BarChart
1058
+ data={data}
1059
+ categoryAccessor="department"
1060
+ valueAccessor="headcount"
1061
+ orientation="horizontal"
1062
+ categoryFormat={(label) => label.length > 12 ? label.slice(0, 12) + "…" : label}
1063
+ />
1064
+ ```
1065
+
1066
+ Key props: `categoryFormat` receives each tick label and returns a formatted string. Available on all ordinal HOCs except Pie/Donut.
1067
+
1068
+ ---
1069
+
1070
+ ## Ordinal Annotations
1071
+
1072
+ ### Threshold + category highlight on BarChart
1073
+
1074
+ ```jsx
1075
+ import { BarChart } from "semiotic/ai"
1076
+
1077
+ <BarChart
1078
+ data={quarterlyData}
1079
+ categoryAccessor="quarter"
1080
+ valueAccessor="revenue"
1081
+ annotations={[
1082
+ { type: "y-threshold", value: 50000, label: "Target", color: "#e45050", labelPosition: "left" },
1083
+ { type: "category-highlight", category: "Q3 2024", color: "#4589ff", opacity: 0.15, label: "Current" },
1084
+ ]}
1085
+ />
1086
+ ```
1087
+
1088
+ Key props: `y-threshold` works on vertical ordinal charts. `category-highlight` highlights a category column. `labelPosition` controls label placement.