matterviz 0.3.7 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Icon.svelte +7 -4
- package/dist/MillerIndexInput.svelte +1 -1
- package/dist/api/optimade.js +32 -26
- package/dist/app.css +0 -3
- package/dist/brillouin/BrillouinZone.svelte +8 -3
- package/dist/brillouin/BrillouinZone.svelte.d.ts +2 -1
- package/dist/brillouin/BrillouinZoneScene.svelte +52 -6
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -0
- package/dist/brillouin/BrillouinZoneTooltip.svelte +16 -25
- package/dist/brillouin/compute.js +10 -14
- package/dist/chempot-diagram/ChemPotDiagram.svelte +14 -13
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +12 -15
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +8 -10
- package/dist/chempot-diagram/async-compute.svelte.js +3 -1
- package/dist/chempot-diagram/chempot-worker.js +2 -1
- package/dist/chempot-diagram/compute.d.ts +1 -1
- package/dist/chempot-diagram/compute.js +17 -19
- package/dist/colors/index.js +6 -5
- package/dist/composition/FormulaFilter.svelte +12 -6
- package/dist/composition/PieChart.svelte +6 -5
- package/dist/composition/chem-sys.d.ts +8 -0
- package/dist/composition/chem-sys.js +85 -0
- package/dist/composition/format.js +4 -2
- package/dist/composition/index.d.ts +1 -0
- package/dist/composition/index.js +1 -0
- package/dist/composition/parse.js +25 -13
- package/dist/convex-hull/ConvexHull2D.svelte +12 -10
- package/dist/convex-hull/ConvexHull3D.svelte +5 -5
- package/dist/convex-hull/ConvexHull4D.svelte +5 -9
- package/dist/convex-hull/ConvexHullStats.svelte +12 -12
- package/dist/convex-hull/GasPressureControls.svelte +4 -4
- package/dist/convex-hull/TemperatureSlider.svelte +2 -2
- package/dist/convex-hull/demo-temperature.d.ts +1 -1
- package/dist/convex-hull/demo-temperature.js +20 -22
- package/dist/convex-hull/gas-thermodynamics.d.ts +2 -2
- package/dist/convex-hull/gas-thermodynamics.js +22 -30
- package/dist/convex-hull/helpers.d.ts +3 -0
- package/dist/convex-hull/helpers.js +17 -9
- package/dist/convex-hull/index.d.ts +1 -1
- package/dist/convex-hull/thermodynamics.js +83 -78
- package/dist/convex-hull/types.d.ts +1 -1
- package/dist/coordination/CoordinationBarPlot.svelte +23 -23
- package/dist/coordination/CoordinationBarPlot.svelte.d.ts +1 -1
- package/dist/element/ElementTile.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSlice.svelte +13 -5
- package/dist/fermi-surface/FermiSurface.svelte +11 -5
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceControls.svelte +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte +3 -0
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +8 -34
- package/dist/fermi-surface/compute.js +59 -59
- package/dist/fermi-surface/export.js +3 -2
- package/dist/fermi-surface/parse.js +7 -4
- package/dist/fermi-surface/types.d.ts +1 -0
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +23 -21
- package/dist/heatmap-matrix/index.js +1 -1
- package/dist/io/decompress.js +4 -2
- package/dist/io/export.d.ts +4 -4
- package/dist/io/export.js +47 -25
- package/dist/io/fetch.js +5 -1
- package/dist/io/file-drop.d.ts +1 -1
- package/dist/io/file-drop.js +35 -36
- package/dist/io/url-drop.js +64 -33
- package/dist/isosurface/parse.js +6 -7
- package/dist/isosurface/slice.js +5 -4
- package/dist/isosurface/types.js +1 -1
- package/dist/keyboard.d.ts +3 -0
- package/dist/keyboard.js +23 -0
- package/dist/labels.d.ts +1 -1
- package/dist/labels.js +8 -7
- package/dist/layout/PropertyFilter.svelte +3 -2
- package/dist/layout/SettingsSection.svelte +1 -1
- package/dist/layout/json-tree/JsonNode.svelte +1 -1
- package/dist/layout/json-tree/JsonTree.svelte +2 -2
- package/dist/layout/json-tree/utils.js +5 -4
- package/dist/marching-cubes.js +8 -13
- package/dist/math.d.ts +5 -1
- package/dist/math.js +24 -9
- package/dist/overlays/DraggablePane.svelte +4 -4
- package/dist/periodic-table/PeriodicTable.svelte +20 -9
- package/dist/periodic-table/PropertySelect.svelte +1 -0
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +9 -3
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +2 -1
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +1 -1
- package/dist/phase-diagram/build-diagram.js +2 -2
- package/dist/phase-diagram/parse.js +6 -5
- package/dist/phase-diagram/types.d.ts +1 -1
- package/dist/phase-diagram/utils.d.ts +3 -3
- package/dist/phase-diagram/utils.js +8 -12
- package/dist/plot/{BarPlot.svelte → bar/BarPlot.svelte} +229 -587
- package/dist/plot/{BarPlot.svelte.d.ts → bar/BarPlot.svelte.d.ts} +5 -5
- package/dist/plot/{BarPlotControls.svelte → bar/BarPlotControls.svelte} +6 -5
- package/dist/plot/{BarPlotControls.svelte.d.ts → bar/BarPlotControls.svelte.d.ts} +3 -3
- package/dist/plot/{SpacegroupBarPlot.svelte → bar/SpacegroupBarPlot.svelte} +6 -6
- package/dist/plot/{SpacegroupBarPlot.svelte.d.ts → bar/SpacegroupBarPlot.svelte.d.ts} +1 -1
- package/dist/plot/bar/data.d.ts +40 -0
- package/dist/plot/bar/data.js +154 -0
- package/dist/plot/bar/geometry.d.ts +39 -0
- package/dist/plot/bar/geometry.js +60 -0
- package/dist/plot/bar/index.d.ts +3 -0
- package/dist/plot/bar/index.js +3 -0
- package/dist/plot/box/BoxPlot.svelte +1462 -0
- package/dist/plot/box/BoxPlot.svelte.d.ts +94 -0
- package/dist/plot/box/BoxPlotControls.svelte +109 -0
- package/dist/plot/box/BoxPlotControls.svelte.d.ts +19 -0
- package/dist/plot/box/Violin.svelte +14 -0
- package/dist/plot/box/Violin.svelte.d.ts +70 -0
- package/dist/plot/box/box-plot.d.ts +55 -0
- package/dist/plot/box/box-plot.js +126 -0
- package/dist/plot/box/index.d.ts +5 -0
- package/dist/plot/box/index.js +5 -0
- package/dist/plot/box/kde.d.ts +16 -0
- package/dist/plot/box/kde.js +160 -0
- package/dist/plot/box/quantile.d.ts +3 -0
- package/dist/plot/box/quantile.js +53 -0
- package/dist/plot/{auto-place.js → core/auto-place.js} +2 -2
- package/dist/plot/core/axis-utils.d.ts +46 -0
- package/dist/plot/core/axis-utils.js +110 -0
- package/dist/plot/{AxisLabel.svelte → core/components/AxisLabel.svelte} +2 -2
- package/dist/plot/{AxisLabel.svelte.d.ts → core/components/AxisLabel.svelte.d.ts} +1 -1
- package/dist/plot/{ColorBar.svelte → core/components/ColorBar.svelte} +36 -33
- package/dist/plot/{ColorBar.svelte.d.ts → core/components/ColorBar.svelte.d.ts} +2 -2
- package/dist/plot/{ColorScaleSelect.svelte → core/components/ColorScaleSelect.svelte} +4 -3
- package/dist/plot/{ColorScaleSelect.svelte.d.ts → core/components/ColorScaleSelect.svelte.d.ts} +2 -2
- package/dist/plot/core/components/ControlPane.svelte +46 -0
- package/dist/plot/core/components/ControlPane.svelte.d.ts +13 -0
- package/dist/plot/{FillArea.svelte → core/components/FillArea.svelte} +17 -6
- package/dist/plot/{FillArea.svelte.d.ts → core/components/FillArea.svelte.d.ts} +1 -1
- package/dist/plot/{InteractiveAxisLabel.svelte → core/components/InteractiveAxisLabel.svelte} +3 -3
- package/dist/plot/{InteractiveAxisLabel.svelte.d.ts → core/components/InteractiveAxisLabel.svelte.d.ts} +2 -2
- package/dist/plot/{Line.svelte → core/components/Line.svelte} +30 -13
- package/dist/plot/{PlotAxis.svelte → core/components/PlotAxis.svelte} +7 -5
- package/dist/plot/{PlotAxis.svelte.d.ts → core/components/PlotAxis.svelte.d.ts} +3 -2
- package/dist/plot/{PlotControls.svelte → core/components/PlotControls.svelte} +17 -29
- package/dist/plot/core/components/PlotControls.svelte.d.ts +4 -0
- package/dist/plot/{PlotLegend.svelte → core/components/PlotLegend.svelte} +21 -10
- package/dist/plot/{PlotLegend.svelte.d.ts → core/components/PlotLegend.svelte.d.ts} +3 -2
- package/dist/plot/{PlotTooltip.svelte → core/components/PlotTooltip.svelte} +17 -1
- package/dist/plot/{PlotTooltip.svelte.d.ts → core/components/PlotTooltip.svelte.d.ts} +8 -0
- package/dist/plot/{PortalSelect.svelte → core/components/PortalSelect.svelte} +11 -7
- package/dist/plot/{ReferenceLine.svelte → core/components/ReferenceLine.svelte} +3 -3
- package/dist/plot/{ReferenceLine.svelte.d.ts → core/components/ReferenceLine.svelte.d.ts} +1 -1
- package/dist/plot/{ReferenceLine3D.svelte → core/components/ReferenceLine3D.svelte} +4 -4
- package/dist/plot/{ReferenceLine3D.svelte.d.ts → core/components/ReferenceLine3D.svelte.d.ts} +2 -2
- package/dist/plot/{ReferencePlane.svelte → core/components/ReferencePlane.svelte} +7 -7
- package/dist/plot/{ReferencePlane.svelte.d.ts → core/components/ReferencePlane.svelte.d.ts} +2 -2
- package/dist/plot/{ZeroLines.svelte → core/components/ZeroLines.svelte} +3 -3
- package/dist/plot/{ZeroLines.svelte.d.ts → core/components/ZeroLines.svelte.d.ts} +3 -3
- package/dist/plot/{ZoomRect.svelte → core/components/ZoomRect.svelte} +1 -1
- package/dist/plot/{ZoomRect.svelte.d.ts → core/components/ZoomRect.svelte.d.ts} +1 -1
- package/dist/plot/core/components/index.d.ts +17 -0
- package/dist/plot/core/components/index.js +17 -0
- package/dist/plot/{data-cleaning.d.ts → core/data-cleaning.d.ts} +71 -1
- package/dist/plot/{data-cleaning.js → core/data-cleaning.js} +3 -5
- package/dist/plot/{data-transform.d.ts → core/data-transform.d.ts} +2 -2
- package/dist/plot/{data-transform.js → core/data-transform.js} +3 -3
- package/dist/plot/core/fill-utils.d.ts +33 -0
- package/dist/plot/core/fill-utils.js +388 -0
- package/dist/plot/{hover-lock.svelte.js → core/hover-lock.svelte.js} +5 -6
- package/dist/plot/core/index.d.ts +10 -0
- package/dist/plot/core/index.js +11 -0
- package/dist/plot/core/interactions.d.ts +35 -0
- package/dist/plot/core/interactions.js +195 -0
- package/dist/plot/{layout.d.ts → core/layout.d.ts} +1 -0
- package/dist/plot/{layout.js → core/layout.js} +16 -8
- package/dist/plot/{reference-line.d.ts → core/reference-line.d.ts} +1 -1
- package/dist/plot/{reference-line.js → core/reference-line.js} +23 -36
- package/dist/plot/{scales.d.ts → core/scales.d.ts} +2 -2
- package/dist/plot/{scales.js → core/scales.js} +84 -85
- package/dist/plot/core/svg.d.ts +2 -0
- package/dist/plot/core/svg.js +41 -0
- package/dist/plot/{types.d.ts → core/types.d.ts} +19 -79
- package/dist/plot/{types.js → core/types.js} +1 -1
- package/dist/plot/{utils → core/utils}/label-placement.d.ts +2 -2
- package/dist/plot/core/utils/series-visibility.d.ts +26 -0
- package/dist/plot/{utils → core/utils}/series-visibility.js +29 -2
- package/dist/plot/core/utils.d.ts +11 -0
- package/dist/plot/core/utils.js +27 -0
- package/dist/plot/{Histogram.svelte → histogram/Histogram.svelte} +154 -294
- package/dist/plot/{Histogram.svelte.d.ts → histogram/Histogram.svelte.d.ts} +2 -2
- package/dist/plot/{HistogramControls.svelte → histogram/HistogramControls.svelte} +6 -6
- package/dist/plot/{HistogramControls.svelte.d.ts → histogram/HistogramControls.svelte.d.ts} +4 -4
- package/dist/plot/histogram/index.d.ts +2 -0
- package/dist/plot/histogram/index.js +2 -0
- package/dist/plot/index.d.ts +8 -41
- package/dist/plot/index.js +10 -39
- package/dist/plot/sankey/Sankey.svelte +700 -0
- package/dist/plot/sankey/Sankey.svelte.d.ts +74 -0
- package/dist/plot/sankey/SankeyControls.svelte +98 -0
- package/dist/plot/sankey/SankeyControls.svelte.d.ts +19 -0
- package/dist/plot/sankey/index.d.ts +4 -0
- package/dist/plot/sankey/index.js +3 -0
- package/dist/plot/sankey/sankey-types.d.ts +42 -0
- package/dist/plot/sankey/sankey-types.js +4 -0
- package/dist/plot/sankey/sankey.d.ts +52 -0
- package/dist/plot/sankey/sankey.js +187 -0
- package/dist/plot/{BinnedScatterPlot.svelte → scatter/BinnedScatterPlot.svelte} +61 -59
- package/dist/plot/{BinnedScatterPlot.svelte.d.ts → scatter/BinnedScatterPlot.svelte.d.ts} +4 -4
- package/dist/plot/{ElementScatter.svelte → scatter/ElementScatter.svelte} +6 -6
- package/dist/plot/{ElementScatter.svelte.d.ts → scatter/ElementScatter.svelte.d.ts} +2 -2
- package/dist/plot/{ScatterPlot.svelte → scatter/ScatterPlot.svelte} +221 -642
- package/dist/plot/{ScatterPlot.svelte.d.ts → scatter/ScatterPlot.svelte.d.ts} +7 -7
- package/dist/plot/{ScatterPlotControls.svelte → scatter/ScatterPlotControls.svelte} +6 -5
- package/dist/plot/{ScatterPlotControls.svelte.d.ts → scatter/ScatterPlotControls.svelte.d.ts} +1 -1
- package/dist/plot/{ScatterPoint.svelte → scatter/ScatterPoint.svelte} +7 -7
- package/dist/plot/{ScatterPoint.svelte.d.ts → scatter/ScatterPoint.svelte.d.ts} +3 -3
- package/dist/plot/{adaptive-density.d.ts → scatter/adaptive-density.d.ts} +14 -4
- package/dist/plot/{adaptive-density.js → scatter/adaptive-density.js} +46 -20
- package/dist/plot/{binned-scatter-types.d.ts → scatter/binned-scatter-types.d.ts} +3 -3
- package/dist/plot/scatter/index.d.ts +7 -0
- package/dist/plot/scatter/index.js +5 -0
- package/dist/plot/scatter/scatter-data.d.ts +19 -0
- package/dist/plot/scatter/scatter-data.js +212 -0
- package/dist/plot/{ScatterPlot3D.svelte → scatter-3d/ScatterPlot3D.svelte} +12 -10
- package/dist/plot/{ScatterPlot3D.svelte.d.ts → scatter-3d/ScatterPlot3D.svelte.d.ts} +7 -7
- package/dist/plot/{ScatterPlot3DControls.svelte → scatter-3d/ScatterPlot3DControls.svelte} +5 -4
- package/dist/plot/{ScatterPlot3DControls.svelte.d.ts → scatter-3d/ScatterPlot3DControls.svelte.d.ts} +2 -2
- package/dist/plot/{ScatterPlot3DScene.svelte → scatter-3d/ScatterPlot3DScene.svelte} +11 -11
- package/dist/plot/{ScatterPlot3DScene.svelte.d.ts → scatter-3d/ScatterPlot3DScene.svelte.d.ts} +3 -3
- package/dist/plot/{Surface3D.svelte → scatter-3d/Surface3D.svelte} +1 -1
- package/dist/plot/{Surface3D.svelte.d.ts → scatter-3d/Surface3D.svelte.d.ts} +1 -1
- package/dist/plot/scatter-3d/index.d.ts +4 -0
- package/dist/plot/scatter-3d/index.js +4 -0
- package/dist/plot/sunburst/Sunburst.svelte +1045 -0
- package/dist/plot/sunburst/Sunburst.svelte.d.ts +96 -0
- package/dist/plot/sunburst/SunburstControls.svelte +200 -0
- package/dist/plot/sunburst/SunburstControls.svelte.d.ts +26 -0
- package/dist/plot/sunburst/index.d.ts +4 -0
- package/dist/plot/sunburst/index.js +4 -0
- package/dist/plot/sunburst/render.d.ts +34 -0
- package/dist/plot/sunburst/render.js +122 -0
- package/dist/plot/sunburst/sunburst.d.ts +62 -0
- package/dist/plot/sunburst/sunburst.js +266 -0
- package/dist/rdf/RdfPlot.svelte +2 -1
- package/dist/rdf/calc-rdf.js +11 -24
- package/dist/sanitize.js +1 -1
- package/dist/settings.d.ts +65 -1
- package/dist/settings.js +262 -0
- package/dist/spectral/Bands.svelte +39 -29
- package/dist/spectral/Bands.svelte.d.ts +3 -4
- package/dist/spectral/BandsAndDos.svelte +1 -1
- package/dist/spectral/BrillouinBandsDos.svelte +39 -27
- package/dist/spectral/Dos.svelte +10 -19
- package/dist/spectral/Dos.svelte.d.ts +2 -2
- package/dist/spectral/helpers.d.ts +3 -1
- package/dist/spectral/helpers.js +95 -29
- package/dist/structure/AtomLegend.svelte +8 -9
- package/dist/structure/CellSelect.svelte +1 -2
- package/dist/structure/Cylinder.svelte +12 -8
- package/dist/structure/Cylinder.svelte.d.ts +4 -1
- package/dist/structure/Structure.svelte +78 -72
- package/dist/structure/Structure.svelte.d.ts +1 -1
- package/dist/structure/StructureInfoPane.svelte +5 -6
- package/dist/structure/StructureScene.svelte +11 -10
- package/dist/structure/atom-properties.js +6 -6
- package/dist/structure/bond-order-perception.js +1 -1
- package/dist/structure/bonding.d.ts +1 -0
- package/dist/structure/bonding.js +43 -15
- package/dist/structure/export.js +27 -23
- package/dist/structure/index.d.ts +2 -4
- package/dist/structure/index.js +1 -3
- package/dist/structure/label-placement.js +4 -4
- package/dist/structure/measure.d.ts +3 -2
- package/dist/structure/measure.js +6 -5
- package/dist/structure/parse.js +121 -103
- package/dist/structure/pbc.js +4 -0
- package/dist/symmetry/SymmetryStats.svelte +2 -2
- package/dist/symmetry/index.d.ts +1 -1
- package/dist/symmetry/index.js +22 -24
- package/dist/symmetry/spacegroups.d.ts +7 -0
- package/dist/symmetry/spacegroups.js +48 -13
- package/dist/table/HeatmapTable.svelte +63 -11
- package/dist/table/HeatmapTable.svelte.d.ts +1 -1
- package/dist/table/index.d.ts +1 -3
- package/dist/table/index.js +1 -1
- package/dist/theme/index.js +8 -8
- package/dist/tooltip/KCoords.svelte +45 -0
- package/dist/tooltip/KCoords.svelte.d.ts +8 -0
- package/dist/tooltip/index.d.ts +1 -0
- package/dist/tooltip/index.js +1 -0
- package/dist/trajectory/Trajectory.svelte +66 -40
- package/dist/trajectory/Trajectory.svelte.d.ts +2 -1
- package/dist/trajectory/TrajectoryExportPane.svelte +2 -1
- package/dist/trajectory/TrajectoryInfoPane.svelte +2 -1
- package/dist/trajectory/format-detect.d.ts +1 -0
- package/dist/trajectory/format-detect.js +25 -11
- package/dist/trajectory/frame-reader.js +17 -50
- package/dist/trajectory/helpers.js +1 -1
- package/dist/trajectory/index.js +1 -1
- package/dist/trajectory/parse/hdf5.js +1 -1
- package/dist/trajectory/parse/index.js +14 -6
- package/dist/trajectory/parse/vasp.js +36 -17
- package/dist/trajectory/parse/xyz.d.ts +24 -0
- package/dist/trajectory/parse/xyz.js +102 -89
- package/dist/trajectory/plotting.d.ts +1 -1
- package/dist/trajectory/plotting.js +15 -15
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +6 -4
- package/dist/xrd/XrdPlot.svelte +2 -1
- package/dist/xrd/calc-xrd.js +15 -12
- package/dist/xrd/parse.js +2 -2
- package/package.json +22 -18
- package/dist/plot/PlotControls.svelte.d.ts +0 -4
- package/dist/plot/axis-utils.d.ts +0 -19
- package/dist/plot/axis-utils.js +0 -78
- package/dist/plot/defaults.d.ts +0 -19
- package/dist/plot/defaults.js +0 -9
- package/dist/plot/fill-utils.d.ts +0 -46
- package/dist/plot/fill-utils.js +0 -322
- package/dist/plot/interactions.d.ts +0 -12
- package/dist/plot/interactions.js +0 -101
- package/dist/plot/svg.d.ts +0 -1
- package/dist/plot/svg.js +0 -11
- package/dist/plot/utils/series-visibility.d.ts +0 -15
- package/dist/plot/utils.d.ts +0 -1
- package/dist/plot/utils.js +0 -14
- /package/dist/plot/{auto-place.d.ts → core/auto-place.d.ts} +0 -0
- /package/dist/plot/{Line.svelte.d.ts → core/components/Line.svelte.d.ts} +0 -0
- /package/dist/plot/{PortalSelect.svelte.d.ts → core/components/PortalSelect.svelte.d.ts} +0 -0
- /package/dist/plot/{hover-lock.svelte.d.ts → core/hover-lock.svelte.d.ts} +0 -0
- /package/dist/plot/{utils → core/utils}/label-placement.js +0 -0
- /package/dist/plot/{binned-scatter-types.js → scatter/binned-scatter-types.js} +0 -0
|
@@ -101,7 +101,7 @@ function group_and_assign_series(series, default_visible_properties) {
|
|
|
101
101
|
// Group by unit
|
|
102
102
|
const unit_map = new Map();
|
|
103
103
|
for (const srs of series) {
|
|
104
|
-
const unit = srs.unit
|
|
104
|
+
const unit = srs.unit ?? `dimensionless`;
|
|
105
105
|
const group = unit_map.get(unit) ?? [];
|
|
106
106
|
group.push(srs);
|
|
107
107
|
unit_map.set(unit, group);
|
|
@@ -112,7 +112,7 @@ function group_and_assign_series(series, default_visible_properties) {
|
|
|
112
112
|
const priority = calculate_priority(unit, group_series);
|
|
113
113
|
const has_default_visible = group_series.some((srs) => {
|
|
114
114
|
const metadata = Array.isArray(srs.metadata) ? srs.metadata[0] : srs.metadata;
|
|
115
|
-
const property_key = metadata?.property_key || srs.label
|
|
115
|
+
const property_key = (metadata?.property_key || srs.label) ?? ``;
|
|
116
116
|
return is_default_visible(property_key, default_visible_properties);
|
|
117
117
|
});
|
|
118
118
|
return { unit, series: group_series, priority, is_visible: has_default_visible };
|
|
@@ -158,7 +158,7 @@ function extract_label_and_unit(key, property_config) {
|
|
|
158
158
|
if (config)
|
|
159
159
|
return { clean_label: config.label, unit: config.unit };
|
|
160
160
|
return {
|
|
161
|
-
clean_label: key.charAt(0).toUpperCase() + key.slice(1).
|
|
161
|
+
clean_label: key.charAt(0).toUpperCase() + key.slice(1).replaceAll('_', ` `),
|
|
162
162
|
unit: ``,
|
|
163
163
|
};
|
|
164
164
|
}
|
|
@@ -169,14 +169,14 @@ function calculate_priority(unit, group_series) {
|
|
|
169
169
|
return unit_priority;
|
|
170
170
|
// Energy properties get high priority
|
|
171
171
|
const has_energy = group_series.some((srs) => {
|
|
172
|
-
const label = srs.label?.toLowerCase()
|
|
172
|
+
const label = srs.label?.toLowerCase() ?? ``;
|
|
173
173
|
return ENERGY_PROPERTIES.some((prop) => label.includes(prop));
|
|
174
174
|
});
|
|
175
175
|
if (has_energy)
|
|
176
176
|
return 10;
|
|
177
177
|
// Force properties get medium priority
|
|
178
178
|
const has_force = group_series.some((srs) => {
|
|
179
|
-
const label = srs.label?.toLowerCase()
|
|
179
|
+
const label = srs.label?.toLowerCase() ?? ``;
|
|
180
180
|
return FORCE_PROPERTIES.some((prop) => label.includes(prop));
|
|
181
181
|
});
|
|
182
182
|
if (has_force)
|
|
@@ -187,8 +187,8 @@ function calculate_priority(unit, group_series) {
|
|
|
187
187
|
const normalize_property_key = (key) => {
|
|
188
188
|
const normalized = key
|
|
189
189
|
.toLowerCase()
|
|
190
|
-
.
|
|
191
|
-
.
|
|
190
|
+
.replaceAll(/<[^>]*>/g, ``)
|
|
191
|
+
.replaceAll('_', ` `)
|
|
192
192
|
.trim();
|
|
193
193
|
// Map common force property aliases to canonical form
|
|
194
194
|
return [`fmax`, `f`, `force maximum`].includes(normalized) ? `force max` : normalized;
|
|
@@ -242,7 +242,7 @@ export function toggle_series_visibility(series, target_series_idx) {
|
|
|
242
242
|
function create_unit_groups_from_series(series) {
|
|
243
243
|
const unit_map = new Map();
|
|
244
244
|
for (const srs of series) {
|
|
245
|
-
const unit = srs.unit
|
|
245
|
+
const unit = srs.unit ?? `dimensionless`;
|
|
246
246
|
const group = unit_map.get(unit) ?? [];
|
|
247
247
|
group.push(srs);
|
|
248
248
|
unit_map.set(unit, group);
|
|
@@ -277,7 +277,7 @@ function update_group_visibility_and_axes(series, unit_groups) {
|
|
|
277
277
|
.filter((group) => group.is_visible)
|
|
278
278
|
.sort((g1, g2) => g1.priority - g2.priority);
|
|
279
279
|
const axis_map = new Map();
|
|
280
|
-
if (final_visible.length
|
|
280
|
+
if (final_visible.length > 0)
|
|
281
281
|
axis_map.set(final_visible[0], `y1`);
|
|
282
282
|
if (final_visible.length === 2)
|
|
283
283
|
axis_map.set(final_visible[1], `y2`);
|
|
@@ -313,12 +313,12 @@ export function should_hide_plot(trajectory, plot_series, tolerance = 1e-10) {
|
|
|
313
313
|
}
|
|
314
314
|
function get_axis_label(axis_series) {
|
|
315
315
|
const visible_series = axis_series.filter((srs) => srs.visible);
|
|
316
|
-
if (
|
|
316
|
+
if (visible_series.length === 0)
|
|
317
317
|
return `Value`;
|
|
318
318
|
const unit_groups = new Map();
|
|
319
319
|
visible_series.forEach((srs) => {
|
|
320
|
-
const unit = srs.unit
|
|
321
|
-
const label = srs.label
|
|
320
|
+
const unit = srs.unit ?? ``;
|
|
321
|
+
const label = srs.label ?? `Value`;
|
|
322
322
|
if (!unit_groups.has(unit))
|
|
323
323
|
unit_groups.set(unit, []);
|
|
324
324
|
const group = unit_groups.get(unit);
|
|
@@ -326,14 +326,14 @@ function get_axis_label(axis_series) {
|
|
|
326
326
|
group.push(label);
|
|
327
327
|
});
|
|
328
328
|
const unit_entries = Array.from(unit_groups.entries());
|
|
329
|
-
if (
|
|
329
|
+
if (unit_entries.length === 0)
|
|
330
330
|
return `Value`;
|
|
331
331
|
const [unit, labels] = unit_entries[0];
|
|
332
332
|
const unique_labels = [...new Set(labels)].sort().join(` / `);
|
|
333
333
|
return unit ? `${unique_labels} (${unit})` : unique_labels;
|
|
334
334
|
}
|
|
335
335
|
export function generate_axis_labels(plot_series) {
|
|
336
|
-
if (
|
|
336
|
+
if (plot_series.length === 0)
|
|
337
337
|
return { y1: `Value`, y2: `Value` };
|
|
338
338
|
return {
|
|
339
339
|
y1: get_axis_label(plot_series.filter((srs) => (srs.y_axis ?? `y1`) === `y1`)),
|
|
@@ -341,7 +341,7 @@ export function generate_axis_labels(plot_series) {
|
|
|
341
341
|
};
|
|
342
342
|
}
|
|
343
343
|
export function generate_streaming_plot_series(metadata_list, options = {}) {
|
|
344
|
-
if (
|
|
344
|
+
if (metadata_list.length === 0)
|
|
345
345
|
return [];
|
|
346
346
|
const { property_config = trajectory_property_config, colors = PLOT_COLORS, default_visible_properties = DEFAULT_VISIBLE, max_points = 10_000, // 10,000 plot points provides good visual fidelity while maintaining browser performance
|
|
347
347
|
} = options;
|
package/dist/utils.d.ts
CHANGED
|
@@ -2,5 +2,6 @@ export declare function merge_nested<T extends Record<string, unknown>>(obj1: T,
|
|
|
2
2
|
export declare const escape_html: (unsafe_string: string) => string;
|
|
3
3
|
export declare const normalize_unicode_minus: (value: string) => string;
|
|
4
4
|
export declare const normalize_scientific_notation: (value: string) => string;
|
|
5
|
+
export declare const to_error: (value: unknown) => Error;
|
|
5
6
|
export declare function make_change_detector(): (value: unknown) => boolean;
|
|
6
7
|
export declare function decode_url_safe_base64(encoded: string): string | undefined;
|
package/dist/utils.js
CHANGED
|
@@ -18,11 +18,13 @@ export const escape_html = (unsafe_string) => unsafe_string
|
|
|
18
18
|
.replaceAll(`"`, `"`)
|
|
19
19
|
.replaceAll(`'`, `'`);
|
|
20
20
|
// Normalize unicode minus (U+2212) to ASCII hyphen-minus.
|
|
21
|
-
export const normalize_unicode_minus = (value) => value.
|
|
21
|
+
export const normalize_unicode_minus = (value) => value.replaceAll('−', `-`);
|
|
22
22
|
// Normalize scientific notation variants (d/D exponent, Mathematica *^).
|
|
23
|
-
export const normalize_scientific_notation = (value) => normalize_unicode_minus(value).toLowerCase().
|
|
23
|
+
export const normalize_scientific_notation = (value) => normalize_unicode_minus(value).toLowerCase().replaceAll('d', `e`).replaceAll('*^', `e`);
|
|
24
|
+
// Coerce an unknown thrown value into an Error (for typed Promise rejections / error callbacks).
|
|
25
|
+
export const to_error = (value) => value instanceof Error ? value : new Error(String(value));
|
|
24
26
|
export function make_change_detector() {
|
|
25
|
-
const unset = Symbol();
|
|
27
|
+
const unset = Symbol(`unset`);
|
|
26
28
|
let prev = unset;
|
|
27
29
|
return (value) => {
|
|
28
30
|
const changed = prev !== unset && value !== prev;
|
|
@@ -34,7 +36,7 @@ export function make_change_detector() {
|
|
|
34
36
|
// Converts `-` → `+`, `_` → `/`, restores padding, then decodes.
|
|
35
37
|
// Returns undefined if decoding fails.
|
|
36
38
|
export function decode_url_safe_base64(encoded) {
|
|
37
|
-
const std_b64 = encoded.
|
|
39
|
+
const std_b64 = encoded.replaceAll('-', `+`).replaceAll('_', `/`);
|
|
38
40
|
const padded = std_b64 + `=`.repeat((4 - (std_b64.length % 4)) % 4);
|
|
39
41
|
try {
|
|
40
42
|
return atob(padded);
|
package/dist/xrd/XrdPlot.svelte
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
import type { BroadeningParams } from './broadening'
|
|
27
27
|
import { compute_broadened_pattern, DEFAULT_BROADENING } from './broadening'
|
|
28
28
|
import type { Hkl, HklFormat, PatternEntry, XrdPattern } from './index'
|
|
29
|
+
import { to_error } from '../utils'
|
|
29
30
|
|
|
30
31
|
function is_xrd_pattern(obj: unknown): obj is XrdPattern {
|
|
31
32
|
if (!obj || typeof obj !== `object`) return false
|
|
@@ -352,7 +353,7 @@
|
|
|
352
353
|
}
|
|
353
354
|
} catch (exc) {
|
|
354
355
|
error_msg = `Failed to load file ${file.name}: ${
|
|
355
|
-
exc
|
|
356
|
+
to_error(exc).message
|
|
356
357
|
}`
|
|
357
358
|
}
|
|
358
359
|
}
|
package/dist/xrd/calc-xrd.js
CHANGED
|
@@ -5,6 +5,7 @@ import { is_crystal } from '../structure/validation';
|
|
|
5
5
|
// Single source of truth for atomic scattering params
|
|
6
6
|
import ATOMIC_SCATTERING_PARAMS from './atomic_scattering_params.json' with { type: 'json' };
|
|
7
7
|
import { is_xrd_data_file, parse_xrd_file } from './parse';
|
|
8
|
+
import { to_error } from '../utils';
|
|
8
9
|
// XRD wavelengths in Angstrom (Å)
|
|
9
10
|
export const WAVELENGTHS = {
|
|
10
11
|
CuKa: 1.54184,
|
|
@@ -73,16 +74,13 @@ function compute_reciprocal_lattice_rows(structure) {
|
|
|
73
74
|
const recip = math.transpose_3x3_matrix(inv);
|
|
74
75
|
return recip;
|
|
75
76
|
}
|
|
76
|
-
function enumerate_reciprocal_points(recip_rows, max_radius, min_radius) {
|
|
77
|
+
function enumerate_reciprocal_points(recip_rows, direct_rows, max_radius, min_radius) {
|
|
77
78
|
const recip_b1 = recip_rows[0];
|
|
78
79
|
const recip_b2 = recip_rows[1];
|
|
79
80
|
const recip_b3 = recip_rows[2];
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
const h_max = Math.ceil(max_radius / n1 + 2);
|
|
84
|
-
const k_max = Math.ceil(max_radius / n2 + 2);
|
|
85
|
-
const l_max = Math.ceil(max_radius / n3 + 2);
|
|
81
|
+
// Exact index bound: |h_i| = |g·a_i| ≤ R·|a_i| (since a_i·b_j = δ_ij). Bounds from
|
|
82
|
+
// reciprocal-row norms (R/|b_i| + 2) undercount for skewed cells, dropping reflections.
|
|
83
|
+
const [h_max, k_max, l_max] = direct_rows.map((row) => Math.ceil(max_radius * Math.hypot(...row)) + 1);
|
|
86
84
|
// Safety cap to avoid pathological enumeration volume
|
|
87
85
|
const CAP = 512;
|
|
88
86
|
if (Math.max(h_max, k_max, l_max) > CAP) {
|
|
@@ -143,7 +141,7 @@ export function compute_xrd_pattern(structure, options = {}) {
|
|
|
143
141
|
const r_max = (2 * Math.sin((t_max / 2) * (Math.PI / 180))) / wavelength;
|
|
144
142
|
return [r_min, r_max];
|
|
145
143
|
})(two_theta_range);
|
|
146
|
-
const recip_points = enumerate_reciprocal_points(recip_rows, max_radius, min_radius);
|
|
144
|
+
const recip_points = enumerate_reciprocal_points(recip_rows, structure.lattice.matrix, max_radius, min_radius);
|
|
147
145
|
const coeffs = [];
|
|
148
146
|
const frac_coords = [];
|
|
149
147
|
const occus = [];
|
|
@@ -163,7 +161,7 @@ export function compute_xrd_pattern(structure, options = {}) {
|
|
|
163
161
|
if (Array.isArray(raw_coeff)) {
|
|
164
162
|
const a_arr = raw_coeff.map(([a]) => a);
|
|
165
163
|
const b_arr = raw_coeff.map(([_, b]) => b);
|
|
166
|
-
coeff_entry = { a: a_arr, b: b_arr };
|
|
164
|
+
coeff_entry = { a: a_arr, b: b_arr, z: ELEMENT_Z[element_symbol] };
|
|
167
165
|
}
|
|
168
166
|
else {
|
|
169
167
|
coeff_entry = { a: raw_coeff.a.slice(), b: raw_coeff.b.slice(), c: raw_coeff.c };
|
|
@@ -194,11 +192,14 @@ export function compute_xrd_pattern(structure, options = {}) {
|
|
|
194
192
|
const g_dot_r_all = frac_coords.map((frac_coord) => math.dot(frac_coord, hkl));
|
|
195
193
|
// Atomic scattering factors (vectorized style)
|
|
196
194
|
const f_scattering = coeffs.map((coeff_entry) => {
|
|
197
|
-
const { a: a_arr, b: b_arr } = coeff_entry;
|
|
195
|
+
const { a: a_arr, b: b_arr, z } = coeff_entry;
|
|
198
196
|
const num_terms = Math.min(a_arr.length, b_arr.length);
|
|
199
197
|
const sum_terms = a_arr
|
|
200
198
|
.slice(0, num_terms)
|
|
201
199
|
.reduce((sum, a_i, term_idx) => sum + a_i * Math.exp(-b_arr[term_idx] * sin_theta_over_lambda_sq), 0);
|
|
200
|
+
// pymatgen-style fitted params: f = Z − 41.78214·s²·Σ aᵢ·exp(−bᵢ·s²)
|
|
201
|
+
if (z !== undefined)
|
|
202
|
+
return z - 41.78214 * sin_theta_over_lambda_sq * sum_terms;
|
|
202
203
|
return sum_terms + (coeff_entry.c ?? 0);
|
|
203
204
|
});
|
|
204
205
|
const dw_corr = dw_factors.map((dw_b) => Math.exp(-dw_b * sin_theta_over_lambda_sq));
|
|
@@ -303,7 +304,9 @@ wavelength) {
|
|
|
303
304
|
}
|
|
304
305
|
// Get base extension (strip .gz if present) for error message
|
|
305
306
|
const base_name = filename.toLowerCase().replace(/\.gz$/, ``);
|
|
306
|
-
|
|
307
|
+
// truthiness (not ??) so an empty extension (filename ending in `.`) falls back to XRD
|
|
308
|
+
const last_part = base_name.split(`.`).pop();
|
|
309
|
+
const ext = last_part ? last_part.toUpperCase() : `XRD`;
|
|
307
310
|
const format_hints = {
|
|
308
311
|
XY: `Expected 2-column format: "2theta intensity" (space/tab/comma separated)`,
|
|
309
312
|
XYE: `Expected 3-column format: "2theta intensity error" (space/tab/comma separated)`,
|
|
@@ -329,7 +332,7 @@ wavelength) {
|
|
|
329
332
|
}
|
|
330
333
|
catch (exc) {
|
|
331
334
|
return {
|
|
332
|
-
error: `Failed to compute XRD pattern: ${exc
|
|
335
|
+
error: `Failed to compute XRD pattern: ${to_error(exc).message}`,
|
|
333
336
|
};
|
|
334
337
|
}
|
|
335
338
|
}
|
package/dist/xrd/parse.js
CHANGED
|
@@ -343,7 +343,7 @@ function parse_bruker_raw_v1(view, bytes) {
|
|
|
343
343
|
// Find where binary data starts (after header)
|
|
344
344
|
let data_offset = 512;
|
|
345
345
|
if (count_match) {
|
|
346
|
-
const expected_count = parseInt(count_match[1]);
|
|
346
|
+
const expected_count = parseInt(count_match[1], 10);
|
|
347
347
|
// Binary data is typically 4 bytes per intensity (float32)
|
|
348
348
|
data_offset = bytes.length - expected_count * 4;
|
|
349
349
|
}
|
|
@@ -406,7 +406,7 @@ function parse_rigaku_raw_file(data) {
|
|
|
406
406
|
return null; // Not a recognizable Rigaku format
|
|
407
407
|
const start = start_match ? parseFloat(start_match[1]) : 0;
|
|
408
408
|
const step = step_match ? parseFloat(step_match[1]) : DEFAULT_STEP_SIZE;
|
|
409
|
-
const expected_count = count_match ? parseInt(count_match[1]) : 0;
|
|
409
|
+
const expected_count = count_match ? parseInt(count_match[1], 10) : 0;
|
|
410
410
|
// Find binary data section
|
|
411
411
|
// Rigaku typically stores intensities as 32-bit floats or integers
|
|
412
412
|
let data_offset = 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "matterviz",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Interactive visualizations for materials science: periodic tables, 3D structures, MD trajectories, heatmaps, scatter plots.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chemistry",
|
|
@@ -169,42 +169,45 @@
|
|
|
169
169
|
"scripts": {
|
|
170
170
|
"test": "vp test --run && playwright test",
|
|
171
171
|
"knip": "knip --include dependencies,devDependencies",
|
|
172
|
-
"package-dist-assets": "
|
|
173
|
-
"package:dist": "svelte-package &&
|
|
174
|
-
"prepare": "
|
|
175
|
-
"prepublishOnly": "
|
|
172
|
+
"package-dist-assets": "node scripts/package-dist-assets.ts",
|
|
173
|
+
"package:dist": "svelte-package && pnpm run package-dist-assets",
|
|
174
|
+
"prepare": "svelte-kit sync && pnpm run package:dist",
|
|
175
|
+
"prepublishOnly": "pnpm run package:dist"
|
|
176
176
|
},
|
|
177
177
|
"dependencies": {
|
|
178
178
|
"@spglib/moyo-wasm": "^0.10.0",
|
|
179
|
-
"@sveltejs/kit": "2.
|
|
179
|
+
"@sveltejs/kit": "2.63.0",
|
|
180
180
|
"@threlte/core": "^8.5.16",
|
|
181
|
-
"@threlte/extras": "^9.
|
|
181
|
+
"@threlte/extras": "^9.21.0",
|
|
182
182
|
"d3-array": "^3.2.4",
|
|
183
183
|
"d3-color": "^3.1.0",
|
|
184
184
|
"d3-format": "^3.1.2",
|
|
185
185
|
"d3-hierarchy": "^3.1.2",
|
|
186
186
|
"d3-interpolate-path": "^2.3.0",
|
|
187
|
+
"d3-sankey": "^0.12.3",
|
|
187
188
|
"d3-scale": "^4.0.2",
|
|
188
189
|
"d3-scale-chromatic": "^3.1.0",
|
|
189
190
|
"d3-shape": "^3.2.0",
|
|
190
191
|
"d3-time-format": "^4.1.0",
|
|
191
|
-
"dompurify": "
|
|
192
|
+
"dompurify": "3.4.8",
|
|
192
193
|
"fflate": "^0.8.3",
|
|
193
194
|
"h5wasm": "^0.10.2",
|
|
194
|
-
"js-yaml": "^4.
|
|
195
|
+
"js-yaml": "^4.2.0",
|
|
195
196
|
"svelte-multiselect": "^11.7.1",
|
|
196
197
|
"three": "^0.184.0"
|
|
197
198
|
},
|
|
198
199
|
"devDependencies": {
|
|
200
|
+
"@janosh/vite-config": "github:janosh/dotfiles",
|
|
199
201
|
"@playwright/test": "^1.60.0",
|
|
200
202
|
"@sveltejs/adapter-static": "3.0.10",
|
|
201
|
-
"@sveltejs/package": "^2.5.
|
|
203
|
+
"@sveltejs/package": "^2.5.8",
|
|
202
204
|
"@sveltejs/vite-plugin-svelte": "^7.1.2",
|
|
203
205
|
"@types/d3-array": "^3.2.2",
|
|
204
206
|
"@types/d3-color": "^3.1.3",
|
|
205
207
|
"@types/d3-format": "^3.0.4",
|
|
206
208
|
"@types/d3-hierarchy": "^3.1.7",
|
|
207
209
|
"@types/d3-interpolate-path": "^2.0.3",
|
|
210
|
+
"@types/d3-sankey": "^0.12.5",
|
|
208
211
|
"@types/d3-scale": "^4.0.9",
|
|
209
212
|
"@types/d3-scale-chromatic": "^3.1.0",
|
|
210
213
|
"@types/d3-shape": "^3.1.8",
|
|
@@ -212,20 +215,20 @@
|
|
|
212
215
|
"@types/js-yaml": "^4.0.9",
|
|
213
216
|
"@types/node": "^25.9.1",
|
|
214
217
|
"@types/three": "^0.184.1",
|
|
215
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
216
|
-
"@vitest/coverage-v8": "4.1.
|
|
218
|
+
"@typescript/native-preview": "7.0.0-dev.20260605.1",
|
|
219
|
+
"@vitest/coverage-v8": "4.1.8",
|
|
217
220
|
"@wooorm/starry-night": "^3.9.0",
|
|
218
|
-
"happy-dom": "^20.
|
|
219
|
-
"knip": "^6.
|
|
221
|
+
"happy-dom": "^20.10.1",
|
|
222
|
+
"knip": "^6.16.0",
|
|
220
223
|
"mdsvex": "^0.12.7",
|
|
221
224
|
"rehype-katex": "^7.0.1",
|
|
222
225
|
"remark-math": "3.0.1",
|
|
223
|
-
"svelte": "5.56.
|
|
224
|
-
"svelte-check-rs": "0.9.
|
|
226
|
+
"svelte": "^5.56.2",
|
|
227
|
+
"svelte-check-rs": "0.9.20",
|
|
225
228
|
"typescript": "6.0.3",
|
|
226
|
-
"vite": "^8.0.
|
|
229
|
+
"vite": "^8.0.16",
|
|
227
230
|
"vite-plus": "latest",
|
|
228
|
-
"vitest": "4.1.
|
|
231
|
+
"vitest": "4.1.8"
|
|
229
232
|
},
|
|
230
233
|
"peerDependencies": {
|
|
231
234
|
"svelte": "^5.0.0"
|
|
@@ -233,6 +236,7 @@
|
|
|
233
236
|
"engines": {
|
|
234
237
|
"node": ">=24"
|
|
235
238
|
},
|
|
239
|
+
"packageManager": "pnpm@11.5.0",
|
|
236
240
|
"knip": {
|
|
237
241
|
"entry": [
|
|
238
242
|
"svelte.config.ts"
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { PlotControlsProps } from './index';
|
|
2
|
-
declare const PlotControls: import("svelte").Component<PlotControlsProps, {}, "display" | "show_controls" | "x_axis" | "y_axis" | "controls_open" | "x2_axis" | "y2_axis">;
|
|
3
|
-
type PlotControls = ReturnType<typeof PlotControls>;
|
|
4
|
-
export default PlotControls;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { AxisConfig, AxisLoadError, BarSeries, DataLoaderFn, DataSeries } from './types';
|
|
2
|
-
type AxisType = `x` | `x2` | `y` | `y2`;
|
|
3
|
-
export declare function merge_series_state<T extends DataSeries | BarSeries>(old_series: T[], new_series: T[]): T[];
|
|
4
|
-
export interface AxisChangeState<T extends DataSeries | BarSeries> {
|
|
5
|
-
get_axis: (axis: AxisType) => AxisConfig;
|
|
6
|
-
set_axis: (axis: AxisType, config: AxisConfig) => void;
|
|
7
|
-
get_series: () => T[];
|
|
8
|
-
set_series: (series: T[]) => void;
|
|
9
|
-
get_loading: () => AxisType | null;
|
|
10
|
-
set_loading: (axis: AxisType | null) => void;
|
|
11
|
-
}
|
|
12
|
-
export declare function 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>;
|
|
13
|
-
export declare const AXIS_LABEL_CONTAINER: {
|
|
14
|
-
readonly width: 200;
|
|
15
|
-
readonly height: 24;
|
|
16
|
-
readonly x_offset: 100;
|
|
17
|
-
readonly y_offset: 12;
|
|
18
|
-
};
|
|
19
|
-
export {};
|
package/dist/plot/axis-utils.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
// Shared utilities for interactive axis functionality
|
|
2
|
-
// Merge new series with preserved UI state from old series.
|
|
3
|
-
// Matches by stable id first, then by index only for ordered id-less series.
|
|
4
|
-
export function merge_series_state(old_series, new_series) {
|
|
5
|
-
// Build id lookup map for O(1) matching (string or number ids)
|
|
6
|
-
const by_id = new Map();
|
|
7
|
-
for (const srs of old_series) {
|
|
8
|
-
if (srs.id !== undefined && srs.id !== ``)
|
|
9
|
-
by_id.set(srs.id, srs);
|
|
10
|
-
}
|
|
11
|
-
return new_series.map((new_srs, idx) => {
|
|
12
|
-
const old_srs = new_srs.id !== undefined && new_srs.id !== `` ? by_id.get(new_srs.id) : old_series[idx];
|
|
13
|
-
if (!old_srs) {
|
|
14
|
-
return new_srs;
|
|
15
|
-
}
|
|
16
|
-
// Preserve UI state: visibility and styling from old series if not in new
|
|
17
|
-
const result = { ...new_srs };
|
|
18
|
-
result.visible ??= old_srs.visible;
|
|
19
|
-
// Preserve style properties only when key exists in BOTH series (guards against
|
|
20
|
-
// cross-type injection when T is a union like DataSeries | BarSeries)
|
|
21
|
-
for (const key of [`point_style`, `line_style`, `color`]) {
|
|
22
|
-
if (key in old_srs && key in new_srs && result[key] === undefined) {
|
|
23
|
-
result[key] = old_srs[key];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return result;
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
// Handle axis property change - loads new data via data_loader
|
|
30
|
-
// Returns a function bound to the component's state accessors
|
|
31
|
-
export function create_axis_change_handler(state, data_loader, on_axis_change, on_error) {
|
|
32
|
-
return async (axis, key) => {
|
|
33
|
-
if (!data_loader || state.get_loading())
|
|
34
|
-
return;
|
|
35
|
-
const axis_config = state.get_axis(axis);
|
|
36
|
-
const prev_key = axis_config.selected_key;
|
|
37
|
-
// Skip if key unchanged AND series already loaded (allows initial load when series empty)
|
|
38
|
-
if (prev_key === key && state.get_series().length > 0)
|
|
39
|
-
return;
|
|
40
|
-
// Update selected_key immediately for UI feedback
|
|
41
|
-
state.set_axis(axis, { ...axis_config, selected_key: key });
|
|
42
|
-
state.set_loading(axis);
|
|
43
|
-
try {
|
|
44
|
-
const result = await data_loader(axis, key, state.get_series());
|
|
45
|
-
// Merge new series with preserved state from old series
|
|
46
|
-
const merged = merge_series_state(state.get_series(), result.series);
|
|
47
|
-
state.set_series(merged);
|
|
48
|
-
// Update axis label/unit if provided
|
|
49
|
-
if (result.axis_label || result.axis_unit) {
|
|
50
|
-
const current = state.get_axis(axis);
|
|
51
|
-
state.set_axis(axis, {
|
|
52
|
-
...current,
|
|
53
|
-
label: result.axis_label ?? current.label,
|
|
54
|
-
unit: result.axis_unit ?? current.unit,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
on_axis_change?.(axis, key, merged);
|
|
58
|
-
}
|
|
59
|
-
catch (err) {
|
|
60
|
-
console.error(`Failed to load data for ${axis}=${key}:`, err);
|
|
61
|
-
// Revert selection
|
|
62
|
-
state.set_axis(axis, { ...state.get_axis(axis), selected_key: prev_key });
|
|
63
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
64
|
-
on_error?.({ axis, key, message });
|
|
65
|
-
}
|
|
66
|
-
finally {
|
|
67
|
-
state.set_loading(null);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
// Constants for axis label foreignObject positioning (all values in px)
|
|
72
|
-
// Use minimal dimensions - overflow: visible handles any dropdown expansion
|
|
73
|
-
export const AXIS_LABEL_CONTAINER = {
|
|
74
|
-
width: 200, // container width for centering; dropdown can overflow
|
|
75
|
-
height: 24, // single line height; dropdown options overflow downward
|
|
76
|
-
x_offset: 100, // half of width for horizontal centering
|
|
77
|
-
y_offset: 12, // half of height for vertical centering
|
|
78
|
-
};
|
package/dist/plot/defaults.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export declare const AXIS_DEFAULTS: {
|
|
2
|
-
format: string;
|
|
3
|
-
scale_type: "linear";
|
|
4
|
-
ticks: number;
|
|
5
|
-
label_shift: {
|
|
6
|
-
x: number;
|
|
7
|
-
y: number;
|
|
8
|
-
};
|
|
9
|
-
tick: {
|
|
10
|
-
label: {
|
|
11
|
-
shift: {
|
|
12
|
-
x: number;
|
|
13
|
-
y: number;
|
|
14
|
-
};
|
|
15
|
-
inside: boolean;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
range: [number | null, number | null];
|
|
19
|
-
};
|
package/dist/plot/defaults.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// Shared axis defaults across plot components (single source of truth)
|
|
2
|
-
export const AXIS_DEFAULTS = {
|
|
3
|
-
format: ``,
|
|
4
|
-
scale_type: `linear`,
|
|
5
|
-
ticks: 5,
|
|
6
|
-
label_shift: { x: 0, y: 0 },
|
|
7
|
-
tick: { label: { shift: { x: 0, y: 0 }, inside: false } },
|
|
8
|
-
range: [null, null],
|
|
9
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { DataSeries, ErrorBand, FillBoundary, FillCurveType, FillGradient, FillRegion, ScaleType } from './types';
|
|
2
|
-
export declare const LOG_EPSILON = 1e-10;
|
|
3
|
-
export interface FillPathPoint {
|
|
4
|
-
x: number;
|
|
5
|
-
y1: number;
|
|
6
|
-
y2: number;
|
|
7
|
-
}
|
|
8
|
-
type FillPathArrays = Record<keyof FillPathPoint, number[]>;
|
|
9
|
-
export interface InterpolatedSeries {
|
|
10
|
-
x: number[];
|
|
11
|
-
y_a: number[];
|
|
12
|
-
y_b: number[];
|
|
13
|
-
}
|
|
14
|
-
export interface FilteredFillData extends FillPathArrays {
|
|
15
|
-
original_indices: number[];
|
|
16
|
-
}
|
|
17
|
-
export interface ConditionedFillData {
|
|
18
|
-
segments: FillPathPoint[][];
|
|
19
|
-
}
|
|
20
|
-
export interface ClampedFillData extends FillPathArrays {
|
|
21
|
-
clamped_indices: number[];
|
|
22
|
-
}
|
|
23
|
-
export declare function resolve_series_ref(ref: {
|
|
24
|
-
type: `series`;
|
|
25
|
-
series_idx?: number;
|
|
26
|
-
series_id?: string | number;
|
|
27
|
-
}, series: readonly DataSeries[]): DataSeries | null;
|
|
28
|
-
export declare function interpolate_series(series_a: {
|
|
29
|
-
x: readonly number[];
|
|
30
|
-
y: readonly number[];
|
|
31
|
-
}, series_b: {
|
|
32
|
-
x: readonly number[];
|
|
33
|
-
y: readonly number[];
|
|
34
|
-
}, method?: `linear` | `step`): InterpolatedSeries;
|
|
35
|
-
interface DomainContext {
|
|
36
|
-
y_domain: [number, number];
|
|
37
|
-
y2_domain?: [number, number];
|
|
38
|
-
}
|
|
39
|
-
export declare function resolve_boundary(boundary: FillBoundary, series: readonly DataSeries[], x_values: readonly number[], domains: DomainContext): number[] | null;
|
|
40
|
-
export declare function apply_range_constraints(x_values: readonly number[], y1_values: readonly number[], y2_values: readonly number[], region: Pick<FillRegion, `x_range` | `y_range`>): FilteredFillData;
|
|
41
|
-
export declare function apply_where_condition(x_values: readonly number[], y1_values: readonly number[], y2_values: readonly number[], region: Pick<FillRegion, `where`>): ConditionedFillData;
|
|
42
|
-
export declare function clamp_for_log_scale(x_values: readonly number[], y1_values: readonly number[], y2_values: readonly number[], y_scale_type: ScaleType, x_scale_type?: ScaleType): ClampedFillData;
|
|
43
|
-
export declare function generate_fill_path(data: readonly FillPathPoint[], curve_type?: FillCurveType): string;
|
|
44
|
-
export declare function convert_error_band_to_fill_region(error_band: ErrorBand, series: readonly DataSeries[], default_color?: string): FillRegion | null;
|
|
45
|
-
export declare const is_fill_gradient: (fill: string | FillGradient | undefined) => fill is FillGradient;
|
|
46
|
-
export {};
|