matterviz 0.4.1 → 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 +75 -85
- package/dist/brillouin/BrillouinZone.svelte.d.ts +5 -7
- package/dist/brillouin/BrillouinZoneControls.svelte +3 -6
- package/dist/brillouin/BrillouinZoneExportPane.svelte +18 -14
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +6 -10
- package/dist/brillouin/BrillouinZoneScene.svelte +26 -39
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -1
- package/dist/chempot-diagram/ChemPotDiagram.svelte +33 -38
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +62 -74
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +1 -1
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +511 -547
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +1 -1
- package/dist/chempot-diagram/async-compute.svelte.js +1 -1
- package/dist/chempot-diagram/controls-state.svelte.js +1 -1
- package/dist/colors/index.d.ts +0 -4
- package/dist/colors/index.js +19 -20
- 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 +92 -95
- package/dist/composition/PieChart.svelte +55 -41
- package/dist/composition/format.js +1 -1
- package/dist/composition/index.d.ts +2 -0
- package/dist/composition/index.js +14 -0
- package/dist/composition/parse.d.ts +2 -2
- package/dist/composition/parse.js +11 -10
- package/dist/constants.js +11 -9
- package/dist/convex-hull/ConvexHull.svelte +12 -15
- package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull2D.svelte +93 -92
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull3D.svelte +109 -140
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull4D.svelte +75 -94
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullChrome.svelte +36 -40
- package/dist/convex-hull/ConvexHullControls.svelte +46 -48
- package/dist/convex-hull/ConvexHullStats.svelte +193 -195
- package/dist/convex-hull/ConvexHullTooltip.svelte +5 -12
- package/dist/convex-hull/GasPressureControls.svelte +5 -12
- package/dist/convex-hull/StructurePopup.svelte +17 -21
- package/dist/convex-hull/StructurePopup.svelte.d.ts +2 -0
- package/dist/convex-hull/TemperatureSlider.svelte +4 -10
- package/dist/convex-hull/canvas-interactions.svelte.js +2 -1
- package/dist/convex-hull/helpers.d.ts +8 -10
- package/dist/convex-hull/helpers.js +36 -36
- package/dist/convex-hull/hull-state.svelte.d.ts +1 -1
- package/dist/convex-hull/thermodynamics.js +18 -17
- package/dist/coordination/CoordinationBarPlot.svelte +38 -33
- package/dist/coordination/CoordinationBarPlot.svelte.d.ts +1 -1
- package/dist/coordination/calc-coordination.d.ts +1 -1
- package/dist/coordination/calc-coordination.js +28 -25
- package/dist/element/BohrAtom.svelte +5 -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/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 -4
- package/dist/element/index.js +3 -18
- package/dist/feedback/DragOverlay.svelte +5 -5
- package/dist/feedback/DragOverlay.svelte.d.ts +2 -2
- package/dist/feedback/StatusMessage.svelte +7 -4
- package/dist/fermi-surface/FermiSlice.svelte +21 -18
- package/dist/fermi-surface/FermiSurface.svelte +14 -22
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +5 -7
- package/dist/fermi-surface/FermiSurfaceControls.svelte +6 -20
- package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte +37 -64
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +9 -6
- package/dist/fermi-surface/compute.js +3 -3
- package/dist/fermi-surface/parse.js +22 -24
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +109 -148
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +2 -2
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +9 -7
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +1 -1
- package/dist/heatmap-matrix/index.d.ts +5 -0
- package/dist/icons.d.ts +4 -0
- package/dist/icons.js +4 -0
- package/dist/io/ExportPane.svelte +10 -6
- package/dist/io/decompress.d.ts +2 -1
- package/dist/io/decompress.js +22 -35
- package/dist/io/export.d.ts +4 -0
- package/dist/io/export.js +5 -1
- package/dist/io/fetch.d.ts +0 -3
- package/dist/io/fetch.js +0 -11
- package/dist/io/index.d.ts +0 -1
- package/dist/io/index.js +2 -9
- package/dist/io/is-binary.d.ts +9 -0
- package/dist/io/is-binary.js +45 -1
- package/dist/io/url-drop.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 +6 -6
- package/dist/labels.d.ts +6 -2
- package/dist/labels.js +43 -13
- package/dist/layout/FullscreenButton.svelte +2 -1
- package/dist/layout/FullscreenToggle.svelte +10 -4
- 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 +9 -10
- package/dist/layout/ViewerChrome.svelte.d.ts +2 -1
- package/dist/layout/fullscreen.js +3 -5
- package/dist/layout/fullscreen.svelte.js +1 -2
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/index.js +1 -0
- package/dist/layout/json-tree/JsonNode.svelte +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 +2 -0
- package/dist/math.js +19 -0
- 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 +7 -0
- package/dist/overlays/index.js +26 -0
- package/dist/overlays/portal.d.ts +2 -0
- package/dist/overlays/portal.js +14 -0
- package/dist/periodic-table/PeriodicTable.svelte +113 -145
- package/dist/periodic-table/PeriodicTable.svelte.d.ts +5 -3
- package/dist/periodic-table/PeriodicTableControls.svelte +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 +70 -94
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +2 -1
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +12 -12
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +54 -58
- package/dist/phase-diagram/TdbInfoPanel.svelte +21 -15
- package/dist/phase-diagram/build-diagram.js +3 -3
- package/dist/phase-diagram/diagram-input.d.ts +1 -2
- package/dist/phase-diagram/parse.js +15 -15
- package/dist/phase-diagram/svg-to-diagram.js +21 -15
- package/dist/phase-diagram/utils.js +2 -3
- package/dist/plot/bar/BarPlot.svelte +430 -391
- package/dist/plot/bar/BarPlot.svelte.d.ts +2 -0
- package/dist/plot/bar/BarPlotControls.svelte +1 -3
- package/dist/plot/bar/BarPlotControls.svelte.d.ts +4 -6
- package/dist/plot/bar/SpacegroupBarPlot.svelte +29 -36
- package/dist/plot/bar/data.d.ts +5 -4
- package/dist/plot/bar/data.js +2 -1
- package/dist/plot/box/BoxPlot.svelte +301 -209
- package/dist/plot/box/BoxPlot.svelte.d.ts +2 -0
- package/dist/plot/box/Violin.svelte.d.ts +1 -0
- package/dist/plot/box/box-plot.js +1 -1
- package/dist/plot/core/auto-place.js +1 -1
- package/dist/plot/core/axis-utils.d.ts +12 -7
- package/dist/plot/core/axis-utils.js +48 -48
- package/dist/plot/core/components/AxisLabel.svelte +82 -20
- package/dist/plot/core/components/AxisLabel.svelte.d.ts +1 -0
- package/dist/plot/core/components/ColorBar.svelte +101 -106
- package/dist/plot/core/components/ColorScaleSelect.svelte +1 -1
- package/dist/plot/core/components/FillArea.svelte +10 -17
- package/dist/plot/core/components/HierarchyControls.svelte +249 -0
- package/dist/plot/{sunburst/SunburstControls.svelte.d.ts → core/components/HierarchyControls.svelte.d.ts} +12 -8
- package/dist/plot/core/components/InteractiveAxisLabel.svelte +1 -1
- package/dist/plot/core/components/InteractiveAxisLabel.svelte.d.ts +1 -1
- package/dist/plot/core/components/Line.svelte +18 -9
- package/dist/plot/core/components/Line.svelte.d.ts +2 -0
- package/dist/plot/core/components/PlotAxis.svelte +40 -17
- package/dist/plot/core/components/PlotControls.svelte +65 -41
- package/dist/plot/core/components/PlotLegend.svelte +31 -35
- package/dist/plot/core/components/PlotMarginals.svelte +616 -0
- package/dist/plot/core/components/PlotMarginals.svelte.d.ts +15 -0
- package/dist/plot/core/components/PlotTooltip.svelte +1 -1
- package/dist/plot/core/components/PortalSelect.svelte +4 -8
- package/dist/plot/core/components/ReferenceLine.svelte +27 -24
- package/dist/plot/core/components/ReferenceLine3D.svelte +54 -57
- package/dist/plot/core/components/ReferencePlane.svelte +7 -8
- package/dist/plot/core/components/ZeroLines.svelte +4 -8
- package/dist/plot/core/components/ZoomRect.svelte +1 -2
- package/dist/plot/core/components/index.d.ts +1 -0
- package/dist/plot/core/components/index.js +1 -0
- package/dist/plot/core/data-cleaning-signal.d.ts +46 -0
- package/dist/plot/core/data-cleaning-signal.js +467 -0
- package/dist/plot/core/data-cleaning.d.ts +2 -42
- package/dist/plot/core/data-cleaning.js +27 -474
- package/dist/plot/core/data-transform.js +9 -5
- package/dist/plot/core/fill-utils.d.ts +3 -1
- package/dist/plot/core/fill-utils.js +28 -6
- package/dist/plot/core/index.d.ts +1 -0
- package/dist/plot/core/index.js +1 -0
- package/dist/plot/core/interactions.js +0 -2
- package/dist/plot/core/layout.d.ts +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/reference-line.js +1 -1
- package/dist/plot/core/scales.d.ts +23 -0
- package/dist/plot/core/scales.js +39 -13
- package/dist/plot/core/types/fills.d.ts +101 -0
- package/dist/plot/core/types/fills.js +15 -0
- package/dist/plot/core/types/plot-3d.d.ts +87 -0
- package/dist/plot/core/types/plot-3d.js +4 -0
- package/dist/plot/core/types/reference-lines.d.ts +140 -0
- package/dist/plot/core/types/reference-lines.js +9 -0
- package/dist/plot/core/types.d.ts +29 -324
- package/dist/plot/core/types.js +23 -20
- package/dist/plot/core/utils/hierarchy-chart.d.ts +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.js +2 -2
- package/dist/plot/histogram/Histogram.svelte +304 -325
- package/dist/plot/histogram/Histogram.svelte.d.ts +7 -7
- package/dist/plot/histogram/HistogramControls.svelte +30 -28
- package/dist/plot/histogram/histogram.d.ts +31 -0
- package/dist/plot/histogram/histogram.js +70 -0
- package/dist/plot/histogram/index.d.ts +1 -0
- package/dist/plot/histogram/index.js +1 -0
- package/dist/plot/index.d.ts +1 -0
- package/dist/plot/index.js +1 -0
- package/dist/plot/sankey/Sankey.svelte +78 -69
- package/dist/plot/sankey/Sankey.svelte.d.ts +2 -2
- package/dist/plot/sankey/SankeyControls.svelte +22 -16
- package/dist/plot/scatter/BinnedScatterPlot.svelte +263 -109
- package/dist/plot/scatter/BinnedScatterPlot.svelte.d.ts +7 -0
- package/dist/plot/scatter/ElementScatter.svelte +4 -1
- package/dist/plot/scatter/ScatterPlot.svelte +477 -385
- package/dist/plot/scatter/ScatterPlot.svelte.d.ts +2 -0
- package/dist/plot/scatter/ScatterPlotControls.svelte +18 -19
- package/dist/plot/scatter/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/scatter/ScatterPoint.svelte +16 -9
- package/dist/plot/scatter/binned-scatter-types.d.ts +3 -2
- package/dist/plot/scatter/binned-scatter-types.js +6 -1
- package/dist/plot/scatter/scatter-data.d.ts +1 -1
- package/dist/plot/scatter/scatter-data.js +8 -7
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte +25 -34
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte.d.ts +2 -2
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte +8 -5
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte +113 -116
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte.d.ts +2 -2
- package/dist/plot/scatter-3d/Surface3D.svelte +4 -13
- package/dist/plot/sunburst/Sunburst.svelte +251 -329
- package/dist/plot/sunburst/Sunburst.svelte.d.ts +2 -2
- package/dist/plot/sunburst/index.d.ts +1 -1
- package/dist/plot/sunburst/index.js +2 -1
- package/dist/plot/sunburst/render.d.ts +2 -2
- package/dist/plot/sunburst/render.js +47 -22
- package/dist/plot/sunburst/sunburst.d.ts +5 -1
- package/dist/plot/sunburst/sunburst.js +10 -3
- package/dist/plot/treemap/Treemap.svelte +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 +1 -1
- package/dist/scene/bind-renderer.svelte.js +14 -6
- package/dist/settings.d.ts +19 -9
- package/dist/settings.js +77 -50
- package/dist/spectral/Bands.svelte +223 -230
- package/dist/spectral/BandsAndDos.svelte +11 -9
- package/dist/spectral/BrillouinBandsDos.svelte +19 -27
- package/dist/spectral/Dos.svelte +70 -73
- package/dist/spectral/helpers.d.ts +3 -3
- package/dist/spectral/helpers.js +25 -35
- package/dist/state.svelte.js +5 -18
- package/dist/structure/Arrow.svelte +5 -18
- package/dist/structure/ArrowInstances.svelte +160 -0
- package/dist/structure/ArrowInstances.svelte.d.ts +16 -0
- package/dist/structure/AtomLegend.svelte +115 -75
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/Bond.svelte +31 -23
- package/dist/structure/CanvasTooltip.svelte +15 -3
- package/dist/structure/CellSelect.svelte +11 -26
- 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 +473 -419
- package/dist/structure/Structure.svelte.d.ts +4 -2
- package/dist/structure/StructureCarousel.svelte +630 -0
- package/dist/structure/StructureCarousel.svelte.d.ts +19 -0
- package/dist/structure/StructureControls.svelte +157 -399
- package/dist/structure/StructureControls.svelte.d.ts +1 -1
- package/dist/structure/StructureExportPane.svelte +17 -21
- package/dist/structure/StructureInfoPane.svelte +72 -66
- package/dist/structure/StructureInfoPane.svelte.d.ts +1 -1
- package/dist/structure/StructureScene.svelte +467 -476
- package/dist/structure/StructureScene.svelte.d.ts +3 -1
- package/dist/structure/StructureViewport.svelte +386 -0
- package/dist/structure/StructureViewport.svelte.d.ts +63 -0
- package/dist/structure/atom-label-placement.d.ts +16 -12
- package/dist/structure/atom-label-placement.js +70 -37
- package/dist/structure/atom-properties.d.ts +2 -0
- package/dist/structure/atom-properties.js +104 -38
- package/dist/structure/bonding.d.ts +10 -3
- package/dist/structure/bonding.js +84 -28
- package/dist/structure/edit-history.d.ts +6 -0
- package/dist/structure/edit-history.js +27 -0
- package/dist/structure/export.d.ts +1 -0
- package/dist/structure/export.js +39 -31
- 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 +16 -1
- package/dist/structure/index.js +13 -2
- package/dist/structure/measure.d.ts +1 -1
- package/dist/structure/measure.js +6 -12
- package/dist/structure/parse.d.ts +2 -1
- package/dist/structure/parse.js +243 -222
- package/dist/structure/partial-occupancy.js +4 -2
- package/dist/structure/pbc.js +78 -98
- package/dist/structure/polyhedra.d.ts +0 -1
- package/dist/structure/polyhedra.js +3 -18
- package/dist/structure/supercell.d.ts +1 -2
- package/dist/structure/supercell.js +7 -13
- package/dist/symmetry/SymmetryElements.svelte +11 -15
- package/dist/symmetry/SymmetryStats.svelte +56 -68
- package/dist/symmetry/WyckoffTable.svelte +5 -24
- package/dist/symmetry/cell-transform.js +1 -0
- package/dist/symmetry/index.d.ts +1 -0
- package/dist/symmetry/index.js +8 -2
- package/dist/symmetry/spacegroups.js +3 -2
- package/dist/table/HeatmapTable.svelte +1102 -365
- 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 +515 -308
- package/dist/trajectory/Trajectory.svelte.d.ts +1 -1
- package/dist/trajectory/TrajectoryError.svelte +11 -8
- package/dist/trajectory/TrajectoryExportPane.svelte +14 -31
- package/dist/trajectory/TrajectoryInfoPane.svelte +85 -97
- package/dist/trajectory/extract.js +56 -34
- package/dist/trajectory/format-detect.js +11 -9
- package/dist/trajectory/frame-reader.d.ts +2 -0
- package/dist/trajectory/frame-reader.js +33 -29
- package/dist/trajectory/helpers.d.ts +2 -0
- package/dist/trajectory/helpers.js +18 -7
- package/dist/trajectory/index.d.ts +1 -0
- package/dist/trajectory/index.js +3 -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 +2 -3
- package/dist/trajectory/parse/index.js +17 -20
- package/dist/trajectory/parse/lammps.js +8 -12
- package/dist/trajectory/parse/vasp.js +10 -7
- package/dist/trajectory/parse/vaspout-electronic.d.ts +13 -0
- package/dist/trajectory/parse/vaspout-electronic.js +207 -0
- package/dist/trajectory/parse/vaspout-h5.d.ts +5 -0
- package/dist/trajectory/parse/vaspout-h5.js +284 -0
- package/dist/trajectory/parse/xyz.js +11 -7
- package/dist/trajectory/plotting.d.ts +8 -9
- package/dist/trajectory/plotting.js +99 -27
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +7 -0
- package/dist/xrd/XrdPlot.svelte +47 -61
- package/dist/xrd/broadening.js +2 -1
- package/dist/xrd/calc-xrd.js +2 -4
- package/dist/xrd/parse.d.ts +0 -1
- package/dist/xrd/parse.js +56 -73
- package/package.json +61 -33
- package/dist/api/mp.d.ts +0 -6
- package/dist/api/mp.js +0 -22
- package/dist/plot/sunburst/SunburstControls.svelte +0 -200
|
@@ -46,20 +46,17 @@
|
|
|
46
46
|
const DEFAULT_SEARCH_EXAMPLES: SearchExampleCategory[] = [
|
|
47
47
|
{
|
|
48
48
|
label: `Has elements`,
|
|
49
|
-
description:
|
|
50
|
-
`Materials containing these elements. Operators/ranges: +Li,-O,Fe:1-2. Use * for any element.`,
|
|
49
|
+
description: `Materials containing these elements. Operators/ranges: +Li,-O,Fe:1-2. Use * for any element.`,
|
|
51
50
|
examples: [`Li,Fe`, `+Li,-O`, `Li,*,*`],
|
|
52
51
|
},
|
|
53
52
|
{
|
|
54
53
|
label: `Chemical system`,
|
|
55
|
-
description:
|
|
56
|
-
`Materials with only these elements (no others). Wildcards/ranges supported.`,
|
|
54
|
+
description: `Materials with only these elements (no others). Wildcards/ranges supported.`,
|
|
57
55
|
examples: [`Li-Fe-O`, `Li-Fe-*-*`, `*-*-O`],
|
|
58
56
|
},
|
|
59
57
|
{
|
|
60
58
|
label: `Exact formula`,
|
|
61
|
-
description:
|
|
62
|
-
`Materials with this exact stoichiometry. Unicode paste, wildcards, and canonicalization supported.`,
|
|
59
|
+
description: `Materials with this exact stoichiometry. Unicode paste, wildcards, and canonicalization supported.`,
|
|
63
60
|
examples: [`LiFePO4`, `LiFe*2*`, `*2O3`],
|
|
64
61
|
},
|
|
65
62
|
]
|
|
@@ -162,10 +159,9 @@
|
|
|
162
159
|
if (!raw) return []
|
|
163
160
|
const parsed: unknown = JSON.parse(raw)
|
|
164
161
|
if (!Array.isArray(parsed)) return []
|
|
165
|
-
return parsed
|
|
166
|
-
|
|
167
|
-
max_history
|
|
168
|
-
)
|
|
162
|
+
return parsed
|
|
163
|
+
.filter((item): item is string => typeof item === `string`)
|
|
164
|
+
.slice(0, max_history)
|
|
169
165
|
} catch {
|
|
170
166
|
return []
|
|
171
167
|
}
|
|
@@ -249,9 +245,7 @@
|
|
|
249
245
|
let visible_history = $derived.by(() => {
|
|
250
246
|
const filtered = history
|
|
251
247
|
.filter((item) => item !== value)
|
|
252
|
-
.filter((item) =>
|
|
253
|
-
item.toLowerCase().includes(history_query.toLowerCase().trim())
|
|
254
|
-
)
|
|
248
|
+
.filter((item) => item.toLowerCase().includes(history_query.toLowerCase().trim()))
|
|
255
249
|
const pinned = filtered.filter((item) => pinned_history.includes(item))
|
|
256
250
|
const unpinned = filtered.filter((item) => !pinned_history.includes(item))
|
|
257
251
|
return [...pinned, ...unpinned]
|
|
@@ -305,9 +299,9 @@
|
|
|
305
299
|
$effect(() => {
|
|
306
300
|
if (!examples_open || !examples_wrapper) return
|
|
307
301
|
requestAnimationFrame(() => {
|
|
308
|
-
const dropdown = examples_wrapper?.querySelector(
|
|
309
|
-
|
|
310
|
-
|
|
302
|
+
const dropdown = examples_wrapper?.querySelector(
|
|
303
|
+
`.examples-dropdown`,
|
|
304
|
+
) as HTMLElement | null
|
|
311
305
|
if (!dropdown) return
|
|
312
306
|
const rect = dropdown.getBoundingClientRect()
|
|
313
307
|
if (rect.right > window.innerWidth && !anchor_left) anchor_left = true
|
|
@@ -337,11 +331,13 @@
|
|
|
337
331
|
for (const [superscript, ascii] of Object.entries(SUPERSCRIPT_TO_ASCII)) {
|
|
338
332
|
normalized = normalized.replaceAll(superscript, ascii)
|
|
339
333
|
}
|
|
340
|
-
return
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
334
|
+
return (
|
|
335
|
+
normalized
|
|
336
|
+
// keep hydrate dots (deleting would glue digits: CuSO4·5H2O -> CuSO45H2O)
|
|
337
|
+
.replaceAll(`⋅`, `·`)
|
|
338
|
+
.replaceAll(`−`, `-`)
|
|
339
|
+
.replaceAll(/\s+/g, ``)
|
|
340
|
+
)
|
|
345
341
|
}
|
|
346
342
|
|
|
347
343
|
function normalize_exact_formula(input: string): string {
|
|
@@ -356,8 +352,9 @@
|
|
|
356
352
|
try {
|
|
357
353
|
const tokens = parse_formula_with_wildcards(sanitized_input)
|
|
358
354
|
const explicit = tokens
|
|
359
|
-
.filter(
|
|
360
|
-
token
|
|
355
|
+
.filter(
|
|
356
|
+
(token): token is { element: ElementSymbol; count: number } =>
|
|
357
|
+
token.element !== null,
|
|
361
358
|
)
|
|
362
359
|
.map((token) => ({ element: token.element, count: token.count }))
|
|
363
360
|
const wildcard_tokens = tokens.filter((token) => token.element === null)
|
|
@@ -365,21 +362,19 @@
|
|
|
365
362
|
// Merge explicit element counts before sorting.
|
|
366
363
|
const merged_explicit: { element: string; count: number }[] = []
|
|
367
364
|
for (const token of explicit) {
|
|
368
|
-
const existing = merged_explicit.find((item) =>
|
|
369
|
-
item.element === token.element
|
|
370
|
-
)
|
|
365
|
+
const existing = merged_explicit.find((item) => item.element === token.element)
|
|
371
366
|
if (existing) existing.count += token.count
|
|
372
367
|
else merged_explicit.push(token)
|
|
373
368
|
}
|
|
374
369
|
const sorted_explicit = merged_explicit.sort((elem_a, elem_b) =>
|
|
375
|
-
elem_a.element.localeCompare(elem_b.element)
|
|
370
|
+
elem_a.element.localeCompare(elem_b.element),
|
|
376
371
|
)
|
|
377
|
-
const wildcard_str = wildcard_tokens
|
|
378
|
-
token.count > 1 ? `*${token.count}` : `*`
|
|
379
|
-
|
|
380
|
-
const explicit_str = sorted_explicit
|
|
381
|
-
token.count > 1 ? `${token.element}${token.count}` : token.element
|
|
382
|
-
|
|
372
|
+
const wildcard_str = wildcard_tokens
|
|
373
|
+
.map((token) => (token.count > 1 ? `*${token.count}` : `*`))
|
|
374
|
+
.join(``)
|
|
375
|
+
const explicit_str = sorted_explicit
|
|
376
|
+
.map((token) => (token.count > 1 ? `${token.element}${token.count}` : token.element))
|
|
377
|
+
.join(``)
|
|
383
378
|
return `${explicit_str}${wildcard_str}`
|
|
384
379
|
} catch {
|
|
385
380
|
return sanitized_input
|
|
@@ -388,16 +383,18 @@
|
|
|
388
383
|
|
|
389
384
|
function is_valid_constraint(constraint: string): boolean {
|
|
390
385
|
if (!constraint) return true
|
|
391
|
-
return
|
|
392
|
-
|
|
386
|
+
return (
|
|
387
|
+
/^\d+$/.test(constraint) ||
|
|
388
|
+
/^\d+-\d+$/.test(constraint) ||
|
|
389
|
+
/^(?:>=|<=|>|<)\d+$/.test(constraint)
|
|
390
|
+
)
|
|
393
391
|
}
|
|
394
392
|
|
|
395
|
-
function strip_operator_prefix(
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
: `include`
|
|
393
|
+
function strip_operator_prefix(token: string): {
|
|
394
|
+
operator: FormulaFilterToken[`operator`]
|
|
395
|
+
value: string
|
|
396
|
+
} {
|
|
397
|
+
const operator = token.startsWith(`-`) || token.startsWith(`!`) ? `exclude` : `include`
|
|
401
398
|
const stripped_value =
|
|
402
399
|
token.startsWith(`+`) || token.startsWith(`-`) || token.startsWith(`!`)
|
|
403
400
|
? token.slice(1)
|
|
@@ -429,8 +426,9 @@
|
|
|
429
426
|
const is_wildcard = element === `*`
|
|
430
427
|
const is_valid_element = is_wildcard || is_elem_symbol(element)
|
|
431
428
|
const normalized_constraint = constraint?.trim() || null
|
|
432
|
-
const is_valid =
|
|
433
|
-
|
|
429
|
+
const is_valid =
|
|
430
|
+
is_valid_element &&
|
|
431
|
+
(normalized_constraint === null || is_valid_constraint(normalized_constraint))
|
|
434
432
|
|
|
435
433
|
return {
|
|
436
434
|
raw: raw_token,
|
|
@@ -442,36 +440,37 @@
|
|
|
442
440
|
}
|
|
443
441
|
}
|
|
444
442
|
|
|
445
|
-
function tokenize_query(
|
|
446
|
-
input: string,
|
|
447
|
-
mode: FormulaSearchMode,
|
|
448
|
-
): FormulaFilterToken[] {
|
|
443
|
+
function tokenize_query(input: string, mode: FormulaSearchMode): FormulaFilterToken[] {
|
|
449
444
|
const trimmed = input.trim()
|
|
450
445
|
if (!trimmed) return []
|
|
451
446
|
if (mode === `exact`) {
|
|
452
|
-
return [
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
447
|
+
return [
|
|
448
|
+
{
|
|
449
|
+
raw: trimmed,
|
|
450
|
+
element: trimmed,
|
|
451
|
+
operator: `include`,
|
|
452
|
+
constraint: null,
|
|
453
|
+
is_wildcard: has_wildcards(trimmed),
|
|
454
|
+
is_valid: sanitize_exact_formula(trimmed).is_valid,
|
|
455
|
+
},
|
|
456
|
+
]
|
|
460
457
|
}
|
|
461
458
|
const normalized = mode === `chemsys` ? trimmed.replaceAll(`,`, `-`) : trimmed
|
|
462
|
-
const tokens =
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
459
|
+
const tokens =
|
|
460
|
+
mode === `chemsys`
|
|
461
|
+
? // Keep range constraints like Fe:1-2 intact while splitting token separators.
|
|
462
|
+
normalized.split(/-(?!\d)/)
|
|
463
|
+
: normalized.split(`,`)
|
|
466
464
|
return tokens
|
|
467
465
|
.map((token) => token.trim())
|
|
468
466
|
.filter(Boolean)
|
|
469
467
|
.map(parse_token)
|
|
470
468
|
}
|
|
471
469
|
|
|
472
|
-
function sanitize_exact_formula(
|
|
473
|
-
|
|
474
|
-
|
|
470
|
+
function sanitize_exact_formula(input: string): {
|
|
471
|
+
is_valid: boolean
|
|
472
|
+
error_message: string | null
|
|
473
|
+
} {
|
|
475
474
|
const trimmed = input.trim()
|
|
476
475
|
if (!trimmed) return { is_valid: true, error_message: null }
|
|
477
476
|
try {
|
|
@@ -510,9 +509,7 @@
|
|
|
510
509
|
return token_a.element.localeCompare(token_b.element)
|
|
511
510
|
})
|
|
512
511
|
|
|
513
|
-
return normalized_tokens
|
|
514
|
-
.map(serialize_token)
|
|
515
|
-
.join(separator)
|
|
512
|
+
return normalized_tokens.map(serialize_token).join(separator)
|
|
516
513
|
}
|
|
517
514
|
|
|
518
515
|
function parse_query(
|
|
@@ -521,14 +518,15 @@
|
|
|
521
518
|
): FormulaFilterParseResult {
|
|
522
519
|
const tokens = tokenize_query(normalized_value, mode)
|
|
523
520
|
const first_invalid_token = tokens.find((token) => !token.is_valid)
|
|
524
|
-
const exact_validation =
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
521
|
+
const exact_validation =
|
|
522
|
+
mode === `exact`
|
|
523
|
+
? sanitize_exact_formula(normalized_value)
|
|
524
|
+
: {
|
|
525
|
+
is_valid: !first_invalid_token,
|
|
526
|
+
error_message: first_invalid_token
|
|
527
|
+
? `Invalid token: ${first_invalid_token.raw}`
|
|
528
|
+
: null,
|
|
529
|
+
}
|
|
532
530
|
return {
|
|
533
531
|
value: normalized_value,
|
|
534
532
|
normalized_value,
|
|
@@ -559,7 +557,10 @@
|
|
|
559
557
|
if (!trimmed) return []
|
|
560
558
|
// If contains commas or dashes, split by those and sort alphabetically
|
|
561
559
|
if (trimmed.includes(`,`) || trimmed.includes(`-`)) {
|
|
562
|
-
const parts = trimmed
|
|
560
|
+
const parts = trimmed
|
|
561
|
+
.split(/[-,]/)
|
|
562
|
+
.map((str) => str.trim())
|
|
563
|
+
.filter(Boolean)
|
|
563
564
|
// Separate wildcards from regular elements
|
|
564
565
|
const wildcards = parts.filter((part) => part === `*`)
|
|
565
566
|
const regular_parts = parts.filter((part) => part !== `*`)
|
|
@@ -569,7 +570,8 @@
|
|
|
569
570
|
}
|
|
570
571
|
// Otherwise parse as formula (already returns sorted by default)
|
|
571
572
|
// For formulas with wildcards, we can't parse them normally
|
|
572
|
-
if (has_wildcards(trimmed)) {
|
|
573
|
+
if (has_wildcards(trimmed)) {
|
|
574
|
+
// Use shared utility and extract unique elements
|
|
573
575
|
const tokens = parse_formula_with_wildcards(trimmed)
|
|
574
576
|
const unique_elements: string[] = []
|
|
575
577
|
for (const token of tokens) {
|
|
@@ -578,9 +580,7 @@
|
|
|
578
580
|
}
|
|
579
581
|
}
|
|
580
582
|
const elements = unique_elements.sort()
|
|
581
|
-
const wildcards = tokens.filter((token) => token.element === null).map(() =>
|
|
582
|
-
`*`
|
|
583
|
-
)
|
|
583
|
+
const wildcards = tokens.filter((token) => token.element === null).map(() => `*`)
|
|
584
584
|
return [...elements, ...wildcards]
|
|
585
585
|
}
|
|
586
586
|
try {
|
|
@@ -672,9 +672,7 @@
|
|
|
672
672
|
focused_history_idx = (focused_history_idx + 1) % len
|
|
673
673
|
} else if (event.key === `ArrowUp`) {
|
|
674
674
|
event.preventDefault()
|
|
675
|
-
focused_history_idx = focused_history_idx <= 0
|
|
676
|
-
? len - 1
|
|
677
|
-
: focused_history_idx - 1
|
|
675
|
+
focused_history_idx = focused_history_idx <= 0 ? len - 1 : focused_history_idx - 1
|
|
678
676
|
}
|
|
679
677
|
}
|
|
680
678
|
}
|
|
@@ -709,8 +707,8 @@
|
|
|
709
707
|
function handle_menu_keydown(event: KeyboardEvent): void {
|
|
710
708
|
const len = all_examples.length
|
|
711
709
|
if (!len) return
|
|
712
|
-
const is_button_activation =
|
|
713
|
-
event.target instanceof HTMLButtonElement
|
|
710
|
+
const is_button_activation =
|
|
711
|
+
(event.key === `Enter` || event.key === ` `) && event.target instanceof HTMLButtonElement
|
|
714
712
|
if (is_button_activation) return
|
|
715
713
|
|
|
716
714
|
const key_actions: Record<string, () => void> = {
|
|
@@ -734,8 +732,9 @@
|
|
|
734
732
|
function remove_token(token_idx: number): void {
|
|
735
733
|
if (search_mode === `exact`) return
|
|
736
734
|
const separator = search_mode === `chemsys` ? `-` : `,`
|
|
737
|
-
const tokens = tokenize_query(input_value, search_mode)
|
|
738
|
-
|
|
735
|
+
const tokens = tokenize_query(input_value, search_mode).filter(
|
|
736
|
+
(_, idx) => idx !== token_idx,
|
|
737
|
+
)
|
|
739
738
|
const next_value = tokens.map(serialize_token).join(separator)
|
|
740
739
|
input_value = next_value
|
|
741
740
|
set_value(next_value, search_mode)
|
|
@@ -752,8 +751,8 @@
|
|
|
752
751
|
search_mode === `chemsys`
|
|
753
752
|
? `Li-Fe-O or Li-*-*`
|
|
754
753
|
: search_mode === `exact`
|
|
755
|
-
|
|
756
|
-
|
|
754
|
+
? `LiFePO4 or LiFe*2*`
|
|
755
|
+
: `Li,Fe,O or Li,*,*`,
|
|
757
756
|
)
|
|
758
757
|
|
|
759
758
|
const MODE_LABELS: Record<FormulaSearchMode, string> = {
|
|
@@ -877,8 +876,8 @@
|
|
|
877
876
|
class:locked={mode_locked}
|
|
878
877
|
onclick={cycle_mode}
|
|
879
878
|
title={mode_locked
|
|
880
|
-
|
|
881
|
-
|
|
879
|
+
? `Mode is locked`
|
|
880
|
+
: `Click to switch to '${next_mode.mode}' → ${next_mode.value}`}
|
|
882
881
|
{@attach tooltip()}
|
|
883
882
|
aria-label="Change search mode"
|
|
884
883
|
>
|
|
@@ -959,11 +958,7 @@
|
|
|
959
958
|
</div>
|
|
960
959
|
{#if show_chip_row}
|
|
961
960
|
<div class="token-chip-row">
|
|
962
|
-
{#each parsed_tokens as
|
|
963
|
-
token,
|
|
964
|
-
idx
|
|
965
|
-
(`${token.operator}:${token.element}:${token.constraint ?? ``}:${idx}`)
|
|
966
|
-
}
|
|
961
|
+
{#each parsed_tokens as token, idx (`${token.operator}:${token.element}:${token.constraint ?? ``}:${idx}`)}
|
|
967
962
|
<button
|
|
968
963
|
type="button"
|
|
969
964
|
class="token-chip"
|
|
@@ -1037,7 +1032,9 @@
|
|
|
1037
1032
|
cursor: pointer;
|
|
1038
1033
|
color: var(--highlight, #4db6ff);
|
|
1039
1034
|
opacity: 0.8;
|
|
1040
|
-
transition:
|
|
1035
|
+
transition:
|
|
1036
|
+
opacity 0.15s,
|
|
1037
|
+
background 0.15s;
|
|
1041
1038
|
&:hover {
|
|
1042
1039
|
opacity: 1;
|
|
1043
1040
|
background: rgba(77, 182, 255, 0.2);
|
|
@@ -6,7 +6,12 @@
|
|
|
6
6
|
import { format_num } from '../labels'
|
|
7
7
|
import type { Snippet } from 'svelte'
|
|
8
8
|
import type { SVGAttributes } from 'svelte/elements'
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
chart_segment_label,
|
|
11
|
+
chart_segment_suffix,
|
|
12
|
+
type ChartSegmentData,
|
|
13
|
+
get_chart_font_scale,
|
|
14
|
+
} from './index'
|
|
10
15
|
import { count_atoms_in_composition, fractional_composition } from './parse'
|
|
11
16
|
|
|
12
17
|
// Constants for pie chart calculations
|
|
@@ -81,15 +86,19 @@
|
|
|
81
86
|
const outer_arc = `M ${center} ${center - radius} A ${radius} ${radius} 0 1 1 ${center} ${
|
|
82
87
|
center + radius
|
|
83
88
|
} A ${radius} ${radius} 0 1 1 ${center} ${center - radius} Z`
|
|
84
|
-
const path =
|
|
85
|
-
|
|
86
|
-
center - ir
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
const path =
|
|
90
|
+
ir > 0
|
|
91
|
+
? `${outer_arc} M ${center} ${center - ir} A ${ir} ${ir} 0 1 0 ${center} ${
|
|
92
|
+
center + ir
|
|
93
|
+
} A ${ir} ${ir} 0 1 0 ${center} ${center - ir} Z`
|
|
94
|
+
: outer_arc
|
|
95
|
+
const label_text = chart_segment_label(
|
|
96
|
+
element,
|
|
97
|
+
amount,
|
|
98
|
+
fraction,
|
|
99
|
+
show_amounts,
|
|
100
|
+
show_percentages,
|
|
101
|
+
)
|
|
93
102
|
return {
|
|
94
103
|
element,
|
|
95
104
|
amount,
|
|
@@ -132,14 +141,15 @@
|
|
|
132
141
|
const large_arc = angle_span > 180 ? 1 : 0
|
|
133
142
|
|
|
134
143
|
// Create donut path if inner radius > 0, otherwise regular pie slice
|
|
135
|
-
const path =
|
|
136
|
-
|
|
137
|
-
|
|
144
|
+
const path =
|
|
145
|
+
inner_radius_adjusted > 0
|
|
146
|
+
? `M ${x1_outer} ${y1_outer} A ${outer_radius} ${outer_radius} 0 ${large_arc} 1 ${x2_outer} ${y2_outer} L ${x2_inner} ${y2_inner} A ${inner_radius_adjusted} ${inner_radius_adjusted} 0 ${large_arc} 0 ${x1_inner} ${y1_inner} Z`
|
|
147
|
+
: `M ${center} ${center} L ${x1_outer} ${y1_outer} A ${outer_radius} ${outer_radius} 0 ${large_arc} 1 ${x2_outer} ${y2_outer} Z`
|
|
138
148
|
|
|
139
149
|
// Position labels with three-tier strategy
|
|
140
150
|
const is_very_thin_slice = angle_span < VERY_THIN_SLICE_THRESHOLD // Place outside
|
|
141
|
-
const is_medium_slice =
|
|
142
|
-
angle_span < MEDIUM_SLICE_THRESHOLD // Near outer edge
|
|
151
|
+
const is_medium_slice =
|
|
152
|
+
angle_span >= VERY_THIN_SLICE_THRESHOLD && angle_span < MEDIUM_SLICE_THRESHOLD // Near outer edge
|
|
143
153
|
|
|
144
154
|
let label_radius: number
|
|
145
155
|
let is_outside_slice = false
|
|
@@ -159,22 +169,22 @@
|
|
|
159
169
|
// Calculate font scale based on slice size and smart text fitting
|
|
160
170
|
const [min_font_scale, max_font_scale] = [1.4, 2] as const
|
|
161
171
|
const scale_factor = angle_span / MAX_ANGLE_FOR_FULL_SCALE
|
|
162
|
-
const base_scale = min_font_scale +
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
172
|
+
const base_scale = min_font_scale + scale_factor * (max_font_scale - min_font_scale)
|
|
173
|
+
const label_text = chart_segment_label(
|
|
174
|
+
element,
|
|
175
|
+
amount,
|
|
176
|
+
fraction,
|
|
177
|
+
show_amounts,
|
|
178
|
+
show_percentages,
|
|
179
|
+
)
|
|
166
180
|
const available_space = is_very_thin_slice
|
|
167
181
|
? outer_radius * 0.8 // More space outside the slice
|
|
168
182
|
: Math.min(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
183
|
+
outer_radius - inner_radius_adjusted, // Radial space
|
|
184
|
+
((angle_span * Math.PI) / 180) * label_radius * 0.8, // Arc space at label radius
|
|
185
|
+
)
|
|
172
186
|
|
|
173
|
-
const font_scale = get_chart_font_scale(
|
|
174
|
-
base_scale,
|
|
175
|
-
label_text,
|
|
176
|
-
available_space,
|
|
177
|
-
)
|
|
187
|
+
const font_scale = get_chart_font_scale(base_scale, label_text, available_space)
|
|
178
188
|
|
|
179
189
|
return {
|
|
180
190
|
element,
|
|
@@ -202,7 +212,7 @@
|
|
|
202
212
|
viewBox="0 0 {size} {size}"
|
|
203
213
|
style:max-width="{size}px"
|
|
204
214
|
{...rest}
|
|
205
|
-
class=
|
|
215
|
+
class={[`pie-chart`, rest.class]}
|
|
206
216
|
bind:this={svg_node}
|
|
207
217
|
>
|
|
208
218
|
{#each segments as segment (segment.element)}
|
|
@@ -211,10 +221,10 @@
|
|
|
211
221
|
fill={segment.color}
|
|
212
222
|
stroke="white"
|
|
213
223
|
stroke-width={segments.length === 1
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
224
|
+
? 0
|
|
225
|
+
: hovered_element === segment.element
|
|
226
|
+
? stroke_width + 1
|
|
227
|
+
: stroke_width}
|
|
218
228
|
class="pie-segment"
|
|
219
229
|
class:interactive
|
|
220
230
|
class:hovered={hovered_element === segment.element}
|
|
@@ -254,15 +264,18 @@
|
|
|
254
264
|
class:outside-slice={segment.is_outside_slice}
|
|
255
265
|
style:color={segment.text_color}
|
|
256
266
|
>
|
|
257
|
-
<span class="element-symbol" style:font-size="{14 * segment.font_scale}px"
|
|
258
|
-
segment.element
|
|
259
|
-
|
|
267
|
+
<span class="element-symbol" style:font-size="{14 * segment.font_scale}px"
|
|
268
|
+
>{segment.element}</span
|
|
269
|
+
>
|
|
260
270
|
{#if show_amounts || show_percentages}
|
|
261
|
-
<sub class="amount" style:font-size="{8 * segment.font_scale}px"
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
271
|
+
<sub class="amount" style:font-size="{8 * segment.font_scale}px"
|
|
272
|
+
>{chart_segment_suffix(
|
|
273
|
+
segment.amount,
|
|
274
|
+
segment.fraction,
|
|
275
|
+
show_amounts,
|
|
276
|
+
show_percentages,
|
|
277
|
+
)}</sub
|
|
278
|
+
>
|
|
266
279
|
{/if}
|
|
267
280
|
</div>
|
|
268
281
|
</foreignObject>
|
|
@@ -285,7 +298,8 @@
|
|
|
285
298
|
.pie-segment.interactive {
|
|
286
299
|
cursor: pointer;
|
|
287
300
|
}
|
|
288
|
-
.pie-segment.interactive:hover,
|
|
301
|
+
.pie-segment.interactive:hover,
|
|
302
|
+
.pie-segment.hovered {
|
|
289
303
|
filter: brightness(1.1);
|
|
290
304
|
}
|
|
291
305
|
.pie-segment.interactive:focus {
|
|
@@ -86,7 +86,7 @@ export const get_electro_neg_formula = (input, plain_text = false, delim = ` `,
|
|
|
86
86
|
export function get_formula_label_segments(formula) {
|
|
87
87
|
const segments = [];
|
|
88
88
|
let cursor = 0;
|
|
89
|
-
for (const match of formula.matchAll(/([A-Za-z])(
|
|
89
|
+
for (const match of formula.matchAll(/(?<letter>[A-Za-z])(?<amount>\d+(?:\.\d+)?)/g)) {
|
|
90
90
|
const match_idx = match.index ?? 0;
|
|
91
91
|
const prefix = match[1];
|
|
92
92
|
const amount = match[2];
|
|
@@ -18,4 +18,6 @@ export type ChartSegmentData = {
|
|
|
18
18
|
font_scale: number;
|
|
19
19
|
text_color: string;
|
|
20
20
|
};
|
|
21
|
+
export declare const chart_segment_suffix: (amount: number | undefined, fraction: number, show_amounts: boolean, show_percentages: boolean) => string;
|
|
22
|
+
export declare const chart_segment_label: (element: string, amount: number | undefined, fraction: number, show_amounts: boolean, show_percentages: boolean) => string;
|
|
21
23
|
export declare function get_chart_font_scale(base_scale: number, label_text: string, available_space: number, min_scale_factor?: number, base_font_size?: number): number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { format_num } from '../labels';
|
|
1
2
|
export { default as BarChart } from './BarChart.svelte';
|
|
2
3
|
export { default as BubbleChart } from './BubbleChart.svelte';
|
|
3
4
|
export * from './chem-sys';
|
|
@@ -7,6 +8,19 @@ export { default as Formula } from './Formula.svelte';
|
|
|
7
8
|
export { default as FormulaFilter } from './FormulaFilter.svelte';
|
|
8
9
|
export * from './parse';
|
|
9
10
|
export { default as PieChart } from './PieChart.svelte';
|
|
11
|
+
// Amount/percentage suffix rendered after the element symbol in bar/pie chart
|
|
12
|
+
// segments; `=` separates amount from percentage when both are shown (Fe2=20%).
|
|
13
|
+
// format_num (not toString) so float noise like 0.30000000000000004 can't leak
|
|
14
|
+
// into labels; same format convention as format_composition_formula subscripts
|
|
15
|
+
// (`.3~s`, avoiding SI prefixes for sub-1 amounts where `s` renders 0.5 as 500m)
|
|
16
|
+
export const chart_segment_suffix = (amount, fraction, show_amounts, show_percentages) => (show_amounts && amount !== undefined
|
|
17
|
+
? format_num(amount, Math.abs(amount) < 1 ? `.3~g` : `.3~s`)
|
|
18
|
+
: ``) +
|
|
19
|
+
(show_amounts && show_percentages ? `=` : ``) +
|
|
20
|
+
(show_percentages ? format_num(fraction, `.1~%`) : ``);
|
|
21
|
+
// Full segment label used to estimate label width for font scaling; must match
|
|
22
|
+
// the text the charts actually render (element symbol + chart_segment_suffix)
|
|
23
|
+
export const chart_segment_label = (element, amount, fraction, show_amounts, show_percentages) => element + chart_segment_suffix(amount, fraction, show_amounts, show_percentages);
|
|
10
24
|
export function get_chart_font_scale(base_scale, label_text, available_space, min_scale_factor = 0.7, base_font_size = 16) {
|
|
11
25
|
const text_width = label_text.length * 0.6 * base_font_size * base_scale;
|
|
12
26
|
return available_space > 0 && text_width > available_space
|
|
@@ -2,8 +2,8 @@ import type { ElementSymbol } from '../element';
|
|
|
2
2
|
import type { CompositionType } from './';
|
|
3
3
|
export declare const ATOMIC_NUMBER_TO_SYMBOL: Record<number, ElementSymbol>;
|
|
4
4
|
export declare const SYMBOL_TO_ATOMIC_NUMBER: Partial<CompositionType>;
|
|
5
|
-
export declare const ATOMIC_WEIGHTS: Map<"
|
|
6
|
-
export declare const ELEMENT_ELECTRONEGATIVITY_MAP: Map<"
|
|
5
|
+
export declare const ATOMIC_WEIGHTS: Map<"Ac" | "Ag" | "Al" | "Am" | "Ar" | "As" | "At" | "Au" | "B" | "Ba" | "Be" | "Bh" | "Bi" | "Bk" | "Br" | "C" | "Ca" | "Cd" | "Ce" | "Cf" | "Cl" | "Cm" | "Co" | "Cr" | "Cs" | "Cu" | "Db" | "Dy" | "Er" | "Es" | "Eu" | "F" | "Fe" | "Fm" | "Fr" | "Ga" | "Gd" | "Ge" | "H" | "He" | "Hf" | "Hg" | "Ho" | "Hs" | "I" | "In" | "Ir" | "K" | "Kr" | "La" | "Li" | "Lr" | "Lu" | "Md" | "Mg" | "Mn" | "Mo" | "Mt" | "N" | "Na" | "Nb" | "Nd" | "Ne" | "Ni" | "No" | "Np" | "O" | "Os" | "P" | "Pa" | "Pb" | "Pd" | "Pm" | "Po" | "Pr" | "Pt" | "Pu" | "Ra" | "Rb" | "Re" | "Rf" | "Rh" | "Rn" | "Ru" | "S" | "Sb" | "Sc" | "Se" | "Sg" | "Si" | "Sm" | "Sn" | "Sr" | "Ta" | "Tb" | "Tc" | "Te" | "Th" | "Ti" | "Tl" | "Tm" | "U" | "V" | "W" | "Xe" | "Y" | "Yb" | "Zn" | "Zr" | "Ds" | "Rg" | "Cn" | "Nh" | "Fl" | "Mc" | "Lv" | "Ts" | "Og", number>;
|
|
6
|
+
export declare const ELEMENT_ELECTRONEGATIVITY_MAP: Map<"Ac" | "Ag" | "Al" | "Am" | "Ar" | "As" | "At" | "Au" | "B" | "Ba" | "Be" | "Bh" | "Bi" | "Bk" | "Br" | "C" | "Ca" | "Cd" | "Ce" | "Cf" | "Cl" | "Cm" | "Co" | "Cr" | "Cs" | "Cu" | "Db" | "Dy" | "Er" | "Es" | "Eu" | "F" | "Fe" | "Fm" | "Fr" | "Ga" | "Gd" | "Ge" | "H" | "He" | "Hf" | "Hg" | "Ho" | "Hs" | "I" | "In" | "Ir" | "K" | "Kr" | "La" | "Li" | "Lr" | "Lu" | "Md" | "Mg" | "Mn" | "Mo" | "Mt" | "N" | "Na" | "Nb" | "Nd" | "Ne" | "Ni" | "No" | "Np" | "O" | "Os" | "P" | "Pa" | "Pb" | "Pd" | "Pm" | "Po" | "Pr" | "Pt" | "Pu" | "Ra" | "Rb" | "Re" | "Rf" | "Rh" | "Rn" | "Ru" | "S" | "Sb" | "Sc" | "Se" | "Sg" | "Si" | "Sm" | "Sn" | "Sr" | "Ta" | "Tb" | "Tc" | "Te" | "Th" | "Ti" | "Tl" | "Tm" | "U" | "V" | "W" | "Xe" | "Y" | "Yb" | "Zn" | "Zr" | "Ds" | "Rg" | "Cn" | "Nh" | "Fl" | "Mc" | "Lv" | "Ts" | "Og", number>;
|
|
7
7
|
export declare const ELEM_NAME_TO_SYMBOL: Record<string, ElementSymbol>;
|
|
8
8
|
export declare const ELEM_SYMBOL_TO_NAME: Partial<Record<ElementSymbol, string>>;
|
|
9
9
|
export declare const atomic_num_to_symbols: (atomic_composition: Record<number, number>) => CompositionType;
|