matterviz 0.3.7 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (324) 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 +8 -3
  6. package/dist/brillouin/BrillouinZone.svelte.d.ts +2 -1
  7. package/dist/brillouin/BrillouinZoneScene.svelte +52 -6
  8. package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -0
  9. package/dist/brillouin/BrillouinZoneTooltip.svelte +16 -25
  10. package/dist/brillouin/compute.js +10 -14
  11. package/dist/chempot-diagram/ChemPotDiagram.svelte +14 -13
  12. package/dist/chempot-diagram/ChemPotDiagram2D.svelte +12 -15
  13. package/dist/chempot-diagram/ChemPotDiagram3D.svelte +8 -10
  14. package/dist/chempot-diagram/async-compute.svelte.js +3 -1
  15. package/dist/chempot-diagram/chempot-worker.js +2 -1
  16. package/dist/chempot-diagram/compute.d.ts +1 -1
  17. package/dist/chempot-diagram/compute.js +17 -19
  18. package/dist/colors/index.js +6 -5
  19. package/dist/composition/FormulaFilter.svelte +12 -6
  20. package/dist/composition/PieChart.svelte +6 -5
  21. package/dist/composition/chem-sys.d.ts +8 -0
  22. package/dist/composition/chem-sys.js +85 -0
  23. package/dist/composition/format.js +4 -2
  24. package/dist/composition/index.d.ts +1 -0
  25. package/dist/composition/index.js +1 -0
  26. package/dist/composition/parse.js +25 -13
  27. package/dist/convex-hull/ConvexHull2D.svelte +12 -10
  28. package/dist/convex-hull/ConvexHull3D.svelte +5 -5
  29. package/dist/convex-hull/ConvexHull4D.svelte +5 -9
  30. package/dist/convex-hull/ConvexHullStats.svelte +12 -12
  31. package/dist/convex-hull/GasPressureControls.svelte +4 -4
  32. package/dist/convex-hull/TemperatureSlider.svelte +2 -2
  33. package/dist/convex-hull/demo-temperature.d.ts +1 -1
  34. package/dist/convex-hull/demo-temperature.js +20 -22
  35. package/dist/convex-hull/gas-thermodynamics.d.ts +2 -2
  36. package/dist/convex-hull/gas-thermodynamics.js +22 -30
  37. package/dist/convex-hull/helpers.d.ts +3 -0
  38. package/dist/convex-hull/helpers.js +17 -9
  39. package/dist/convex-hull/index.d.ts +1 -1
  40. package/dist/convex-hull/thermodynamics.js +83 -78
  41. package/dist/convex-hull/types.d.ts +1 -1
  42. package/dist/coordination/CoordinationBarPlot.svelte +23 -23
  43. package/dist/coordination/CoordinationBarPlot.svelte.d.ts +1 -1
  44. package/dist/element/ElementTile.svelte.d.ts +1 -1
  45. package/dist/fermi-surface/FermiSlice.svelte +13 -5
  46. package/dist/fermi-surface/FermiSurface.svelte +11 -5
  47. package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
  48. package/dist/fermi-surface/FermiSurfaceControls.svelte +1 -1
  49. package/dist/fermi-surface/FermiSurfaceScene.svelte +3 -0
  50. package/dist/fermi-surface/FermiSurfaceTooltip.svelte +8 -34
  51. package/dist/fermi-surface/compute.js +59 -59
  52. package/dist/fermi-surface/export.js +3 -2
  53. package/dist/fermi-surface/parse.js +7 -4
  54. package/dist/fermi-surface/types.d.ts +1 -0
  55. package/dist/heatmap-matrix/HeatmapMatrix.svelte +23 -21
  56. package/dist/heatmap-matrix/index.js +1 -1
  57. package/dist/io/decompress.js +4 -2
  58. package/dist/io/export.d.ts +4 -4
  59. package/dist/io/export.js +47 -25
  60. package/dist/io/fetch.js +5 -1
  61. package/dist/io/file-drop.d.ts +1 -1
  62. package/dist/io/file-drop.js +35 -36
  63. package/dist/io/url-drop.js +64 -33
  64. package/dist/isosurface/parse.js +6 -7
  65. package/dist/isosurface/slice.js +5 -4
  66. package/dist/isosurface/types.js +1 -1
  67. package/dist/keyboard.d.ts +3 -0
  68. package/dist/keyboard.js +23 -0
  69. package/dist/labels.d.ts +1 -1
  70. package/dist/labels.js +8 -7
  71. package/dist/layout/PropertyFilter.svelte +3 -2
  72. package/dist/layout/SettingsSection.svelte +1 -1
  73. package/dist/layout/json-tree/JsonNode.svelte +1 -1
  74. package/dist/layout/json-tree/JsonTree.svelte +2 -2
  75. package/dist/layout/json-tree/utils.js +5 -4
  76. package/dist/marching-cubes.js +8 -13
  77. package/dist/math.d.ts +5 -1
  78. package/dist/math.js +24 -9
  79. package/dist/overlays/DraggablePane.svelte +4 -4
  80. package/dist/periodic-table/PeriodicTable.svelte +20 -9
  81. package/dist/periodic-table/PropertySelect.svelte +1 -0
  82. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +9 -3
  83. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +1 -1
  84. package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +1 -1
  85. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +2 -1
  86. package/dist/phase-diagram/PhaseDiagramTooltip.svelte +1 -1
  87. package/dist/phase-diagram/build-diagram.js +2 -2
  88. package/dist/phase-diagram/parse.js +6 -5
  89. package/dist/phase-diagram/types.d.ts +1 -1
  90. package/dist/phase-diagram/utils.d.ts +3 -3
  91. package/dist/phase-diagram/utils.js +8 -12
  92. package/dist/plot/{BarPlot.svelte → bar/BarPlot.svelte} +229 -587
  93. package/dist/plot/{BarPlot.svelte.d.ts → bar/BarPlot.svelte.d.ts} +5 -5
  94. package/dist/plot/{BarPlotControls.svelte → bar/BarPlotControls.svelte} +6 -5
  95. package/dist/plot/{BarPlotControls.svelte.d.ts → bar/BarPlotControls.svelte.d.ts} +3 -3
  96. package/dist/plot/{SpacegroupBarPlot.svelte → bar/SpacegroupBarPlot.svelte} +6 -6
  97. package/dist/plot/{SpacegroupBarPlot.svelte.d.ts → bar/SpacegroupBarPlot.svelte.d.ts} +1 -1
  98. package/dist/plot/bar/data.d.ts +40 -0
  99. package/dist/plot/bar/data.js +154 -0
  100. package/dist/plot/bar/geometry.d.ts +39 -0
  101. package/dist/plot/bar/geometry.js +60 -0
  102. package/dist/plot/bar/index.d.ts +3 -0
  103. package/dist/plot/bar/index.js +3 -0
  104. package/dist/plot/box/BoxPlot.svelte +1462 -0
  105. package/dist/plot/box/BoxPlot.svelte.d.ts +94 -0
  106. package/dist/plot/box/BoxPlotControls.svelte +109 -0
  107. package/dist/plot/box/BoxPlotControls.svelte.d.ts +19 -0
  108. package/dist/plot/box/Violin.svelte +14 -0
  109. package/dist/plot/box/Violin.svelte.d.ts +70 -0
  110. package/dist/plot/box/box-plot.d.ts +55 -0
  111. package/dist/plot/box/box-plot.js +126 -0
  112. package/dist/plot/box/index.d.ts +5 -0
  113. package/dist/plot/box/index.js +5 -0
  114. package/dist/plot/box/kde.d.ts +16 -0
  115. package/dist/plot/box/kde.js +160 -0
  116. package/dist/plot/box/quantile.d.ts +3 -0
  117. package/dist/plot/box/quantile.js +53 -0
  118. package/dist/plot/{auto-place.js → core/auto-place.js} +2 -2
  119. package/dist/plot/core/axis-utils.d.ts +46 -0
  120. package/dist/plot/core/axis-utils.js +110 -0
  121. package/dist/plot/{AxisLabel.svelte → core/components/AxisLabel.svelte} +2 -2
  122. package/dist/plot/{AxisLabel.svelte.d.ts → core/components/AxisLabel.svelte.d.ts} +1 -1
  123. package/dist/plot/{ColorBar.svelte → core/components/ColorBar.svelte} +36 -33
  124. package/dist/plot/{ColorBar.svelte.d.ts → core/components/ColorBar.svelte.d.ts} +2 -2
  125. package/dist/plot/{ColorScaleSelect.svelte → core/components/ColorScaleSelect.svelte} +4 -3
  126. package/dist/plot/{ColorScaleSelect.svelte.d.ts → core/components/ColorScaleSelect.svelte.d.ts} +2 -2
  127. package/dist/plot/core/components/ControlPane.svelte +46 -0
  128. package/dist/plot/core/components/ControlPane.svelte.d.ts +13 -0
  129. package/dist/plot/{FillArea.svelte → core/components/FillArea.svelte} +17 -6
  130. package/dist/plot/{FillArea.svelte.d.ts → core/components/FillArea.svelte.d.ts} +1 -1
  131. package/dist/plot/{InteractiveAxisLabel.svelte → core/components/InteractiveAxisLabel.svelte} +3 -3
  132. package/dist/plot/{InteractiveAxisLabel.svelte.d.ts → core/components/InteractiveAxisLabel.svelte.d.ts} +2 -2
  133. package/dist/plot/{Line.svelte → core/components/Line.svelte} +30 -13
  134. package/dist/plot/{PlotAxis.svelte → core/components/PlotAxis.svelte} +7 -5
  135. package/dist/plot/{PlotAxis.svelte.d.ts → core/components/PlotAxis.svelte.d.ts} +3 -2
  136. package/dist/plot/{PlotControls.svelte → core/components/PlotControls.svelte} +17 -29
  137. package/dist/plot/core/components/PlotControls.svelte.d.ts +4 -0
  138. package/dist/plot/{PlotLegend.svelte → core/components/PlotLegend.svelte} +21 -10
  139. package/dist/plot/{PlotLegend.svelte.d.ts → core/components/PlotLegend.svelte.d.ts} +3 -2
  140. package/dist/plot/{PlotTooltip.svelte → core/components/PlotTooltip.svelte} +17 -1
  141. package/dist/plot/{PlotTooltip.svelte.d.ts → core/components/PlotTooltip.svelte.d.ts} +8 -0
  142. package/dist/plot/{PortalSelect.svelte → core/components/PortalSelect.svelte} +11 -7
  143. package/dist/plot/{ReferenceLine.svelte → core/components/ReferenceLine.svelte} +3 -3
  144. package/dist/plot/{ReferenceLine.svelte.d.ts → core/components/ReferenceLine.svelte.d.ts} +1 -1
  145. package/dist/plot/{ReferenceLine3D.svelte → core/components/ReferenceLine3D.svelte} +4 -4
  146. package/dist/plot/{ReferenceLine3D.svelte.d.ts → core/components/ReferenceLine3D.svelte.d.ts} +2 -2
  147. package/dist/plot/{ReferencePlane.svelte → core/components/ReferencePlane.svelte} +7 -7
  148. package/dist/plot/{ReferencePlane.svelte.d.ts → core/components/ReferencePlane.svelte.d.ts} +2 -2
  149. package/dist/plot/{ZeroLines.svelte → core/components/ZeroLines.svelte} +3 -3
  150. package/dist/plot/{ZeroLines.svelte.d.ts → core/components/ZeroLines.svelte.d.ts} +3 -3
  151. package/dist/plot/{ZoomRect.svelte → core/components/ZoomRect.svelte} +1 -1
  152. package/dist/plot/{ZoomRect.svelte.d.ts → core/components/ZoomRect.svelte.d.ts} +1 -1
  153. package/dist/plot/core/components/index.d.ts +17 -0
  154. package/dist/plot/core/components/index.js +17 -0
  155. package/dist/plot/{data-cleaning.d.ts → core/data-cleaning.d.ts} +71 -1
  156. package/dist/plot/{data-cleaning.js → core/data-cleaning.js} +3 -5
  157. package/dist/plot/{data-transform.d.ts → core/data-transform.d.ts} +2 -2
  158. package/dist/plot/{data-transform.js → core/data-transform.js} +3 -3
  159. package/dist/plot/core/fill-utils.d.ts +33 -0
  160. package/dist/plot/core/fill-utils.js +388 -0
  161. package/dist/plot/{hover-lock.svelte.js → core/hover-lock.svelte.js} +5 -6
  162. package/dist/plot/core/index.d.ts +10 -0
  163. package/dist/plot/core/index.js +11 -0
  164. package/dist/plot/core/interactions.d.ts +35 -0
  165. package/dist/plot/core/interactions.js +195 -0
  166. package/dist/plot/{layout.d.ts → core/layout.d.ts} +1 -0
  167. package/dist/plot/{layout.js → core/layout.js} +16 -8
  168. package/dist/plot/{reference-line.d.ts → core/reference-line.d.ts} +1 -1
  169. package/dist/plot/{reference-line.js → core/reference-line.js} +23 -36
  170. package/dist/plot/{scales.d.ts → core/scales.d.ts} +2 -2
  171. package/dist/plot/{scales.js → core/scales.js} +84 -85
  172. package/dist/plot/core/svg.d.ts +2 -0
  173. package/dist/plot/core/svg.js +41 -0
  174. package/dist/plot/{types.d.ts → core/types.d.ts} +19 -79
  175. package/dist/plot/{types.js → core/types.js} +1 -1
  176. package/dist/plot/{utils → core/utils}/label-placement.d.ts +2 -2
  177. package/dist/plot/core/utils/series-visibility.d.ts +26 -0
  178. package/dist/plot/{utils → core/utils}/series-visibility.js +29 -2
  179. package/dist/plot/core/utils.d.ts +11 -0
  180. package/dist/plot/core/utils.js +27 -0
  181. package/dist/plot/{Histogram.svelte → histogram/Histogram.svelte} +154 -294
  182. package/dist/plot/{Histogram.svelte.d.ts → histogram/Histogram.svelte.d.ts} +2 -2
  183. package/dist/plot/{HistogramControls.svelte → histogram/HistogramControls.svelte} +6 -6
  184. package/dist/plot/{HistogramControls.svelte.d.ts → histogram/HistogramControls.svelte.d.ts} +4 -4
  185. package/dist/plot/histogram/index.d.ts +2 -0
  186. package/dist/plot/histogram/index.js +2 -0
  187. package/dist/plot/index.d.ts +8 -41
  188. package/dist/plot/index.js +10 -39
  189. package/dist/plot/sankey/Sankey.svelte +700 -0
  190. package/dist/plot/sankey/Sankey.svelte.d.ts +74 -0
  191. package/dist/plot/sankey/SankeyControls.svelte +98 -0
  192. package/dist/plot/sankey/SankeyControls.svelte.d.ts +19 -0
  193. package/dist/plot/sankey/index.d.ts +4 -0
  194. package/dist/plot/sankey/index.js +3 -0
  195. package/dist/plot/sankey/sankey-types.d.ts +42 -0
  196. package/dist/plot/sankey/sankey-types.js +4 -0
  197. package/dist/plot/sankey/sankey.d.ts +52 -0
  198. package/dist/plot/sankey/sankey.js +187 -0
  199. package/dist/plot/{BinnedScatterPlot.svelte → scatter/BinnedScatterPlot.svelte} +61 -59
  200. package/dist/plot/{BinnedScatterPlot.svelte.d.ts → scatter/BinnedScatterPlot.svelte.d.ts} +4 -4
  201. package/dist/plot/{ElementScatter.svelte → scatter/ElementScatter.svelte} +6 -6
  202. package/dist/plot/{ElementScatter.svelte.d.ts → scatter/ElementScatter.svelte.d.ts} +2 -2
  203. package/dist/plot/{ScatterPlot.svelte → scatter/ScatterPlot.svelte} +221 -642
  204. package/dist/plot/{ScatterPlot.svelte.d.ts → scatter/ScatterPlot.svelte.d.ts} +7 -7
  205. package/dist/plot/{ScatterPlotControls.svelte → scatter/ScatterPlotControls.svelte} +6 -5
  206. package/dist/plot/{ScatterPlotControls.svelte.d.ts → scatter/ScatterPlotControls.svelte.d.ts} +1 -1
  207. package/dist/plot/{ScatterPoint.svelte → scatter/ScatterPoint.svelte} +7 -7
  208. package/dist/plot/{ScatterPoint.svelte.d.ts → scatter/ScatterPoint.svelte.d.ts} +3 -3
  209. package/dist/plot/{adaptive-density.d.ts → scatter/adaptive-density.d.ts} +14 -4
  210. package/dist/plot/{adaptive-density.js → scatter/adaptive-density.js} +46 -20
  211. package/dist/plot/{binned-scatter-types.d.ts → scatter/binned-scatter-types.d.ts} +3 -3
  212. package/dist/plot/scatter/index.d.ts +7 -0
  213. package/dist/plot/scatter/index.js +5 -0
  214. package/dist/plot/scatter/scatter-data.d.ts +19 -0
  215. package/dist/plot/scatter/scatter-data.js +212 -0
  216. package/dist/plot/{ScatterPlot3D.svelte → scatter-3d/ScatterPlot3D.svelte} +12 -10
  217. package/dist/plot/{ScatterPlot3D.svelte.d.ts → scatter-3d/ScatterPlot3D.svelte.d.ts} +7 -7
  218. package/dist/plot/{ScatterPlot3DControls.svelte → scatter-3d/ScatterPlot3DControls.svelte} +5 -4
  219. package/dist/plot/{ScatterPlot3DControls.svelte.d.ts → scatter-3d/ScatterPlot3DControls.svelte.d.ts} +2 -2
  220. package/dist/plot/{ScatterPlot3DScene.svelte → scatter-3d/ScatterPlot3DScene.svelte} +11 -11
  221. package/dist/plot/{ScatterPlot3DScene.svelte.d.ts → scatter-3d/ScatterPlot3DScene.svelte.d.ts} +3 -3
  222. package/dist/plot/{Surface3D.svelte → scatter-3d/Surface3D.svelte} +1 -1
  223. package/dist/plot/{Surface3D.svelte.d.ts → scatter-3d/Surface3D.svelte.d.ts} +1 -1
  224. package/dist/plot/scatter-3d/index.d.ts +4 -0
  225. package/dist/plot/scatter-3d/index.js +4 -0
  226. package/dist/plot/sunburst/Sunburst.svelte +1045 -0
  227. package/dist/plot/sunburst/Sunburst.svelte.d.ts +96 -0
  228. package/dist/plot/sunburst/SunburstControls.svelte +200 -0
  229. package/dist/plot/sunburst/SunburstControls.svelte.d.ts +26 -0
  230. package/dist/plot/sunburst/index.d.ts +4 -0
  231. package/dist/plot/sunburst/index.js +4 -0
  232. package/dist/plot/sunburst/render.d.ts +34 -0
  233. package/dist/plot/sunburst/render.js +122 -0
  234. package/dist/plot/sunburst/sunburst.d.ts +62 -0
  235. package/dist/plot/sunburst/sunburst.js +266 -0
  236. package/dist/rdf/RdfPlot.svelte +2 -1
  237. package/dist/rdf/calc-rdf.js +11 -24
  238. package/dist/sanitize.js +1 -1
  239. package/dist/settings.d.ts +65 -1
  240. package/dist/settings.js +262 -0
  241. package/dist/spectral/Bands.svelte +39 -29
  242. package/dist/spectral/Bands.svelte.d.ts +3 -4
  243. package/dist/spectral/BandsAndDos.svelte +1 -1
  244. package/dist/spectral/BrillouinBandsDos.svelte +39 -27
  245. package/dist/spectral/Dos.svelte +10 -19
  246. package/dist/spectral/Dos.svelte.d.ts +2 -2
  247. package/dist/spectral/helpers.d.ts +3 -1
  248. package/dist/spectral/helpers.js +95 -29
  249. package/dist/structure/AtomLegend.svelte +8 -9
  250. package/dist/structure/CellSelect.svelte +1 -2
  251. package/dist/structure/Cylinder.svelte +12 -8
  252. package/dist/structure/Cylinder.svelte.d.ts +4 -1
  253. package/dist/structure/Structure.svelte +78 -72
  254. package/dist/structure/Structure.svelte.d.ts +1 -1
  255. package/dist/structure/StructureInfoPane.svelte +5 -6
  256. package/dist/structure/StructureScene.svelte +11 -10
  257. package/dist/structure/atom-properties.js +6 -6
  258. package/dist/structure/bond-order-perception.js +1 -1
  259. package/dist/structure/bonding.d.ts +1 -0
  260. package/dist/structure/bonding.js +43 -15
  261. package/dist/structure/export.js +27 -23
  262. package/dist/structure/index.d.ts +2 -4
  263. package/dist/structure/index.js +1 -3
  264. package/dist/structure/label-placement.js +4 -4
  265. package/dist/structure/measure.d.ts +3 -2
  266. package/dist/structure/measure.js +6 -5
  267. package/dist/structure/parse.js +121 -103
  268. package/dist/structure/pbc.js +4 -0
  269. package/dist/symmetry/SymmetryStats.svelte +2 -2
  270. package/dist/symmetry/index.d.ts +1 -1
  271. package/dist/symmetry/index.js +22 -24
  272. package/dist/symmetry/spacegroups.d.ts +7 -0
  273. package/dist/symmetry/spacegroups.js +48 -13
  274. package/dist/table/HeatmapTable.svelte +63 -11
  275. package/dist/table/HeatmapTable.svelte.d.ts +1 -1
  276. package/dist/table/index.d.ts +1 -3
  277. package/dist/table/index.js +1 -1
  278. package/dist/theme/index.js +8 -8
  279. package/dist/tooltip/KCoords.svelte +45 -0
  280. package/dist/tooltip/KCoords.svelte.d.ts +8 -0
  281. package/dist/tooltip/index.d.ts +1 -0
  282. package/dist/tooltip/index.js +1 -0
  283. package/dist/trajectory/Trajectory.svelte +66 -40
  284. package/dist/trajectory/Trajectory.svelte.d.ts +2 -1
  285. package/dist/trajectory/TrajectoryExportPane.svelte +2 -1
  286. package/dist/trajectory/TrajectoryInfoPane.svelte +2 -1
  287. package/dist/trajectory/format-detect.d.ts +1 -0
  288. package/dist/trajectory/format-detect.js +25 -11
  289. package/dist/trajectory/frame-reader.js +17 -50
  290. package/dist/trajectory/helpers.js +1 -1
  291. package/dist/trajectory/index.js +1 -1
  292. package/dist/trajectory/parse/hdf5.js +1 -1
  293. package/dist/trajectory/parse/index.js +14 -6
  294. package/dist/trajectory/parse/vasp.js +36 -17
  295. package/dist/trajectory/parse/xyz.d.ts +24 -0
  296. package/dist/trajectory/parse/xyz.js +102 -89
  297. package/dist/trajectory/plotting.d.ts +1 -1
  298. package/dist/trajectory/plotting.js +15 -15
  299. package/dist/utils.d.ts +1 -0
  300. package/dist/utils.js +6 -4
  301. package/dist/xrd/XrdPlot.svelte +2 -1
  302. package/dist/xrd/calc-xrd.js +15 -12
  303. package/dist/xrd/parse.js +2 -2
  304. package/package.json +22 -18
  305. package/dist/plot/PlotControls.svelte.d.ts +0 -4
  306. package/dist/plot/axis-utils.d.ts +0 -19
  307. package/dist/plot/axis-utils.js +0 -78
  308. package/dist/plot/defaults.d.ts +0 -19
  309. package/dist/plot/defaults.js +0 -9
  310. package/dist/plot/fill-utils.d.ts +0 -46
  311. package/dist/plot/fill-utils.js +0 -322
  312. package/dist/plot/interactions.d.ts +0 -12
  313. package/dist/plot/interactions.js +0 -101
  314. package/dist/plot/svg.d.ts +0 -1
  315. package/dist/plot/svg.js +0 -11
  316. package/dist/plot/utils/series-visibility.d.ts +0 -15
  317. package/dist/plot/utils.d.ts +0 -1
  318. package/dist/plot/utils.js +0 -14
  319. /package/dist/plot/{auto-place.d.ts → core/auto-place.d.ts} +0 -0
  320. /package/dist/plot/{Line.svelte.d.ts → core/components/Line.svelte.d.ts} +0 -0
  321. /package/dist/plot/{PortalSelect.svelte.d.ts → core/components/PortalSelect.svelte.d.ts} +0 -0
  322. /package/dist/plot/{hover-lock.svelte.d.ts → core/hover-lock.svelte.d.ts} +0 -0
  323. /package/dist/plot/{utils → core/utils}/label-placement.js +0 -0
  324. /package/dist/plot/{binned-scatter-types.js → scatter/binned-scatter-types.js} +0 -0
