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
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { Vec2 } from '../../math';
|
|
1
2
|
import type { BandwidthOption, BasePlotProps, BoxHandlerProps, BoxPlotSeries, LegendConfig, Orientation, PanConfig, PlotConfig, RefLine, RefLineEvent, UserContentProps, ViolinKind, ViolinSide, WhiskerMode } from '..';
|
|
3
|
+
import type { MarginalsProp } from '../core/marginals';
|
|
2
4
|
import type { Snippet } from 'svelte';
|
|
3
5
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
6
|
declare function $$render<Metadata extends Record<string, unknown> = Record<string, unknown>>(): {
|
|
@@ -30,7 +32,7 @@ declare function $$render<Metadata extends Record<string, unknown> = Record<stri
|
|
|
30
32
|
};
|
|
31
33
|
whisker_mode?: WhiskerMode;
|
|
32
34
|
whisker_range?: number;
|
|
33
|
-
whisker_percentiles?:
|
|
35
|
+
whisker_percentiles?: Vec2;
|
|
34
36
|
show_outliers?: boolean;
|
|
35
37
|
show_mean?: boolean;
|
|
36
38
|
show_value_labels?: boolean;
|
|
@@ -69,9 +71,10 @@ declare function $$render<Metadata extends Record<string, unknown> = Record<stri
|
|
|
69
71
|
on_ref_line_click?: (event: RefLineEvent) => void;
|
|
70
72
|
on_ref_line_hover?: (event: RefLineEvent | null) => void;
|
|
71
73
|
pan?: PanConfig;
|
|
74
|
+
marginals?: MarginalsProp;
|
|
72
75
|
};
|
|
73
76
|
exports: {};
|
|
74
|
-
bindings: "
|
|
77
|
+
bindings: "display" | "orientation" | "show_controls" | "x2_axis" | "y_axis" | "y2_axis" | "fullscreen" | "series" | "hovered" | "ref_lines" | "controls_open" | "x_axis" | "kind" | "side" | "whisker_mode" | "show_outliers" | "show_mean";
|
|
75
78
|
slots: {};
|
|
76
79
|
events: {};
|
|
77
80
|
};
|
|
@@ -79,7 +82,7 @@ declare class __sveltets_Render<Metadata extends Record<string, unknown> = Recor
|
|
|
79
82
|
props(): ReturnType<typeof $$render<Metadata>>['props'];
|
|
80
83
|
events(): ReturnType<typeof $$render<Metadata>>['events'];
|
|
81
84
|
slots(): ReturnType<typeof $$render<Metadata>>['slots'];
|
|
82
|
-
bindings(): "
|
|
85
|
+
bindings(): "display" | "orientation" | "show_controls" | "x2_axis" | "y_axis" | "y2_axis" | "fullscreen" | "series" | "hovered" | "ref_lines" | "controls_open" | "x_axis" | "kind" | "side" | "whisker_mode" | "show_outliers" | "show_mean";
|
|
83
86
|
exports(): {};
|
|
84
87
|
}
|
|
85
88
|
interface $$IsomorphicComponent {
|
|
@@ -14,6 +14,6 @@ type $$ComponentProps = Omit<PlotControlsProps, `children` | `post_children`> &
|
|
|
14
14
|
orientation: Orientation;
|
|
15
15
|
} & Required<PlotConfig>]>;
|
|
16
16
|
};
|
|
17
|
-
declare const BoxPlotControls: import("svelte").Component<$$ComponentProps, {}, "
|
|
17
|
+
declare const BoxPlotControls: import("svelte").Component<$$ComponentProps, {}, "display" | "orientation" | "show_controls" | "x2_axis" | "y_axis" | "y2_axis" | "controls_open" | "x_axis" | "kind" | "side" | "whisker_mode" | "show_outliers" | "show_mean">;
|
|
18
18
|
type BoxPlotControls = ReturnType<typeof BoxPlotControls>;
|
|
19
19
|
export default BoxPlotControls;
|
|
@@ -26,7 +26,7 @@ declare const Violin: import("svelte").Component<import("svelte/elements").HTMLA
|
|
|
26
26
|
} | undefined;
|
|
27
27
|
whisker_mode?: import("./box-plot").WhiskerMode;
|
|
28
28
|
whisker_range?: number;
|
|
29
|
-
whisker_percentiles?:
|
|
29
|
+
whisker_percentiles?: import("../..").Vec2;
|
|
30
30
|
show_outliers?: boolean;
|
|
31
31
|
show_mean?: boolean;
|
|
32
32
|
show_value_labels?: boolean;
|
|
@@ -65,6 +65,7 @@ declare const Violin: import("svelte").Component<import("svelte/elements").HTMLA
|
|
|
65
65
|
on_ref_line_click?: ((event: import("..").RefLineEvent) => void) | undefined;
|
|
66
66
|
on_ref_line_hover?: ((event: import("..").RefLineEvent | null) => void) | undefined;
|
|
67
67
|
pan?: import("..").PanConfig;
|
|
68
|
+
marginals?: import("..").MarginalsProp;
|
|
68
69
|
}, {}, "series" | "kind">;
|
|
69
70
|
type Violin = ReturnType<typeof Violin>;
|
|
70
71
|
export default Violin;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Vec2 } from '../../math';
|
|
1
2
|
import type { HandlerProps } from '../core/types';
|
|
2
3
|
export type WhiskerMode = `tukey` | `minmax` | `percentile` | `std`;
|
|
3
4
|
export type ViolinKind = `box` | `violin` | `violin+box`;
|
|
@@ -16,7 +17,7 @@ export interface BoxPlotSeries<Metadata = Record<string, unknown>> {
|
|
|
16
17
|
y_axis?: `y1` | `y2`;
|
|
17
18
|
whisker_mode?: WhiskerMode;
|
|
18
19
|
whisker_range?: number;
|
|
19
|
-
whisker_percentiles?:
|
|
20
|
+
whisker_percentiles?: Vec2;
|
|
20
21
|
kind?: ViolinKind;
|
|
21
22
|
side?: ViolinSide;
|
|
22
23
|
bandwidth?: BandwidthOption;
|
|
@@ -47,7 +48,7 @@ export interface BoxStats {
|
|
|
47
48
|
export interface BoxStatsOptions {
|
|
48
49
|
whisker_mode?: WhiskerMode;
|
|
49
50
|
whisker_range?: number;
|
|
50
|
-
whisker_percentiles?:
|
|
51
|
+
whisker_percentiles?: Vec2;
|
|
51
52
|
collect_outliers?: boolean;
|
|
52
53
|
}
|
|
53
54
|
export declare const WHISKER_MODES: readonly ["tukey", "minmax", "percentile", "std"];
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
// Single source of truth for the quantile math used by BoxPlot.svelte.
|
|
3
3
|
import { ascending } from 'd3-array';
|
|
4
4
|
import { quantile_unordered } from './quantile';
|
|
5
|
+
import { DEFAULTS } from '../../settings';
|
|
6
|
+
import { clamp01 } from '../../utils';
|
|
5
7
|
export const WHISKER_MODES = [`tukey`, `minmax`, `percentile`, `std`];
|
|
6
8
|
const WHISKER_MODE_SET = new Set(WHISKER_MODES);
|
|
7
9
|
export const is_whisker_mode = (val) => WHISKER_MODE_SET.has(val);
|
|
@@ -17,7 +19,6 @@ const EMPTY_STATS = {
|
|
|
17
19
|
outliers: [],
|
|
18
20
|
n: 0,
|
|
19
21
|
};
|
|
20
|
-
const clamp01 = (val) => Math.max(0, Math.min(1, val));
|
|
21
22
|
function collect_outliers_by_scan(values, low_bound, high_bound, collect) {
|
|
22
23
|
if (!collect)
|
|
23
24
|
return [];
|
|
@@ -56,7 +57,9 @@ function tukey_scan(values, low_bound, high_bound, collect, data_min, data_max)
|
|
|
56
57
|
// Quartiles use type-7 linear interpolation, matching d3/numpy/pandas defaults.
|
|
57
58
|
// Non-finite values are filtered out; the input array is never mutated.
|
|
58
59
|
export function compute_box_stats(values, opts = {}) {
|
|
59
|
-
const {
|
|
60
|
+
const {
|
|
61
|
+
// Fallback derives from DEFAULTS.box so component and helper defaults can't drift
|
|
62
|
+
whisker_mode = DEFAULTS.box.whisker_mode, whisker_range = 1.5, whisker_percentiles = [5, 95], collect_outliers = true, } = opts;
|
|
60
63
|
const vals = values.filter((val) => Number.isFinite(val));
|
|
61
64
|
const n_vals = vals.length;
|
|
62
65
|
if (n_vals === 0)
|
|
@@ -72,7 +75,7 @@ export function compute_box_stats(values, opts = {}) {
|
|
|
72
75
|
data_max = val;
|
|
73
76
|
}
|
|
74
77
|
const mean = sum / n_vals;
|
|
75
|
-
const qtl = (
|
|
78
|
+
const qtl = (prob) => quantile_unordered(vals, prob);
|
|
76
79
|
const collect_beyond = (lo, hi) => collect_outliers_by_scan(vals, lo, hi, collect_outliers);
|
|
77
80
|
const q1 = qtl(0.25);
|
|
78
81
|
const median = qtl(0.5);
|
package/dist/plot/box/kde.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Vec2 } from '../../math';
|
|
1
2
|
export interface KdeResult {
|
|
2
3
|
grid: number[];
|
|
3
4
|
density: number[];
|
|
@@ -8,7 +9,7 @@ export interface KdeOptions {
|
|
|
8
9
|
n_points?: number;
|
|
9
10
|
cut?: number;
|
|
10
11
|
clip?: [number | null, number | null];
|
|
11
|
-
range?:
|
|
12
|
+
range?: Vec2;
|
|
12
13
|
max_samples?: number;
|
|
13
14
|
}
|
|
14
15
|
export declare function silverman_bandwidth(sorted: readonly number[]): number;
|
package/dist/plot/box/kde.js
CHANGED
|
@@ -55,8 +55,8 @@ function exact_density(eval_samples, grid, band) {
|
|
|
55
55
|
const g_val = grid[grid_idx];
|
|
56
56
|
let sum = 0;
|
|
57
57
|
for (const sample of eval_samples) {
|
|
58
|
-
const
|
|
59
|
-
sum += Math.exp(-0.5 *
|
|
58
|
+
const z_score = (g_val - sample) / band;
|
|
59
|
+
sum += Math.exp(-0.5 * z_score * z_score);
|
|
60
60
|
}
|
|
61
61
|
density[grid_idx] = sum * norm;
|
|
62
62
|
}
|
|
@@ -98,8 +98,8 @@ function binned_density(eval_samples, grid, band) {
|
|
|
98
98
|
const count = counts[bin_idx];
|
|
99
99
|
if (count === 0)
|
|
100
100
|
continue;
|
|
101
|
-
const
|
|
102
|
-
sum += count * Math.exp(-0.5 *
|
|
101
|
+
const z_score = (g_val - centers[bin_idx]) / band;
|
|
102
|
+
sum += count * Math.exp(-0.5 * z_score * z_score);
|
|
103
103
|
}
|
|
104
104
|
density[grid_idx] = sum * norm;
|
|
105
105
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Sides } from './layout';
|
|
2
|
-
export declare const DECOR_GAP = 8;
|
|
3
2
|
type Pt = {
|
|
4
3
|
x: number;
|
|
5
4
|
y: number;
|
|
@@ -8,6 +7,7 @@ type Size = {
|
|
|
8
7
|
width: number;
|
|
9
8
|
height: number;
|
|
10
9
|
};
|
|
10
|
+
export declare const placed_coords: (auto_outside: boolean, outside: Pt, placement: Pt | null, tweened: Pt, fallback: Pt) => Pt;
|
|
11
11
|
export declare const has_explicit_position: (style?: string | null) => boolean;
|
|
12
12
|
export declare const measured_footprint: (el: HTMLElement | null | undefined, fallback: Size) => Size;
|
|
13
13
|
export declare function build_obstacles_norm(series: {
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { compute_element_placement, sample_series_obstacle_points, } from './layout';
|
|
2
2
|
// Shared "move a decoration (legend/colorbar) outside the plot when interior overlap is
|
|
3
3
|
// unavoidable" logic, reused by every 2D plot (ScatterPlot/BarPlot/Histogram/BinnedScatterPlot).
|
|
4
|
-
|
|
4
|
+
const DECOR_GAP = 8; // px gap between an outside decoration and the plot edge
|
|
5
|
+
// Final on-screen position for an auto-placed decoration: explicit outside placement
|
|
6
|
+
// wins, then the tweened auto placement, else a static padding fallback
|
|
7
|
+
export const placed_coords = (auto_outside, outside, placement, tweened, fallback) => (auto_outside ? outside : placement ? tweened : fallback);
|
|
5
8
|
// True when the user pinned a decoration via its style (an edge property or position:absolute),
|
|
6
9
|
// in which case auto-placement must leave it alone.
|
|
7
|
-
export const has_explicit_position = (style) => /(
|
|
10
|
+
export const has_explicit_position = (style) => /(?:^|[;{]\s*)(?:top|bottom|left|right)\s*:|position\s*:\s*absolute/.test(style ?? ``);
|
|
8
11
|
// A decoration's pixel footprint: its rendered box once laid out, else `fallback` (offset dims read
|
|
9
12
|
// 0 before first render). Used to decide crowding before the real size is known.
|
|
10
13
|
export const measured_footprint = (el, fallback) => el?.offsetWidth && el?.offsetHeight
|
|
@@ -21,14 +21,19 @@ export declare const AXIS_DEFAULTS: {
|
|
|
21
21
|
type AxisType = `x` | `x2` | `y` | `y2`;
|
|
22
22
|
export declare function merge_series_state<T extends DataSeries | BarSeries>(old_series: T[], new_series: T[]): T[];
|
|
23
23
|
export interface AxisChangeState<T extends DataSeries | BarSeries> {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
axes: Record<AxisType, {
|
|
25
|
+
get: () => AxisConfig;
|
|
26
|
+
set: (config: AxisConfig) => void;
|
|
27
|
+
}>;
|
|
28
|
+
series: {
|
|
29
|
+
get: () => T[];
|
|
30
|
+
set: (series: T[]) => void;
|
|
31
|
+
};
|
|
32
|
+
loading: {
|
|
33
|
+
get: () => AxisType | null;
|
|
34
|
+
set: (axis: AxisType | null) => void;
|
|
35
|
+
};
|
|
30
36
|
}
|
|
31
|
-
export declare const create_axis_change_handler: <T extends DataSeries | BarSeries>(state: AxisChangeState<T>, data_loader: DataLoaderFn<Record<string, unknown>, T> | undefined, on_axis_change?: (axis: AxisType, key: string, new_series: T[]) => void, on_error?: (error: AxisLoadError) => void) => ((axis: AxisType, key: string) => Promise<void>);
|
|
32
37
|
export declare function create_axis_loader<T extends DataSeries | BarSeries>(state: AxisChangeState<T>, get_props: () => {
|
|
33
38
|
data_loader?: DataLoaderFn<Record<string, unknown>, T>;
|
|
34
39
|
on_axis_change?: (axis: AxisType, key: string, new_series: T[]) => void;
|
|
@@ -36,61 +36,61 @@ export function merge_series_state(old_series, new_series) {
|
|
|
36
36
|
return result;
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return;
|
|
44
|
-
const axis_config = state.get_axis(axis);
|
|
45
|
-
const prev_key = axis_config.selected_key;
|
|
46
|
-
// Skip if key unchanged AND series already loaded (allows initial load when series empty)
|
|
47
|
-
if (prev_key === key && state.get_series().length > 0)
|
|
48
|
-
return;
|
|
49
|
-
// Update selected_key immediately for UI feedback
|
|
50
|
-
state.set_axis(axis, { ...axis_config, selected_key: key });
|
|
51
|
-
state.set_loading(axis);
|
|
52
|
-
try {
|
|
53
|
-
const result = await data_loader(axis, key, state.get_series());
|
|
54
|
-
// Merge new series with preserved state from old series
|
|
55
|
-
const merged = merge_series_state(state.get_series(), result.series);
|
|
56
|
-
state.set_series(merged);
|
|
57
|
-
// Update axis label/unit if provided
|
|
58
|
-
if (result.axis_label || result.axis_unit) {
|
|
59
|
-
const current = state.get_axis(axis);
|
|
60
|
-
state.set_axis(axis, {
|
|
61
|
-
...current,
|
|
62
|
-
label: result.axis_label ?? current.label,
|
|
63
|
-
unit: result.axis_unit ?? current.unit,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
on_axis_change?.(axis, key, merged);
|
|
67
|
-
}
|
|
68
|
-
catch (err) {
|
|
69
|
-
console.error(`Failed to load data for ${axis}=${key}:`, err);
|
|
70
|
-
// Revert selection
|
|
71
|
-
state.set_axis(axis, { ...state.get_axis(axis), selected_key: prev_key });
|
|
72
|
-
const message = to_error(err).message;
|
|
73
|
-
on_error?.({ axis, key, message });
|
|
74
|
-
}
|
|
75
|
-
finally {
|
|
76
|
-
state.set_loading(null);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
// Bundle axis change handler with one-shot auto-load of the first axis option.
|
|
80
|
-
// get_props keeps callback props fresh; try_auto_load reads series/axis configs
|
|
81
|
-
// through state getters so a component `$effect(try_auto_load)` tracks them reactively.
|
|
39
|
+
// Axis-change loader: `handle_axis_change` loads new data for an axis property change via the
|
|
40
|
+
// data_loader (reading `get_props` fresh each call so callbacks stay current), and `try_auto_load`
|
|
41
|
+
// loads the first axis option once when series start empty. Reads state through getters so a
|
|
42
|
+
// component `$effect(try_auto_load)` tracks them reactively.
|
|
82
43
|
export function create_axis_loader(state, get_props) {
|
|
83
44
|
let auto_load_attempted = false; // prevent infinite retries on failure
|
|
84
|
-
|
|
45
|
+
// No-op when already loading, or when the key is unchanged and series are already present
|
|
46
|
+
const handle_axis_change = async (axis, key) => {
|
|
85
47
|
const { data_loader, on_axis_change, on_error } = get_props();
|
|
86
|
-
|
|
48
|
+
if (!data_loader || state.loading.get())
|
|
49
|
+
return;
|
|
50
|
+
const axis_config = state.axes[axis].get();
|
|
51
|
+
const prev_key = axis_config.selected_key;
|
|
52
|
+
if (prev_key === key && state.series.get().length > 0)
|
|
53
|
+
return;
|
|
54
|
+
state.axes[axis].set({ ...axis_config, selected_key: key }); // immediate UI feedback
|
|
55
|
+
state.loading.set(axis);
|
|
56
|
+
let merged = state.series.get();
|
|
57
|
+
let load_error;
|
|
58
|
+
try {
|
|
59
|
+
const result = await data_loader(axis, key, state.series.get());
|
|
60
|
+
merged = merge_series_state(state.series.get(), result.series);
|
|
61
|
+
state.series.set(merged);
|
|
62
|
+
// !== undefined (not truthiness) so a loader can intentionally clear a label/unit to ``
|
|
63
|
+
if (result.axis_label !== undefined || result.axis_unit !== undefined) {
|
|
64
|
+
const current = state.axes[axis].get();
|
|
65
|
+
state.axes[axis].set({
|
|
66
|
+
...current,
|
|
67
|
+
label: result.axis_label ?? current.label,
|
|
68
|
+
unit: result.axis_unit ?? current.unit,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
console.error(`Failed to load data for ${axis}=${key}:`, err);
|
|
74
|
+
state.axes[axis].set(axis_config); // revert every axis field mutated above, not just selected_key
|
|
75
|
+
load_error = { axis, key, message: to_error(err).message };
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
state.loading.set(null); // always clears, even if a consumer callback below throws
|
|
79
|
+
}
|
|
80
|
+
// callbacks run only after internal state is fully settled, so a throwing consumer callback
|
|
81
|
+
// can neither leave `loading` stuck nor trigger the loader rollback
|
|
82
|
+
if (load_error) {
|
|
83
|
+
on_error?.(load_error);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
on_axis_change?.(axis, key, merged);
|
|
87
87
|
};
|
|
88
|
-
// Auto-load
|
|
88
|
+
// Auto-load once if series is empty but options exist (x-axis first, then y)
|
|
89
89
|
const try_auto_load = () => {
|
|
90
|
-
if (state.
|
|
90
|
+
if (state.series.get().length > 0 || !get_props().data_loader || auto_load_attempted)
|
|
91
91
|
return;
|
|
92
92
|
for (const axis of [`x`, `y`]) {
|
|
93
|
-
const config = state.
|
|
93
|
+
const config = state.axes[axis].get();
|
|
94
94
|
if (config.options?.length) {
|
|
95
95
|
auto_load_attempted = true;
|
|
96
96
|
handle_axis_change(axis, config.selected_key ?? config.options[0].key).catch(() => { });
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
loading = false,
|
|
15
15
|
axis_type,
|
|
16
16
|
on_select,
|
|
17
|
+
width = AXIS_LABEL_CONTAINER.width,
|
|
17
18
|
}: {
|
|
18
19
|
x: number
|
|
19
20
|
y: number
|
|
@@ -25,27 +26,88 @@
|
|
|
25
26
|
loading?: boolean
|
|
26
27
|
axis_type: `x` | `x2` | `y` | `y2`
|
|
27
28
|
on_select?: (key: string) => void
|
|
29
|
+
// container width for centering/wrapping; wider lets long horizontal titles fit on one line
|
|
30
|
+
width?: number
|
|
28
31
|
} = $props()
|
|
32
|
+
|
|
33
|
+
interface LabelSegment {
|
|
34
|
+
text: string
|
|
35
|
+
shift?: `sub` | `super`
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const decode_text = (value: string, textarea?: HTMLTextAreaElement): string => {
|
|
39
|
+
// Strip only sub/sup markup so literal angle-bracket text like <100> survives
|
|
40
|
+
const without_tags = value.replaceAll(/<\/?(?:sub|sup)\b[^>]*>/gi, ``)
|
|
41
|
+
if (!textarea) return without_tags
|
|
42
|
+
textarea.innerHTML = without_tags
|
|
43
|
+
return textarea.value
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const label_segments = (value: string): LabelSegment[] => {
|
|
47
|
+
const segments: LabelSegment[] = []
|
|
48
|
+
const tag_pattern = /<(?<tag>sub|sup)\b[^>]*>(?<inner>.*?)<\/\k<tag>>/gis
|
|
49
|
+
const textarea =
|
|
50
|
+
typeof document === `undefined` ? undefined : document.createElement(`textarea`)
|
|
51
|
+
let cursor = 0
|
|
52
|
+
for (const match of value.matchAll(tag_pattern)) {
|
|
53
|
+
const start = match.index ?? 0
|
|
54
|
+
const plain_text = decode_text(value.slice(cursor, start), textarea)
|
|
55
|
+
if (plain_text) segments.push({ text: plain_text })
|
|
56
|
+
const shifted_text = decode_text(match.groups?.inner ?? ``, textarea)
|
|
57
|
+
if (shifted_text) {
|
|
58
|
+
segments.push({
|
|
59
|
+
text: shifted_text,
|
|
60
|
+
shift: match.groups?.tag?.toLowerCase() === `sub` ? `sub` : `super`,
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
cursor = start + match[0].length
|
|
64
|
+
}
|
|
65
|
+
const tail_text = decode_text(value.slice(cursor), textarea)
|
|
66
|
+
if (tail_text) segments.push({ text: tail_text })
|
|
67
|
+
return segments
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let use_svg_text = $derived(rotate && !options?.length && !loading)
|
|
71
|
+
let segments = $derived(use_svg_text ? label_segments(label) : [])
|
|
29
72
|
</script>
|
|
30
73
|
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
width={AXIS_LABEL_CONTAINER.width}
|
|
35
|
-
height={AXIS_LABEL_CONTAINER.height}
|
|
36
|
-
style="overflow: visible; pointer-events: none"
|
|
37
|
-
transform={rotate ? `rotate(-90, ${x}, ${y})` : undefined}
|
|
38
|
-
>
|
|
39
|
-
<div xmlns="http://www.w3.org/1999/xhtml" style="pointer-events: auto">
|
|
40
|
-
<InteractiveAxisLabel
|
|
41
|
-
{label}
|
|
42
|
-
{options}
|
|
43
|
-
{selected_key}
|
|
44
|
-
{loading}
|
|
45
|
-
{axis_type}
|
|
46
|
-
{color}
|
|
47
|
-
{on_select}
|
|
74
|
+
<g transform={rotate ? `rotate(-90, ${x}, ${y})` : undefined}>
|
|
75
|
+
{#if use_svg_text}
|
|
76
|
+
<text
|
|
48
77
|
class="axis-label {axis_type}-label"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
78
|
+
dominant-baseline="central"
|
|
79
|
+
fill={color ?? `currentColor`}
|
|
80
|
+
pointer-events="none"
|
|
81
|
+
text-anchor="middle"
|
|
82
|
+
{x}
|
|
83
|
+
{y}
|
|
84
|
+
>
|
|
85
|
+
{#each segments as segment}
|
|
86
|
+
<tspan baseline-shift={segment.shift} font-size={segment.shift ? `75%` : undefined}
|
|
87
|
+
>{segment.text}</tspan
|
|
88
|
+
>
|
|
89
|
+
{/each}
|
|
90
|
+
</text>
|
|
91
|
+
{:else}
|
|
92
|
+
<foreignObject
|
|
93
|
+
x={x - width / 2}
|
|
94
|
+
y={y - AXIS_LABEL_CONTAINER.y_offset}
|
|
95
|
+
{width}
|
|
96
|
+
height={AXIS_LABEL_CONTAINER.height}
|
|
97
|
+
style="overflow: visible; pointer-events: none"
|
|
98
|
+
>
|
|
99
|
+
<div xmlns="http://www.w3.org/1999/xhtml" style="pointer-events: auto">
|
|
100
|
+
<InteractiveAxisLabel
|
|
101
|
+
{label}
|
|
102
|
+
{options}
|
|
103
|
+
{selected_key}
|
|
104
|
+
{loading}
|
|
105
|
+
{axis_type}
|
|
106
|
+
{color}
|
|
107
|
+
{on_select}
|
|
108
|
+
class="axis-label {axis_type}-label"
|
|
109
|
+
/>
|
|
110
|
+
</div>
|
|
111
|
+
</foreignObject>
|
|
112
|
+
{/if}
|
|
113
|
+
</g>
|
|
@@ -10,6 +10,7 @@ type $$ComponentProps = {
|
|
|
10
10
|
loading?: boolean;
|
|
11
11
|
axis_type: `x` | `x2` | `y` | `y2`;
|
|
12
12
|
on_select?: (key: string) => void;
|
|
13
|
+
width?: number;
|
|
13
14
|
};
|
|
14
15
|
declare const AxisLabel: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
15
16
|
type AxisLabel = ReturnType<typeof AxisLabel>;
|