matterviz 0.3.7 → 0.4.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 (486) hide show
  1. package/dist/Icon.svelte +7 -4
  2. package/dist/MillerIndexInput.svelte +1 -1
  3. package/dist/api/optimade.js +32 -26
  4. package/dist/app.css +0 -3
  5. package/dist/brillouin/BrillouinZone.svelte +76 -148
  6. package/dist/brillouin/BrillouinZone.svelte.d.ts +6 -14
  7. package/dist/brillouin/BrillouinZoneExportPane.svelte +43 -96
  8. package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
  9. package/dist/brillouin/BrillouinZoneInfoPane.svelte +9 -32
  10. package/dist/brillouin/BrillouinZoneInfoPane.svelte.d.ts +2 -3
  11. package/dist/brillouin/BrillouinZoneScene.svelte +97 -205
  12. package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +4 -23
  13. package/dist/brillouin/BrillouinZoneTooltip.svelte +16 -25
  14. package/dist/brillouin/ReciprocalVectors.svelte +39 -0
  15. package/dist/brillouin/ReciprocalVectors.svelte.d.ts +9 -0
  16. package/dist/brillouin/compute.d.ts +2 -0
  17. package/dist/brillouin/compute.js +89 -90
  18. package/dist/brillouin/geometry.d.ts +8 -0
  19. package/dist/brillouin/geometry.js +57 -0
  20. package/dist/brillouin/index.d.ts +2 -0
  21. package/dist/brillouin/index.js +2 -0
  22. package/dist/brillouin/types.d.ts +2 -2
  23. package/dist/chempot-diagram/ChemPotDiagram.svelte +14 -13
  24. package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +1 -1
  25. package/dist/chempot-diagram/ChemPotDiagram2D.svelte +109 -203
  26. package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +4 -1
  27. package/dist/chempot-diagram/ChemPotDiagram3D.svelte +180 -470
  28. package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +7 -1
  29. package/dist/chempot-diagram/async-compute.svelte.js +3 -1
  30. package/dist/chempot-diagram/chempot-worker.js +2 -1
  31. package/dist/chempot-diagram/color.d.ts +3 -6
  32. package/dist/chempot-diagram/color.js +5 -5
  33. package/dist/chempot-diagram/compute.d.ts +4 -4
  34. package/dist/chempot-diagram/compute.js +20 -20
  35. package/dist/chempot-diagram/controls-state.svelte.d.ts +10 -0
  36. package/dist/chempot-diagram/controls-state.svelte.js +42 -0
  37. package/dist/chempot-diagram/export.d.ts +47 -0
  38. package/dist/chempot-diagram/export.js +133 -0
  39. package/dist/chempot-diagram/index.d.ts +1 -0
  40. package/dist/chempot-diagram/index.js +1 -0
  41. package/dist/chempot-diagram/pointer.d.ts +0 -10
  42. package/dist/chempot-diagram/pointer.js +4 -4
  43. package/dist/chempot-diagram/types.d.ts +3 -3
  44. package/dist/colors/index.js +8 -7
  45. package/dist/composition/FormulaFilter.svelte +18 -11
  46. package/dist/composition/PieChart.svelte +11 -10
  47. package/dist/composition/chem-sys.d.ts +8 -0
  48. package/dist/composition/chem-sys.js +86 -0
  49. package/dist/composition/format.js +7 -4
  50. package/dist/composition/index.d.ts +1 -0
  51. package/dist/composition/index.js +1 -0
  52. package/dist/composition/parse.d.ts +0 -1
  53. package/dist/composition/parse.js +41 -31
  54. package/dist/controls.d.ts +1 -0
  55. package/dist/controls.js +0 -1
  56. package/dist/convex-hull/ConvexHull.svelte +8 -10
  57. package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -4
  58. package/dist/convex-hull/ConvexHull2D.svelte +106 -185
  59. package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
  60. package/dist/convex-hull/ConvexHull3D.svelte +179 -683
  61. package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
  62. package/dist/convex-hull/ConvexHull4D.svelte +183 -687
  63. package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
  64. package/dist/convex-hull/ConvexHullChrome.svelte +268 -0
  65. package/dist/convex-hull/ConvexHullChrome.svelte.d.ts +30 -0
  66. package/dist/convex-hull/ConvexHullControls.svelte +88 -7
  67. package/dist/convex-hull/ConvexHullControls.svelte.d.ts +7 -6
  68. package/dist/convex-hull/ConvexHullInfoPane.svelte +18 -5
  69. package/dist/convex-hull/ConvexHullInfoPane.svelte.d.ts +6 -5
  70. package/dist/convex-hull/ConvexHullStats.svelte +36 -175
  71. package/dist/convex-hull/ConvexHullStats.svelte.d.ts +3 -1
  72. package/dist/convex-hull/ConvexHullTooltip.svelte +11 -2
  73. package/dist/convex-hull/ConvexHullTooltip.svelte.d.ts +2 -1
  74. package/dist/convex-hull/GasPressureControls.svelte +4 -4
  75. package/dist/convex-hull/TemperatureSlider.svelte +2 -2
  76. package/dist/convex-hull/barycentric-coords.d.ts +2 -4
  77. package/dist/convex-hull/barycentric-coords.js +6 -33
  78. package/dist/convex-hull/canvas-interactions.svelte.d.ts +79 -0
  79. package/dist/convex-hull/canvas-interactions.svelte.js +278 -0
  80. package/dist/convex-hull/demo-temperature.d.ts +1 -1
  81. package/dist/convex-hull/demo-temperature.js +20 -22
  82. package/dist/convex-hull/gas-thermodynamics.d.ts +2 -2
  83. package/dist/convex-hull/gas-thermodynamics.js +22 -30
  84. package/dist/convex-hull/helpers.d.ts +42 -7
  85. package/dist/convex-hull/helpers.js +171 -78
  86. package/dist/convex-hull/hull-state.svelte.d.ts +44 -0
  87. package/dist/convex-hull/hull-state.svelte.js +124 -0
  88. package/dist/convex-hull/index.d.ts +10 -8
  89. package/dist/convex-hull/index.js +7 -2
  90. package/dist/convex-hull/thermodynamics.js +136 -960
  91. package/dist/convex-hull/types.d.ts +13 -5
  92. package/dist/convex-hull/types.js +12 -0
  93. package/dist/coordination/CoordinationBarPlot.svelte +27 -34
  94. package/dist/coordination/CoordinationBarPlot.svelte.d.ts +1 -1
  95. package/dist/element/BohrAtom.svelte +2 -1
  96. package/dist/element/index.d.ts +4 -0
  97. package/dist/element/index.js +18 -0
  98. package/dist/feedback/DragOverlay.svelte +3 -1
  99. package/dist/feedback/DragOverlay.svelte.d.ts +1 -0
  100. package/dist/feedback/StatusMessage.svelte +13 -3
  101. package/dist/fermi-surface/FermiSlice.svelte +13 -5
  102. package/dist/fermi-surface/FermiSurface.svelte +78 -151
  103. package/dist/fermi-surface/FermiSurface.svelte.d.ts +5 -14
  104. package/dist/fermi-surface/FermiSurfaceControls.svelte +1 -1
  105. package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
  106. package/dist/fermi-surface/FermiSurfaceScene.svelte +72 -221
  107. package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +3 -23
  108. package/dist/fermi-surface/FermiSurfaceTooltip.svelte +8 -34
  109. package/dist/fermi-surface/compute.js +67 -66
  110. package/dist/fermi-surface/export.js +6 -16
  111. package/dist/fermi-surface/index.d.ts +0 -1
  112. package/dist/fermi-surface/index.js +0 -1
  113. package/dist/fermi-surface/parse.d.ts +1 -1
  114. package/dist/fermi-surface/parse.js +71 -79
  115. package/dist/fermi-surface/types.d.ts +3 -2
  116. package/dist/heatmap-matrix/HeatmapMatrix.svelte +69 -52
  117. package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +4 -3
  118. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +3 -2
  119. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +5 -5
  120. package/dist/heatmap-matrix/index.d.ts +3 -2
  121. package/dist/heatmap-matrix/index.js +1 -1
  122. package/dist/index.d.ts +1 -0
  123. package/dist/index.js +1 -0
  124. package/dist/io/ExportPane.svelte +166 -0
  125. package/dist/io/ExportPane.svelte.d.ts +17 -0
  126. package/dist/io/decompress.js +5 -4
  127. package/dist/io/export.d.ts +9 -5
  128. package/dist/io/export.js +77 -51
  129. package/dist/io/fetch.d.ts +2 -1
  130. package/dist/io/fetch.js +5 -1
  131. package/dist/io/file-drop.d.ts +8 -1
  132. package/dist/io/file-drop.js +48 -36
  133. package/dist/io/index.d.ts +2 -0
  134. package/dist/io/index.js +10 -0
  135. package/dist/io/types.d.ts +13 -0
  136. package/dist/io/url-drop.js +64 -33
  137. package/dist/isosurface/parse.js +52 -51
  138. package/dist/isosurface/slice.js +5 -4
  139. package/dist/isosurface/types.js +1 -1
  140. package/dist/keyboard.d.ts +3 -0
  141. package/dist/keyboard.js +23 -0
  142. package/dist/labels.d.ts +1 -1
  143. package/dist/labels.js +9 -8
  144. package/dist/layout/FullscreenButton.svelte +33 -0
  145. package/dist/layout/FullscreenButton.svelte.d.ts +10 -0
  146. package/dist/layout/FullscreenToggle.svelte +8 -14
  147. package/dist/layout/PropertyFilter.svelte +3 -2
  148. package/dist/layout/SettingsSection.svelte +1 -1
  149. package/dist/layout/ViewerChrome.svelte +116 -0
  150. package/dist/layout/ViewerChrome.svelte.d.ts +17 -0
  151. package/dist/layout/fullscreen.d.ts +4 -0
  152. package/dist/layout/fullscreen.svelte.d.ts +8 -0
  153. package/dist/layout/fullscreen.svelte.js +37 -0
  154. package/dist/layout/index.d.ts +3 -0
  155. package/dist/layout/index.js +3 -0
  156. package/dist/layout/json-tree/JsonNode.svelte +1 -1
  157. package/dist/layout/json-tree/JsonTree.svelte +2 -2
  158. package/dist/layout/json-tree/utils.js +5 -4
  159. package/dist/marching-cubes.js +8 -13
  160. package/dist/math.d.ts +12 -4
  161. package/dist/math.js +42 -30
  162. package/dist/overlays/DraggablePane.svelte +4 -4
  163. package/dist/overlays/index.d.ts +4 -0
  164. package/dist/periodic-table/PeriodicTable.svelte +27 -15
  165. package/dist/periodic-table/PropertySelect.svelte +1 -0
  166. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +9 -3
  167. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +1 -1
  168. package/dist/phase-diagram/PhaseDiagramControls.svelte +3 -2
  169. package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +4 -3
  170. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +4 -2
  171. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +2 -3
  172. package/dist/phase-diagram/PhaseDiagramExportPane.svelte +47 -132
  173. package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +3 -4
  174. package/dist/phase-diagram/PhaseDiagramTooltip.svelte +1 -1
  175. package/dist/phase-diagram/build-diagram.js +2 -2
  176. package/dist/phase-diagram/colors.js +1 -1
  177. package/dist/phase-diagram/parse.d.ts +2 -1
  178. package/dist/phase-diagram/parse.js +6 -5
  179. package/dist/phase-diagram/types.d.ts +1 -1
  180. package/dist/phase-diagram/utils.d.ts +3 -3
  181. package/dist/phase-diagram/utils.js +8 -12
  182. package/dist/plot/{BarPlot.svelte → bar/BarPlot.svelte} +246 -841
  183. package/dist/plot/{BarPlot.svelte.d.ts → bar/BarPlot.svelte.d.ts} +8 -16
  184. package/dist/plot/{BarPlotControls.svelte → bar/BarPlotControls.svelte} +6 -5
  185. package/dist/plot/{BarPlotControls.svelte.d.ts → bar/BarPlotControls.svelte.d.ts} +3 -3
  186. package/dist/plot/{SpacegroupBarPlot.svelte → bar/SpacegroupBarPlot.svelte} +8 -7
  187. package/dist/plot/{SpacegroupBarPlot.svelte.d.ts → bar/SpacegroupBarPlot.svelte.d.ts} +1 -1
  188. package/dist/plot/bar/data.d.ts +40 -0
  189. package/dist/plot/bar/data.js +154 -0
  190. package/dist/plot/bar/geometry.d.ts +39 -0
  191. package/dist/plot/bar/geometry.js +60 -0
  192. package/dist/plot/bar/index.d.ts +3 -0
  193. package/dist/plot/bar/index.js +3 -0
  194. package/dist/plot/box/BoxPlot.svelte +1292 -0
  195. package/dist/plot/box/BoxPlot.svelte.d.ts +95 -0
  196. package/dist/plot/box/BoxPlotControls.svelte +109 -0
  197. package/dist/plot/box/BoxPlotControls.svelte.d.ts +19 -0
  198. package/dist/plot/box/Violin.svelte +14 -0
  199. package/dist/plot/box/Violin.svelte.d.ts +70 -0
  200. package/dist/plot/box/box-plot.d.ts +56 -0
  201. package/dist/plot/box/box-plot.js +129 -0
  202. package/dist/plot/box/index.d.ts +5 -0
  203. package/dist/plot/box/index.js +5 -0
  204. package/dist/plot/box/kde.d.ts +17 -0
  205. package/dist/plot/box/kde.js +160 -0
  206. package/dist/plot/box/quantile.d.ts +3 -0
  207. package/dist/plot/box/quantile.js +53 -0
  208. package/dist/plot/{auto-place.d.ts → core/auto-place.d.ts} +1 -1
  209. package/dist/plot/{auto-place.js → core/auto-place.js} +6 -3
  210. package/dist/plot/core/axis-utils.d.ts +46 -0
  211. package/dist/plot/core/axis-utils.js +110 -0
  212. package/dist/plot/{AxisLabel.svelte → core/components/AxisLabel.svelte} +2 -2
  213. package/dist/plot/{AxisLabel.svelte.d.ts → core/components/AxisLabel.svelte.d.ts} +1 -1
  214. package/dist/plot/{ColorBar.svelte → core/components/ColorBar.svelte} +41 -38
  215. package/dist/plot/{ColorBar.svelte.d.ts → core/components/ColorBar.svelte.d.ts} +7 -6
  216. package/dist/plot/{ColorScaleSelect.svelte → core/components/ColorScaleSelect.svelte} +4 -3
  217. package/dist/plot/{ColorScaleSelect.svelte.d.ts → core/components/ColorScaleSelect.svelte.d.ts} +2 -2
  218. package/dist/plot/core/components/ControlPane.svelte +46 -0
  219. package/dist/plot/core/components/ControlPane.svelte.d.ts +13 -0
  220. package/dist/plot/{FillArea.svelte → core/components/FillArea.svelte} +17 -6
  221. package/dist/plot/{FillArea.svelte.d.ts → core/components/FillArea.svelte.d.ts} +1 -1
  222. package/dist/plot/{InteractiveAxisLabel.svelte → core/components/InteractiveAxisLabel.svelte} +3 -3
  223. package/dist/plot/{InteractiveAxisLabel.svelte.d.ts → core/components/InteractiveAxisLabel.svelte.d.ts} +2 -2
  224. package/dist/plot/{Line.svelte → core/components/Line.svelte} +33 -15
  225. package/dist/plot/{Line.svelte.d.ts → core/components/Line.svelte.d.ts} +3 -2
  226. package/dist/plot/{PlotAxis.svelte → core/components/PlotAxis.svelte} +9 -6
  227. package/dist/plot/{PlotAxis.svelte.d.ts → core/components/PlotAxis.svelte.d.ts} +5 -3
  228. package/dist/plot/{PlotControls.svelte → core/components/PlotControls.svelte} +17 -29
  229. package/dist/plot/core/components/PlotControls.svelte.d.ts +4 -0
  230. package/dist/plot/{PlotLegend.svelte → core/components/PlotLegend.svelte} +21 -10
  231. package/dist/plot/{PlotLegend.svelte.d.ts → core/components/PlotLegend.svelte.d.ts} +3 -2
  232. package/dist/plot/{PlotTooltip.svelte → core/components/PlotTooltip.svelte} +17 -1
  233. package/dist/plot/{PlotTooltip.svelte.d.ts → core/components/PlotTooltip.svelte.d.ts} +8 -0
  234. package/dist/plot/{PortalSelect.svelte → core/components/PortalSelect.svelte} +11 -7
  235. package/dist/plot/{ReferenceLine.svelte → core/components/ReferenceLine.svelte} +3 -3
  236. package/dist/plot/{ReferenceLine.svelte.d.ts → core/components/ReferenceLine.svelte.d.ts} +1 -1
  237. package/dist/plot/{ReferenceLine3D.svelte → core/components/ReferenceLine3D.svelte} +5 -5
  238. package/dist/plot/{ReferenceLine3D.svelte.d.ts → core/components/ReferenceLine3D.svelte.d.ts} +5 -5
  239. package/dist/plot/{ReferencePlane.svelte → core/components/ReferencePlane.svelte} +8 -8
  240. package/dist/plot/{ReferencePlane.svelte.d.ts → core/components/ReferencePlane.svelte.d.ts} +5 -5
  241. package/dist/plot/{ZeroLines.svelte → core/components/ZeroLines.svelte} +3 -3
  242. package/dist/plot/{ZeroLines.svelte.d.ts → core/components/ZeroLines.svelte.d.ts} +3 -3
  243. package/dist/plot/{ZoomRect.svelte → core/components/ZoomRect.svelte} +1 -1
  244. package/dist/plot/{ZoomRect.svelte.d.ts → core/components/ZoomRect.svelte.d.ts} +1 -1
  245. package/dist/plot/core/components/index.d.ts +17 -0
  246. package/dist/plot/core/components/index.js +17 -0
  247. package/dist/plot/{data-cleaning.d.ts → core/data-cleaning.d.ts} +71 -1
  248. package/dist/plot/{data-cleaning.js → core/data-cleaning.js} +21 -23
  249. package/dist/plot/{data-transform.d.ts → core/data-transform.d.ts} +2 -2
  250. package/dist/plot/{data-transform.js → core/data-transform.js} +3 -3
  251. package/dist/plot/core/fill-utils.d.ts +34 -0
  252. package/dist/plot/core/fill-utils.js +391 -0
  253. package/dist/plot/core/index.d.ts +10 -0
  254. package/dist/plot/core/index.js +11 -0
  255. package/dist/plot/core/interactions.d.ts +39 -0
  256. package/dist/plot/core/interactions.js +209 -0
  257. package/dist/plot/{layout.d.ts → core/layout.d.ts} +1 -0
  258. package/dist/plot/{layout.js → core/layout.js} +16 -8
  259. package/dist/plot/core/pan-zoom.svelte.d.ts +35 -0
  260. package/dist/plot/core/pan-zoom.svelte.js +221 -0
  261. package/dist/plot/core/placed-tween.svelte.d.ts +21 -0
  262. package/dist/plot/core/placed-tween.svelte.js +68 -0
  263. package/dist/plot/{reference-line.d.ts → core/reference-line.d.ts} +11 -11
  264. package/dist/plot/{reference-line.js → core/reference-line.js} +29 -42
  265. package/dist/plot/core/scales.d.ts +40 -0
  266. package/dist/plot/{scales.js → core/scales.js} +94 -93
  267. package/dist/plot/core/svg.d.ts +3 -0
  268. package/dist/plot/core/svg.js +41 -0
  269. package/dist/plot/{types.d.ts → core/types.d.ts} +36 -85
  270. package/dist/plot/{types.js → core/types.js} +1 -1
  271. package/dist/plot/{utils → core/utils}/label-placement.d.ts +3 -3
  272. package/dist/plot/{utils → core/utils}/label-placement.js +3 -3
  273. package/dist/plot/core/utils/series-visibility.d.ts +26 -0
  274. package/dist/plot/{utils → core/utils}/series-visibility.js +29 -2
  275. package/dist/plot/core/utils.d.ts +12 -0
  276. package/dist/plot/core/utils.js +27 -0
  277. package/dist/plot/{Histogram.svelte → histogram/Histogram.svelte} +174 -551
  278. package/dist/plot/{Histogram.svelte.d.ts → histogram/Histogram.svelte.d.ts} +2 -2
  279. package/dist/plot/{HistogramControls.svelte → histogram/HistogramControls.svelte} +6 -6
  280. package/dist/plot/{HistogramControls.svelte.d.ts → histogram/HistogramControls.svelte.d.ts} +4 -4
  281. package/dist/plot/histogram/index.d.ts +2 -0
  282. package/dist/plot/histogram/index.js +2 -0
  283. package/dist/plot/index.d.ts +8 -41
  284. package/dist/plot/index.js +10 -39
  285. package/dist/plot/sankey/Sankey.svelte +697 -0
  286. package/dist/plot/sankey/Sankey.svelte.d.ts +74 -0
  287. package/dist/plot/sankey/SankeyControls.svelte +98 -0
  288. package/dist/plot/sankey/SankeyControls.svelte.d.ts +19 -0
  289. package/dist/plot/sankey/index.d.ts +4 -0
  290. package/dist/plot/sankey/index.js +3 -0
  291. package/dist/plot/sankey/sankey-types.d.ts +42 -0
  292. package/dist/plot/sankey/sankey-types.js +4 -0
  293. package/dist/plot/sankey/sankey.d.ts +52 -0
  294. package/dist/plot/sankey/sankey.js +189 -0
  295. package/dist/plot/{BinnedScatterPlot.svelte → scatter/BinnedScatterPlot.svelte} +64 -64
  296. package/dist/plot/{BinnedScatterPlot.svelte.d.ts → scatter/BinnedScatterPlot.svelte.d.ts} +6 -6
  297. package/dist/plot/{ElementScatter.svelte → scatter/ElementScatter.svelte} +6 -6
  298. package/dist/plot/{ElementScatter.svelte.d.ts → scatter/ElementScatter.svelte.d.ts} +2 -2
  299. package/dist/plot/{ScatterPlot.svelte → scatter/ScatterPlot.svelte} +297 -1008
  300. package/dist/plot/{ScatterPlot.svelte.d.ts → scatter/ScatterPlot.svelte.d.ts} +10 -18
  301. package/dist/plot/{ScatterPlotControls.svelte → scatter/ScatterPlotControls.svelte} +6 -5
  302. package/dist/plot/{ScatterPlotControls.svelte.d.ts → scatter/ScatterPlotControls.svelte.d.ts} +2 -2
  303. package/dist/plot/{ScatterPoint.svelte → scatter/ScatterPoint.svelte} +7 -7
  304. package/dist/plot/{ScatterPoint.svelte.d.ts → scatter/ScatterPoint.svelte.d.ts} +3 -3
  305. package/dist/plot/{adaptive-density.d.ts → scatter/adaptive-density.d.ts} +14 -4
  306. package/dist/plot/{adaptive-density.js → scatter/adaptive-density.js} +46 -20
  307. package/dist/plot/{binned-scatter-types.d.ts → scatter/binned-scatter-types.d.ts} +5 -12
  308. package/dist/plot/scatter/index.d.ts +7 -0
  309. package/dist/plot/scatter/index.js +5 -0
  310. package/dist/plot/scatter/scatter-data.d.ts +19 -0
  311. package/dist/plot/scatter/scatter-data.js +212 -0
  312. package/dist/plot/{ScatterPlot3D.svelte → scatter-3d/ScatterPlot3D.svelte} +25 -34
  313. package/dist/plot/{ScatterPlot3D.svelte.d.ts → scatter-3d/ScatterPlot3D.svelte.d.ts} +9 -17
  314. package/dist/plot/{ScatterPlot3DControls.svelte → scatter-3d/ScatterPlot3DControls.svelte} +14 -14
  315. package/dist/plot/{ScatterPlot3DControls.svelte.d.ts → scatter-3d/ScatterPlot3DControls.svelte.d.ts} +6 -6
  316. package/dist/plot/{ScatterPlot3DScene.svelte → scatter-3d/ScatterPlot3DScene.svelte} +129 -128
  317. package/dist/plot/{ScatterPlot3DScene.svelte.d.ts → scatter-3d/ScatterPlot3DScene.svelte.d.ts} +6 -15
  318. package/dist/plot/{Surface3D.svelte → scatter-3d/Surface3D.svelte} +7 -6
  319. package/dist/plot/{Surface3D.svelte.d.ts → scatter-3d/Surface3D.svelte.d.ts} +5 -4
  320. package/dist/plot/scatter-3d/index.d.ts +4 -0
  321. package/dist/plot/scatter-3d/index.js +4 -0
  322. package/dist/plot/sunburst/Sunburst.svelte +1041 -0
  323. package/dist/plot/sunburst/Sunburst.svelte.d.ts +97 -0
  324. package/dist/plot/sunburst/SunburstControls.svelte +200 -0
  325. package/dist/plot/sunburst/SunburstControls.svelte.d.ts +26 -0
  326. package/dist/plot/sunburst/index.d.ts +4 -0
  327. package/dist/plot/sunburst/index.js +4 -0
  328. package/dist/plot/sunburst/render.d.ts +34 -0
  329. package/dist/plot/sunburst/render.js +122 -0
  330. package/dist/plot/sunburst/sunburst.d.ts +62 -0
  331. package/dist/plot/sunburst/sunburst.js +269 -0
  332. package/dist/rdf/RdfPlot.svelte +2 -1
  333. package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
  334. package/dist/rdf/calc-rdf.js +11 -24
  335. package/dist/sanitize.js +14 -3
  336. package/dist/scene/SceneCamera.svelte +62 -0
  337. package/dist/scene/SceneCamera.svelte.d.ts +19 -0
  338. package/dist/scene/bind-renderer.svelte.d.ts +2 -0
  339. package/dist/scene/bind-renderer.svelte.js +14 -0
  340. package/dist/scene/index.d.ts +4 -0
  341. package/dist/scene/index.js +5 -0
  342. package/dist/scene/props.js +52 -0
  343. package/dist/scene/types.d.ts +26 -0
  344. package/dist/scene/types.js +1 -0
  345. package/dist/settings.d.ts +79 -3
  346. package/dist/settings.js +321 -1
  347. package/dist/spectral/Bands.svelte +47 -36
  348. package/dist/spectral/Bands.svelte.d.ts +6 -6
  349. package/dist/spectral/BandsAndDos.svelte +23 -25
  350. package/dist/spectral/BrillouinBandsDos.svelte +42 -30
  351. package/dist/spectral/Dos.svelte +15 -23
  352. package/dist/spectral/Dos.svelte.d.ts +4 -3
  353. package/dist/spectral/helpers.d.ts +8 -6
  354. package/dist/spectral/helpers.js +137 -65
  355. package/dist/state.svelte.d.ts +0 -7
  356. package/dist/state.svelte.js +0 -6
  357. package/dist/structure/Arrow.svelte +2 -4
  358. package/dist/structure/AtomLegend.svelte +8 -9
  359. package/dist/structure/AtomLegend.svelte.d.ts +1 -1
  360. package/dist/structure/CanvasTooltip.svelte +1 -0
  361. package/dist/structure/CellSelect.svelte +12 -5
  362. package/dist/structure/CellSelect.svelte.d.ts +2 -1
  363. package/dist/structure/Cylinder.svelte +12 -8
  364. package/dist/structure/Cylinder.svelte.d.ts +4 -1
  365. package/dist/structure/Lattice.svelte +2 -2
  366. package/dist/structure/Structure.svelte +365 -423
  367. package/dist/structure/Structure.svelte.d.ts +5 -15
  368. package/dist/structure/StructureControls.svelte +217 -2
  369. package/dist/structure/StructureControls.svelte.d.ts +5 -3
  370. package/dist/structure/StructureExportPane.svelte +54 -156
  371. package/dist/structure/StructureExportPane.svelte.d.ts +4 -5
  372. package/dist/structure/StructureInfoPane.svelte +10 -9
  373. package/dist/structure/StructureInfoPane.svelte.d.ts +5 -5
  374. package/dist/structure/StructureScene.svelte +376 -208
  375. package/dist/structure/StructureScene.svelte.d.ts +22 -20
  376. package/dist/structure/{label-placement.d.ts → atom-label-placement.d.ts} +3 -3
  377. package/dist/structure/{label-placement.js → atom-label-placement.js} +15 -5
  378. package/dist/structure/atom-properties.d.ts +1 -1
  379. package/dist/structure/atom-properties.js +17 -22
  380. package/dist/structure/bond-order-perception.js +3 -5
  381. package/dist/structure/bonding.d.ts +4 -0
  382. package/dist/structure/bonding.js +134 -63
  383. package/dist/structure/export.d.ts +24 -4
  384. package/dist/structure/export.js +89 -143
  385. package/dist/structure/index.d.ts +4 -4
  386. package/dist/structure/index.js +3 -3
  387. package/dist/structure/measure.d.ts +3 -2
  388. package/dist/structure/measure.js +6 -5
  389. package/dist/structure/parse.d.ts +3 -2
  390. package/dist/structure/parse.js +419 -438
  391. package/dist/structure/partial-occupancy.d.ts +0 -1
  392. package/dist/structure/partial-occupancy.js +1 -1
  393. package/dist/structure/pbc.d.ts +1 -1
  394. package/dist/structure/pbc.js +190 -13
  395. package/dist/structure/polyhedra.d.ts +41 -0
  396. package/dist/structure/polyhedra.js +602 -0
  397. package/dist/structure/site.d.ts +4 -0
  398. package/dist/structure/site.js +1 -0
  399. package/dist/structure/supercell.js +3 -2
  400. package/dist/structure/validation.js +5 -6
  401. package/dist/symmetry/SymmetryElementControls.svelte +69 -0
  402. package/dist/symmetry/SymmetryElementControls.svelte.d.ts +9 -0
  403. package/dist/symmetry/SymmetryElements.svelte +354 -0
  404. package/dist/symmetry/SymmetryElements.svelte.d.ts +24 -0
  405. package/dist/symmetry/SymmetryStats.svelte +113 -8
  406. package/dist/symmetry/WyckoffTable.svelte +68 -7
  407. package/dist/symmetry/WyckoffTable.svelte.d.ts +3 -0
  408. package/dist/symmetry/cell-transform.js +7 -14
  409. package/dist/symmetry/index.d.ts +14 -4
  410. package/dist/symmetry/index.js +291 -72
  411. package/dist/symmetry/spacegroups.d.ts +12 -1
  412. package/dist/symmetry/spacegroups.js +63 -14
  413. package/dist/symmetry/symmetry-elements.d.ts +33 -0
  414. package/dist/symmetry/symmetry-elements.js +521 -0
  415. package/dist/symmetry/wyckoff-db.d.ts +9 -0
  416. package/dist/symmetry/wyckoff-db.js +87 -0
  417. package/dist/table/HeatmapTable.svelte +66 -25
  418. package/dist/table/HeatmapTable.svelte.d.ts +1 -1
  419. package/dist/table/index.d.ts +1 -3
  420. package/dist/table/index.js +1 -1
  421. package/dist/theme/index.js +8 -8
  422. package/dist/tooltip/KCoords.svelte +45 -0
  423. package/dist/tooltip/KCoords.svelte.d.ts +8 -0
  424. package/dist/tooltip/index.d.ts +1 -0
  425. package/dist/tooltip/index.js +1 -0
  426. package/dist/trajectory/Trajectory.svelte +123 -100
  427. package/dist/trajectory/Trajectory.svelte.d.ts +11 -22
  428. package/dist/trajectory/TrajectoryExportPane.svelte +17 -25
  429. package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +4 -5
  430. package/dist/trajectory/TrajectoryInfoPane.svelte +5 -3
  431. package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +3 -2
  432. package/dist/trajectory/constants.js +6 -2
  433. package/dist/trajectory/extract.js +17 -37
  434. package/dist/trajectory/format-detect.d.ts +1 -1
  435. package/dist/trajectory/format-detect.js +27 -19
  436. package/dist/trajectory/frame-reader.d.ts +0 -1
  437. package/dist/trajectory/frame-reader.js +63 -162
  438. package/dist/trajectory/helpers.d.ts +10 -2
  439. package/dist/trajectory/helpers.js +56 -36
  440. package/dist/trajectory/index.js +1 -1
  441. package/dist/trajectory/parse/ase.d.ts +9 -1
  442. package/dist/trajectory/parse/ase.js +47 -32
  443. package/dist/trajectory/parse/diagnostics.d.ts +3 -0
  444. package/dist/trajectory/parse/diagnostics.js +14 -0
  445. package/dist/trajectory/parse/hdf5.js +1 -1
  446. package/dist/trajectory/parse/index.d.ts +1 -1
  447. package/dist/trajectory/parse/index.js +65 -105
  448. package/dist/trajectory/parse/lammps.d.ts +0 -2
  449. package/dist/trajectory/parse/lammps.js +8 -6
  450. package/dist/trajectory/parse/pymatgen.d.ts +2 -0
  451. package/dist/trajectory/parse/pymatgen.js +74 -0
  452. package/dist/trajectory/parse/vasp.js +38 -18
  453. package/dist/trajectory/parse/xyz.d.ts +13 -1
  454. package/dist/trajectory/parse/xyz.js +102 -94
  455. package/dist/trajectory/plotting.d.ts +1 -2
  456. package/dist/trajectory/plotting.js +16 -113
  457. package/dist/utils.d.ts +2 -0
  458. package/dist/utils.js +7 -5
  459. package/dist/xrd/XrdPlot.svelte +16 -30
  460. package/dist/xrd/broadening.d.ts +2 -1
  461. package/dist/xrd/calc-xrd.js +18 -20
  462. package/dist/xrd/index.d.ts +2 -2
  463. package/dist/xrd/parse.js +2 -2
  464. package/package.json +43 -26
  465. package/dist/element/data.json +0 -11864
  466. package/dist/fermi-surface/marching-cubes.d.ts +0 -2
  467. package/dist/fermi-surface/marching-cubes.js +0 -2
  468. package/dist/plot/PlotControls.svelte.d.ts +0 -4
  469. package/dist/plot/axis-utils.d.ts +0 -19
  470. package/dist/plot/axis-utils.js +0 -78
  471. package/dist/plot/defaults.d.ts +0 -19
  472. package/dist/plot/defaults.js +0 -9
  473. package/dist/plot/fill-utils.d.ts +0 -46
  474. package/dist/plot/fill-utils.js +0 -322
  475. package/dist/plot/hover-lock.svelte.d.ts +0 -14
  476. package/dist/plot/hover-lock.svelte.js +0 -46
  477. package/dist/plot/interactions.d.ts +0 -12
  478. package/dist/plot/interactions.js +0 -101
  479. package/dist/plot/scales.d.ts +0 -48
  480. package/dist/plot/svg.d.ts +0 -1
  481. package/dist/plot/svg.js +0 -11
  482. package/dist/plot/utils/series-visibility.d.ts +0 -15
  483. package/dist/plot/utils.d.ts +0 -1
  484. package/dist/plot/utils.js +0 -14
  485. /package/dist/plot/{PortalSelect.svelte.d.ts → core/components/PortalSelect.svelte.d.ts} +0 -0
  486. /package/dist/plot/{binned-scatter-types.js → scatter/binned-scatter-types.js} +0 -0