@@ -0,0 +1,266 @@
1
+ // Layout helpers for Sunburst charts, wrapping d3-hierarchy's partition.
2
+ // Single source of truth for the hierarchy/angle math so the component stays
3
+ // declarative and the layout is independently unit-testable. The partition is
4
+ // computed in normalized coordinates (angle as fraction of full circle in [0, 1],
5
+ // radius in integer ring units where y0 === depth) independent of pixel size and
6
+ // zoom — the component maps these to screen space per frame (zoomable-sunburst trick).
7
+ import { hsl } from 'd3-color';
8
+ import { hierarchy, partition } from 'd3-hierarchy';
9
+ import { DEFAULT_SERIES_COLORS } from '../core/types';
10
+ // Compute normalized arc extents, resolved colors and breadcrumbs for a node tree.
11
+ // Never mutates user data: d3-hierarchy wraps inputs in HierarchyNodes and all derived
12
+ // fields (value overrides, ids, colors) are written onto the returned arcs only.
13
+ export function compute_sunburst_layout(data, opts = {}) {
14
+ const { value_mode = `leaf-sum`, sort = `none`, level_lighten = 0, min_fraction = 0, other_label = `Other`, } = opts;
15
+ // Fresh object each call (not a shared constant) so callers can't corrupt each other
16
+ if (Array.isArray(data) ? data.length === 0 : !data) {
17
+ return { arcs: [], root: null, max_depth: 0 };
18
+ }
19
+ // Single root node is used directly; arrays get a synthetic invisible root
20
+ const root_data = Array.isArray(data) ? { children: data } : data;
21
+ const root = hierarchy(root_data, (node) => node.children);
22
+ // 'remainder': d3's .sum() adds the node's own value on top of its children's sum,
23
+ // which is exactly plotly's branchvalues='remainder'. 'leaf-sum' ignores parent values.
24
+ // 'total': every explicitly set value is authoritative (plotly branchvalues='total');
25
+ // nodes without one get their children's sum. Children summing to less than their
26
+ // parent leave a trailing angular gap; more than the parent overflows (plotly errors
27
+ // here; we warn and the component clamps angles).
28
+ if (value_mode === `remainder`)
29
+ root.sum((node) => node.value ?? 0);
30
+ else if (value_mode === `total`) {
31
+ root.eachAfter((node) => {
32
+ const child_sum = node.children?.reduce((sum, child) => sum + (child.value ?? 0), 0) ?? 0;
33
+ node.value = node.data.value ?? child_sum;
34
+ if (node.children && node.data.value != null && child_sum > node.data.value + 1e-9) {
35
+ console.warn(`Sunburst: children of "${node.data.label ?? node.data.id ?? `root`}" sum to ${child_sum}, exceeding its value of ${node.data.value} (value_mode='total')`);
36
+ }
37
+ });
38
+ }
39
+ else
40
+ root.sum((node) => (node.children?.length ? 0 : (node.value ?? 0)));
41
+ if (sort !== `none`) {
42
+ const sign = sort === `descending` ? -1 : 1;
43
+ root.sort((node_a, node_b) => sign * ((node_a.value ?? 0) - (node_b.value ?? 0)));
44
+ }
45
+ // 'Other' bucketing: move sub-threshold children to the end of each sibling list
46
+ // (after sorting, before partition) so the smalls occupy one contiguous angular run
47
+ // that flatten() below can merge into a single synthetic arc.
48
+ const bucket_threshold = min_fraction > 0 ? min_fraction * (root.value ?? 0) : 0;
49
+ if (bucket_threshold > 0) {
50
+ root.each((node) => {
51
+ if (!node.children)
52
+ return;
53
+ const small = node.children.filter((child) => (child.value ?? 0) < bucket_threshold);
54
+ if (small.length >= 2) {
55
+ const kept = node.children.filter((child) => (child.value ?? 0) >= bucket_threshold);
56
+ node.children = [...kept, ...small];
57
+ }
58
+ });
59
+ }
60
+ // x in [0, 1] (angle fraction), y in ring units (y0 === depth, y1 === depth + 1)
61
+ const part_root = partition().size([1, root.height + 1])(root);
62
+ const arcs = [];
63
+ const seen_ids = new Set();
64
+ const root_value = root.value ?? 0;
65
+ const palette_len = DEFAULT_SERIES_COLORS.length;
66
+ let depth1_count = 0; // running index among depth-1 nodes, for palette cycling
67
+ // Resolved fill for a node: explicit > depth-1 palette > inherited, optionally
68
+ // lightened by depth. base = unlightened color descendants inherit.
69
+ const resolve_color = (depth, explicit, parent_base) => {
70
+ const base = explicit ??
71
+ (depth === 1
72
+ ? DEFAULT_SERIES_COLORS[depth1_count++ % palette_len]
73
+ : (parent_base ?? `transparent`));
74
+ let color = base;
75
+ if (!explicit && depth > 1 && level_lighten > 0) {
76
+ color = hsl(base)
77
+ .brighter(level_lighten * (depth - 1))
78
+ .formatHex();
79
+ }
80
+ return { base, color };
81
+ };
82
+ // Construct + append an arc, deriving indices, breadcrumbs and fractions from the
83
+ // parent (shared by regular nodes and synthetic 'Other' arcs)
84
+ const push_arc = (parent, fields) => {
85
+ if (seen_ids.has(fields.id)) {
86
+ console.warn(`Sunburst: duplicate node id "${fields.id}" — set unique \`id\`s or labels.`);
87
+ }
88
+ seen_ids.add(fields.id);
89
+ const arc = {
90
+ node_idx: arcs.length,
91
+ subtree_end: arcs.length, // leaves keep this; branches update after recursion
92
+ parent_idx: parent?.node_idx ?? null,
93
+ path: parent ? [...parent.path, fields.id] : [],
94
+ label_path: parent ? [...parent.label_path, fields.label ?? `${fields.id}`] : [],
95
+ fraction: root_value > 0 ? fields.value / root_value : 0,
96
+ parent_fraction: parent ? (parent.value > 0 ? fields.value / parent.value : 0) : 1,
97
+ ...fields,
98
+ };
99
+ arcs.push(arc);
100
+ return arc;
101
+ };
102
+ // Pre-order DFS so each subtree occupies a contiguous node_idx range
103
+ const flatten = (node, parent, parent_base, // unlightened color descendants inherit
104
+ child_idx) => {
105
+ const { depth } = node;
106
+ const explicit = node.data.color;
107
+ const { base, color } = resolve_color(depth, explicit, parent_base);
108
+ // Stable id: explicit, else slash-joined label path (e.g. "cubic/Fm-3m")
109
+ const parent_prefix = parent && parent.id !== `` ? `${parent.id}/` : ``;
110
+ const segment = node.data.label ?? `${child_idx}`;
111
+ const id = node.data.id ?? (depth === 0 ? (node.data.label ?? ``) : `${parent_prefix}${segment}`);
112
+ const { x0, x1, y0, y1 } = node;
113
+ const arc = push_arc(parent, {
114
+ id,
115
+ label: node.data.label,
116
+ value: node.value ?? 0,
117
+ color,
118
+ depth,
119
+ is_leaf: !node.children?.length,
120
+ x0,
121
+ x1,
122
+ y0,
123
+ y1,
124
+ metadata: node.data.metadata,
125
+ });
126
+ // Children below the bucket threshold form a contiguous trailing run (reordered
127
+ // above); merge runs of >= 2 into one synthetic 'Other' leaf instead of recursing
128
+ const kids = node.children ?? [];
129
+ let cut = kids.length;
130
+ if (bucket_threshold > 0) {
131
+ const first_small = kids.findLastIndex((kid) => (kid.value ?? 0) >= bucket_threshold) + 1;
132
+ if (kids.length - first_small >= 2)
133
+ cut = first_small;
134
+ }
135
+ kids.forEach((child, idx) => {
136
+ if (idx < cut)
137
+ flatten(child, arc, explicit ?? base, idx);
138
+ });
139
+ if (cut < kids.length) {
140
+ const smalls = kids.slice(cut);
141
+ push_arc(arc, {
142
+ id: `${arc.id !== `` ? `${arc.id}/` : ``}${other_label}`,
143
+ label: other_label,
144
+ value: smalls.reduce((sum, child) => sum + (child.value ?? 0), 0),
145
+ color: resolve_color(depth + 1, undefined, explicit ?? base).color,
146
+ depth: depth + 1,
147
+ is_leaf: true,
148
+ is_other: true,
149
+ x0: smalls[0].x0,
150
+ x1: smalls[smalls.length - 1].x1,
151
+ y0: depth + 1,
152
+ y1: depth + 2,
153
+ });
154
+ }
155
+ arc.subtree_end = arcs.length - 1;
156
+ };
157
+ flatten(part_root, null, null, 0);
158
+ return { arcs, root: arcs[0], max_depth: root.height };
159
+ }
160
+ // Build a nested node tree from flat path rows (plotly-express style), e.g.
161
+ // { path: ['cubic', 'Fm-3m'], value: 12 }. Rows sharing a full path accumulate their
162
+ // values; rows whose path is a proper prefix of others set that interior node's own
163
+ // value (meaningful with value_mode 'total'/'remainder').
164
+ export function sunburst_from_paths(rows) {
165
+ const roots = new Map();
166
+ rows.forEach((row, row_idx) => {
167
+ if (!row.path || row.path.length === 0) {
168
+ throw new Error(`sunburst_from_paths: row ${row_idx} has an empty path`);
169
+ }
170
+ let level = roots;
171
+ let trie;
172
+ let id = ``;
173
+ for (const segment of row.path) {
174
+ id = id ? `${id}/${segment}` : `${segment}`;
175
+ trie = level.get(segment);
176
+ if (!trie) {
177
+ trie = { node: { id, label: `${segment}` }, children: new Map() };
178
+ level.set(segment, trie);
179
+ }
180
+ level = trie.children;
181
+ }
182
+ const node = trie.node;
183
+ node.value = (node.value ?? 0) + row.value;
184
+ if (row.color != null)
185
+ node.color = row.color;
186
+ if (row.metadata != null)
187
+ node.metadata = row.metadata;
188
+ });
189
+ const to_nodes = (level) => [...level.values()].map(({ node, children }) => children.size ? { ...node, children: to_nodes(children) } : node);
190
+ return to_nodes(roots);
191
+ }
192
+ // Build a nested node tree from plotly trace arrays (labels/parents/values [+ ids]),
193
+ // the format pymatviz/matbench-discovery sunburst exports use (with branchvalues
194
+ // 'total' -> pair with value_mode 'total'). parents entries of ''/null/undefined mark
195
+ // root-level nodes; parents reference ids when given, else labels.
196
+ export function sunburst_from_labels_parents(labels, parents, values, opts = {}) {
197
+ const { ids, colors, metadata } = opts;
198
+ for (const [name, arr] of [
199
+ [`parents`, parents],
200
+ [`values`, values],
201
+ [`ids`, ids],
202
+ [`colors`, colors],
203
+ [`metadata`, metadata],
204
+ ]) {
205
+ if (arr && arr.length !== labels.length) {
206
+ throw new Error(`sunburst_from_labels_parents: labels (${labels.length}) and ${name} (${arr.length}) must have equal length`);
207
+ }
208
+ }
209
+ const key_to_idx = new Map();
210
+ const nodes = labels.map((label, idx) => {
211
+ const key = ids?.[idx] ?? label;
212
+ if (key_to_idx.has(key)) {
213
+ throw new Error(`sunburst_from_labels_parents: duplicate node ${ids ? `id` : `label`} "${key}"${ids ? `` : ` — pass opts.ids to disambiguate`}`);
214
+ }
215
+ key_to_idx.set(key, idx);
216
+ const node = { id: key, label };
217
+ if (values?.[idx] != null)
218
+ node.value = values[idx];
219
+ if (colors?.[idx] != null)
220
+ node.color = colors[idx];
221
+ if (metadata?.[idx] != null)
222
+ node.metadata = metadata[idx];
223
+ return node;
224
+ });
225
+ // Resolve all parent references up front (one map lookup per node)
226
+ const parent_idxs = labels.map((_, idx) => {
227
+ const ref = parents[idx];
228
+ if (ref == null || ref === ``)
229
+ return null;
230
+ const found = key_to_idx.get(ref);
231
+ if (found === undefined) {
232
+ throw new Error(`sunburst_from_labels_parents: node "${ids?.[idx] ?? labels[idx]}" references unknown parent "${ref}"`);
233
+ }
234
+ return found;
235
+ });
236
+ // O(n) cycle detection: walk each unvisited parent chain once, marking nodes
237
+ // 'in-progress' on the way up. Hitting an in-progress node = cycle; hitting a
238
+ // 'done' node = chain already verified acyclic.
239
+ const state = new Uint8Array(nodes.length); // 0 = unvisited, 1 = in progress, 2 = done
240
+ for (let idx = 0; idx < nodes.length; idx++) {
241
+ if (state[idx] !== 0)
242
+ continue;
243
+ let cur = idx;
244
+ while (cur != null && state[cur] === 0) {
245
+ state[cur] = 1;
246
+ cur = parent_idxs[cur];
247
+ }
248
+ if (cur != null && state[cur] === 1) {
249
+ throw new Error(`sunburst_from_labels_parents: cycle detected involving node "${ids?.[cur] ?? labels[cur]}"`);
250
+ }
251
+ // Mark the walked chain as verified
252
+ for (let mark = idx; mark != null && state[mark] === 1;) {
253
+ state[mark] = 2;
254
+ mark = parent_idxs[mark];
255
+ }
256
+ }
257
+ const roots = [];
258
+ nodes.forEach((node, idx) => {
259
+ const parent = parent_idxs[idx];
260
+ if (parent == null)
261
+ roots.push(node);
262
+ else
263
+ (nodes[parent].children ??= []).push(node);
264
+ });
265
+ return roots;
266
+ }
@@ -10,6 +10,7 @@
10
10
  import { is_crystal } from '../structure/validation'
