matterviz 0.4.0 → 0.4.2
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 +12 -14
- package/dist/Icon.svelte +7 -4
- package/dist/MillerIndexInput.svelte +2 -2
- package/dist/app.css +53 -0
- package/dist/brillouin/BrillouinZone.svelte +132 -219
- package/dist/brillouin/BrillouinZone.svelte.d.ts +9 -20
- package/dist/brillouin/BrillouinZoneControls.svelte +3 -6
- package/dist/brillouin/BrillouinZoneExportPane.svelte +47 -96
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +15 -42
- package/dist/brillouin/BrillouinZoneInfoPane.svelte.d.ts +2 -3
- package/dist/brillouin/BrillouinZoneScene.svelte +63 -230
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +3 -23
- package/dist/brillouin/ReciprocalVectors.svelte +39 -0
- package/dist/brillouin/ReciprocalVectors.svelte.d.ts +9 -0
- package/dist/brillouin/compute.d.ts +2 -0
- package/dist/brillouin/compute.js +80 -77
- package/dist/brillouin/geometry.d.ts +8 -0
- package/dist/brillouin/geometry.js +57 -0
- package/dist/brillouin/index.d.ts +2 -0
- package/dist/brillouin/index.js +2 -0
- package/dist/brillouin/types.d.ts +2 -2
- package/dist/chempot-diagram/ChemPotDiagram.svelte +33 -38
- package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +1 -1
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +143 -246
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +4 -1
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +652 -976
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +7 -1
- package/dist/chempot-diagram/async-compute.svelte.js +1 -1
- package/dist/chempot-diagram/color.d.ts +3 -6
- package/dist/chempot-diagram/color.js +5 -5
- package/dist/chempot-diagram/compute.d.ts +3 -3
- package/dist/chempot-diagram/compute.js +3 -1
- package/dist/chempot-diagram/controls-state.svelte.d.ts +10 -0
- package/dist/chempot-diagram/controls-state.svelte.js +42 -0
- package/dist/chempot-diagram/export.d.ts +47 -0
- package/dist/chempot-diagram/export.js +133 -0
- package/dist/chempot-diagram/index.d.ts +1 -0
- package/dist/chempot-diagram/index.js +1 -0
- package/dist/chempot-diagram/pointer.d.ts +0 -10
- package/dist/chempot-diagram/pointer.js +4 -4
- package/dist/chempot-diagram/types.d.ts +3 -3
- package/dist/colors/index.d.ts +0 -4
- package/dist/colors/index.js +21 -22
- package/dist/composition/BarChart.svelte +37 -31
- package/dist/composition/BubbleChart.svelte +17 -17
- package/dist/composition/Composition.svelte +7 -11
- package/dist/composition/Formula.svelte +18 -25
- package/dist/composition/FormulaFilter.svelte +96 -98
- package/dist/composition/PieChart.svelte +60 -46
- package/dist/composition/chem-sys.js +3 -2
- package/dist/composition/format.js +4 -3
- package/dist/composition/index.d.ts +2 -0
- package/dist/composition/index.js +14 -0
- package/dist/composition/parse.d.ts +2 -3
- package/dist/composition/parse.js +27 -28
- package/dist/constants.js +11 -9
- package/dist/controls.d.ts +1 -0
- package/dist/controls.js +0 -1
- package/dist/convex-hull/ConvexHull.svelte +20 -25
- package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -4
- package/dist/convex-hull/ConvexHull2D.svelte +176 -256
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull3D.svelte +269 -804
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull4D.svelte +236 -755
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullChrome.svelte +264 -0
- package/dist/convex-hull/ConvexHullChrome.svelte.d.ts +30 -0
- package/dist/convex-hull/ConvexHullControls.svelte +128 -49
- package/dist/convex-hull/ConvexHullControls.svelte.d.ts +7 -6
- package/dist/convex-hull/ConvexHullInfoPane.svelte +18 -5
- package/dist/convex-hull/ConvexHullInfoPane.svelte.d.ts +6 -5
- package/dist/convex-hull/ConvexHullStats.svelte +210 -351
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +3 -1
- package/dist/convex-hull/ConvexHullTooltip.svelte +16 -14
- package/dist/convex-hull/ConvexHullTooltip.svelte.d.ts +2 -1
- package/dist/convex-hull/GasPressureControls.svelte +5 -12
- package/dist/convex-hull/StructurePopup.svelte +17 -21
- package/dist/convex-hull/StructurePopup.svelte.d.ts +2 -0
- package/dist/convex-hull/TemperatureSlider.svelte +4 -10
- package/dist/convex-hull/barycentric-coords.d.ts +2 -4
- package/dist/convex-hull/barycentric-coords.js +6 -33
- package/dist/convex-hull/canvas-interactions.svelte.d.ts +79 -0
- package/dist/convex-hull/canvas-interactions.svelte.js +279 -0
- package/dist/convex-hull/helpers.d.ts +47 -17
- package/dist/convex-hull/helpers.js +186 -101
- package/dist/convex-hull/hull-state.svelte.d.ts +44 -0
- package/dist/convex-hull/hull-state.svelte.js +124 -0
- package/dist/convex-hull/index.d.ts +9 -7
- package/dist/convex-hull/index.js +7 -2
- package/dist/convex-hull/thermodynamics.js +109 -937
- package/dist/convex-hull/types.d.ts +12 -4
- package/dist/convex-hull/types.js +12 -0
- package/dist/coordination/CoordinationBarPlot.svelte +41 -43
- 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 +6 -8
- 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 +24 -29
- package/dist/element/ElementTile.svelte.d.ts +1 -1
- package/dist/element/Nucleus.svelte +4 -2
- package/dist/element/data.d.ts +1 -2
- package/dist/element/helpers.d.ts +4 -0
- package/dist/element/helpers.js +18 -0
- package/dist/element/index.d.ts +1 -0
- package/dist/element/index.js +3 -0
- package/dist/feedback/DragOverlay.svelte +5 -3
- package/dist/feedback/DragOverlay.svelte.d.ts +2 -1
- package/dist/feedback/StatusMessage.svelte +20 -7
- package/dist/fermi-surface/FermiSlice.svelte +21 -18
- package/dist/fermi-surface/FermiSurface.svelte +78 -165
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +9 -20
- package/dist/fermi-surface/FermiSurfaceControls.svelte +6 -20
- package/dist/fermi-surface/FermiSurfaceScene.svelte +93 -272
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +3 -23
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +9 -6
- package/dist/fermi-surface/compute.js +14 -13
- package/dist/fermi-surface/export.js +4 -15
- package/dist/fermi-surface/index.d.ts +0 -1
- package/dist/fermi-surface/index.js +0 -1
- package/dist/fermi-surface/parse.d.ts +1 -1
- package/dist/fermi-surface/parse.js +84 -97
- package/dist/fermi-surface/types.d.ts +2 -2
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +161 -185
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +6 -5
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +12 -9
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +5 -5
- package/dist/heatmap-matrix/index.d.ts +8 -2
- package/dist/icons.d.ts +4 -0
- package/dist/icons.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/io/ExportPane.svelte +170 -0
- package/dist/io/ExportPane.svelte.d.ts +17 -0
- package/dist/io/decompress.d.ts +2 -1
- package/dist/io/decompress.js +22 -36
- package/dist/io/export.d.ts +9 -1
- package/dist/io/export.js +37 -29
- package/dist/io/fetch.d.ts +2 -4
- package/dist/io/fetch.js +0 -11
- package/dist/io/file-drop.d.ts +7 -0
- package/dist/io/file-drop.js +13 -0
- package/dist/io/index.d.ts +1 -0
- package/dist/io/index.js +3 -0
- package/dist/io/is-binary.d.ts +9 -0
- package/dist/io/is-binary.js +45 -1
- package/dist/io/types.d.ts +13 -0
- package/dist/io/url-drop.js +13 -25
- package/dist/isosurface/Isosurface.svelte +17 -23
- package/dist/isosurface/IsosurfaceControls.svelte +37 -42
- package/dist/isosurface/parse-vaspwave.d.ts +3 -0
- package/dist/isosurface/parse-vaspwave.js +138 -0
- package/dist/isosurface/parse.js +50 -48
- package/dist/labels.d.ts +6 -2
- package/dist/labels.js +44 -14
- package/dist/layout/FullscreenButton.svelte +34 -0
- package/dist/layout/FullscreenButton.svelte.d.ts +10 -0
- package/dist/layout/FullscreenToggle.svelte +12 -12
- package/dist/layout/InfoCard.svelte +7 -18
- 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 +21 -17
- package/dist/layout/SubpageGrid.svelte +3 -1
- package/dist/layout/ViewerChrome.svelte +115 -0
- package/dist/layout/ViewerChrome.svelte.d.ts +18 -0
- package/dist/layout/fullscreen.d.ts +4 -0
- package/dist/layout/fullscreen.js +3 -5
- package/dist/layout/fullscreen.svelte.d.ts +8 -0
- package/dist/layout/fullscreen.svelte.js +36 -0
- package/dist/layout/index.d.ts +4 -0
- package/dist/layout/index.js +4 -0
- package/dist/layout/json-tree/JsonNode.svelte +8 -11
- package/dist/layout/json-tree/JsonTree.svelte +53 -77
- package/dist/layout/json-tree/JsonValue.svelte +7 -15
- package/dist/layout/json-tree/utils.js +14 -23
- package/dist/math.d.ts +9 -3
- package/dist/math.js +37 -21
- package/dist/overlays/ContextMenu.svelte +4 -2
- package/dist/overlays/CopyButton.svelte +11 -5
- package/dist/overlays/DragControlTab.svelte +6 -1
- package/dist/overlays/DraggablePane.svelte +81 -26
- package/dist/overlays/DraggablePane.svelte.d.ts +1 -0
- package/dist/overlays/GlassChip.svelte +30 -0
- package/dist/overlays/GlassChip.svelte.d.ts +8 -0
- package/dist/overlays/InfoPaneCards.svelte +11 -23
- package/dist/overlays/index.d.ts +11 -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 +115 -146
- package/dist/periodic-table/PeriodicTable.svelte.d.ts +5 -3
- package/dist/periodic-table/PeriodicTableControls.svelte +11 -63
- package/dist/periodic-table/TableInset.svelte +9 -4
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +50 -71
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -8
- package/dist/phase-diagram/PhaseDiagramControls.svelte +73 -96
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +4 -3
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +4 -2
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +2 -3
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +49 -134
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +3 -4
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +54 -58
- package/dist/phase-diagram/TdbInfoPanel.svelte +21 -15
- package/dist/phase-diagram/build-diagram.js +3 -3
- package/dist/phase-diagram/colors.js +1 -1
- package/dist/phase-diagram/diagram-input.d.ts +1 -2
- package/dist/phase-diagram/parse.d.ts +2 -1
- package/dist/phase-diagram/parse.js +15 -15
- package/dist/phase-diagram/svg-to-diagram.js +21 -15
- package/dist/phase-diagram/utils.js +2 -3
- package/dist/plot/bar/BarPlot.svelte +494 -692
- package/dist/plot/bar/BarPlot.svelte.d.ts +9 -15
- package/dist/plot/bar/BarPlotControls.svelte +1 -3
- package/dist/plot/bar/BarPlotControls.svelte.d.ts +5 -7
- package/dist/plot/bar/SpacegroupBarPlot.svelte +31 -37
- package/dist/plot/bar/data.d.ts +5 -4
- package/dist/plot/bar/data.js +2 -1
- package/dist/plot/box/BoxPlot.svelte +361 -439
- package/dist/plot/box/BoxPlot.svelte.d.ts +6 -3
- package/dist/plot/box/BoxPlotControls.svelte.d.ts +1 -1
- package/dist/plot/box/Violin.svelte.d.ts +2 -1
- package/dist/plot/box/box-plot.d.ts +3 -2
- package/dist/plot/box/box-plot.js +6 -3
- package/dist/plot/box/kde.d.ts +2 -1
- package/dist/plot/box/kde.js +4 -4
- package/dist/plot/core/auto-place.d.ts +1 -1
- package/dist/plot/core/auto-place.js +5 -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 +106 -111
- package/dist/plot/core/components/ColorBar.svelte.d.ts +5 -4
- 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 +21 -11
- package/dist/plot/core/components/Line.svelte.d.ts +5 -2
- package/dist/plot/core/components/PlotAxis.svelte +42 -18
- package/dist/plot/core/components/PlotAxis.svelte.d.ts +2 -1
- package/dist/plot/core/components/PlotControls.svelte +65 -41
- package/dist/plot/core/components/PlotControls.svelte.d.ts +1 -1
- 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 +56 -59
- package/dist/plot/core/components/ReferenceLine3D.svelte.d.ts +4 -4
- package/dist/plot/core/components/ReferencePlane.svelte +9 -10
- package/dist/plot/core/components/ReferencePlane.svelte.d.ts +4 -4
- 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 +29 -476
- package/dist/plot/core/data-transform.js +9 -5
- package/dist/plot/core/fill-utils.d.ts +7 -4
- package/dist/plot/core/fill-utils.js +34 -9
- package/dist/plot/core/index.d.ts +1 -0
- package/dist/plot/core/index.js +1 -0
- package/dist/plot/core/interactions.d.ts +5 -1
- package/dist/plot/core/interactions.js +14 -2
- package/dist/plot/core/layout.d.ts +3 -1
- package/dist/plot/core/layout.js +22 -13
- 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 +35 -0
- package/dist/plot/core/pan-zoom.svelte.js +221 -0
- package/dist/plot/core/placed-tween.svelte.d.ts +21 -0
- package/dist/plot/core/placed-tween.svelte.js +68 -0
- package/dist/plot/core/reference-line.d.ts +10 -10
- package/dist/plot/core/reference-line.js +7 -7
- package/dist/plot/core/scales.d.ts +40 -25
- package/dist/plot/core/scales.js +49 -21
- package/dist/plot/core/svg.d.ts +2 -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 +47 -331
- package/dist/plot/core/types.js +23 -20
- package/dist/plot/core/utils/hierarchy-chart.d.ts +51 -0
- package/dist/plot/core/utils/hierarchy-chart.js +179 -0
- package/dist/plot/core/utils/hierarchy-labels.d.ts +20 -0
- package/dist/plot/core/utils/hierarchy-labels.js +99 -0
- package/dist/plot/core/utils/label-placement.d.ts +1 -1
- package/dist/plot/core/utils/label-placement.js +5 -5
- package/dist/plot/core/utils.d.ts +2 -1
- package/dist/plot/histogram/Histogram.svelte +373 -631
- package/dist/plot/histogram/Histogram.svelte.d.ts +7 -7
- package/dist/plot/histogram/HistogramControls.svelte +30 -28
- package/dist/plot/histogram/HistogramControls.svelte.d.ts +1 -1
- 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 +79 -73
- package/dist/plot/sankey/Sankey.svelte.d.ts +3 -3
- package/dist/plot/sankey/SankeyControls.svelte +22 -16
- package/dist/plot/sankey/sankey.js +3 -1
- package/dist/plot/scatter/BinnedScatterPlot.svelte +264 -112
- package/dist/plot/scatter/BinnedScatterPlot.svelte.d.ts +11 -4
- package/dist/plot/scatter/ElementScatter.svelte +4 -1
- package/dist/plot/scatter/ScatterPlot.svelte +623 -821
- package/dist/plot/scatter/ScatterPlot.svelte.d.ts +9 -15
- 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/binned-scatter-types.d.ts +6 -12
- package/dist/plot/scatter/binned-scatter-types.js +6 -1
- package/dist/plot/scatter/index.d.ts +1 -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 +40 -60
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte.d.ts +6 -14
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte +17 -15
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte.d.ts +5 -5
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte +232 -234
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte.d.ts +5 -14
- package/dist/plot/scatter-3d/Surface3D.svelte +9 -17
- package/dist/plot/scatter-3d/Surface3D.svelte.d.ts +4 -3
- package/dist/plot/sunburst/Sunburst.svelte +256 -338
- package/dist/plot/sunburst/Sunburst.svelte.d.ts +4 -3
- 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 +14 -4
- package/dist/plot/treemap/Treemap.svelte +907 -0
- package/dist/plot/treemap/Treemap.svelte.d.ts +84 -0
- package/dist/plot/treemap/index.d.ts +3 -0
- package/dist/plot/treemap/index.js +4 -0
- package/dist/plot/treemap/treemap.d.ts +26 -0
- package/dist/plot/treemap/treemap.js +99 -0
- package/dist/rdf/RdfPlot.svelte +22 -26
- package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
- package/dist/rdf/calc-rdf.js +4 -8
- package/dist/sanitize.js +14 -3
- package/dist/scene/SceneCamera.svelte +62 -0
- package/dist/scene/SceneCamera.svelte.d.ts +19 -0
- package/dist/scene/bind-renderer.svelte.d.ts +2 -0
- package/dist/scene/bind-renderer.svelte.js +22 -0
- package/dist/scene/index.d.ts +4 -0
- package/dist/scene/index.js +5 -0
- package/dist/scene/props.js +52 -0
- package/dist/scene/types.d.ts +26 -0
- package/dist/scene/types.js +1 -0
- package/dist/settings.d.ts +33 -11
- package/dist/settings.js +136 -51
- package/dist/spectral/Bands.svelte +231 -237
- package/dist/spectral/Bands.svelte.d.ts +3 -2
- package/dist/spectral/BandsAndDos.svelte +29 -29
- package/dist/spectral/BrillouinBandsDos.svelte +21 -29
- package/dist/spectral/Dos.svelte +75 -77
- package/dist/spectral/Dos.svelte.d.ts +2 -1
- package/dist/spectral/helpers.d.ts +9 -9
- package/dist/spectral/helpers.js +66 -70
- package/dist/state.svelte.d.ts +0 -7
- package/dist/state.svelte.js +5 -24
- package/dist/structure/Arrow.svelte +6 -21
- package/dist/structure/ArrowInstances.svelte +160 -0
- package/dist/structure/ArrowInstances.svelte.d.ts +16 -0
- package/dist/structure/AtomLegend.svelte +115 -75
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/Bond.svelte +31 -23
- package/dist/structure/CanvasTooltip.svelte +16 -3
- package/dist/structure/CellSelect.svelte +22 -29
- package/dist/structure/CellSelect.svelte.d.ts +2 -1
- 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 +725 -735
- package/dist/structure/Structure.svelte.d.ts +8 -16
- package/dist/structure/StructureCarousel.svelte +630 -0
- package/dist/structure/StructureCarousel.svelte.d.ts +19 -0
- package/dist/structure/StructureControls.svelte +298 -325
- package/dist/structure/StructureControls.svelte.d.ts +5 -3
- package/dist/structure/StructureExportPane.svelte +62 -168
- package/dist/structure/StructureExportPane.svelte.d.ts +4 -5
- package/dist/structure/StructureInfoPane.svelte +77 -69
- package/dist/structure/StructureInfoPane.svelte.d.ts +6 -6
- package/dist/structure/StructureScene.svelte +758 -600
- package/dist/structure/StructureScene.svelte.d.ts +24 -20
- package/dist/structure/StructureViewport.svelte +386 -0
- package/dist/structure/StructureViewport.svelte.d.ts +63 -0
- package/dist/structure/atom-label-placement.d.ts +18 -0
- package/dist/structure/atom-label-placement.js +115 -0
- package/dist/structure/atom-properties.d.ts +3 -1
- package/dist/structure/atom-properties.js +115 -54
- package/dist/structure/bond-order-perception.js +2 -4
- package/dist/structure/bonding.d.ts +12 -2
- package/dist/structure/bonding.js +172 -73
- package/dist/structure/edit-history.d.ts +6 -0
- package/dist/structure/edit-history.js +27 -0
- package/dist/structure/export.d.ts +25 -4
- package/dist/structure/export.js +103 -153
- package/dist/structure/format-detect.d.ts +1 -0
- package/dist/structure/format-detect.js +22 -0
- package/dist/structure/geometry.d.ts +9 -0
- package/dist/structure/geometry.js +27 -0
- package/dist/structure/index.d.ts +18 -1
- package/dist/structure/index.js +15 -2
- package/dist/structure/measure.d.ts +1 -1
- package/dist/structure/measure.js +6 -12
- package/dist/structure/parse.d.ts +5 -3
- package/dist/structure/parse.js +551 -567
- package/dist/structure/partial-occupancy.d.ts +0 -1
- package/dist/structure/partial-occupancy.js +5 -3
- package/dist/structure/pbc.d.ts +1 -1
- package/dist/structure/pbc.js +204 -51
- package/dist/structure/polyhedra.d.ts +40 -0
- package/dist/structure/polyhedra.js +587 -0
- package/dist/structure/site.d.ts +4 -0
- package/dist/structure/site.js +1 -0
- package/dist/structure/supercell.d.ts +1 -2
- package/dist/structure/supercell.js +10 -15
- package/dist/structure/validation.js +5 -6
- package/dist/symmetry/SymmetryElementControls.svelte +69 -0
- package/dist/symmetry/SymmetryElementControls.svelte.d.ts +9 -0
- package/dist/symmetry/SymmetryElements.svelte +350 -0
- package/dist/symmetry/SymmetryElements.svelte.d.ts +24 -0
- package/dist/symmetry/SymmetryStats.svelte +142 -49
- package/dist/symmetry/WyckoffTable.svelte +58 -16
- package/dist/symmetry/WyckoffTable.svelte.d.ts +3 -0
- package/dist/symmetry/cell-transform.js +8 -14
- package/dist/symmetry/index.d.ts +15 -4
- package/dist/symmetry/index.js +308 -81
- package/dist/symmetry/spacegroups.d.ts +5 -1
- package/dist/symmetry/spacegroups.js +18 -3
- package/dist/symmetry/symmetry-elements.d.ts +33 -0
- package/dist/symmetry/symmetry-elements.js +521 -0
- package/dist/symmetry/wyckoff-db.d.ts +9 -0
- package/dist/symmetry/wyckoff-db.js +87 -0
- package/dist/table/HeatmapTable.svelte +1104 -378
- package/dist/table/HeatmapTable.svelte.d.ts +12 -2
- package/dist/table/ToggleMenu.svelte +5 -12
- 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/index.d.ts +1 -5
- package/dist/theme/index.js +4 -10
- package/dist/theme/themes.mjs +14 -7
- package/dist/tooltip/KCoords.svelte +4 -1
- package/dist/tooltip/TooltipContent.svelte +2 -5
- package/dist/trajectory/Trajectory.svelte +556 -352
- package/dist/trajectory/Trajectory.svelte.d.ts +10 -22
- package/dist/trajectory/TrajectoryError.svelte +11 -8
- package/dist/trajectory/TrajectoryExportPane.svelte +28 -54
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +4 -5
- package/dist/trajectory/TrajectoryInfoPane.svelte +88 -99
- package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +3 -2
- package/dist/trajectory/constants.js +6 -2
- package/dist/trajectory/extract.js +73 -71
- package/dist/trajectory/format-detect.d.ts +0 -1
- package/dist/trajectory/format-detect.js +13 -17
- package/dist/trajectory/frame-reader.d.ts +2 -1
- package/dist/trajectory/frame-reader.js +74 -136
- package/dist/trajectory/helpers.d.ts +12 -2
- package/dist/trajectory/helpers.js +68 -37
- package/dist/trajectory/index.d.ts +1 -0
- package/dist/trajectory/index.js +3 -0
- package/dist/trajectory/parse/ase.d.ts +9 -1
- package/dist/trajectory/parse/ase.js +47 -32
- package/dist/trajectory/parse/diagnostics.d.ts +3 -0
- package/dist/trajectory/parse/diagnostics.js +14 -0
- 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 +3 -4
- package/dist/trajectory/parse/index.js +68 -119
- package/dist/trajectory/parse/lammps.d.ts +0 -2
- package/dist/trajectory/parse/lammps.js +14 -16
- package/dist/trajectory/parse/pymatgen.d.ts +2 -0
- package/dist/trajectory/parse/pymatgen.js +74 -0
- package/dist/trajectory/parse/vasp.js +13 -9
- 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 +5 -0
- package/dist/trajectory/parse/vaspout-h5.js +284 -0
- package/dist/trajectory/parse/xyz.d.ts +9 -21
- package/dist/trajectory/parse/xyz.js +38 -39
- package/dist/trajectory/plotting.d.ts +8 -10
- package/dist/trajectory/plotting.js +102 -127
- package/dist/utils.d.ts +4 -0
- package/dist/utils.js +8 -1
- package/dist/xrd/XrdPlot.svelte +56 -85
- package/dist/xrd/broadening.d.ts +2 -1
- package/dist/xrd/broadening.js +2 -1
- package/dist/xrd/calc-xrd.js +8 -15
- package/dist/xrd/index.d.ts +2 -2
- package/dist/xrd/parse.d.ts +0 -1
- package/dist/xrd/parse.js +56 -73
- package/package.json +77 -36
- package/dist/api/mp.d.ts +0 -6
- package/dist/api/mp.js +0 -22
- package/dist/element/data.json +0 -11864
- package/dist/fermi-surface/marching-cubes.d.ts +0 -2
- package/dist/fermi-surface/marching-cubes.js +0 -2
- package/dist/plot/core/hover-lock.svelte.d.ts +0 -14
- package/dist/plot/core/hover-lock.svelte.js +0 -45
- package/dist/plot/sunburst/SunburstControls.svelte +0 -200
- package/dist/structure/label-placement.d.ts +0 -14
- package/dist/structure/label-placement.js +0 -72
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// State/interaction helpers shared by the hierarchical part-of-whole charts
|
|
2
|
+
// (Sunburst, Treemap): metric coloring, hover/mute dimming, handler payloads,
|
|
3
|
+
// breadcrumbs and keyboard plumbing. All pure functions over the flat pre-order
|
|
4
|
+
// arc arrays that compute_sunburst_layout produces — each component keeps only
|
|
5
|
+
// its geometry-specific logic (polar projection vs squarified tiling).
|
|
6
|
+
import { get_relative_coords } from '../interactions';
|
|
7
|
+
import { create_color_scale } from '../scales';
|
|
8
|
+
import { node_display_name, node_label_variants } from './hierarchy-labels';
|
|
9
|
+
import { compute_sunburst_layout } from '../../sunburst/sunburst';
|
|
10
|
+
// Degrade to an empty layout (instead of crashing the host page) on invalid data
|
|
11
|
+
export function safe_hierarchy_layout(data, opts) {
|
|
12
|
+
try {
|
|
13
|
+
return compute_sunburst_layout(data, opts);
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
console.error(err);
|
|
17
|
+
return { arcs: [], root: null, max_depth: 0 };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
// Continuous metric coloring: when color_values is given, nodes are colored by
|
|
21
|
+
// their metric on a d3 colormap (nodes returning null keep their categorical
|
|
22
|
+
// color). The user accessor runs exactly once per node.
|
|
23
|
+
export function compute_metric_colors(arcs, color_values, color_scale, color_range) {
|
|
24
|
+
if (!color_values)
|
|
25
|
+
return null;
|
|
26
|
+
const vals = arcs.map((arc) => {
|
|
27
|
+
const val = arc.depth === 0 ? null : color_values(arc);
|
|
28
|
+
return val != null && Number.isFinite(val) ? val : null;
|
|
29
|
+
});
|
|
30
|
+
// iterative min/max: spreading into Math.min/max overflows the call stack
|
|
31
|
+
// for very large arc arrays
|
|
32
|
+
let min_val = Infinity;
|
|
33
|
+
let max_val = -Infinity;
|
|
34
|
+
for (const val of vals) {
|
|
35
|
+
if (val == null)
|
|
36
|
+
continue;
|
|
37
|
+
if (val < min_val)
|
|
38
|
+
min_val = val;
|
|
39
|
+
if (val > max_val)
|
|
40
|
+
max_val = val;
|
|
41
|
+
}
|
|
42
|
+
if (min_val > max_val)
|
|
43
|
+
return null; // no finite values
|
|
44
|
+
const range = color_range ?? [min_val, max_val];
|
|
45
|
+
const scale = create_color_scale({ scheme: color_scale, value_range: range }, range);
|
|
46
|
+
return {
|
|
47
|
+
range,
|
|
48
|
+
colors: vals.map((val, idx) => (val == null ? arcs[idx].color : scale(val))),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const MUTED_OPACITY = 0.12;
|
|
52
|
+
// Legend muting + hover dimming per node, indexed by node_idx. The hovered node
|
|
53
|
+
// + its ancestors/descendants stay fully opaque, other nodes dim to 0.3; muted
|
|
54
|
+
// categories dim hardest. Pre-order indexing makes the ancestor/descendant
|
|
55
|
+
// tests O(1): a subtree is the contiguous index range [node_idx, subtree_end].
|
|
56
|
+
// Zoom-independent: recomputed only when hover/mute state changes, so during
|
|
57
|
+
// zoom tweens (where geometry re-evaluates per frame) this is an array lookup.
|
|
58
|
+
export function compute_node_dim(arcs, muted_ids, hovered_idx) {
|
|
59
|
+
const hov = hovered_idx != null ? arcs[hovered_idx] : null;
|
|
60
|
+
const active = (arc) => !hov ||
|
|
61
|
+
(arc.node_idx >= hov.node_idx && arc.node_idx <= hov.subtree_end) ||
|
|
62
|
+
(hov.node_idx >= arc.node_idx && hov.node_idx <= arc.subtree_end);
|
|
63
|
+
return arcs.map((arc) => {
|
|
64
|
+
const muted = arc.path.length > 0 && muted_ids.has(arc.path[0]);
|
|
65
|
+
return {
|
|
66
|
+
opacity: muted ? MUTED_OPACITY : active(arc) ? 1 : 0.3,
|
|
67
|
+
// labels dim only when muted, not when hover-inactive (undefined omits the attr)
|
|
68
|
+
label_opacity: muted ? MUTED_OPACITY : undefined,
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
// Drop muted ids that no longer exist in the current layout (e.g. after a data swap)
|
|
73
|
+
export function prune_muted_ids(arcs, muted_ids) {
|
|
74
|
+
const valid = new Set(arcs.filter((arc) => arc.depth === 1).map((arc) => arc.id));
|
|
75
|
+
for (const id of muted_ids)
|
|
76
|
+
if (!valid.has(id))
|
|
77
|
+
muted_ids.delete(id);
|
|
78
|
+
}
|
|
79
|
+
// Toggle one depth-1 category's muted state (legend click)
|
|
80
|
+
export function toggle_muted(muted_ids, id) {
|
|
81
|
+
if (id !== undefined && !muted_ids.delete(id))
|
|
82
|
+
muted_ids.add(id);
|
|
83
|
+
}
|
|
84
|
+
// Legend: one item per depth-1 category; toggling mutes (dims) rather than removes
|
|
85
|
+
export function hierarchy_legend_items(depth1_arcs, muted_ids, color_for) {
|
|
86
|
+
return depth1_arcs.map((arc, idx) => ({
|
|
87
|
+
series_idx: idx,
|
|
88
|
+
label: node_display_name(arc),
|
|
89
|
+
visible: !muted_ids.has(arc.id),
|
|
90
|
+
display_style: { symbol_type: `Square`, symbol_color: color_for(arc) },
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
// Handler props are the node minus its layout geometry (screen coords are an
|
|
94
|
+
// implementation detail), plus the resolved parent id
|
|
95
|
+
export function node_handler_props(arcs, arc, color) {
|
|
96
|
+
const { x0: _x0, x1: _x1, y0: _y0, y1: _y1, subtree_end: _end, parent_idx, ...node } = arc;
|
|
97
|
+
return {
|
|
98
|
+
...node,
|
|
99
|
+
type: `node`,
|
|
100
|
+
color,
|
|
101
|
+
parent_id: parent_idx != null ? arcs[parent_idx].id : null,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
// True while the user has an uncollapsed text selection inside the chart. Labels
|
|
105
|
+
// are selectable text, and the mouseup that ends a selection drag also fires a
|
|
106
|
+
// click — selecting a label must not zoom or fire on_node_click.
|
|
107
|
+
export function selection_within(wrapper) {
|
|
108
|
+
const selection = globalThis.getSelection?.();
|
|
109
|
+
return Boolean(selection &&
|
|
110
|
+
!selection.isCollapsed &&
|
|
111
|
+
selection.anchorNode &&
|
|
112
|
+
wrapper?.contains(selection.anchorNode));
|
|
113
|
+
}
|
|
114
|
+
// Ancestor chain from the root to the current zoom root (clickable breadcrumb trail)
|
|
115
|
+
export function ancestor_chain(arcs, zoom_root) {
|
|
116
|
+
if (!zoom_root || zoom_root.depth === 0)
|
|
117
|
+
return [];
|
|
118
|
+
const chain = [];
|
|
119
|
+
let cur = zoom_root;
|
|
120
|
+
while (cur) {
|
|
121
|
+
chain.unshift(cur);
|
|
122
|
+
cur = cur.parent_idx != null ? arcs[cur.parent_idx] : null;
|
|
123
|
+
}
|
|
124
|
+
return chain;
|
|
125
|
+
}
|
|
126
|
+
// Per-node label text, measured widths, fill/label colors, aria string (and
|
|
127
|
+
// optional clickability) — all zoom-independent, so computed once per
|
|
128
|
+
// layout/option change instead of per animation frame (format_value, canvas
|
|
129
|
+
// measureText, contrast picking and color resolution would otherwise run per
|
|
130
|
+
// visible node per frame during zoom tweens)
|
|
131
|
+
export function compute_node_infos(arcs, opts) {
|
|
132
|
+
const { label_text, value_format, label_font } = opts;
|
|
133
|
+
return arcs.map((arc) => {
|
|
134
|
+
const { text, extended, short } = node_label_variants(arc, label_text, value_format);
|
|
135
|
+
const fill = opts.color_for(arc);
|
|
136
|
+
const variants = (text ? [extended, text, short] : []).flatMap((variant) => variant === undefined
|
|
137
|
+
? []
|
|
138
|
+
: [{ text: variant, width: opts.text_width(variant, label_font) }]);
|
|
139
|
+
return {
|
|
140
|
+
variants,
|
|
141
|
+
aria: `${node_display_name(arc)}: ${arc.value}`,
|
|
142
|
+
fill,
|
|
143
|
+
label_fill: opts.contrast(fill),
|
|
144
|
+
...(opts.clickable ? { clickable: opts.clickable(arc) } : {}),
|
|
145
|
+
};
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
// The font node labels actually render in (respects the chart's font-size CSS
|
|
149
|
+
// var instead of assuming 11px), for canvas-measured label fitting
|
|
150
|
+
export function svg_label_font(svg_element) {
|
|
151
|
+
if (!svg_element)
|
|
152
|
+
return `11px sans-serif`;
|
|
153
|
+
const { fontSize, fontFamily } = getComputedStyle(svg_element);
|
|
154
|
+
return `${fontSize} ${fontFamily}`;
|
|
155
|
+
}
|
|
156
|
+
// Anchor tooltips at the cursor (mouse hover) so they follow the pointer across
|
|
157
|
+
// wide nodes; callers fall back to the node center on keyboard focus (no cursor).
|
|
158
|
+
export const pointer_pos = (event, svg_element) => event instanceof MouseEvent ? get_relative_coords(event, svg_element) : null;
|
|
159
|
+
export const is_activation_key = (evt) => [`Enter`, ` `].includes(evt.key);
|
|
160
|
+
// Escape zooms out one level, then exits fullscreen once at the root — but only
|
|
161
|
+
// when the user is interacting with this chart (pointer over it, focus inside
|
|
162
|
+
// it, or fullscreen)
|
|
163
|
+
export function handle_hierarchy_escape(evt, ctx) {
|
|
164
|
+
if (evt.key !== `Escape`)
|
|
165
|
+
return;
|
|
166
|
+
const within = ctx.fullscreen ||
|
|
167
|
+
(ctx.wrapper != null &&
|
|
168
|
+
(ctx.wrapper.matches(`:hover`) || ctx.wrapper.contains(document.activeElement)));
|
|
169
|
+
if (!within)
|
|
170
|
+
return;
|
|
171
|
+
if (ctx.zoomed) {
|
|
172
|
+
evt.preventDefault();
|
|
173
|
+
ctx.zoom_out();
|
|
174
|
+
}
|
|
175
|
+
else if (ctx.fullscreen) {
|
|
176
|
+
evt.preventDefault();
|
|
177
|
+
ctx.exit_fullscreen();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SunburstLabelText } from '../../sunburst/sunburst';
|
|
2
|
+
interface LabeledNode {
|
|
3
|
+
id: string | number;
|
|
4
|
+
label?: string;
|
|
5
|
+
label_short?: string;
|
|
6
|
+
value: number;
|
|
7
|
+
fraction: number;
|
|
8
|
+
parent_fraction?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const node_display_name: (node: LabeledNode) => string;
|
|
11
|
+
export declare function node_label_str(node: LabeledNode, label_text: SunburstLabelText, value_format: string): string;
|
|
12
|
+
export declare function node_label_variants(node: LabeledNode, label_text: SunburstLabelText, value_format: string): {
|
|
13
|
+
text: string;
|
|
14
|
+
extended?: string;
|
|
15
|
+
short?: string;
|
|
16
|
+
};
|
|
17
|
+
export declare function make_cached_contrast(): (fill: string) => string;
|
|
18
|
+
export declare function make_cached_text_width(): (text: string, font: string) => number;
|
|
19
|
+
export declare function export_hierarchy_chart(svg_element: SVGSVGElement | null, base_filename: string, format: `svg` | `png`): void;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// Label/color helpers shared by the hierarchical part-of-whole charts
|
|
2
|
+
// (Sunburst, Treemap): per-node label strings, memoized contrast picking and
|
|
3
|
+
// text measurement, and SVG/PNG export. Pure + cache-factory functions so each
|
|
4
|
+
// component instance owns its caches without sharing global state.
|
|
5
|
+
import { pick_contrast_color } from '../../../colors';
|
|
6
|
+
import { export_svg_as_png, export_svg_as_svg } from '../../../io/export';
|
|
7
|
+
import { format_value } from '../../../labels';
|
|
8
|
+
import { measure_text_width } from '../layout';
|
|
9
|
+
export const node_display_name = (node) => node.label ?? `${node.id}`;
|
|
10
|
+
// What a node's label displays, per the label_text mode (plotly textinfo
|
|
11
|
+
// equivalent); percent is of the root total, parent-percent of the parent node
|
|
12
|
+
export function node_label_str(node, label_text, value_format) {
|
|
13
|
+
const name = node_display_name(node);
|
|
14
|
+
if (label_text === `label`)
|
|
15
|
+
return name;
|
|
16
|
+
const val = format_value(node.value, value_format);
|
|
17
|
+
if (label_text === `value`)
|
|
18
|
+
return val;
|
|
19
|
+
if (label_text === `label+value`)
|
|
20
|
+
return `${name} ${val}`;
|
|
21
|
+
if (label_text === `label+parent-percent`) {
|
|
22
|
+
return `${name} (${format_value(node.parent_fraction ?? node.fraction, `.0%`)})`;
|
|
23
|
+
}
|
|
24
|
+
const pct = format_value(node.fraction, `.1%`);
|
|
25
|
+
if (label_text === `percent`)
|
|
26
|
+
return pct;
|
|
27
|
+
return `${name} ${pct}`; // label+percent
|
|
28
|
+
}
|
|
29
|
+
const COMPOUND_LABEL_MODES = new Set([
|
|
30
|
+
`label+value`,
|
|
31
|
+
`label+percent`,
|
|
32
|
+
`label+parent-percent`,
|
|
33
|
+
]);
|
|
34
|
+
// Base + optional richer/compact variants for fit-aware rendering: compound
|
|
35
|
+
// modes degrade to the bare label when the full text doesn't fit its node,
|
|
36
|
+
// and nodes with a `label_short` degrade once more to that compact form
|
|
37
|
+
// before the label is hidden entirely.
|
|
38
|
+
export function node_label_variants(node, label_text, value_format) {
|
|
39
|
+
const short = node.label_short;
|
|
40
|
+
const text = node_label_str(node, label_text, value_format);
|
|
41
|
+
if (!COMPOUND_LABEL_MODES.has(label_text))
|
|
42
|
+
return { text, short };
|
|
43
|
+
return { text: node_display_name(node), extended: text, short };
|
|
44
|
+
}
|
|
45
|
+
// Black/white label text, whichever contrasts with the given fill. Memoized per
|
|
46
|
+
// color string - parsing/luminance is too slow per label per frame, and distinct
|
|
47
|
+
// node colors are few.
|
|
48
|
+
export function make_cached_contrast() {
|
|
49
|
+
const cache = new Map();
|
|
50
|
+
return (fill) => {
|
|
51
|
+
let contrast = cache.get(fill);
|
|
52
|
+
if (contrast === undefined) {
|
|
53
|
+
// growth guard (same as make_cached_text_width): continuous metric coloring
|
|
54
|
+
// can emit unbounded distinct fills
|
|
55
|
+
if (cache.size > 10_000)
|
|
56
|
+
cache.clear();
|
|
57
|
+
contrast = pick_contrast_color({ bg_color: fill });
|
|
58
|
+
cache.set(fill, contrast);
|
|
59
|
+
}
|
|
60
|
+
return contrast;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// Memoized canvas text measurement (far too slow per visible node per frame)
|
|
64
|
+
export function make_cached_text_width() {
|
|
65
|
+
const cache = new Map();
|
|
66
|
+
return (text, font) => {
|
|
67
|
+
const key = `${font}|${text}`;
|
|
68
|
+
let text_width = cache.get(key);
|
|
69
|
+
if (text_width === undefined) {
|
|
70
|
+
if (cache.size > 10_000)
|
|
71
|
+
cache.clear(); // growth guard
|
|
72
|
+
text_width = measure_text_width(text, font);
|
|
73
|
+
cache.set(key, text_width);
|
|
74
|
+
}
|
|
75
|
+
return text_width;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
// Styles these components apply via CSS that exported standalone SVGs must carry
|
|
79
|
+
// as presentation attributes (inlined onto a clone by the io/export helpers)
|
|
80
|
+
const EXPORT_INLINE_STYLES = [
|
|
81
|
+
`fill`,
|
|
82
|
+
`stroke`,
|
|
83
|
+
`stroke-width`,
|
|
84
|
+
`text-anchor`,
|
|
85
|
+
`dominant-baseline`,
|
|
86
|
+
`font-size`,
|
|
87
|
+
`font-family`,
|
|
88
|
+
`font-weight`,
|
|
89
|
+
`opacity`,
|
|
90
|
+
];
|
|
91
|
+
export function export_hierarchy_chart(svg_element, base_filename, format) {
|
|
92
|
+
if (!svg_element)
|
|
93
|
+
return;
|
|
94
|
+
const filename = `${base_filename}.${format}`;
|
|
95
|
+
if (format === `svg`)
|
|
96
|
+
export_svg_as_svg(svg_element, filename, EXPORT_INLINE_STYLES);
|
|
97
|
+
else
|
|
98
|
+
export_svg_as_png(svg_element, filename, 150, EXPORT_INLINE_STYLES);
|
|
99
|
+
}
|
|
@@ -42,7 +42,7 @@ export interface LeaderLineOptions {
|
|
|
42
42
|
}
|
|
43
43
|
export declare function parse_font_size(size_str?: string): number;
|
|
44
44
|
export declare function estimate_label_size(text: string, font_size_str?: string): LabelSize;
|
|
45
|
-
export declare function rect_overlap_area(
|
|
45
|
+
export declare function rect_overlap_area(rect_a: Rect, rect_b: Rect): number;
|
|
46
46
|
export declare function rect_circle_overlap(rect: Rect, cx: number, cy: number, radius: number): number;
|
|
47
47
|
export declare function segments_intersect(ax1: number, ay1: number, ax2: number, ay2: number, bx1: number, by1: number, bx2: number, by2: number): boolean;
|
|
48
48
|
export declare function segment_rect_intersects(sx1: number, sy1: number, sx2: number, sy2: number, rect: Rect): boolean;
|
|
@@ -18,10 +18,10 @@ const copy_state = (target, source) => {
|
|
|
18
18
|
export function parse_font_size(size_str) {
|
|
19
19
|
if (!size_str)
|
|
20
20
|
return 12;
|
|
21
|
-
const match = /^(
|
|
21
|
+
const match = /^(?<size>\d+(?:\.\d+)?)(?<unit>px|em|rem)?$/.exec(size_str);
|
|
22
22
|
if (!match)
|
|
23
23
|
return 12;
|
|
24
|
-
const value =
|
|
24
|
+
const value = Number(match[1]);
|
|
25
25
|
return match[2] === `em` || match[2] === `rem` ? value * 16 : value;
|
|
26
26
|
}
|
|
27
27
|
export function estimate_label_size(text, font_size_str) {
|
|
@@ -34,9 +34,9 @@ export function estimate_label_size(text, font_size_str) {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
// === Geometry helpers ===
|
|
37
|
-
export function rect_overlap_area(
|
|
38
|
-
const ox = Math.max(0, Math.min(
|
|
39
|
-
const oy = Math.max(0, Math.min(
|
|
37
|
+
export function rect_overlap_area(rect_a, rect_b) {
|
|
38
|
+
const ox = Math.max(0, Math.min(rect_a.x + rect_a.w, rect_b.x + rect_b.w) - Math.max(rect_a.x, rect_b.x));
|
|
39
|
+
const oy = Math.max(0, Math.min(rect_a.y + rect_a.h, rect_b.y + rect_b.h) - Math.max(rect_a.y, rect_b.y));
|
|
40
40
|
return ox * oy;
|
|
41
41
|
}
|
|
42
42
|
export function rect_circle_overlap(rect, cx, cy, radius) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Vec2 } from '../../math';
|
|
1
2
|
import type { TweenOptions } from 'svelte/motion';
|
|
2
3
|
export declare const unique_id: (prefix?: string) => string;
|
|
3
4
|
export declare const LINE_TWEEN: {
|
|
@@ -8,4 +9,4 @@ export declare const resolve_line_tween: (line_tween: TweenOptions<string> | und
|
|
|
8
9
|
series: number;
|
|
9
10
|
points: number;
|
|
10
11
|
}) => TweenOptions<string> | undefined;
|
|
11
|
-
export declare function calc_auto_range(values: number[]):
|
|
12
|
+
export declare function calc_auto_range(values: number[]): Vec2;
|