@@ -0,0 +1,160 @@
1
+ // 1-D Gaussian kernel density estimation for violin plots.
2
+ // Pure and unit-tested; mirrors the style of box-plot.ts. Never mutates inputs.
3
+ import { quantile_sorted, quantile_unordered } from './quantile';
4
+ const KDE_EXACT_SAMPLE_LIMIT = 1024;
5
+ const KDE_TAIL_SIGMA = 6;
6
+ function sample_deviation(sorted) {
7
+ const n_vals = sorted.length;
8
+ if (n_vals < 2)
9
+ return 0;
10
+ let sum = 0;
11
+ for (const val of sorted)
12
+ sum += val;
13
+ const mean = sum / n_vals;
14
+ let variance_sum = 0;
15
+ for (const val of sorted) {
16
+ const delta = val - mean;
17
+ variance_sum += delta * delta;
18
+ }
19
+ return Math.sqrt(variance_sum / (n_vals - 1));
20
+ }
21
+ // Silverman's rule of thumb: 0.9 * min(std, IQR/1.34) * n^(-1/5). Matches scipy/seaborn.
22
+ // (`sigma` floors to std then 1 to avoid a zero bandwidth.)
23
+ const silverman_from_stats = (n_vals, std, iqr) => {
24
+ const spread = iqr > 0 ? Math.min(std, iqr / 1.34) : std;
25
+ const sigma = spread > 0 ? spread : std > 0 ? std : 1;
26
+ return 0.9 * sigma * n_vals ** (-1 / 5);
27
+ };
28
+ export function silverman_bandwidth(sorted) {
29
+ if (sorted.length < 2)
30
+ return 1;
31
+ const iqr = quantile_sorted(sorted, 0.75) - quantile_sorted(sorted, 0.25);
32
+ return silverman_from_stats(sorted.length, sample_deviation(sorted), iqr);
33
+ }
34
+ function silverman_bandwidth_unordered(samples) {
35
+ if (samples.length < 2)
36
+ return 1;
37
+ const q1 = quantile_unordered(samples, 0.25);
38
+ const q3 = quantile_unordered(samples, 0.75);
39
+ return silverman_from_stats(samples.length, sample_deviation(samples), q3 - q1);
40
+ }
41
+ // Scott's rule: std * n^(-1/5) for 1-D data.
42
+ // `samples` need not be sorted (only uses sample_deviation, unlike silverman_bandwidth)
43
+ export function scott_bandwidth(samples) {
44
+ const n_vals = samples.length;
45
+ if (n_vals < 2)
46
+ return 1;
47
+ const std = sample_deviation(samples) || 1;
48
+ return std * n_vals ** (-1 / 5);
49
+ }
50
+ function exact_density(eval_samples, grid, band) {
51
+ const n_eval = eval_samples.length;
52
+ const norm = 1 / (n_eval * band * Math.sqrt(2 * Math.PI));
53
+ const density = Array.from({ length: grid.length }, () => 0);
54
+ for (let grid_idx = 0; grid_idx < grid.length; grid_idx++) {
55
+ const g_val = grid[grid_idx];
56
+ let sum = 0;
57
+ for (const sample of eval_samples) {
58
+ const z_score = (g_val - sample) / band;
59
+ sum += Math.exp(-0.5 * z_score * z_score);
60
+ }
61
+ density[grid_idx] = sum * norm;
62
+ }
63
+ return density;
64
+ }
65
+ function binned_density(eval_samples, grid, band) {
66
+ const n_eval = eval_samples.length;
67
+ let sample_min = Infinity;
68
+ let sample_max = -Infinity;
69
+ for (const sample of eval_samples) {
70
+ if (sample < sample_min)
71
+ sample_min = sample;
72
+ if (sample > sample_max)
73
+ sample_max = sample;
74
+ }
75
+ if (sample_max <= sample_min)
76
+ return exact_density(eval_samples, grid, band);
77
+ const bin_count = Math.min(1024, Math.max(128, grid.length * 4));
78
+ const counts = new Float64Array(bin_count);
79
+ const span = sample_max - sample_min;
80
+ const inv_bin_width = bin_count / span;
81
+ for (const sample of eval_samples) {
82
+ const idx = Math.min(bin_count - 1, Math.floor((sample - sample_min) * inv_bin_width));
83
+ counts[idx] += 1;
84
+ }
85
+ const centers = new Float64Array(bin_count);
86
+ const bin_width = span / bin_count;
87
+ for (let idx = 0; idx < bin_count; idx++)
88
+ centers[idx] = sample_min + (idx + 0.5) * bin_width;
89
+ const density = Array.from({ length: grid.length }, () => 0);
90
+ const norm = 1 / (n_eval * band * Math.sqrt(2 * Math.PI));
91
+ const radius = KDE_TAIL_SIGMA * band;
92
+ for (let grid_idx = 0; grid_idx < grid.length; grid_idx++) {
93
+ const g_val = grid[grid_idx];
94
+ const start = Math.max(0, Math.floor((g_val - radius - sample_min) * inv_bin_width));
95
+ const stop = Math.min(bin_count - 1, Math.floor((g_val + radius - sample_min) * inv_bin_width));
96
+ let sum = 0;
97
+ for (let bin_idx = start; bin_idx <= stop; bin_idx++) {
98
+ const count = counts[bin_idx];
99
+ if (count === 0)
100
+ continue;
101
+ const z_score = (g_val - centers[bin_idx]) / band;
102
+ sum += count * Math.exp(-0.5 * z_score * z_score);
103
+ }
104
+ density[grid_idx] = sum * norm;
105
+ }
106
+ return density;
107
+ }
108
+ // Estimate a smooth density from raw samples via a Gaussian kernel.
109
+ export function gaussian_kde(samples, opts = {}) {
110
+ const { bandwidth = `silverman`, n_points = 100, cut = 2, clip, range, max_samples } = opts;
111
+ const finite = samples.filter((val) => Number.isFinite(val));
112
+ const n_vals = finite.length;
113
+ if (n_vals === 0)
114
+ return { grid: [], density: [], bandwidth: 0 };
115
+ let data_min = Infinity;
116
+ let data_max = -Infinity;
117
+ for (const sample of finite) {
118
+ if (sample < data_min)
119
+ data_min = sample;
120
+ if (sample > data_max)
121
+ data_max = sample;
122
+ }
123
+ // Deterministic stride subsample for the density sum on large inputs.
124
+ // Do this before unordered quantile selection mutates `finite`.
125
+ let eval_samples = finite;
126
+ if (max_samples && n_vals > max_samples) {
127
+ const step = n_vals / max_samples;
128
+ const sampled = Array.from({ length: max_samples }, () => 0);
129
+ for (let idx = 0; idx < max_samples; idx++)
130
+ sampled[idx] = finite[Math.floor(idx * step)];
131
+ eval_samples = sampled;
132
+ }
133
+ let band = typeof bandwidth === `number`
134
+ ? bandwidth
135
+ : bandwidth === `scott`
136
+ ? scott_bandwidth(finite)
137
+ : silverman_bandwidth_unordered(finite);
138
+ band = Math.max(band, 1e-12); // guard against zero/negative bandwidth
139
+ const n_eval = eval_samples.length;
140
+ let lo = range ? range[0] : data_min - cut * band;
141
+ let hi = range ? range[1] : data_max + cut * band;
142
+ if (clip) {
143
+ if (clip[0] != null)
144
+ lo = Math.max(lo, clip[0]);
145
+ if (clip[1] != null)
146
+ hi = Math.min(hi, clip[1]);
147
+ }
148
+ // An inverted/collapsed range (e.g. clip [10, 5], or a clip bound outside the data) leaves
149
+ // no valid grid -> degrade to an empty density rather than a corrupted descending grid.
150
+ if (hi <= lo)
151
+ return { grid: [], density: [], bandwidth: band };
152
+ const points = Math.max(2, Math.floor(n_points));
153
+ const grid = Array.from({ length: points }, () => 0);
154
+ for (let idx = 0; idx < points; idx++)
155
+ grid[idx] = lo + ((hi - lo) * idx) / (points - 1);
156
+ const density = max_samples && n_eval > KDE_EXACT_SAMPLE_LIMIT
157
+ ? binned_density(eval_samples, grid, band)
158
+ : exact_density(eval_samples, grid, band);
159
+ return { grid, density, bandwidth: band };
160
+ }
@@ -0,0 +1,3 @@
1
+ export declare function quickselect(values: number[], kth: number): number;
2
+ export declare function quantile_sorted(values: readonly number[], p: number): number;
3
+ export declare function quantile_unordered(values: number[], p: number): number;
@@ -0,0 +1,53 @@
1
+ // Shared quantile + selection helpers used by box-plot.ts and kde.ts.
2
+ // quickselect partially sorts in place; quantile_unordered mutates its input
3
+ // (quantile_sorted assumes an already-ascending array and never mutates).
4
+ //
5
+ // Unguarded contract: quickselect, quantile_sorted and quantile_unordered all assume
6
+ // values.length > 0 and 0 <= p <= 1. Out-of-range inputs index past the array and
7
+ // yield undefined/NaN — callers (box-plot.ts, kde.ts) must length- and p-range-check
8
+ // before calling.
9
+ export function quickselect(values, kth) {
10
+ let left = 0;
11
+ let right = values.length - 1;
12
+ while (left < right) {
13
+ const pivot = values[(left + right) >>> 1];
14
+ let scan_lo = left;
15
+ let scan_hi = right;
16
+ while (scan_lo <= scan_hi) {
17
+ while (values[scan_lo] < pivot)
18
+ scan_lo++;
19
+ while (values[scan_hi] > pivot)
20
+ scan_hi--;
21
+ if (scan_lo <= scan_hi) {
22
+ const tmp = values[scan_lo];
23
+ values[scan_lo] = values[scan_hi];
24
+ values[scan_hi] = tmp;
25
+ scan_lo++;
26
+ scan_hi--;
27
+ }
28
+ }
29
+ if (kth <= scan_hi)
30
+ right = scan_hi;
31
+ else if (kth >= scan_lo)
32
+ left = scan_lo;
33
+ else
34
+ return values[kth];
35
+ }
36
+ return values[kth];
37
+ }
38
+ export function quantile_sorted(values, p) {
39
+ const idx = (values.length - 1) * p;
40
+ const lo = Math.floor(idx);
41
+ const hi = Math.ceil(idx);
42
+ const frac = idx - lo;
43
+ const lo_val = values[lo];
44
+ return hi === lo ? lo_val : lo_val + (values[hi] - lo_val) * frac;
45
+ }
46
+ export function quantile_unordered(values, p) {
47
+ const idx = (values.length - 1) * p;
48
+ const lo = Math.floor(idx);
49
+ const hi = Math.ceil(idx);
50
+ const frac = idx - lo;
51
+ const lo_val = quickselect(values, lo);
52
+ return hi === lo ? lo_val : lo_val + (quickselect(values, hi) - lo_val) * frac;
53
+ }
@@ -1,5 +1,4 @@
1
1
  import type { Sides } from './layout';