11
11
  import type { ComponentProps, Snippet } from 'svelte'
12
12
  import { calculate_all_pair_rdfs, calculate_rdf, type RdfEntry } from './index'
13
+ import { to_error } from '../utils'
13
14
 
14
15
  let {
15
16
  patterns,
@@ -66,7 +67,7 @@
66
67
  }
67
68
  } catch (exc) {
68
69
  error_msg = `Failed to process structure: ${
69
- exc instanceof Error ? exc.message : String(exc)
70
+ to_error(exc).message
70
71
  }`
71
72
  }
72
73
  }
@@ -6,7 +6,7 @@ const sum_occu = (sites, elem) => sites.reduce((sum, site) => sum + get_occu(sit
6
6
  // Calculate radial distribution function
7
7
  export function calculate_rdf(structure, options = {}) {
8
8
  const { center_species, neighbor_species, cutoff = 15, n_bins = 75, auto_expand = true, expansion_factor = 2.0, } = options;
9
- let { pbc = [true, true, true] } = options;
9
+ const { pbc = [true, true, true] } = options;
10
10
  if (cutoff <= 0 || n_bins <= 0) {
11
11
  throw new Error(`cutoff and n_bins must be positive`);
12
12
  }
@@ -16,6 +16,7 @@ export function calculate_rdf(structure, options = {}) {
16
16
  }
17
17
  let lattice = structure.lattice.matrix;
18
18
  let { sites } = structure;
19
+ let center_sites = sites;
19
20
  // Expand structure if needed to ensure shortest lattice vector is expansion_factor× the cutoff
20
21
  // This prevents artificial close contacts at cell boundaries when using PBC
21
22
  // Standard practice uses 2.0-2.5× to eliminate finite-size effects
@@ -27,7 +28,10 @@ export function calculate_rdf(structure, options = {}) {
27
28
  const expanded_structure = make_supercell(structure, [n_a, n_b, n_c], false);
28
29
  sites = expanded_structure.sites;
29
30
  lattice = expanded_structure.lattice.matrix;
30
- pbc = [false, false, false]; // Disable PBC since we explicitly expanded the structure
31
+ // Keep PBC: min-image is exact once every lattice vector cutoff (disabling PBC
32
+ // starves boundary atoms and biases g(r) low). Under full PBC all periodic copies are
33
+ // equivalent, so restrict centers to the first copy (make_supercell emits (0,0,0) first)
34
+ center_sites = pbc.every(Boolean) ? sites.slice(0, structure.sites.length) : sites;
31
35
  }
32
36
  }
33
37
  const bin_size = cutoff / n_bins;
@@ -36,7 +40,7 @@ export function calculate_rdf(structure, options = {}) {
36
40
  if (sites.length === 0)
37
41
  return { r, g_r };
38
42
  // Get occupancy weight for a site-species pair (supports mixed occupancy)
39
- const centers = sites.filter((site) => has_species(site, center_species));
43
+ const centers = center_sites.filter((site) => has_species(site, center_species));
40
44
  const neighbors = sites.filter((site) => has_species(site, neighbor_species));
41
45
  if (centers.length === 0 || neighbors.length === 0) {
42
46
  const element_pair = center_species && neighbor_species
@@ -45,7 +49,7 @@ export function calculate_rdf(structure, options = {}) {
45
49
  return { r, g_r, element_pair };
46
50
  }
47
51
  // Calculate distances and bin them with occupancy weighting
48
- const use_pbc = pbc.some((flag) => flag);
52
+ const use_pbc = pbc.some(Boolean);
49
53
  const converters = use_pbc ? create_lattice_converters(lattice) : undefined;
50
54
  for (const center of centers) {
51
55
  for (const neighbor of neighbors) {
@@ -85,26 +89,9 @@ export function calculate_all_pair_rdfs(structure, options = {}) {
85
89
  const elems = [
86
90
  ...new Set(structure.sites.flatMap((site) => site.species.map((spec) => spec.element))),
87
91
  ].sort();
88
- // If auto_expand is true, expand the structure once and reuse it for all pairs
89
- // to avoid repeated supercell computations
90
- let structure_to_use = structure;
91
- if (options.auto_expand !== false) {
92
- const { cutoff = 15, expansion_factor = 2.0 } = options;
93
- const lattice = structure.lattice?.matrix;
94
- if (lattice) {
95
- const { a, b, c } = calc_lattice_params(lattice);
96
- const min_size = cutoff * expansion_factor;
97
- const [n_a, n_b, n_c] = [a, b, c].map((len) => Math.ceil(min_size / len));
98
- if (n_a > 1 || n_b > 1 || n_c > 1) {
99
- structure_to_use = make_supercell(structure, [n_a, n_b, n_c], false);
100
- }
101
- }
102
- }
103
- // Pass auto_expand=false since we've already expanded, and pbc=false for expanded structure
104
- const pbc = [false, false, false];
105
- const rdf_options = { ...options, auto_expand: false, pbc };
106
- return elems.flatMap((el1, idx1) => elems.slice(idx1).map((el2) => calculate_rdf(structure_to_use, {
107
- ...rdf_options,
92
+ // Forward options unchanged (preserves caller's pbc); each calculate_rdf expands itself
93
+ return elems.flatMap((el1, idx1) => elems.slice(idx1).map((el2) => calculate_rdf(structure, {
94
+ ...options,
108
95
  center_species: el1,
109
96
  neighbor_species: el2,
110
97
  })));
package/dist/sanitize.js CHANGED
@@ -53,7 +53,7 @@ function sanitize_svg_content(html, allowed_tags, allowed_attrs) {
53
53
  });
54
54
  const open_end = wrapped.indexOf(`>`);
55
55
  const close_start = wrapped.lastIndexOf(`</svg>`);
56
- if (open_end < 0 || close_start < 0)
56
+ if (open_end === -1 || close_start === -1)
57
57
  return wrapped;
58
58
  return wrapped.slice(open_end + 1, close_start);
59
59
  }
@@ -2,7 +2,7 @@ import type { ColorScaleType, D3InterpolateName } from './colors';
2
2
  import type { HullFaceColorMode } from './convex-hull/types';
3
3
  import type { D3SymbolName } from './labels';
4
4
  import type { Vec3 } from './math';
5
- import type { Orientation } from './plot';
5
+ import type { BandwidthOption, Orientation, SankeyNodeAlign, SankeyOrientation, SunburstLabelRotation, SunburstLabelText, SunburstShape, SunburstValueMode, ViolinKind, ViolinSide, WhiskerMode } from './plot';
6
6
  import type { BondingStrategy } from './structure/bonding';
7
7
  export interface SettingType<T = unknown> {
8
8
  value: T;
@@ -63,6 +63,31 @@ type SimpleLineStyleType = {
63
63
  width: SettingType<number>;
64
64
  color: SettingType<string>;
65
65
  };
66
+ type BoxStyleType = {
67
+ color: SettingType<string>;
68
+ opacity: SettingType<number>;
69
+ stroke_width: SettingType<number>;
70
+ stroke_color: SettingType<string>;
71
+ border_radius: SettingType<number>;
72
+ };
73
+ type BoxWhiskerStyleType = {
74
+ width: SettingType<number>;
75
+ color: SettingType<string>;
76
+ cap_fraction: SettingType<number>;
77
+ };
78
+ type BoxLineStyleType = {
79
+ width: SettingType<number>;
80
+ color: SettingType<string>;
81
+ };
82
+ type BoxOutlierStyleType = {
83
+ radius: SettingType<number>;
84
+ opacity: SettingType<number>;
85
+ stroke_width: SettingType<number>;
86
+ };
87
+ type BoxViolinStyleType = {
88
+ opacity: SettingType<number>;
89
+ stroke_width: SettingType<number>;
90
+ };
66
91
  type ConvexHullCommonType = {
67
92
  camera_zoom: SettingType<number>;
68
93
  camera_center_x: SettingType<number>;
@@ -226,6 +251,45 @@ export interface SettingsConfig {
226
251
  bar: SimpleBarStyleType;
227
252
  line: SimpleLineStyleType;
228
253
  };
254
+ box: {
255
+ whisker_mode: SettingType<WhiskerMode>;
256
+ box_width: SettingType<number>;
257
+ show_outliers: SettingType<boolean>;
258
+ show_mean: SettingType<boolean>;
259
+ kind: SettingType<ViolinKind>;
260
+ side: SettingType<ViolinSide>;
261
+ bandwidth: SettingType<Exclude<BandwidthOption, number>>;
262
+ violin_width: SettingType<number>;
263
+ violin_box_width: SettingType<number>;
264
+ box: BoxStyleType;
265
+ whisker: BoxWhiskerStyleType;
266
+ median: BoxLineStyleType;
267
+ outlier: BoxOutlierStyleType;
268
+ violin: BoxViolinStyleType;
269
+ display: DisplayConfigType;
270
+ };
271
+ sankey: {
272
+ orientation: SettingType<SankeyOrientation>;
273
+ node_align: SettingType<SankeyNodeAlign>;
274
+ node_width: SettingType<number>;
275
+ node_padding: SettingType<number>;
276
+ link_opacity: SettingType<number>;
277
+ show_node_labels: SettingType<boolean>;
278
+ iterations: SettingType<number>;
279
+ };
280
+ sunburst: {
281
+ shape: SettingType<SunburstShape>;
282
+ value_mode: SettingType<SunburstValueMode>;
283
+ max_depth: SettingType<number>;
284
+ inner_radius: SettingType<number>;
285
+ pad_angle: SettingType<number>;
286
+ min_fraction: SettingType<number>;
287
+ show_labels: SettingType<boolean>;
288
+ label_rotation: SettingType<SunburstLabelRotation>;
289
+ label_text: SettingType<SunburstLabelText>;
290
+ zoom_on_click: SettingType<boolean>;
291
+ show_breadcrumbs: SettingType<boolean>;
292
+ };
229
293
  composition: {
230
294
  display_mode: SettingType<`pie` | `bubble` | `bar`>;
231
295
  color_scheme: SettingType<string>;