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
@@ -1,322 +0,0 @@
1
- // Fill-between utility functions for ScatterPlot fill regions
2
- // Handles interpolation, boundary resolution, and path generation
3
- import { area, curveBasis, curveCardinal, curveCatmullRom, curveLinear, curveMonotoneX, curveMonotoneY, curveNatural, curveStep, curveStepAfter, curveStepBefore, } from 'd3-shape';
4
- // Epsilon value for log scale clamping (to avoid log(0) = -Infinity)
5
- export const LOG_EPSILON = 1e-10;
6
- // Resolves a series reference (by index or id) to the actual DataSeries
7
- // Returns null if the reference cannot be resolved
8
- export function resolve_series_ref(ref, series) {
9
- if (`series_idx` in ref && typeof ref.series_idx === `number`) {
10
- const idx = ref.series_idx;
11
- if (idx >= 0 && idx < series.length) {
12
- return series[idx];
13
- }
14
- return null;
15
- }
16
- if (`series_id` in ref && ref.series_id !== undefined) {
17
- const found = series.find((data_series) => data_series.id === ref.series_id);
18
- return found ?? null;
19
- }
20
- return null;
21
- }
22
- // Helper: linear interpolation at a specific x value
23
- function interpolate_at(x_values, y_values, target_x) {
24
- // Find bracketing indices
25
- let [left_idx, right_idx] = [-1, -1];
26
- for (let idx = 0; idx < x_values.length; idx++) {
27
- if (x_values[idx] <= target_x)
28
- left_idx = idx;
29
- if (x_values[idx] >= target_x && right_idx === -1)
30
- right_idx = idx;
31
- }
32
- // Handle edge cases: exact match, before all, after all
33
- if (left_idx >= 0 && x_values[left_idx] === target_x)
34
- return y_values[left_idx];
35
- if (left_idx === -1)
36
- return y_values[0];
37
- if (right_idx === -1)
38
- return y_values[y_values.length - 1];
39
- // Linear interpolation
40
- const x_left = x_values[left_idx];
41
- const x_right = x_values[right_idx];
42
- const y_left = y_values[left_idx];
43
- const y_right = y_values[right_idx];
44
- return x_right === x_left
45
- ? y_left
46
- : y_left + ((target_x - x_left) / (x_right - x_left)) * (y_right - y_left);
47
- }
48
- // Helper: step interpolation at a specific x value
49
- function step_interpolate_at(x_values, y_values, target_x) {
50
- // Find the last x value <= target_x
51
- let last_idx = -1;
52
- for (let idx = 0; idx < x_values.length; idx++) {
53
- if (x_values[idx] <= target_x)
54
- last_idx = idx;
55
- else
56
- break;
57
- }
58
- // Before all x values, use first y value
59
- if (last_idx === -1)
60
- return y_values[0];
61
- return y_values[last_idx];
62
- }
63
- // Interpolates two series to have matching x-values
64
- // Returns arrays with the union of all x-values, sorted
65
- export function interpolate_series(series_a, series_b, method = `linear`) {
66
- // Create union of x-values
67
- const x_set = new Set();
68
- for (const curr_x of series_a.x)
69
- x_set.add(curr_x);
70
- for (const curr_x of series_b.x)
71
- x_set.add(curr_x);
72
- // Sort x-values
73
- const all_x = Array.from(x_set).sort((val_a, val_b) => val_a - val_b);
74
- const interpolate_fn = method === `step` ? step_interpolate_at : interpolate_at;
75
- // Interpolate y values for each x
76
- const y_a = all_x.map((target_x) => interpolate_fn(series_a.x, series_a.y, target_x));
77
- const y_b = all_x.map((target_x) => interpolate_fn(series_b.x, series_b.y, target_x));
78
- return { x: all_x, y_a, y_b };
79
- }
80
- // Resolves a FillBoundary definition to an array of y-values at given x positions
81
- // Returns null if the boundary cannot be resolved
82
- export function resolve_boundary(boundary, series, x_values, domains) {
83
- // Handle shorthand number (constant value)
84
- if (typeof boundary === `number`) {
85
- return x_values.map(() => boundary);
86
- }
87
- if (boundary.type === `series`) {
88
- const resolved = resolve_series_ref(boundary, series);
89
- if (!resolved)
90
- return null;
91
- // Interpolate to match x_values
92
- const interpolated = interpolate_series({ x: x_values, y: x_values.map(() => 0) }, { x: resolved.x, y: resolved.y }, `linear`);
93
- return interpolated.y_b;
94
- }
95
- if (boundary.type === `constant`)
96
- return x_values.map(() => boundary.value);
97
- if (boundary.type === `axis`) {
98
- // For axis boundaries, return the edge value of the appropriate axis domain
99
- const value = boundary.value ??
100
- (boundary.axis === `y2` ? domains.y2_domain?.[0] : undefined) ??
101
- domains.y_domain[0];
102
- return x_values.map(() => value);
103
- }
104
- if (boundary.type === `function`)
105
- return x_values.map((curr_x) => boundary.fn(curr_x));
106
- if (boundary.type === `data`) {
107
- if (boundary.values.length === 0)
108
- return Array(x_values.length).fill(NaN);
109
- // If lengths match, use directly; otherwise interpolate
110
- if (boundary.values.length === x_values.length)
111
- return [...boundary.values];
112
- // Lengths don't match: truncate if values is longer, or extend last value if shorter
113
- return x_values.map((_, idx) => boundary.values[idx] ?? boundary.values[boundary.values.length - 1]);
114
- }
115
- return null;
116
- }
117
- export function apply_range_constraints(x_values, y1_values, y2_values, region) {
118
- const [x_min, x_max] = region.x_range ?? [null, null];
119
- const [y_min, y_max] = region.y_range ?? [null, null];
120
- // Helper to clamp value within optional bounds
121
- const clamp = (val) => Math.min(y_max ?? Infinity, Math.max(y_min ?? -Infinity, val));
122
- const result = {
123
- x: [],
124
- y1: [],
125
- y2: [],
126
- original_indices: [],
127
- };
128
- for (let idx = 0; idx < x_values.length; idx++) {
129
- const [curr_x, curr_y1, curr_y2] = [x_values[idx], y1_values[idx], y2_values[idx]];
130
- // Skip if outside x range
131
- if ((x_min !== null && curr_x < x_min) || (x_max !== null && curr_x > x_max))
132
- continue;
133
- // Skip if fill region doesn't overlap y range
134
- const [fill_min, fill_max] = [Math.min(curr_y1, curr_y2), Math.max(curr_y1, curr_y2)];
135
- if ((y_min !== null && fill_max < y_min) || (y_max !== null && fill_min > y_max)) {
136
- continue;
137
- }
138
- result.x.push(curr_x);
139
- result.y1.push(clamp(curr_y1));
140
- result.y2.push(clamp(curr_y2));
141
- result.original_indices.push(idx);
142
- }
143
- return result;
144
- }
145
- // Helper: find x-coordinate where condition changes (linear interpolation)
146
- function find_crossing(x1, y1_upper, y1_lower, x2, y2_upper, y2_lower, condition) {
147
- const cond1 = condition(x1, y1_upper, y1_lower);
148
- const cond2 = condition(x2, y2_upper, y2_lower);
149
- if (cond1 === cond2)
150
- return null;
151
- // Binary search for crossing point
152
- let left = x1;
153
- let right = x2;
154
- const tolerance = (x2 - x1) * 0.001;
155
- for (let iter = 0; iter < 20; iter++) {
156
- const mid = (left + right) / 2;
157
- const weight = (mid - x1) / (x2 - x1);
158
- const mid_upper = y1_upper + weight * (y2_upper - y1_upper);
159
- const mid_lower = y1_lower + weight * (y2_lower - y1_lower);
160
- const mid_cond = condition(mid, mid_upper, mid_lower);
161
- if (mid_cond === cond1) {
162
- left = mid;
163
- }
164
- else {
165
- right = mid;
166
- }
167
- if (right - left < tolerance)
168
- break;
169
- }
170
- return (left + right) / 2;
171
- }
172
- export function apply_where_condition(x_values, y1_values, y2_values, region) {
173
- if (!region.where) {
174
- // No condition - return single segment with all points
175
- const points = x_values.map((curr_x, idx) => ({
176
- x: curr_x,
177
- y1: y1_values[idx],
178
- y2: y2_values[idx],
179
- }));
180
- return { segments: [points] };
181
- }
182
- const segments = [];
183
- let current_segment = [];
184
- for (let idx = 0; idx < x_values.length; idx++) {
185
- const curr_x = x_values[idx];
186
- const curr_y1 = y1_values[idx];
187
- const curr_y2 = y2_values[idx];
188
- const passes = region.where(curr_x, curr_y1, curr_y2);
189
- if (idx > 0) {
190
- const prev_x = x_values[idx - 1];
191
- const prev_y1 = y1_values[idx - 1];
192
- const prev_y2 = y2_values[idx - 1];
193
- const prev_passes = region.where(prev_x, prev_y1, prev_y2);
194
- // Check for condition crossing between prev and current
195
- if (passes !== prev_passes) {
196
- const crossing_x = find_crossing(prev_x, prev_y1, prev_y2, curr_x, curr_y1, curr_y2, region.where);
197
- if (crossing_x !== null) {
198
- // Interpolate y values at crossing point
199
- const weight = (crossing_x - prev_x) / (curr_x - prev_x);
200
- const crossing_y1 = prev_y1 + weight * (curr_y1 - prev_y1);
201
- const crossing_y2 = prev_y2 + weight * (curr_y2 - prev_y2);
202
- if (prev_passes) {
203
- // End current segment at crossing
204
- current_segment.push({ x: crossing_x, y1: crossing_y1, y2: crossing_y2 });
205
- segments.push(current_segment);
206
- current_segment = [];
207
- }
208
- else {
209
- // Start new segment at crossing
210
- current_segment.push({ x: crossing_x, y1: crossing_y1, y2: crossing_y2 });
211
- }
212
- }
213
- }
214
- }
215
- if (passes) {
216
- current_segment.push({ x: curr_x, y1: curr_y1, y2: curr_y2 });
217
- }
218
- else if (current_segment.length > 0) {
219
- segments.push(current_segment);
220
- current_segment = [];
221
- }
222
- }
223
- // Don't forget the last segment
224
- if (current_segment.length > 0) {
225
- segments.push(current_segment);
226
- }
227
- return { segments };
228
- }
229
- export function clamp_for_log_scale(x_values, y1_values, y2_values, y_scale_type, x_scale_type = `linear`) {
230
- const result_x = [];
231
- const result_y1 = [];
232
- const result_y2 = [];
233
- const clamped_indices = [];
234
- for (let idx = 0; idx < x_values.length; idx++) {
235
- let curr_x = x_values[idx];
236
- let curr_y1 = y1_values[idx];
237
- let curr_y2 = y2_values[idx];
238
- let was_clamped = false;
239
- // Clamp x if x-axis is log scale
240
- if (x_scale_type === `log` && curr_x <= 0) {
241
- curr_x = LOG_EPSILON;
242
- was_clamped = true;
243
- }
244
- // Clamp y values if y-axis is log scale
245
- if (y_scale_type === `log`) {
246
- if (curr_y1 <= 0) {
247
- curr_y1 = LOG_EPSILON;
248
- was_clamped = true;
249
- }
250
- if (curr_y2 <= 0) {
251
- curr_y2 = LOG_EPSILON;
252
- was_clamped = true;
253
- }
254
- }
255
- result_x.push(curr_x);
256
- result_y1.push(curr_y1);
257
- result_y2.push(curr_y2);
258
- if (was_clamped) {
259
- clamped_indices.push(idx);
260
- }
261
- }
262
- return {
263
- x: result_x,
264
- y1: result_y1,
265
- y2: result_y2,
266
- clamped_indices,
267
- };
268
- }
269
- // Map FillCurveType to d3 curve factory
270
- const CURVE_MAP = {
271
- linear: curveLinear,
272
- monotoneX: curveMonotoneX,
273
- monotoneY: curveMonotoneY,
274
- step: curveStep,
275
- stepBefore: curveStepBefore,
276
- stepAfter: curveStepAfter,
277
- basis: curveBasis,
278
- cardinal: curveCardinal,
279
- catmullRom: curveCatmullRom,
280
- natural: curveNatural,
281
- };
282
- const get_curve = (curve_type) => CURVE_MAP[curve_type] ?? curveMonotoneX;
283
- // Generate SVG path string for a fill region
284
- // data should already be in pixel coordinates
285
- export function generate_fill_path(data, curve_type = `monotoneX`) {
286
- if (data.length === 0)
287
- return ``;
288
- const curve = get_curve(curve_type);
289
- const area_generator = area()
290
- .x((point) => point.x)
291
- .y0((point) => point.y1)
292
- .y1((point) => point.y2)
293
- .curve(curve);
294
- return area_generator(data) ?? ``;
295
- }
296
- // Helper to expand error definition to array
297
- const expand_error = (err, length) => typeof err === `number` ? Array(length).fill(err) : err;
298
- // Convert an ErrorBand convenience type to a full FillRegion
299
- export function convert_error_band_to_fill_region(error_band, series, default_color) {
300
- const resolved = resolve_series_ref(error_band.series, series);
301
- if (!resolved)
302
- return null;
303
- const { y } = resolved;
304
- const { error } = error_band;
305
- // Determine upper/lower error arrays
306
- const [upper_err, lower_err] = typeof error === `object` && `upper` in error
307
- ? [expand_error(error.upper, y.length), expand_error(error.lower, y.length)]
308
- : [expand_error(error, y.length), expand_error(error, y.length)];
309
- return {
310
- id: error_band.id,
311
- label: error_band.label,
312
- upper: { type: `data`, values: y.map((val, idx) => val + upper_err[idx]) },
313
- lower: { type: `data`, values: y.map((val, idx) => val - lower_err[idx]) },
314
- fill: error_band.fill ?? default_color ?? `#4e79a7`,
315
- fill_opacity: error_band.fill_opacity ?? 0.3,
316
- edge_upper: error_band.edge_style,
317
- edge_lower: error_band.edge_style,
318
- show_in_legend: error_band.show_in_legend ?? true,
319
- };
320
- }
321
- // Type guard to check if fill is a gradient
322
- export const is_fill_gradient = (fill) => typeof fill === `object` && fill !== null && `type` in fill && `stops` in fill;
@@ -1,12 +0,0 @@
1
- import type { Point2D, Vec2 } from '../math';
2
- import type { Y2SyncConfig, Y2SyncMode } from './types';
3
- export declare function get_relative_coords(evt: MouseEvent): Point2D | null;
4
- export declare function normalize_y2_sync(sync: Y2SyncConfig | Y2SyncMode | undefined): Y2SyncConfig;
5
- export declare function sync_y2_range(y1_range: Vec2, y2_base_range: Vec2, sync: Y2SyncConfig): Vec2;
6
- export declare const pan_range: (current: Vec2, delta: number) => Vec2;
7
- export declare function pixels_to_data_delta(pixel_delta: number, data_range: Vec2, pixel_range: number): number;
8
- export declare const PINCH_ZOOM_THRESHOLD = 0.1;
9
- export declare function expand_range_if_needed(current: Vec2, new_range: Vec2): {
10
- range: Vec2;
11
- changed: boolean;
12
- };
@@ -1,101 +0,0 @@
1
- // Get relative coordinates from a mouse event
2
- export function get_relative_coords(evt) {
3
- const current_target = evt.currentTarget;
4
- if (!(current_target instanceof SVGElement))
5
- return null;
6
- const svg_box = current_target.getBoundingClientRect();
7
- if (!svg_box)
8
- return null;
9
- return { x: evt.clientX - svg_box.left, y: evt.clientY - svg_box.top };
10
- }
11
- // Normalize Y2 sync config (handle shorthand string vs full object)
12
- export function normalize_y2_sync(sync) {
13
- if (!sync || sync === `none`)
14
- return { mode: `none` };
15
- if (typeof sync === `string`)
16
- return { mode: sync };
17
- return sync;
18
- }
19
- // Helper to check if all values in ranges are finite
20
- const all_finite = (...ranges) => ranges.every(([a, b]) => Number.isFinite(a) && Number.isFinite(b));
21
- // Calculate synced y2 range based on sync mode
22
- export function sync_y2_range(y1_range, y2_base_range, sync) {
23
- if (sync.mode === `none`)
24
- return y2_base_range;
25
- if (!all_finite(y1_range, y2_base_range))
26
- return y2_base_range;
27
- // Synced: Y2 has exact same range as Y1
28
- if (sync.mode === `synced`) {
29
- return [y1_range[0], y1_range[1]];
30
- }
31
- // Align: Position so align_val (default 0) is at same relative position on both axes
32
- // Y2 range expands as needed to show all data while maintaining alignment
33
- if (sync.mode === `align`) {
34
- const align_val = sync.align_value ?? 0;
35
- const y1_span = y1_range[1] - y1_range[0];
36
- if (y1_span === 0)
37
- return y2_base_range;
38
- // Where is align_val in Y1's range? (0 = bottom, 1 = top)
39
- const rel_pos = (align_val - y1_range[0]) / y1_span;
40
- // Ensure Y2 range includes both align_val and all data
41
- const y2_min_data = Math.min(y2_base_range[0], align_val);
42
- const y2_max_data = Math.max(y2_base_range[1], align_val);
43
- // Calculate minimum span needed to fit all data while keeping align_val at rel_pos
44
- // Constraints: y2_min <= y2_min_data AND y2_max >= y2_max_data
45
- let y2_span = y2_max_data - y2_min_data;
46
- if (rel_pos > 0) {
47
- y2_span = Math.max(y2_span, (align_val - y2_min_data) / rel_pos);
48
- }
49
- if (rel_pos < 1) {
50
- y2_span = Math.max(y2_span, (y2_max_data - align_val) / (1 - rel_pos));
51
- }
52
- const y2_min_computed = align_val - rel_pos * y2_span;
53
- const y2_max_computed = align_val + (1 - rel_pos) * y2_span;
54
- // When align_val is outside y1_range (rel_pos < 0 or > 1), the formula can produce
55
- // a range that omits y2_base_range or align_val. Ensure both are always included.
56
- const y2_min = Math.min(y2_min_computed, y2_base_range[0], align_val);
57
- const y2_max = Math.max(y2_max_computed, y2_base_range[1], align_val);
58
- return [y2_min, y2_max];
59
- }
60
- return y2_base_range;
61
- }
62
- // Shift a range by a delta amount (no bounds constraint for free panning)
63
- export const pan_range = (current, delta) => [
64
- current[0] + delta,
65
- current[1] + delta,
66
- ];
67
- // Convert pixel delta to data delta using current data range and pixel range
68
- export function pixels_to_data_delta(pixel_delta, data_range, pixel_range) {
69
- if (pixel_range === 0)
70
- return 0;
71
- const data_span = data_range[1] - data_range[0];
72
- return (pixel_delta / pixel_range) * data_span;
73
- }
74
- // Threshold for distinguishing pinch-zoom from pan in touch gestures
75
- // Scale change > this value triggers zoom instead of pan
76
- export const PINCH_ZOOM_THRESHOLD = 0.1;
77
- // Helper to check if range is the default [0, 1] sentinel (no data)
78
- // Note: min === 0 handles -0 correctly since -0 === 0 in JavaScript
79
- const is_default_range = ([min, max]) => min === 0 && max === 1;
80
- // Adopt the new data range, unless all series were hidden (sentinel [0, 1] fallback).
81
- // NOTE: [0, 1] is the "no data" sentinel - when all series are hidden, auto ranges
82
- // fall back to [0, 1]. Actual data spanning exactly [0, 1] is a rare edge case.
83
- export function expand_range_if_needed(current, new_range) {
84
- // Guard against NaN/Infinity - prefer valid range, fall back to sentinel [0, 1] if both invalid
85
- const current_valid = all_finite(current);
86
- const new_valid = all_finite(new_range);
87
- if (!current_valid && !new_valid)
88
- return { range: [0, 1], changed: true };
89
- if (!new_valid)
90
- return { range: current, changed: false };
91
- if (!current_valid)
92
- return { range: new_range, changed: true };
93
- // When all series are hidden, auto ranges fall back to [0, 1] sentinel.
94
- // Don't shrink to that — preserve the current view so it doesn't jump.
95
- if (!is_default_range(current) && is_default_range(new_range)) {
96
- return { range: current, changed: false };
97
- }
98
- // Otherwise adopt the new range directly (both expand and shrink)
99
- const changed = new_range[0] !== current[0] || new_range[1] !== current[1];
100
- return { range: new_range, changed };
101
- }
@@ -1 +0,0 @@
1
- export declare function bar_path(x: number, y: number, w: number, h: number, r: number, vertical?: boolean): string;
package/dist/plot/svg.js DELETED
@@ -1,11 +0,0 @@
1
- // SVG path and rendering utilities for plot components.
2
- //
3
- // Generate SVG path for a bar with rounded corners on the "free" end (away from axis).
4
- // For vertical bars, rounds top corners. For horizontal bars, rounds right corners.
5
- export function bar_path(x, y, w, h, r, vertical = true) {
6
- if (r <= 0)
7
- return `M${x},${y}h${w}v${h}h${-w}Z`;
8
- return vertical
9
- ? `M${x},${y + h}V${y + r}A${r},${r} 0 0 1 ${x + r},${y}H${x + w - r}A${r},${r} 0 0 1 ${x + w},${y + r}V${y + h}Z`
10
- : `M${x},${y}H${x + w - r}A${r},${r} 0 0 1 ${x + w},${y + r}V${y + h - r}A${r},${r} 0 0 1 ${x + w - r},${y + h}H${x}Z`;
11
- }
@@ -1,15 +0,0 @@
1
- import type { DataSeries } from '../types';
2
- export type StrRecord = Record<string, unknown>;
3
- type SeriesSource = [string, string, string, unknown, unknown];
4
- export type SeriesVisibilitySnapshot = {
5
- visibility: boolean[];
6
- source: SeriesSource[];
7
- };
8
- export declare function have_compatible_units<Metadata extends StrRecord = StrRecord>(series1: DataSeries<Metadata>, series2: DataSeries<Metadata>): boolean;
9
- export declare function toggle_series_visibility<Metadata extends StrRecord = StrRecord>(series: DataSeries<Metadata>[], series_idx: number): DataSeries<Metadata>[];
10
- export declare function toggle_group_visibility<Metadata extends StrRecord = StrRecord>(series: DataSeries<Metadata>[], series_indices: number[]): DataSeries<Metadata>[];
11
- export declare function handle_legend_double_click<Metadata extends StrRecord = StrRecord>(series: DataSeries<Metadata>[], idx: number, prev_snapshot: SeriesVisibilitySnapshot | null): {
12
- series: DataSeries<Metadata>[];
13
- prev_visibility: SeriesVisibilitySnapshot | null;
14
- };
15
- export {};
@@ -1 +0,0 @@
1
- export declare function calc_auto_range(values: number[]): [number, number];
@@ -1,14 +0,0 @@
1
- export function calc_auto_range(values) {
2
- const finite_values = values.filter(Number.isFinite);
3
- if (finite_values.length === 0)
4
- return [0, 1];
5
- let [min_value, max_value] = [finite_values[0], finite_values[0]];
6
- for (const value of finite_values) {
7
- if (value < min_value)
8
- min_value = value;
9
- else if (value > max_value)
10
- max_value = value;
11
- }
12
- const padding = (max_value - min_value) * 0.05 || 0.5;
13
- return [min_value - padding, max_value + padding];
14
- }