2
- export declare const DECOR_GAP = 8;
3
2
  type Pt = {
4
3
  x: number;
5
4
  y: number;
@@ -8,6 +7,7 @@ type Size = {
8
7
  width: number;
9
8
  height: number;
10
9
  };
10
+ export declare const placed_coords: (auto_outside: boolean, outside: Pt, placement: Pt | null, tweened: Pt, fallback: Pt) => Pt;
11
11
  export declare const has_explicit_position: (style?: string | null) => boolean;
12
12
  export declare const measured_footprint: (el: HTMLElement | null | undefined, fallback: Size) => Size;
13
13
  export declare function build_obstacles_norm(series: {
@@ -1,7 +1,10 @@
1
- import { compute_element_placement, sample_series_obstacle_points } from './layout';
1
+ import { compute_element_placement, sample_series_obstacle_points, } from './layout';
2
2
  // Shared "move a decoration (legend/colorbar) outside the plot when interior overlap is
3
3
  // unavoidable" logic, reused by every 2D plot (ScatterPlot/BarPlot/Histogram/BinnedScatterPlot).
4
- export const DECOR_GAP = 8; // px gap between an outside decoration and the plot edge
4
+ const DECOR_GAP = 8; // px gap between an outside decoration and the plot edge
5
+ // Final on-screen position for an auto-placed decoration: explicit outside placement
6
+ // wins, then the tweened auto placement, else a static padding fallback
7
+ export const placed_coords = (auto_outside, outside, placement, tweened, fallback) => (auto_outside ? outside : placement ? tweened : fallback);
5
8
  // True when the user pinned a decoration via its style (an edge property or position:absolute),
6
9
  // in which case auto-placement must leave it alone.
7
10
  export const has_explicit_position = (style) => /(^|[;{]\s*)(top|bottom|left|right)\s*:|position\s*:\s*absolute/.test(style ?? ``);
@@ -55,7 +58,7 @@ export function clip_bar(vertical, cross, a, b) {
55
58
  const CROWDING_RATIO = 0.5;
56
59
  // True when even the best interior spot for `footprint` (px) is too dense to host the decoration
57
60
  function is_crowded(obstacles, footprint, base_w, base_h, clearance) {
58
- if (!obstacles.length || base_w <= 0 || base_h <= 0)
61
+ if (obstacles.length === 0 || base_w <= 0 || base_h <= 0)
59
62
  return false;
60
63
  const fw = footprint.width / base_w;
61
64
  const fh = footprint.height / base_h;
@@ -0,0 +1,46 @@
1
+ import type { AxisConfig, AxisLoadError, BarSeries, DataLoaderFn, DataSeries } from './types';
2
+ export declare const AXIS_DEFAULTS: {
3
+ format: string;
4
+ scale_type: "linear";
5
+ ticks: number;
6
+ label_shift: {
7
+ x: number;
8
+ y: number;
9
+ };
10
+ tick: {
11
+ label: {
12
+ shift: {
13
+ x: number;
14
+ y: number;
15
+ };
16
+ inside: boolean;
17
+ };
18
+ };
19
+ range: [number | null, number | null];
20
+ };
21
+ type AxisType = `x` | `x2` | `y` | `y2`;
22
+ export declare function merge_series_state<T extends DataSeries | BarSeries>(old_series: T[], new_series: T[]): T[];
23
+ export interface AxisChangeState<T extends DataSeries | BarSeries> {
24
+ get_axis: (axis: AxisType) => AxisConfig;
25
+ set_axis: (axis: AxisType, config: AxisConfig) => void;
26
+ get_series: () => T[];
27
+ set_series: (series: T[]) => void;
28
+ get_loading: () => AxisType | null;
29
+ set_loading: (axis: AxisType | null) => void;
30
+ }
31
+ export declare const create_axis_change_handler: <T extends DataSeries | BarSeries>(state: AxisChangeState<T>, data_loader: DataLoaderFn<Record<string, unknown>, T> | undefined, on_axis_change?: (axis: AxisType, key: string, new_series: T[]) => void, on_error?: (error: AxisLoadError) => void) => ((axis: AxisType, key: string) => Promise<void>);
32
+ export declare function create_axis_loader<T extends DataSeries | BarSeries>(state: AxisChangeState<T>, get_props: () => {
33
+ data_loader?: DataLoaderFn<Record<string, unknown>, T>;
34
+ on_axis_change?: (axis: AxisType, key: string, new_series: T[]) => void;
35
+ on_error?: (error: AxisLoadError) => void;
36
+ }): {
37
+ handle_axis_change: (axis: AxisType, key: string) => Promise<void>;
38
+ try_auto_load: () => void;
39
+ };
40
+ export declare const AXIS_LABEL_CONTAINER: {
41
+ readonly width: 200;
42
+ readonly height: 24;
43
+ readonly x_offset: 100;
44
+ readonly y_offset: 12;
45
+ };
46
+ export {};
@@ -0,0 +1,110 @@
1
+ // Shared utilities for interactive axis functionality
2
+ import { to_error } from '../../utils';
3
+ // Shared axis defaults across plot components (single source of truth)
4
+ export const AXIS_DEFAULTS = {
5
+ format: ``,
6
+ scale_type: `linear`,
7
+ ticks: 5,
8
+ label_shift: { x: 0, y: 0 },
9
+ tick: { label: { shift: { x: 0, y: 0 }, inside: false } },
10
+ range: [null, null],
11
+ };
12
+ // Merge new series with preserved UI state from old series.
13
+ // Matches by stable id first, then by index only for ordered id-less series.
14
+ export function merge_series_state(old_series, new_series) {
15
+ // Build id lookup map for O(1) matching (string or number ids)
16
+ const by_id = new Map();
17
+ for (const srs of old_series) {
18
+ if (srs.id !== undefined && srs.id !== ``)
19
+ by_id.set(srs.id, srs);
20
+ }
21
+ return new_series.map((new_srs, idx) => {
22
+ const old_srs = new_srs.id !== undefined && new_srs.id !== `` ? by_id.get(new_srs.id) : old_series[idx];
23
+ if (!old_srs) {
24
+ return new_srs;
25
+ }
26
+ // Preserve UI state: visibility and styling from old series if not in new
27
+ const result = { ...new_srs };
28
+ result.visible ??= old_srs.visible;
29
+ // Preserve style properties only when key exists in BOTH series (guards against
30
+ // cross-type injection when T is a union like DataSeries | BarSeries)
31
+ for (const key of [`point_style`, `line_style`, `color`]) {
32
+ if (key in old_srs && key in new_srs && result[key] === undefined) {
33
+ result[key] = old_srs[key];
34
+ }
35
+ }
36
+ return result;
37
+ });
38
+ }
39
+ // Handle axis property change - loads new data via data_loader
40
+ // Returns a function bound to the component's state accessors
41
+ export const create_axis_change_handler = (state, data_loader, on_axis_change, on_error) => async (axis, key) => {
42
+ if (!data_loader || state.get_loading())
43
+ return;
44
+ const axis_config = state.get_axis(axis);
45
+ const prev_key = axis_config.selected_key;
46
+ // Skip if key unchanged AND series already loaded (allows initial load when series empty)
47
+ if (prev_key === key && state.get_series().length > 0)
48
+ return;
49
+ // Update selected_key immediately for UI feedback
50
+ state.set_axis(axis, { ...axis_config, selected_key: key });
51
+ state.set_loading(axis);
52
+ try {
53
+ const result = await data_loader(axis, key, state.get_series());
54
+ // Merge new series with preserved state from old series
55
+ const merged = merge_series_state(state.get_series(), result.series);
56
+ state.set_series(merged);
57
+ // Update axis label/unit if provided
58
+ if (result.axis_label || result.axis_unit) {
59
+ const current = state.get_axis(axis);
60
+ state.set_axis(axis, {
61
+ ...current,
62
+ label: result.axis_label ?? current.label,
63
+ unit: result.axis_unit ?? current.unit,
64
+ });
65
+ }
66
+ on_axis_change?.(axis, key, merged);
67
+ }
68
+ catch (err) {
69
+ console.error(`Failed to load data for ${axis}=${key}:`, err);
70
+ // Revert selection
71
+ state.set_axis(axis, { ...state.get_axis(axis), selected_key: prev_key });
72
+ const message = to_error(err).message;
73
+ on_error?.({ axis, key, message });
74
+ }
75
+ finally {
76
+ state.set_loading(null);
77
+ }
78
+ };
79
+ // Bundle axis change handler with one-shot auto-load of the first axis option.
80
+ // get_props keeps callback props fresh; try_auto_load reads series/axis configs
81
+ // through state getters so a component `$effect(try_auto_load)` tracks them reactively.
82
+ export function create_axis_loader(state, get_props) {
83
+ let auto_load_attempted = false; // prevent infinite retries on failure
84
+ const handle_axis_change = (axis, key) => {
85
+ const { data_loader, on_axis_change, on_error } = get_props();
86
+ return create_axis_change_handler(state, data_loader, on_axis_change, on_error)(axis, key);
87
+ };
88
+ // Auto-load data if series is empty but options exist (runs once, x-axis first then y)
89
+ const try_auto_load = () => {
90
+ if (state.get_series().length > 0 || !get_props().data_loader || auto_load_attempted)
91
+ return;
92
+ for (const axis of [`x`, `y`]) {
93
+ const config = state.get_axis(axis);
94
+ if (config.options?.length) {
95
+ auto_load_attempted = true;
96
+ handle_axis_change(axis, config.selected_key ?? config.options[0].key).catch(() => { });
97
+ return;
98
+ }
99
+ }
100
+ };
101
+ return { handle_axis_change, try_auto_load };
102
+ }
103
+ // Constants for axis label foreignObject positioning (all values in px)
104
+ // Use minimal dimensions - overflow: visible handles any dropdown expansion
105
+ export const AXIS_LABEL_CONTAINER = {
106
+ width: 200, // container width for centering; dropdown can overflow
107
+ height: 24, // single line height; dropdown options overflow downward
108
+ x_offset: 100, // half of width for horizontal centering
109
+ y_offset: 12, // half of height for vertical centering
110
+ };
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
- import { AXIS_LABEL_CONTAINER } from './axis-utils'
3
- import type { AxisOption } from './types'
2
+ import { AXIS_LABEL_CONTAINER } from '../axis-utils'
3
+ import type { AxisOption } from '../types'
4
4
  import InteractiveAxisLabel from './InteractiveAxisLabel.svelte'
5
5
 
6
6
  let {
@@ -1,4 +1,4 @@
1
- import type { AxisOption } from './types';
1
+ import type { AxisOption } from '../types';
2
2
  type $$ComponentProps = {
3
3
  x: number;
4
4
  y: number;
@@ -1,26 +1,26 @@
1
1
  <script lang="ts">
2
- import { luminance } from '../colors'
3
- import Spinner from '../feedback/Spinner.svelte'
4
- import { format_num } from '../labels'
5
- import { sanitize_html } from '../sanitize'
6
- import type { Vec2 } from '../math'
7
- import * as math from '../math'
2
+ import { luminance } from '../../../colors'
3
+ import Spinner from '../../../feedback/Spinner.svelte'
4
+ import { format_num } from '../../../labels'
5
+ import { sanitize_html } from '../../../sanitize'
6
+ import type { Vec2 } from '../../../math'
7
+ import * as math from '../../../math'
8
8
  import { format } from 'd3-format'
9
9
  import * as d3 from 'd3-scale'
10
10
  import * as d3_sc from 'd3-scale-chromatic'
11
11
  import { timeFormat } from 'd3-time-format'
12
12
  import type { HTMLAttributes } from 'svelte/elements'
13
- import type { D3InterpolateName } from '../colors'
13
+ import type { D3InterpolateName } from '../../../colors'
14
14
  import PortalSelect from './PortalSelect.svelte'
15
- import { generate_arcsinh_ticks, scale_arcsinh } from './scales'
15
+ import { generate_arcsinh_ticks, scale_arcsinh } from '../scales'
16
16
  import type {
17
17
  AxisOption,
18
18
  ColorBarDataLoaderFn,
19
19
  ColorScaleOption,
20
20
  Orientation,
21
21
  ScaleType,
22
- } from './types'
23
- import { get_arcsinh_threshold, get_scale_type_name } from './types'
22
+ } from '../types'
23
+ import { get_arcsinh_threshold, get_scale_type_name } from '../types'
24
24
 
25
25
  let {
26
26
  title = $bindable(),
@@ -59,7 +59,7 @@
59
59
  wrapper_style?: string
60
60
  tick_labels?: (string | number)[] | number
61
61
  tick_format?: string
62
- range?: [number, number]
62
+ range?: Vec2
63
63
  // tick_side determines tick placement relative to orientation:
64
64
  // 'primary' = bottom (horizontal) / right (vertical), outside bar
65
65
  // 'secondary' = top (horizontal) / left (vertical), outside bar
@@ -72,18 +72,18 @@
72
72
  steps?: number
73
73
  // computed "nice" range resulting from snapping ticks
74
74
  // https://github.com/d3/d3-scale/issues/86
75
- nice_range?: [number, number]
75
+ nice_range?: Vec2
76
76
  // type of scale to use for ticks and potentially color (if color_scale_fn not provided)
77
77
  scale_type?: ScaleType
78
78
  // Optional pre-configured d3 color scale function
79
79
  color_scale_fn?: (value: number) => string
80
80
  // Optional domain for pre-configured color scale function
81
- color_scale_domain?: [number, number]
81
+ color_scale_domain?: Vec2
82
82
  // Property selection options (makes title interactive)
83
83
  property_options?: AxisOption[]
84
84
  selected_property_key?: string
85
85
  data_loader?: ColorBarDataLoaderFn
86
- on_property_change?: (key: string, range: [number, number]) => void
86
+ on_property_change?: (key: string, range: Vec2) => void
87
87
  // Color scale selection options
88
88
  color_scale_options?: ColorScaleOption[]
89
89
  selected_color_scale_key?: string
@@ -103,11 +103,11 @@
103
103
  // If ticks are secondary (top), default label to bottom
104
104
  if (orientation === `horizontal`) {
105
105
  return tick_side === `primary` ? `top` : `bottom`
106
- } else { // orientation === `vertical`
106
+ } // orientation === `vertical`
107
107
  // If ticks are primary (right), default label to left
108
108
  // If ticks are secondary (left), default label to right
109
109
  return tick_side === `primary` ? `left` : `right`
110
- }
110
+
111
111
  })
112
112
 
113
113
  // Number of ticks to generate
@@ -200,7 +200,7 @@
200
200
 
201
201
  const power_of_10_ticks: number[] = []
202
202
  for (let exp = start_exp; exp <= end_exp; exp++) {
203
- power_of_10_ticks.push(Math.pow(10, exp))
203
+ power_of_10_ticks.push(10 ** exp)
204
204
  }
205
205
 
206
206
  // Ensure domain endpoints are included if they are powers of 10 and missed by loop
@@ -225,27 +225,24 @@
225
225
  }
226
226
 
227
227
  return power_of_10_ticks
228
- } else {
229
- // Generate exactly n_ticks manually for log scale if not snapping
230
- const log_min = Math.log10(scale_min)
231
- const log_max = Math.log10(scale_max)
232
- return [...Array(n_ticks).keys()].map((idx) => {
233
- const fraction = idx / (n_ticks - 1)
234
- const log_val = log_min + fraction * (log_max - log_min)
235
- return Math.pow(10, log_val)
236
- })
237
- }
238
- } else {
239
- // Use D3's default nice ticks for linear scale
240
- if (snap_ticks) return scale.ticks(n_ticks)
241
- else {
242
- // Generate exactly n_ticks evenly spaced linear ticks
243
- return [...Array(n_ticks).keys()].map((idx) => {
244
- const fraction = idx / (n_ticks - 1)
245
- return scale_min + fraction * (scale_max - scale_min)
246
- })
247
228
  }
229
+ // Generate exactly n_ticks manually for log scale if not snapping
230
+ const log_min = Math.log10(scale_min)
231
+ const log_max = Math.log10(scale_max)
232
+ return [...Array(n_ticks).keys()].map((idx) => {
233
+ const fraction = idx / (n_ticks - 1)
234
+ const log_val = log_min + fraction * (log_max - log_min)
235
+ return 10 ** log_val
236
+ })
248
237
  }
238
+ // Use D3's default nice ticks for linear scale
239
+ if (snap_ticks) return scale.ticks(n_ticks)
240
+ // Generate exactly n_ticks evenly spaced linear ticks
241
+ return [...Array(n_ticks).keys()].map((idx) => {
242
+ const fraction = idx / (n_ticks - 1)
243
+ return scale_min + fraction * (scale_max - scale_min)
244
+ })
245
+
249
246
  })
