matterviz 0.4.1 → 0.4.3
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.
- package/dist/EmptyState.svelte +10 -4
- package/dist/FilePicker.svelte +48 -60
- package/dist/Icon.svelte +7 -4
- package/dist/MillerIndexInput.svelte +2 -2
- package/dist/api/optimade.js +10 -7
- package/dist/app.css +68 -0
- package/dist/brillouin/BrillouinZone.svelte +90 -91
- package/dist/brillouin/BrillouinZone.svelte.d.ts +5 -7
- package/dist/brillouin/BrillouinZoneControls.svelte +3 -6
- package/dist/brillouin/BrillouinZoneExportPane.svelte +18 -14
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +6 -10
- package/dist/brillouin/BrillouinZoneScene.svelte +46 -68
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -1
- package/dist/brillouin/compute.js +10 -16
- package/dist/brillouin/geometry.js +2 -2
- package/dist/chempot-diagram/ChemPotDiagram.svelte +48 -50
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +61 -169
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +1 -1
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +559 -755
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +1 -1
- package/dist/chempot-diagram/async-compute.svelte.js +13 -14
- package/dist/chempot-diagram/color.d.ts +21 -1
- package/dist/chempot-diagram/color.js +70 -1
- package/dist/chempot-diagram/compute.d.ts +7 -0
- package/dist/chempot-diagram/compute.js +85 -26
- package/dist/chempot-diagram/controls-state.svelte.js +1 -1
- package/dist/chempot-diagram/export.js +1 -6
- package/dist/chempot-diagram/temperature.js +9 -10
- package/dist/colors/index.d.ts +0 -4
- package/dist/colors/index.js +19 -20
- package/dist/composition/BarChart.svelte +30 -26
- package/dist/composition/BubbleChart.svelte +17 -17
- package/dist/composition/Composition.svelte +10 -19
- package/dist/composition/Formula.svelte +20 -27
- package/dist/composition/FormulaFilter.svelte +115 -184
- package/dist/composition/PieChart.svelte +55 -41
- package/dist/composition/format.js +7 -9
- package/dist/composition/index.d.ts +2 -0
- package/dist/composition/index.js +14 -0
- package/dist/composition/parse.d.ts +2 -2
- package/dist/composition/parse.js +61 -115
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +17 -26
- package/dist/convex-hull/ConvexHull.svelte +12 -15
- package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull2D.svelte +93 -94
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull3D.svelte +127 -186
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull4D.svelte +131 -180
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullChrome.svelte +36 -40
- package/dist/convex-hull/ConvexHullControls.svelte +46 -48
- package/dist/convex-hull/ConvexHullStats.svelte +193 -195
- package/dist/convex-hull/ConvexHullTooltip.svelte +5 -12
- package/dist/convex-hull/GasPressureControls.svelte +5 -12
- package/dist/convex-hull/StructurePopup.svelte +18 -22
- package/dist/convex-hull/StructurePopup.svelte.d.ts +2 -0
- package/dist/convex-hull/TemperatureSlider.svelte +4 -10
- package/dist/convex-hull/canvas-interactions.svelte.js +2 -1
- package/dist/convex-hull/gas-thermodynamics.js +21 -53
- package/dist/convex-hull/helpers.d.ts +8 -10
- package/dist/convex-hull/helpers.js +37 -43
- package/dist/convex-hull/hull-state.svelte.d.ts +1 -1
- package/dist/convex-hull/thermodynamics.js +37 -44
- package/dist/coordination/CoordinationBarPlot.svelte +49 -53
- package/dist/coordination/CoordinationBarPlot.svelte.d.ts +1 -1
- package/dist/coordination/calc-coordination.d.ts +1 -1
- package/dist/coordination/calc-coordination.js +28 -25
- package/dist/element/BohrAtom.svelte +5 -9
- package/dist/element/ElementHeading.svelte +4 -1
- package/dist/element/ElementPhoto.svelte +11 -9
- package/dist/element/ElementStats.svelte +12 -10
- package/dist/element/ElementTile.svelte +44 -67
- package/dist/element/Nucleus.svelte +4 -2
- package/dist/element/data.d.ts +3 -2
- package/dist/element/data.js +5 -1
- package/dist/element/helpers.d.ts +4 -0
- package/dist/element/helpers.js +18 -0
- package/dist/element/index.d.ts +2 -5
- package/dist/element/index.js +4 -19
- package/dist/feedback/DragOverlay.svelte +5 -5
- package/dist/feedback/DragOverlay.svelte.d.ts +2 -2
- package/dist/feedback/StatusMessage.svelte +7 -4
- package/dist/fermi-surface/FermiSlice.svelte +21 -18
- package/dist/fermi-surface/FermiSurface.svelte +35 -44
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +7 -13
- package/dist/fermi-surface/FermiSurfaceControls.svelte +6 -20
- package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte +64 -136
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +9 -6
- package/dist/fermi-surface/compute.js +25 -58
- package/dist/fermi-surface/parse.js +54 -88
- package/dist/file-viewer/JsonBrowser.svelte +1043 -0
- package/dist/file-viewer/JsonBrowser.svelte.d.ts +9 -0
- package/dist/file-viewer/PlotPanel.svelte +350 -0
- package/dist/file-viewer/PlotPanel.svelte.d.ts +9 -0
- package/dist/file-viewer/TrajectoryWithDos.svelte +30 -0
- package/dist/file-viewer/TrajectoryWithDos.svelte.d.ts +10 -0
- package/dist/file-viewer/detect.d.ts +11 -0
- package/dist/file-viewer/detect.js +381 -0
- package/dist/file-viewer/eligibility.d.ts +4 -0
- package/dist/file-viewer/eligibility.js +53 -0
- package/dist/file-viewer/host-protocol.d.ts +50 -0
- package/dist/file-viewer/host-transfer.d.ts +25 -0
- package/dist/file-viewer/host-transfer.js +42 -0
- package/dist/file-viewer/index.d.ts +5 -0
- package/dist/file-viewer/index.js +5 -0
- package/dist/file-viewer/main.d.ts +44 -0
- package/dist/file-viewer/main.js +535 -0
- package/dist/file-viewer/parse.d.ts +9 -0
- package/dist/file-viewer/parse.js +170 -0
- package/dist/file-viewer/plot-utils.d.ts +24 -0
- package/dist/file-viewer/plot-utils.js +191 -0
- package/dist/file-viewer/types.d.ts +4 -0
- package/dist/file-viewer/types.js +5 -0
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +153 -219
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +2 -2
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +9 -7
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +1 -1
- package/dist/heatmap-matrix/index.d.ts +5 -0
- package/dist/icons.d.ts +4 -0
- package/dist/icons.js +4 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/io/ExportPane.svelte +11 -7
- package/dist/io/decompress.d.ts +4 -1
- package/dist/io/decompress.js +24 -36
- package/dist/io/export.d.ts +11 -4
- package/dist/io/export.js +75 -19
- package/dist/io/fetch.d.ts +0 -3
- package/dist/io/fetch.js +0 -11
- package/dist/io/file-drop.js +60 -35
- package/dist/io/index.d.ts +0 -1
- package/dist/io/index.js +2 -9
- package/dist/io/is-binary.d.ts +9 -0
- package/dist/io/is-binary.js +45 -1
- package/dist/io/url-drop.d.ts +2 -0
- package/dist/io/url-drop.js +40 -40
- package/dist/isosurface/Isosurface.svelte +700 -215
- package/dist/isosurface/Isosurface.svelte.d.ts +7 -1
- package/dist/isosurface/IsosurfaceControls.svelte +590 -116
- package/dist/isosurface/IsosurfaceControls.svelte.d.ts +1 -1
- package/dist/isosurface/VolumeSlice.svelte +224 -0
- package/dist/isosurface/VolumeSlice.svelte.d.ts +28 -0
- package/dist/isosurface/coloring.d.ts +20 -0
- package/dist/isosurface/coloring.js +118 -0
- package/dist/isosurface/geometry-worker-types.d.ts +38 -0
- package/dist/isosurface/geometry.worker.d.ts +1 -0
- package/dist/isosurface/geometry.worker.js +59 -0
- package/dist/isosurface/grid.d.ts +10 -0
- package/dist/isosurface/grid.js +31 -0
- package/dist/isosurface/index.d.ts +4 -0
- package/dist/isosurface/index.js +4 -0
- package/dist/isosurface/parse-vaspwave.d.ts +3 -0
- package/dist/isosurface/parse-vaspwave.js +138 -0
- package/dist/isosurface/parse.js +6 -6
- package/dist/isosurface/profile.d.ts +12 -0
- package/dist/isosurface/profile.js +19 -0
- package/dist/isosurface/sampling.d.ts +34 -0
- package/dist/isosurface/sampling.js +408 -0
- package/dist/isosurface/slice-rendering.d.ts +13 -0
- package/dist/isosurface/slice-rendering.js +79 -0
- package/dist/isosurface/slice.d.ts +22 -2
- package/dist/isosurface/slice.js +200 -116
- package/dist/isosurface/types.d.ts +24 -1
- package/dist/isosurface/types.js +120 -8
- package/dist/json-path.d.ts +4 -0
- package/dist/json-path.js +89 -0
- package/dist/labels.d.ts +6 -2
- package/dist/labels.js +44 -14
- package/dist/layout/FullscreenButton.svelte +2 -1
- package/dist/layout/FullscreenToggle.svelte +10 -4
- package/dist/layout/InfoCard.svelte +8 -21
- package/dist/layout/InfoTag.svelte +1 -3
- package/dist/layout/NumberRangeInput.svelte +46 -0
- package/dist/layout/NumberRangeInput.svelte.d.ts +12 -0
- package/dist/layout/PropertyFilter.svelte +2 -6
- package/dist/layout/SettingsSection.svelte +57 -62
- package/dist/layout/SettingsSection.svelte.d.ts +6 -7
- package/dist/layout/SubpageGrid.svelte +3 -1
- package/dist/layout/ViewerChrome.svelte +16 -11
- package/dist/layout/ViewerChrome.svelte.d.ts +2 -1
- package/dist/layout/fullscreen.js +3 -5
- package/dist/layout/fullscreen.svelte.js +1 -2
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/index.js +1 -0
- package/dist/layout/json-tree/JsonNode.svelte +22 -59
- package/dist/layout/json-tree/JsonTree.svelte +101 -172
- package/dist/layout/json-tree/JsonValue.svelte +9 -32
- package/dist/layout/json-tree/utils.d.ts +0 -3
- package/dist/layout/json-tree/utils.js +50 -188
- package/dist/marching-cubes.d.ts +8 -1
- package/dist/marching-cubes.js +115 -48
- package/dist/math.d.ts +5 -2
- package/dist/math.js +48 -38
- package/dist/overlays/ContextMenu.svelte +19 -34
- package/dist/overlays/CopyButton.svelte +11 -5
- package/dist/overlays/DragControlTab.svelte +6 -1
- package/dist/overlays/DraggablePane.svelte +110 -74
- package/dist/overlays/DraggablePane.svelte.d.ts +2 -1
- package/dist/overlays/GlassChip.svelte +32 -0
- package/dist/overlays/GlassChip.svelte.d.ts +8 -0
- package/dist/overlays/InfoPaneCards.svelte +11 -23
- package/dist/overlays/index.d.ts +7 -0
- package/dist/overlays/index.js +26 -0
- package/dist/overlays/portal.d.ts +2 -0
- package/dist/overlays/portal.js +14 -0
- package/dist/periodic-table/PeriodicTable.svelte +113 -145
- package/dist/periodic-table/PeriodicTable.svelte.d.ts +5 -3
- package/dist/periodic-table/PeriodicTableControls.svelte +37 -115
- package/dist/periodic-table/TableInset.svelte +9 -4
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +68 -105
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -8
- package/dist/phase-diagram/PhaseDiagramControls.svelte +70 -94
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +2 -1
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +12 -12
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +54 -58
- package/dist/phase-diagram/TdbInfoPanel.svelte +21 -15
- package/dist/phase-diagram/build-diagram.js +4 -9
- package/dist/phase-diagram/diagram-input.d.ts +1 -2
- package/dist/phase-diagram/parse.js +15 -15
- package/dist/phase-diagram/svg-to-diagram.js +28 -27
- package/dist/phase-diagram/utils.js +2 -3
- package/dist/plot/bar/BarPlot.svelte +461 -426
- package/dist/plot/bar/BarPlot.svelte.d.ts +2 -0
- package/dist/plot/bar/BarPlotControls.svelte +1 -3
- package/dist/plot/bar/BarPlotControls.svelte.d.ts +4 -6
- package/dist/plot/bar/SpacegroupBarPlot.svelte +46 -77
- package/dist/plot/bar/data.d.ts +5 -4
- package/dist/plot/bar/data.js +2 -1
- package/dist/plot/box/BoxPlot.svelte +322 -226
- package/dist/plot/box/BoxPlot.svelte.d.ts +2 -0
- package/dist/plot/box/Violin.svelte.d.ts +1 -0
- package/dist/plot/box/box-plot.js +1 -1
- package/dist/plot/core/auto-place.d.ts +1 -1
- package/dist/plot/core/auto-place.js +2 -2
- package/dist/plot/core/axis-utils.d.ts +12 -7
- package/dist/plot/core/axis-utils.js +48 -48
- package/dist/plot/core/components/AxisLabel.svelte +82 -20
- package/dist/plot/core/components/AxisLabel.svelte.d.ts +1 -0
- package/dist/plot/core/components/ColorBar.svelte +101 -106
- package/dist/plot/core/components/ColorScaleSelect.svelte +1 -1
- package/dist/plot/core/components/FillArea.svelte +10 -17
- package/dist/plot/core/components/HierarchyControls.svelte +249 -0
- package/dist/plot/{sunburst/SunburstControls.svelte.d.ts → core/components/HierarchyControls.svelte.d.ts} +12 -8
- package/dist/plot/core/components/InteractiveAxisLabel.svelte +1 -1
- package/dist/plot/core/components/InteractiveAxisLabel.svelte.d.ts +1 -1
- package/dist/plot/core/components/Line.svelte +18 -9
- package/dist/plot/core/components/Line.svelte.d.ts +2 -0
- package/dist/plot/core/components/PlotAxis.svelte +40 -17
- package/dist/plot/core/components/PlotControls.svelte +65 -41
- package/dist/plot/core/components/PlotLegend.svelte +31 -35
- package/dist/plot/core/components/PlotMarginals.svelte +616 -0
- package/dist/plot/core/components/PlotMarginals.svelte.d.ts +15 -0
- package/dist/plot/core/components/PlotTooltip.svelte +1 -1
- package/dist/plot/core/components/PortalSelect.svelte +4 -8
- package/dist/plot/core/components/ReferenceLine.svelte +27 -24
- package/dist/plot/core/components/ReferenceLine3D.svelte +54 -57
- package/dist/plot/core/components/ReferencePlane.svelte +7 -8
- package/dist/plot/core/components/ZeroLines.svelte +4 -8
- package/dist/plot/core/components/ZoomRect.svelte +1 -2
- package/dist/plot/core/components/index.d.ts +1 -0
- package/dist/plot/core/components/index.js +1 -0
- package/dist/plot/core/data-cleaning-signal.d.ts +46 -0
- package/dist/plot/core/data-cleaning-signal.js +467 -0
- package/dist/plot/core/data-cleaning.d.ts +2 -42
- package/dist/plot/core/data-cleaning.js +27 -474
- package/dist/plot/core/data-transform.d.ts +1 -2
- package/dist/plot/core/data-transform.js +9 -15
- package/dist/plot/core/fill-utils.d.ts +3 -1
- package/dist/plot/core/fill-utils.js +28 -6
- package/dist/plot/core/index.d.ts +1 -0
- package/dist/plot/core/index.js +1 -0
- package/dist/plot/core/interactions.js +0 -2
- package/dist/plot/core/layout.d.ts +15 -6
- package/dist/plot/core/layout.js +57 -38
- package/dist/plot/core/marginals.d.ts +170 -0
- package/dist/plot/core/marginals.js +436 -0
- package/dist/plot/core/pan-zoom.svelte.d.ts +2 -4
- package/dist/plot/core/pan-zoom.svelte.js +34 -17
- package/dist/plot/core/placed-tween.svelte.d.ts +3 -0
- package/dist/plot/core/placed-tween.svelte.js +68 -21
- package/dist/plot/core/reference-line.js +1 -1
- package/dist/plot/core/scales.d.ts +23 -0
- package/dist/plot/core/scales.js +39 -13
- package/dist/plot/core/svg.js +0 -1
- package/dist/plot/core/types/fills.d.ts +101 -0
- package/dist/plot/core/types/fills.js +15 -0
- package/dist/plot/core/types/plot-3d.d.ts +87 -0
- package/dist/plot/core/types/plot-3d.js +4 -0
- package/dist/plot/core/types/reference-lines.d.ts +140 -0
- package/dist/plot/core/types/reference-lines.js +9 -0
- package/dist/plot/core/types.d.ts +29 -324
- package/dist/plot/core/types.js +23 -20
- package/dist/plot/core/utils/hierarchy-chart.d.ts +52 -0
- package/dist/plot/core/utils/hierarchy-chart.js +191 -0
- package/dist/plot/core/utils/hierarchy-labels.d.ts +20 -0
- package/dist/plot/core/utils/hierarchy-labels.js +100 -0
- package/dist/plot/core/utils/label-placement.js +2 -2
- package/dist/plot/histogram/Histogram.svelte +314 -340
- package/dist/plot/histogram/Histogram.svelte.d.ts +7 -7
- package/dist/plot/histogram/HistogramControls.svelte +30 -28
- package/dist/plot/histogram/histogram.d.ts +31 -0
- package/dist/plot/histogram/histogram.js +70 -0
- package/dist/plot/histogram/index.d.ts +1 -0
- package/dist/plot/histogram/index.js +1 -0
- package/dist/plot/index.d.ts +1 -0
- package/dist/plot/index.js +1 -0
- package/dist/plot/sankey/Sankey.svelte +78 -69
- package/dist/plot/sankey/Sankey.svelte.d.ts +2 -2
- package/dist/plot/sankey/SankeyControls.svelte +22 -16
- package/dist/plot/sankey/sankey.js +13 -9
- package/dist/plot/scatter/BinnedScatterPlot.svelte +311 -141
- package/dist/plot/scatter/BinnedScatterPlot.svelte.d.ts +7 -0
- package/dist/plot/scatter/ElementScatter.svelte +4 -1
- package/dist/plot/scatter/ScatterPlot.svelte +517 -410
- package/dist/plot/scatter/ScatterPlot.svelte.d.ts +2 -0
- package/dist/plot/scatter/ScatterPlotControls.svelte +18 -19
- package/dist/plot/scatter/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/scatter/ScatterPoint.svelte +16 -9
- package/dist/plot/scatter/adaptive-density.d.ts +1 -1
- package/dist/plot/scatter/adaptive-density.js +36 -20
- package/dist/plot/scatter/binned-scatter-types.d.ts +3 -2
- package/dist/plot/scatter/binned-scatter-types.js +6 -1
- package/dist/plot/scatter/scatter-data.d.ts +1 -1
- package/dist/plot/scatter/scatter-data.js +8 -7
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte +25 -34
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte.d.ts +2 -2
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte +8 -5
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte +113 -116
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte.d.ts +2 -2
- package/dist/plot/scatter-3d/Surface3D.svelte +4 -13
- package/dist/plot/sunburst/Sunburst.svelte +269 -347
- package/dist/plot/sunburst/Sunburst.svelte.d.ts +2 -2
- package/dist/plot/sunburst/index.d.ts +1 -1
- package/dist/plot/sunburst/index.js +2 -1
- package/dist/plot/sunburst/render.d.ts +2 -2
- package/dist/plot/sunburst/render.js +47 -22
- package/dist/plot/sunburst/sunburst.d.ts +5 -1
- package/dist/plot/sunburst/sunburst.js +10 -3
- package/dist/plot/treemap/Treemap.svelte +1022 -0
- package/dist/plot/treemap/Treemap.svelte.d.ts +90 -0
- package/dist/plot/treemap/index.d.ts +4 -0
- package/dist/plot/treemap/index.js +4 -0
- package/dist/plot/treemap/labels.d.ts +38 -0
- package/dist/plot/treemap/labels.js +80 -0
- package/dist/plot/treemap/treemap.d.ts +28 -0
- package/dist/plot/treemap/treemap.js +102 -0
- package/dist/rdf/RdfPlot.svelte +37 -59
- package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
- package/dist/rdf/calc-rdf.js +63 -52
- package/dist/rdf/index.d.ts +0 -1
- package/dist/sanitize.js +85 -27
- package/dist/scene/SceneCamera.svelte +1 -1
- package/dist/scene/SceneCamera.svelte.d.ts +1 -1
- package/dist/scene/bind-renderer.svelte.js +14 -6
- package/dist/scene/index.d.ts +1 -2
- package/dist/scene/index.js +1 -1
- package/dist/scene/{props.js → props.svelte.js} +15 -1
- package/dist/settings.d.ts +19 -9
- package/dist/settings.js +229 -525
- package/dist/spectral/Bands.svelte +207 -221
- package/dist/spectral/BandsAndDos.svelte +11 -9
- package/dist/spectral/BrillouinBandsDos.svelte +19 -42
- package/dist/spectral/Dos.svelte +92 -93
- package/dist/spectral/helpers.d.ts +3 -3
- package/dist/spectral/helpers.js +65 -140
- package/dist/state.svelte.js +5 -18
- package/dist/structure/Arrow.svelte +5 -18
- package/dist/structure/ArrowInstances.svelte +160 -0
- package/dist/structure/ArrowInstances.svelte.d.ts +16 -0
- package/dist/structure/AtomLegend.svelte +120 -85
- package/dist/structure/AtomLegend.svelte.d.ts +2 -3
- package/dist/structure/Bond.svelte +31 -23
- package/dist/structure/CanvasTooltip.svelte +15 -3
- package/dist/structure/CellSelect.svelte +45 -35
- package/dist/structure/Cylinder.svelte +24 -40
- package/dist/structure/InstancedAtoms.svelte +114 -0
- package/dist/structure/InstancedAtoms.svelte.d.ts +15 -0
- package/dist/structure/Lattice.svelte +85 -149
- package/dist/structure/SiteLabels.svelte +122 -0
- package/dist/structure/SiteLabels.svelte.d.ts +18 -0
- package/dist/structure/Structure.svelte +636 -504
- package/dist/structure/Structure.svelte.d.ts +4 -2
- package/dist/structure/StructureCarousel.svelte +637 -0
- package/dist/structure/StructureCarousel.svelte.d.ts +19 -0
- package/dist/structure/StructureControls.svelte +165 -425
- package/dist/structure/StructureControls.svelte.d.ts +1 -1
- package/dist/structure/StructureExportPane.svelte +17 -21
- package/dist/structure/StructureInfoPane.svelte +128 -133
- package/dist/structure/StructureInfoPane.svelte.d.ts +1 -1
- package/dist/structure/StructureScene.svelte +535 -578
- package/dist/structure/StructureScene.svelte.d.ts +6 -2
- package/dist/structure/StructureViewport.svelte +451 -0
- package/dist/structure/StructureViewport.svelte.d.ts +65 -0
- package/dist/structure/atom-label-placement.d.ts +16 -12
- package/dist/structure/atom-label-placement.js +70 -37
- package/dist/structure/atom-properties.d.ts +2 -0
- package/dist/structure/atom-properties.js +105 -38
- package/dist/structure/bond-order-perception.js +3 -8
- package/dist/structure/bonding.d.ts +9 -3
- package/dist/structure/bonding.js +95 -46
- package/dist/structure/edit-history.d.ts +6 -0
- package/dist/structure/edit-history.js +27 -0
- package/dist/structure/export.d.ts +1 -0
- package/dist/structure/export.js +89 -105
- package/dist/structure/format-detect.d.ts +1 -0
- package/dist/structure/format-detect.js +20 -0
- package/dist/structure/geometry.d.ts +9 -0
- package/dist/structure/geometry.js +27 -0
- package/dist/structure/index.d.ts +16 -1
- package/dist/structure/index.js +15 -10
- package/dist/structure/measure.d.ts +1 -1
- package/dist/structure/measure.js +6 -12
- package/dist/structure/parse.d.ts +2 -1
- package/dist/structure/parse.js +272 -313
- package/dist/structure/partial-occupancy.js +10 -5
- package/dist/structure/pbc.js +85 -107
- package/dist/structure/polyhedra.d.ts +0 -1
- package/dist/structure/polyhedra.js +7 -21
- package/dist/structure/prop-groups.d.ts +85 -0
- package/dist/structure/prop-groups.js +18 -0
- package/dist/structure/supercell.d.ts +1 -2
- package/dist/structure/supercell.js +7 -13
- package/dist/symmetry/SymmetryElements.svelte +11 -15
- package/dist/symmetry/SymmetryStats.svelte +55 -71
- package/dist/symmetry/WyckoffTable.svelte +10 -28
- package/dist/symmetry/cell-transform.js +6 -14
- package/dist/symmetry/index.d.ts +1 -0
- package/dist/symmetry/index.js +13 -10
- package/dist/symmetry/spacegroups.js +3 -2
- package/dist/table/HeatmapTable.svelte +1142 -447
- package/dist/table/HeatmapTable.svelte.d.ts +12 -2
- package/dist/table/ToggleMenu.svelte +168 -53
- package/dist/table/ToggleMenu.svelte.d.ts +1 -1
- package/dist/table/index.d.ts +21 -6
- package/dist/table/index.js +34 -21
- package/dist/theme/ThemeControl.svelte +16 -8
- package/dist/theme/embedded.d.ts +18 -0
- package/dist/theme/embedded.js +206 -0
- package/dist/theme/index.d.ts +5 -5
- package/dist/theme/index.js +5 -12
- package/dist/theme/themes.mjs +44 -66
- package/dist/tooltip/KCoords.svelte +4 -1
- package/dist/tooltip/TooltipContent.svelte +3 -6
- package/dist/tooltip/TooltipContent.svelte.d.ts +1 -1
- package/dist/tooltip/index.d.ts +8 -1
- package/dist/trajectory/Trajectory.svelte +613 -386
- package/dist/trajectory/Trajectory.svelte.d.ts +1 -1
- package/dist/trajectory/TrajectoryError.svelte +12 -74
- package/dist/trajectory/TrajectoryExportPane.svelte +14 -32
- package/dist/trajectory/TrajectoryInfoPane.svelte +127 -164
- package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +2 -1
- package/dist/trajectory/extract.js +61 -49
- package/dist/trajectory/format-detect.d.ts +2 -0
- package/dist/trajectory/format-detect.js +17 -13
- package/dist/trajectory/frame-reader.d.ts +2 -0
- package/dist/trajectory/frame-reader.js +35 -32
- package/dist/trajectory/helpers.d.ts +2 -0
- package/dist/trajectory/helpers.js +34 -56
- package/dist/trajectory/index.d.ts +1 -0
- package/dist/trajectory/index.js +5 -8
- package/dist/trajectory/parse/ase.js +1 -1
- package/dist/trajectory/parse/h5-utils.d.ts +13 -0
- package/dist/trajectory/parse/h5-utils.js +109 -0
- package/dist/trajectory/parse/hdf5.d.ts +1 -1
- package/dist/trajectory/parse/hdf5.js +116 -106
- package/dist/trajectory/parse/index.d.ts +6 -6
- package/dist/trajectory/parse/index.js +25 -33
- package/dist/trajectory/parse/lammps.js +8 -12
- package/dist/trajectory/parse/vasp.js +10 -7
- package/dist/trajectory/parse/vaspout-electronic.d.ts +13 -0
- package/dist/trajectory/parse/vaspout-electronic.js +207 -0
- package/dist/trajectory/parse/vaspout-h5.d.ts +4 -0
- package/dist/trajectory/parse/vaspout-h5.js +281 -0
- package/dist/trajectory/parse/xyz.js +59 -9
- package/dist/trajectory/plotting.d.ts +8 -9
- package/dist/trajectory/plotting.js +113 -64
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +7 -0
- package/dist/xrd/XrdPlot.svelte +79 -118
- package/dist/xrd/broadening.js +2 -1
- package/dist/xrd/calc-xrd.js +24 -62
- package/dist/xrd/parse.d.ts +0 -1
- package/dist/xrd/parse.js +69 -95
- package/package.json +94 -34
- package/readme.md +6 -5
- package/dist/api/mp.d.ts +0 -6
- package/dist/api/mp.js +0 -22
- package/dist/plot/sunburst/SunburstControls.svelte +0 -200
- package/dist/scene/types.d.ts +0 -26
- package/dist/tooltip/types.d.ts +0 -8
- package/dist/trajectory/constants.d.ts +0 -6
- package/dist/trajectory/constants.js +0 -11
- /package/dist/{scene/types.js → file-viewer/host-protocol.js} +0 -0
- /package/dist/{tooltip/types.js → isosurface/geometry-worker-types.js} +0 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { D3InterpolateName } from '../../colors';
|
|
2
|
+
import type { Vec2 } from '../../math';
|
|
3
|
+
import type { BasePlotProps, LegendConfig, SunburstLabelText, SunburstSort, SunburstValueMode } from '..';
|
|
4
|
+
import { ColorBar } from '..';
|
|
5
|
+
import type { Rect, Sides } from '../core/layout';
|
|
6
|
+
import type { PositionedArc } from '../sunburst/sunburst';
|
|
7
|
+
import { type TreemapLabelFit, type TreemapLabelFormatter } from './labels';
|
|
8
|
+
import type { TreemapNode, TreemapNodeHandlerProps } from './treemap';
|
|
9
|
+
import type { ComponentProps, Snippet } from 'svelte';
|
|
10
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
11
|
+
import { type TweenOptions } from 'svelte/motion';
|
|
12
|
+
declare function $$render<Metadata extends Record<string, unknown> = Record<string, unknown>>(): {
|
|
13
|
+
props: HTMLAttributes<HTMLDivElement> & Omit<BasePlotProps, "change"> & {
|
|
14
|
+
data?: TreemapNode<Metadata> | TreemapNode<Metadata>[];
|
|
15
|
+
value_mode?: SunburstValueMode;
|
|
16
|
+
sort?: SunburstSort;
|
|
17
|
+
level_lighten?: number;
|
|
18
|
+
min_fraction?: number;
|
|
19
|
+
other_label?: string;
|
|
20
|
+
max_depth?: number;
|
|
21
|
+
padding_inner?: number;
|
|
22
|
+
padding_top?: number;
|
|
23
|
+
padding_outer?: number;
|
|
24
|
+
show_labels?: boolean;
|
|
25
|
+
label_text?: SunburstLabelText;
|
|
26
|
+
label_formatter?: TreemapLabelFormatter<Metadata>;
|
|
27
|
+
label_fit?: TreemapLabelFit;
|
|
28
|
+
label_min_font_size?: number;
|
|
29
|
+
label_max_font_size?: number;
|
|
30
|
+
parent_label_font_size?: number;
|
|
31
|
+
zoom_on_click?: boolean;
|
|
32
|
+
zoom_root_id?: string | number | null;
|
|
33
|
+
show_breadcrumbs?: boolean;
|
|
34
|
+
color_values?: (rect: PositionedArc<Metadata>) => number | null;
|
|
35
|
+
color_scale?: D3InterpolateName;
|
|
36
|
+
color_range?: Vec2;
|
|
37
|
+
colorbar?: ComponentProps<typeof ColorBar> | null;
|
|
38
|
+
export_buttons?: boolean;
|
|
39
|
+
export_filename?: string;
|
|
40
|
+
tween?: Omit<TweenOptions<Rect[]>, `interpolate`>;
|
|
41
|
+
value_format?: string;
|
|
42
|
+
padding?: Sides;
|
|
43
|
+
legend?: LegendConfig | null;
|
|
44
|
+
show_legend?: boolean;
|
|
45
|
+
tooltip?: Snippet<[TreemapNodeHandlerProps<Metadata>]>;
|
|
46
|
+
cell_content?: Snippet<[{
|
|
47
|
+
arc: PositionedArc<Metadata>;
|
|
48
|
+
rect: Rect;
|
|
49
|
+
}]>;
|
|
50
|
+
change?: (data: TreemapNodeHandlerProps<Metadata> | null) => void;
|
|
51
|
+
on_node_click?: (data: TreemapNodeHandlerProps<Metadata> & {
|
|
52
|
+
event: MouseEvent | KeyboardEvent;
|
|
53
|
+
}) => void;
|
|
54
|
+
on_node_hover?: (data: (TreemapNodeHandlerProps<Metadata> & {
|
|
55
|
+
event: MouseEvent | FocusEvent;
|
|
56
|
+
}) | null) => void;
|
|
57
|
+
on_zoom?: (data: {
|
|
58
|
+
root: TreemapNodeHandlerProps<Metadata> | null;
|
|
59
|
+
}) => void;
|
|
60
|
+
header_controls?: Snippet<[{
|
|
61
|
+
height: number;
|
|
62
|
+
width: number;
|
|
63
|
+
fullscreen: boolean;
|
|
64
|
+
}]>;
|
|
65
|
+
controls_extra?: Snippet<[{
|
|
66
|
+
zoom_root_id: string | number | null;
|
|
67
|
+
}]>;
|
|
68
|
+
};
|
|
69
|
+
exports: {};
|
|
70
|
+
bindings: "show_controls" | "data" | "show_labels" | "fullscreen" | "hovered" | "controls_open" | "padding_inner" | "padding_top" | "padding_outer" | "value_mode" | "max_depth" | "min_fraction" | "label_text" | "zoom_on_click" | "show_breadcrumbs" | "zoom_root_id";
|
|
71
|
+
slots: {};
|
|
72
|
+
events: {};
|
|
73
|
+
};
|
|
74
|
+
declare class __sveltets_Render<Metadata extends Record<string, unknown> = Record<string, unknown>> {
|
|
75
|
+
props(): ReturnType<typeof $$render<Metadata>>['props'];
|
|
76
|
+
events(): ReturnType<typeof $$render<Metadata>>['events'];
|
|
77
|
+
slots(): ReturnType<typeof $$render<Metadata>>['slots'];
|
|
78
|
+
bindings(): "show_controls" | "data" | "show_labels" | "fullscreen" | "hovered" | "controls_open" | "padding_inner" | "padding_top" | "padding_outer" | "value_mode" | "max_depth" | "min_fraction" | "label_text" | "zoom_on_click" | "show_breadcrumbs" | "zoom_root_id";
|
|
79
|
+
exports(): {};
|
|
80
|
+
}
|
|
81
|
+
interface $$IsomorphicComponent {
|
|
82
|
+
new <Metadata extends Record<string, unknown> = Record<string, unknown>>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<Metadata>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<Metadata>['props']>, ReturnType<__sveltets_Render<Metadata>['events']>, ReturnType<__sveltets_Render<Metadata>['slots']>> & {
|
|
83
|
+
$$bindings?: ReturnType<__sveltets_Render<Metadata>['bindings']>;
|
|
84
|
+
} & ReturnType<__sveltets_Render<Metadata>['exports']>;
|
|
85
|
+
<Metadata extends Record<string, unknown> = Record<string, unknown>>(internal: unknown, props: ReturnType<__sveltets_Render<Metadata>['props']> & {}): ReturnType<__sveltets_Render<Metadata>['exports']>;
|
|
86
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
87
|
+
}
|
|
88
|
+
declare const Treemap: $$IsomorphicComponent;
|
|
89
|
+
type Treemap<Metadata extends Record<string, unknown> = Record<string, unknown>> = InstanceType<typeof Treemap<Metadata>>;
|
|
90
|
+
export default Treemap;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Rect } from '../core/layout';
|
|
2
|
+
import type { TreemapArc } from './treemap';
|
|
3
|
+
export type TreemapLabelFit = `hide` | `shrink` | `clip`;
|
|
4
|
+
export interface TreemapLabelLine {
|
|
5
|
+
text: string;
|
|
6
|
+
class?: string;
|
|
7
|
+
font_scale?: number;
|
|
8
|
+
font_weight?: string | number;
|
|
9
|
+
opacity?: number;
|
|
10
|
+
fill?: string;
|
|
11
|
+
}
|
|
12
|
+
type TreemapLabelContent = string | TreemapLabelLine | null | undefined;
|
|
13
|
+
export type TreemapLabelFormatter<Metadata extends Record<string, unknown> = Record<string, unknown>> = (arc: TreemapArc<Metadata>) => TreemapLabelContent | readonly TreemapLabelContent[];
|
|
14
|
+
export interface TreemapLabelPlacement {
|
|
15
|
+
x: number;
|
|
16
|
+
lines: (TreemapLabelLine & {
|
|
17
|
+
y: number;
|
|
18
|
+
})[];
|
|
19
|
+
font_size: number;
|
|
20
|
+
header: boolean;
|
|
21
|
+
dominant_baseline: `central`;
|
|
22
|
+
transform?: string;
|
|
23
|
+
}
|
|
24
|
+
interface TreemapLabelPlacementOptions {
|
|
25
|
+
rect: Rect;
|
|
26
|
+
lines: readonly TreemapLabelLine[];
|
|
27
|
+
header: boolean;
|
|
28
|
+
fit: TreemapLabelFit;
|
|
29
|
+
min_font_size: number;
|
|
30
|
+
max_font_size: number;
|
|
31
|
+
padding_top: number;
|
|
32
|
+
margin: number;
|
|
33
|
+
measure_line: (line: TreemapLabelLine, font_size: number) => number;
|
|
34
|
+
}
|
|
35
|
+
export declare const safe_font_size: (font_size: number, fallback: number) => number;
|
|
36
|
+
export declare function normalize_treemap_label_lines(content: ReturnType<TreemapLabelFormatter>): TreemapLabelLine[];
|
|
37
|
+
export declare function place_treemap_label({ rect, lines, header, fit, min_font_size, max_font_size, padding_top, margin, measure_line, }: TreemapLabelPlacementOptions): TreemapLabelPlacement | null;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const LINE_HEIGHT = 1.1;
|
|
2
|
+
const MIN_FONT_SIZE = 0.5;
|
|
3
|
+
const MIN_FONT_SCALE = 0.05;
|
|
4
|
+
// Coerce a user-provided font size to a usable px value (0.5px floor guards
|
|
5
|
+
// against zero/negative sizes; non-finite input falls back)
|
|
6
|
+
export const safe_font_size = (font_size, fallback) => Number.isFinite(font_size) ? Math.max(MIN_FONT_SIZE, font_size) : fallback;
|
|
7
|
+
export function normalize_treemap_label_lines(content) {
|
|
8
|
+
if (content == null)
|
|
9
|
+
return [];
|
|
10
|
+
const lines = Array.isArray(content) ? content : [content];
|
|
11
|
+
return lines.flatMap((line) => {
|
|
12
|
+
const normalized = typeof line === `string` ? { text: line } : line;
|
|
13
|
+
return normalized?.text ? [{ ...normalized }] : [];
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
const line_scale = (line) => Number.isFinite(line.font_scale) ? Math.max(MIN_FONT_SCALE, line.font_scale ?? 1) : 1;
|
|
17
|
+
function block_metrics(lines, font_size, measure_line) {
|
|
18
|
+
let width = 0;
|
|
19
|
+
let height = 0;
|
|
20
|
+
for (const line of lines) {
|
|
21
|
+
const line_font_size = font_size * line_scale(line);
|
|
22
|
+
width = Math.max(width, measure_line(line, line_font_size));
|
|
23
|
+
height += line_font_size * LINE_HEIGHT;
|
|
24
|
+
}
|
|
25
|
+
return { width, height };
|
|
26
|
+
}
|
|
27
|
+
export function place_treemap_label({ rect, lines, header, fit, min_font_size, max_font_size, padding_top, margin, measure_line, }) {
|
|
28
|
+
if (lines.length === 0)
|
|
29
|
+
return null;
|
|
30
|
+
const safe_max_font_size = safe_font_size(max_font_size, 11);
|
|
31
|
+
const safe_min_font_size = Math.min(safe_max_font_size, safe_font_size(min_font_size, MIN_FONT_SIZE));
|
|
32
|
+
const header_height = Math.min(rect.height, padding_top);
|
|
33
|
+
const available_width = Math.max(0, rect.width - 2 * margin);
|
|
34
|
+
const label_height = header ? header_height : rect.height;
|
|
35
|
+
const available_height = Math.max(0, label_height - 2 * (header ? 1 : margin));
|
|
36
|
+
// Single guard for all degenerate geometry (zero/negative/NaN rects, missing
|
|
37
|
+
// header strips, margin-swallowed slivers): negated > 0 so NaN also bails
|
|
38
|
+
// instead of emitting NaN SVG coordinates, same idiom as tile_rects.
|
|
39
|
+
if (!(available_width > 0) || !(available_height > 0))
|
|
40
|
+
return null;
|
|
41
|
+
const max_metrics = block_metrics(lines, safe_max_font_size, measure_line);
|
|
42
|
+
const fit_ratio = (block_width, block_height) => block_width > 0 && block_height > 0
|
|
43
|
+
? Math.min(1, available_width / block_width, available_height / block_height)
|
|
44
|
+
: 0;
|
|
45
|
+
const horizontal_ratio = fit_ratio(max_metrics.width, max_metrics.height);
|
|
46
|
+
// rotated 90°: the block's width runs along the cell's height (swapped args)
|
|
47
|
+
const vertical_ratio = header ? 0 : fit_ratio(max_metrics.height, max_metrics.width);
|
|
48
|
+
const rotated = vertical_ratio > horizontal_ratio;
|
|
49
|
+
const best_ratio = Math.max(horizontal_ratio, vertical_ratio);
|
|
50
|
+
if (fit === `hide` && best_ratio < 1)
|
|
51
|
+
return null;
|
|
52
|
+
const font_size = fit === `shrink`
|
|
53
|
+
? Math.max(safe_min_font_size, safe_max_font_size * best_ratio)
|
|
54
|
+
: safe_max_font_size;
|
|
55
|
+
// text metrics scale linearly with font size, so the block height at the
|
|
56
|
+
// final size derives from the max-size measurement — no re-measuring (which
|
|
57
|
+
// would miss the width cache on every frame of a zoom tween in shrink mode,
|
|
58
|
+
// since the fitted size varies continuously with the animated rect)
|
|
59
|
+
const block_height = max_metrics.height * (font_size / safe_max_font_size);
|
|
60
|
+
const center_x = rect.x + rect.width / 2;
|
|
61
|
+
const center_y = rect.y + label_height / 2;
|
|
62
|
+
const x = header ? rect.x + margin : center_x;
|
|
63
|
+
let line_top = center_y - block_height / 2;
|
|
64
|
+
const placed_lines = lines.map((line) => {
|
|
65
|
+
const font_scale = line_scale(line);
|
|
66
|
+
const line_height = font_size * font_scale * LINE_HEIGHT;
|
|
67
|
+
line_top += line_height / 2;
|
|
68
|
+
const y = line_top;
|
|
69
|
+
line_top += line_height / 2;
|
|
70
|
+
return { ...line, font_scale, y };
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
x,
|
|
74
|
+
lines: placed_lines,
|
|
75
|
+
font_size,
|
|
76
|
+
header,
|
|
77
|
+
dominant_baseline: `central`,
|
|
78
|
+
...(rotated ? { transform: `rotate(-90, ${center_x}, ${center_y})` } : {}),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Rect } from '../core/layout';
|
|
2
|
+
import type { PositionedArc, SunburstLayoutOptions, SunburstNode, SunburstNodeHandlerProps, SunburstSort } from '../sunburst/sunburst';
|
|
3
|
+
export type TreemapNode<Metadata = Record<string, unknown>> = SunburstNode<Metadata>;
|
|
4
|
+
export type TreemapArc<Metadata = Record<string, unknown>> = PositionedArc<Metadata>;
|
|
5
|
+
export type TreemapNodeHandlerProps<Metadata = Record<string, unknown>> = SunburstNodeHandlerProps<Metadata>;
|
|
6
|
+
export interface TreemapLayoutOptions extends Omit<SunburstLayoutOptions, `sort`> {
|
|
7
|
+
sort?: SunburstSort;
|
|
8
|
+
}
|
|
9
|
+
export interface TilePadding {
|
|
10
|
+
padding_inner: number;
|
|
11
|
+
padding_top: number;
|
|
12
|
+
padding_outer: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function tile_rects<Metadata>(arcs: readonly PositionedArc<Metadata>[], root_idx: number, size: {
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
}, pad: TilePadding): Rect[];
|
|
18
|
+
export declare function lerp_rects(prev: readonly Rect[], next: readonly Rect[], t: number): Rect[];
|
|
19
|
+
export interface TreemapLayoutResult<Metadata = Record<string, unknown>> {
|
|
20
|
+
arcs: TreemapArc<Metadata>[];
|
|
21
|
+
rects: Rect[];
|
|
22
|
+
root: TreemapArc<Metadata> | null;
|
|
23
|
+
max_depth: number;
|
|
24
|
+
}
|
|
25
|
+
export declare function compute_treemap_layout<Metadata = Record<string, unknown>>(data: TreemapNode<Metadata> | TreemapNode<Metadata>[], size: {
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
}, opts?: TreemapLayoutOptions & Partial<TilePadding>): TreemapLayoutResult<Metadata>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// Layout helpers for Treemap charts. All tree semantics (value modes, sorting,
|
|
2
|
+
// 'Other' bucketing, color inheritance, stable ids, pre-order indexing) are
|
|
3
|
+
// delegated to compute_sunburst_layout — a treemap is the same hierarchy with
|
|
4
|
+
// squarified pixel rects instead of polar partition coordinates, so the two
|
|
5
|
+
// charts share data builders (sunburst_from_paths, chem_sys_sunburst_data, …)
|
|
6
|
+
// and value semantics (plotly branchvalues) by construction.
|
|
7
|
+
import { hierarchy, treemap, treemapSquarify } from 'd3-hierarchy';
|
|
8
|
+
import { compute_sunburst_layout } from '../sunburst/sunburst';
|
|
9
|
+
import { DEFAULTS } from '../../settings';
|
|
10
|
+
// Fresh object per call: returned rect arrays hand these to consumers, and a
|
|
11
|
+
// shared constant would let mutating one zero rect corrupt every other one
|
|
12
|
+
const zero_rect = () => ({ x: 0, y: 0, width: 0, height: 0 });
|
|
13
|
+
// Squarify the subtree under arcs[root_idx] into pixel rects filling `size`.
|
|
14
|
+
// Returns an array aligned with `arcs` by node_idx (nodes outside the subtree
|
|
15
|
+
// get zero rects). Separate from tree-semantics so zooming re-tiles the new
|
|
16
|
+
// root's subtree to the full viewport (plotly behavior) — unlike the sunburst's
|
|
17
|
+
// size-independent partition, squarified tiling depends on the target aspect
|
|
18
|
+
// ratio, so projecting one fixed layout through a zoom window would distort
|
|
19
|
+
// cells and scale up the fixed-px header strips.
|
|
20
|
+
export function tile_rects(arcs, root_idx, size, pad) {
|
|
21
|
+
const rects = arcs.map(zero_rect);
|
|
22
|
+
const root_arc = arcs[root_idx];
|
|
23
|
+
if (!root_arc || !(size.width > 0) || !(size.height > 0))
|
|
24
|
+
return rects;
|
|
25
|
+
// Rebuild the (already value-resolved, sorted and bucketed) subtree from the
|
|
26
|
+
// flat pre-order arcs: children of arc N are the top-level subtree ranges in
|
|
27
|
+
// (N, N.subtree_end].
|
|
28
|
+
const children_of = (arc) => {
|
|
29
|
+
const kids = [];
|
|
30
|
+
for (let idx = arc.node_idx + 1; idx <= arc.subtree_end; idx = arcs[idx].subtree_end + 1) {
|
|
31
|
+
kids.push(arcs[idx]);
|
|
32
|
+
}
|
|
33
|
+
return kids;
|
|
34
|
+
};
|
|
35
|
+
const root = hierarchy(root_arc, children_of);
|
|
36
|
+
// Values are assigned manually (the documented d3 way to bypass .sum()) so all
|
|
37
|
+
// three value modes carry over — with 'total', children summing to less than
|
|
38
|
+
// their parent leave unfilled space in the parent cell, matching plotly.
|
|
39
|
+
// Non-finite/negative values would make d3's tiling emit NaN/out-of-bounds
|
|
40
|
+
// rects; coerce them to zero-size instead of corrupting the whole chart.
|
|
41
|
+
root.each((node) => {
|
|
42
|
+
const { value } = node.data;
|
|
43
|
+
node.value = Number.isFinite(value) && value >= 0 ? value : 0;
|
|
44
|
+
});
|
|
45
|
+
const tiled = treemap()
|
|
46
|
+
.tile(treemapSquarify)
|
|
47
|
+
.size([size.width, size.height])
|
|
48
|
+
.paddingInner(pad.padding_inner)
|
|
49
|
+
// inset children within branch cells below the tiling root (the root fills
|
|
50
|
+
// the viewport and is labeled by breadcrumbs, not a frame + header) …
|
|
51
|
+
.paddingOuter((node) => (node.depth > 0 ? pad.padding_outer : 0))
|
|
52
|
+
// … with the top inset enlarged into the label header strip. paddingTop is
|
|
53
|
+
// applied after paddingOuter, overriding its top component.
|
|
54
|
+
.paddingTop((node) => node.depth > 0 && node.children ? Math.max(pad.padding_top, pad.padding_outer) : 0)(root);
|
|
55
|
+
// Clamp to the tiling area: with value_mode 'total', children exceeding their
|
|
56
|
+
// parent's value overflow the parent rect (d3 scales children by parent value;
|
|
57
|
+
// compute_sunburst_layout warns). Clamping keeps overflow inside the chart,
|
|
58
|
+
// mirroring the sunburst's clamp01 window projection.
|
|
59
|
+
const clamp_x = (val) => Math.min(Math.max(val, 0), size.width);
|
|
60
|
+
const clamp_y = (val) => Math.min(Math.max(val, 0), size.height);
|
|
61
|
+
tiled.each((node) => {
|
|
62
|
+
const x = clamp_x(node.x0);
|
|
63
|
+
const y = clamp_y(node.y0);
|
|
64
|
+
rects[node.data.node_idx] = {
|
|
65
|
+
x,
|
|
66
|
+
y,
|
|
67
|
+
width: Math.max(0, clamp_x(node.x1) - x),
|
|
68
|
+
height: Math.max(0, clamp_y(node.y1) - y),
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
return rects;
|
|
72
|
+
}
|
|
73
|
+
// Interpolate between two tilings (zoom animation). Rects are aligned by
|
|
74
|
+
// node_idx; frames allocate one array but reuse rect objects at t = 0/1.
|
|
75
|
+
export function lerp_rects(prev, next, t) {
|
|
76
|
+
if (t >= 1 || prev.length !== next.length)
|
|
77
|
+
return next;
|
|
78
|
+
if (t <= 0)
|
|
79
|
+
return prev;
|
|
80
|
+
return next.map((to, idx) => {
|
|
81
|
+
const from = prev[idx];
|
|
82
|
+
return {
|
|
83
|
+
x: from.x + (to.x - from.x) * t,
|
|
84
|
+
y: from.y + (to.y - from.y) * t,
|
|
85
|
+
width: from.width + (to.width - from.width) * t,
|
|
86
|
+
height: from.height + (to.height - from.height) * t,
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
// One-shot semantic layout + root tiling (tests and non-zooming callers; the
|
|
91
|
+
// component calls compute_sunburst_layout and tile_rects separately so zoom
|
|
92
|
+
// re-tiles without recomputing tree semantics).
|
|
93
|
+
export function compute_treemap_layout(data, size, opts = {}) {
|
|
94
|
+
// padding fallbacks derive from DEFAULTS.treemap to prevent drift with the component
|
|
95
|
+
const { padding_inner = DEFAULTS.treemap.padding_inner, padding_top = DEFAULTS.treemap.padding_top, padding_outer = DEFAULTS.treemap.padding_outer,
|
|
96
|
+
// descending (matching the Treemap component): squarified tiling reads best
|
|
97
|
+
// with the largest cell top-left and smallest bottom-right
|
|
98
|
+
sort = `descending`, ...tree_opts } = opts;
|
|
99
|
+
const { arcs, root, max_depth } = compute_sunburst_layout(data, { sort, ...tree_opts });
|
|
100
|
+
const rects = tile_rects(arcs, 0, size, { padding_inner, padding_top, padding_outer });
|
|
101
|
+
return { arcs, rects, root, max_depth };
|
|
102
|
+
}
|
package/dist/rdf/RdfPlot.svelte
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
y_axis = {},
|
|
22
22
|
cutoff = 15,
|
|
23
23
|
n_bins = 75,
|
|
24
|
-
pbc
|
|
24
|
+
pbc,
|
|
25
25
|
enable_drop = false,
|
|
26
26
|
on_file_drop,
|
|
27
27
|
loading = $bindable(false),
|
|
@@ -56,9 +56,7 @@
|
|
|
56
56
|
|
|
57
57
|
const compute_and_add = (content: string | ArrayBuffer, filename: string) => {
|
|
58
58
|
try {
|
|
59
|
-
const text = content instanceof ArrayBuffer
|
|
60
|
-
? new TextDecoder().decode(content)
|
|
61
|
-
: content
|
|
59
|
+
const text = content instanceof ArrayBuffer ? new TextDecoder().decode(content) : content
|
|
62
60
|
const parsed_struct = parse_any_structure(text, filename)
|
|
63
61
|
if (is_crystal(parsed_struct)) {
|
|
64
62
|
drag_dropped = [...drag_dropped, parsed_struct]
|
|
@@ -66,16 +64,13 @@
|
|
|
66
64
|
error_msg = `Crystal has no lattice or sites; cannot compute RDF`
|
|
67
65
|
}
|
|
68
66
|
} catch (exc) {
|
|
69
|
-
error_msg = `Failed to process structure: ${
|
|
70
|
-
to_error(exc).message
|
|
71
|
-
}`
|
|
67
|
+
error_msg = `Failed to process structure: ${to_error(exc).message}`
|
|
72
68
|
}
|
|
73
69
|
}
|
|
74
70
|
|
|
75
71
|
const handle_drop = create_file_drop_handler({
|
|
76
72
|
allow: () => enable_drop,
|
|
77
|
-
on_drop: (content, filename) =>
|
|
78
|
-
(on_file_drop || compute_and_add)(content, filename),
|
|
73
|
+
on_drop: (content, filename) => (on_file_drop || compute_and_add)(content, filename),
|
|
79
74
|
on_error: (msg) => {
|
|
80
75
|
error_msg = msg
|
|
81
76
|
},
|
|
@@ -85,57 +80,43 @@
|
|
|
85
80
|
},
|
|
86
81
|
})
|
|
87
82
|
|
|
88
|
-
function handle_dragover(
|
|
89
|
-
|
|
90
|
-
if (
|
|
83
|
+
function handle_dragover(event: DragEvent) {
|
|
84
|
+
event.preventDefault()
|
|
85
|
+
if (event.dataTransfer) event.dataTransfer.dropEffect = `copy`
|
|
91
86
|
dragging = true
|
|
92
87
|
}
|
|
93
88
|
|
|
94
89
|
const entries = $derived.by(() => {
|
|
95
|
-
const result: RdfEntry[] =
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
struct,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
)
|
|
113
|
-
} else if (is_crystal(structures)) {
|
|
114
|
-
struct_list.push({
|
|
115
|
-
struct: structures,
|
|
116
|
-
label: format_structure_label(structures, ``),
|
|
117
|
-
})
|
|
118
|
-
} else {
|
|
119
|
-
Object.entries(structures).forEach(([label, struct]) =>
|
|
120
|
-
struct_list.push({ struct, label: format_structure_label(struct, label) })
|
|
121
|
-
)
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
drag_dropped.forEach((struct, idx) =>
|
|
125
|
-
struct_list.push({
|
|
126
|
-
struct,
|
|
127
|
-
label: format_structure_label(struct, `Dropped ${idx + 1}`),
|
|
128
|
-
})
|
|
129
|
-
)
|
|
90
|
+
const result: RdfEntry[] = patterns
|
|
91
|
+
? Array.isArray(patterns)
|
|
92
|
+
? [...patterns]
|
|
93
|
+
: [patterns]
|
|
94
|
+
: []
|
|
95
|
+
|
|
96
|
+
// Normalize structures prop (single, array, or dict) plus dropped files to labeled list
|
|
97
|
+
const struct_list = [
|
|
98
|
+
...(!structures
|
|
99
|
+
? []
|
|
100
|
+
: Array.isArray(structures)
|
|
101
|
+
? structures.map((struct, idx) => ({ struct, base: `Crystal ${idx + 1}` }))
|
|
102
|
+
: is_crystal(structures)
|
|
103
|
+
? [{ struct: structures, base: `` }]
|
|
104
|
+
: Object.entries(structures).map(([base, struct]) => ({ struct, base }))),
|
|
105
|
+
...drag_dropped.map((struct, idx) => ({ struct, base: `Dropped ${idx + 1}` })),
|
|
106
|
+
].map(({ struct, base }) => ({ struct, label: format_structure_label(struct, base) }))
|
|
130
107
|
|
|
131
108
|
for (const { struct, label } of struct_list) {
|
|
132
109
|
if (mode === `element_pairs`) {
|
|
133
110
|
const pairs = calculate_all_pair_rdfs(struct, { cutoff, n_bins, pbc })
|
|
134
|
-
result.push(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
111
|
+
result.push(
|
|
112
|
+
...pairs.map((pair) => ({
|
|
113
|
+
label: pair.element_pair
|
|
114
|
+
? `${pair.element_pair[0]}-${pair.element_pair[1]}`
|
|
115
|
+
: label,
|
|
116
|
+
legend_group: label, // Group by structure name for multi-structure plots
|
|
117
|
+
pattern: pair,
|
|
118
|
+
})),
|
|
119
|
+
)
|
|
139
120
|
} else {
|
|
140
121
|
const pattern = calculate_rdf(struct, { cutoff, n_bins, pbc })
|
|
141
122
|
result.push({ label, pattern })
|
|
@@ -146,7 +127,6 @@
|
|
|
146
127
|
|
|
147
128
|
const max_r = $derived(Math.max(...entries.flatMap((entry) => entry.pattern.r), 0))
|
|
148
129
|
const max_g = $derived(Math.max(1.2, ...entries.flatMap((entry) => entry.pattern.g_r)))
|
|
149
|
-
|
|
150
130
|
const series = $derived<DataSeries[]>(
|
|
151
131
|
entries.map((ent, idx) => ({
|
|
152
132
|
x: ent.pattern.r,
|
|
@@ -182,8 +162,8 @@
|
|
|
182
162
|
>
|
|
183
163
|
<StatusMessage
|
|
184
164
|
message={enable_drop
|
|
185
|
-
|
|
186
|
-
|
|
165
|
+
? `Drag and drop structure files here to visualize RDFs`
|
|
166
|
+
: `No RDF data to display`}
|
|
187
167
|
style="border: none"
|
|
188
168
|
/>
|
|
189
169
|
</div>
|
|
@@ -194,7 +174,7 @@
|
|
|
194
174
|
x_axis={{ label: `r (Å)`, range: [0, max_r], ...x_axis }}
|
|
195
175
|
y_axis={{ label: `g(r)`, range: [0, max_g * 1.05], ...y_axis }}
|
|
196
176
|
styles={{ show_lines: true, show_points: false }}
|
|
197
|
-
class=
|
|
177
|
+
class={[rest.class, dragging && `dragging`]}
|
|
198
178
|
style={rest.style ?? `height: 400px;`}
|
|
199
179
|
ondragover={enable_drop ? handle_dragover : undefined}
|
|
200
180
|
ondragleave={enable_drop ? () => (dragging = false) : undefined}
|
|
@@ -207,9 +187,7 @@
|
|
|
207
187
|
{@const [x1, x2] = [pad.l, width - pad.r]}
|
|
208
188
|
{@const [x, y] = [width - pad.r - 5, y1 - 5]}
|
|
209
189
|
<line {x1} {x2} {y1} y2={y1} stroke="gray" stroke-dasharray="4" opacity="0.5" />
|
|
210
|
-
<text {x} {y} text-anchor="end" fill="gray" font-size="0.8em">
|
|
211
|
-
g(r) = 1
|
|
212
|
-
</text>
|
|
190
|
+
<text {x} {y} text-anchor="end" fill="gray" font-size="0.8em"> g(r) = 1 </text>
|
|
213
191
|
{/if}
|
|
214
192
|
{/if}
|
|
215
193
|
{/snippet}
|
|
@@ -22,6 +22,6 @@ type $$ComponentProps = {
|
|
|
22
22
|
drag_dropped?: Crystal[];
|
|
23
23
|
dragging?: boolean;
|
|
24
24
|
} & ComponentProps<typeof ScatterPlot>;
|
|
25
|
-
declare const RdfPlot: import("svelte").Component<$$ComponentProps, {}, "
|
|
25
|
+
declare const RdfPlot: import("svelte").Component<$$ComponentProps, {}, "dragging" | "loading" | "error_msg" | "drag_dropped">;
|
|
26
26
|
type RdfPlot = ReturnType<typeof RdfPlot>;
|
|
27
27
|
export default RdfPlot;
|