250
247
 
251
248
  // Update nice_range binding when snapping ticks
@@ -304,7 +301,7 @@
304
301
  // Use potentially adjusted min/max for domain (ascending)
305
302
  const lo = Math.min(min_val, max_val)
306
303
  const hi = Math.max(min_val, max_val)
307
- const domain_for_scale: [number, number] = [lo, hi]
304
+ const domain_for_scale: Vec2 = [lo, hi]
308
305
 
309
306
  // For arcsinh, create a custom color scale
310
307
  if (type_name === `arcsinh`) {
@@ -380,7 +377,7 @@
380
377
  if (use_log_interp) {
381
378
  data_value = log_span === 0
382
379
  ? adjusted_min_ramp
383
- : Math.pow(10, log_min + fraction * log_span)
380
+ : 10 ** (log_min + fraction * log_span)
384
381
  } else if (type_name === `arcsinh`) {
385
382
  data_value = asinh_span === 0
386
383
  ? min_ramp_domain
@@ -644,6 +641,12 @@
644
641
  display: var(--cbar-label-display);
645
642
  align-items: center;
646
643
  justify-content: center;
644
+ /* blur-only (no tint): invisible over uniform bg, smears busy bg to keep title readable */
645
+ background: var(--cbar-label-bg, transparent);
646
+ backdrop-filter: var(--cbar-label-backdrop-filter, blur(4px));
647
+ border-radius: var(--cbar-label-border-radius, var(--border-radius, 3pt));
648
+ /* keep title selectable/copyable */
649
+ user-select: text;
647
650
  }
648
651
  span.tick-label {
649
652
  position: absolute;
@@ -1,5 +1,6 @@
1
+ import type { Vec2 } from '../../../math';
1
2
  import type { HTMLAttributes } from 'svelte/elements';
2
- import type { AxisOption, ColorBarDataLoaderFn, ColorScaleOption, Orientation, ScaleType } from './types';
3
+ import type { AxisOption, ColorBarDataLoaderFn, ColorScaleOption, Orientation, ScaleType } from '../types';
3
4
  type $$ComponentProps = HTMLAttributes<HTMLDivElement> & {
4
5
  title?: string;
5
6
  color_scale?: ((x: number) => string) | string | null;
@@ -9,23 +10,23 @@ type $$ComponentProps = HTMLAttributes<HTMLDivElement> & {
9
10
  wrapper_style?: string;
10
11
  tick_labels?: (string | number)[] | number;
11
12
  tick_format?: string;
12
- range?: [number, number];
13
+ range?: Vec2;
13
14
  tick_side?: `primary` | `secondary` | `inside`;
14
15
  orientation?: Orientation;
15
16
  snap_ticks?: boolean;
16
17
  steps?: number;
17
- nice_range?: [number, number];
18
+ nice_range?: Vec2;
18
19
  scale_type?: ScaleType;
19
20
  color_scale_fn?: (value: number) => string;
20
- color_scale_domain?: [number, number];
21
+ color_scale_domain?: Vec2;
21
22
  property_options?: AxisOption[];
22
23
  selected_property_key?: string;
23
24
  data_loader?: ColorBarDataLoaderFn;
24
- on_property_change?: (key: string, range: [number, number]) => void;
25
+ on_property_change?: (key: string, range: Vec2) => void;
25
26
  color_scale_options?: ColorScaleOption[];
26
27
  selected_color_scale_key?: string;
27
28
  on_color_scale_change?: (key: string) => void;
28
29
  };
29
- declare const ColorBar: import("svelte").Component<$$ComponentProps, {}, "title" | "color_scale" | "range" | "tick_labels" | "nice_range" | "selected_property_key" | "selected_color_scale_key">;
30
+ declare const ColorBar: import("svelte").Component<$$ComponentProps, {}, "title" | "range" | "color_scale" | "tick_labels" | "nice_range" | "selected_property_key" | "selected_color_scale_key">;
30
31
  type ColorBar = ReturnType<typeof ColorBar>;
31
32
  export default ColorBar;
@@ -1,9 +1,9 @@
1
1
  <script lang="ts">
2
- import { ColorBar } from './'
2
+ import { ColorBar } from '../..'
3
3
  import * as d3_sc from 'd3-scale-chromatic'
4
4
  import type { ComponentProps } from 'svelte'
5
5
  import Select from 'svelte-multiselect'
6
- import type { D3InterpolateName } from '../colors'
6
+ import type { D3InterpolateName } from '../../../colors'
7
7
 
8
8
  let {
9
9
  options = Object.keys(d3_sc).filter((key) =>
@@ -28,6 +28,7 @@
28
28
  <Select
29
29
  {options}
30
30
  maxSelect={1}
31
+ maxOptions={options.length}
31
32
  {minSelect}
32
33
  bind:value
33
34
  bind:selected
@@ -47,7 +48,7 @@
47
48
  tick_labels={0}
48
49
  title_side="left"
49
50
  wrapper_style="width: 100%;"
50
- title_style="width: 6em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left;"
51
+ title_style="width: 6em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; font-size: 0.9rem;"
51
52
  {...colorbar}
52
53
  />
53
54
  {/snippet}
@@ -1,7 +1,7 @@
1
- import { ColorBar } from './';
1
+ import { ColorBar } from '../..';
2
2
  import type { ComponentProps } from 'svelte';
3
3
  import Select from 'svelte-multiselect';
4
- import type { D3InterpolateName } from '../colors';
4
+ import type { D3InterpolateName } from '../../../colors';
5
5
  type $$ComponentProps = Omit<ComponentProps<typeof Select>, `options`> & {
6
6
  options?: D3InterpolateName[];
7
7
  value?: D3InterpolateName;