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
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
|
|
47
47
|
// Active when either bound is set (undefined = unbounded)
|
|
48
48
|
let active = $derived(min_value !== undefined || max_value !== undefined)
|
|
49
|
-
let plain_label = $derived(label.
|
|
49
|
+
let plain_label = $derived(label.replaceAll(/<[^>]*>/g, ``))
|
|
50
50
|
|
|
51
51
|
let filtered_data = $derived.by(() => {
|
|
52
52
|
if (!histogram_data) return []
|
|
@@ -69,7 +69,8 @@
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
function clear_filter(): void {
|
|
72
|
-
min_value =
|
|
72
|
+
min_value = undefined
|
|
73
|
+
max_value = undefined
|
|
73
74
|
onclear?.()
|
|
74
75
|
onchange?.(undefined, undefined)
|
|
75
76
|
}
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
// Create a deep copy of current_values on mount to use as reference values
|
|
27
27
|
function deep_copy(obj: unknown): unknown {
|
|
28
28
|
if (obj === null || typeof obj !== `object`) return obj
|
|
29
|
-
if (obj instanceof Date) return new Date(obj
|
|
29
|
+
if (obj instanceof Date) return new Date(obj)
|
|
30
30
|
if (obj instanceof RegExp) return new RegExp(obj)
|
|
31
31
|
if (Array.isArray(obj)) {
|
|
32
32
|
return obj.map((item) =>
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
// Get children based on value type
|
|
121
|
-
function get_children():
|
|
121
|
+
function get_children(): { key: string | number; value: unknown }[] {
|
|
122
122
|
if (!expandable) return []
|
|
123
123
|
|
|
124
124
|
if (value_type === `array`) {
|
|
@@ -252,8 +252,8 @@
|
|
|
252
252
|
const all_paths = collect_all_paths(value, root_path)
|
|
253
253
|
const descendants = target_path === `` ? all_paths : all_paths.filter(
|
|
254
254
|
(entry) =>
|
|
255
|
-
entry === target_path || entry.startsWith(target_path
|
|
256
|
-
entry.startsWith(target_path
|
|
255
|
+
entry === target_path || entry.startsWith(`${target_path}.`) ||
|
|
256
|
+
entry.startsWith(`${target_path}[`),
|
|
257
257
|
)
|
|
258
258
|
return descendants.includes(target_path)
|
|
259
259
|
? descendants
|
|
@@ -13,6 +13,7 @@ function safe_stringify(val) {
|
|
|
13
13
|
return `${inner}n`;
|
|
14
14
|
if (typeof inner === `symbol`)
|
|
15
15
|
return inner.toString();
|
|
16
|
+
// oxlint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- anonymous fns have name ``
|
|
16
17
|
if (typeof inner === `function`)
|
|
17
18
|
return `[Function: ${inner.name || `anonymous`}]`;
|
|
18
19
|
return inner;
|
|
@@ -93,7 +94,7 @@ function format_path_segment(segment, is_first = false) {
|
|
|
93
94
|
return is_first ? segment : `.${segment}`;
|
|
94
95
|
}
|
|
95
96
|
// Use bracket notation for keys with special characters
|
|
96
|
-
return `["${segment.
|
|
97
|
+
return `["${segment.replaceAll('"', `\\"`)}"]`;
|
|
97
98
|
}
|
|
98
99
|
// Format a full path from segments
|
|
99
100
|
// e.g., ["users", 0, "name"] -> "users[0].name"
|
|
@@ -317,7 +318,7 @@ export function parse_path(path) {
|
|
|
317
318
|
const num = Number(current);
|
|
318
319
|
if (Number.isNaN(num)) {
|
|
319
320
|
// Remove surrounding quotes and unescape internal quotes
|
|
320
|
-
const unquoted = current.
|
|
321
|
+
const unquoted = current.replaceAll(/^"|"$/g, ``).replaceAll('\\"', `"`);
|
|
321
322
|
segments.push(unquoted);
|
|
322
323
|
}
|
|
323
324
|
else
|
|
@@ -335,7 +336,7 @@ export function parse_path(path) {
|
|
|
335
336
|
// Apply same numeric/quoted-string logic as inside brackets
|
|
336
337
|
const num = Number(current);
|
|
337
338
|
if (Number.isNaN(num)) {
|
|
338
|
-
const unquoted = current.
|
|
339
|
+
const unquoted = current.replaceAll(/^"|"$/g, ``).replaceAll('\\"', `"`);
|
|
339
340
|
segments.push(unquoted);
|
|
340
341
|
}
|
|
341
342
|
else
|
|
@@ -407,7 +408,7 @@ export function set_at_path(root, path_str, new_value, root_label) {
|
|
|
407
408
|
const start = root_label && segments[0] === root_label ? 1 : 0;
|
|
408
409
|
if (start >= segments.length)
|
|
409
410
|
return new_value;
|
|
410
|
-
const cloned =
|
|
411
|
+
const cloned = structuredClone(root);
|
|
411
412
|
let current = cloned;
|
|
412
413
|
for (let idx = start; idx < segments.length - 1; idx++) {
|
|
413
414
|
const next = current[segments[idx]];
|
package/dist/marching-cubes.js
CHANGED
|
@@ -335,9 +335,11 @@ export function marching_cubes(grid, iso_value, k_lattice, options = {}) {
|
|
|
335
335
|
const vertices = [];
|
|
336
336
|
const faces = [];
|
|
337
337
|
const normals = [];
|
|
338
|
-
//
|
|
339
|
-
|
|
340
|
-
const
|
|
338
|
+
// Cache keys use UNWRAPPED grid coords (reach n in periodic mode, hence radix n+1):
|
|
339
|
+
// wrapping would merge vertices on opposite cell faces into cell-spanning triangles.
|
|
340
|
+
const key_nz = nz + 1;
|
|
341
|
+
const key_ny_nz = (ny + 1) * key_nz;
|
|
342
|
+
const max_flat = (nx + 1) * key_ny_nz; // for computing cache keys
|
|
341
343
|
// Use numeric cache key - safe for grids up to ~300³ (2^53 / 2 / max_flat)
|
|
342
344
|
// For much larger grids (>30M cells), consider switching to Map<string, number>
|
|
343
345
|
// with keys like `${flat1},${flat2}` or Map<bigint, number> to avoid
|
|
@@ -367,17 +369,10 @@ export function marching_cubes(grid, iso_value, k_lattice, options = {}) {
|
|
|
367
369
|
const ox2 = CUBE_VERTS_X[v2_idx];
|
|
368
370
|
const oy2 = CUBE_VERTS_Y[v2_idx];
|
|
369
371
|
const oz2 = CUBE_VERTS_Z[v2_idx];
|
|
370
|
-
//
|
|
371
|
-
const g1x = periodic ? wrap_grid_idx(ix + ox1, nx) : ix + ox1;
|
|
372
|
-
const g1y = periodic ? wrap_grid_idx(iy + oy1, ny) : iy + oy1;
|
|
373
|
-
const g1z = periodic ? wrap_grid_idx(iz + oz1, nz) : iz + oz1;
|
|
374
|
-
const g2x = periodic ? wrap_grid_idx(ix + ox2, nx) : ix + ox2;
|
|
375
|
-
const g2y = periodic ? wrap_grid_idx(iy + oy2, ny) : iy + oy2;
|
|
376
|
-
const g2z = periodic ? wrap_grid_idx(iz + oz2, nz) : iz + oz2;
|
|
377
|
-
// Create numeric cache key (sorted for consistency)
|
|
372
|
+
// Sorted numeric key from UNWRAPPED coords (value/gradient lookups wrap internally).
|
|
378
373
|
// Safe for grids up to ~300³ before exceeding Number.MAX_SAFE_INTEGER
|
|
379
|
-
const flat1 =
|
|
380
|
-
const flat2 =
|
|
374
|
+
const flat1 = (ix + ox1) * key_ny_nz + (iy + oy1) * key_nz + (iz + oz1);
|
|
375
|
+
const flat2 = (ix + ox2) * key_ny_nz + (iy + oy2) * key_nz + (iz + oz2);
|
|
381
376
|
const cache_key = flat1 < flat2 ? flat1 * max_flat + flat2 : flat2 * max_flat + flat1;
|
|
382
377
|
const cached = vertex_cache.get(cache_key);
|
|
383
378
|
if (cached !== undefined)
|
package/dist/math.d.ts
CHANGED
|
@@ -78,7 +78,10 @@ export declare const lerp: (start: number, end: number, t: number) => number;
|
|
|
78
78
|
export declare const lerp_vec3: (start: Vec3, end: Vec3, t: number) => Vec3;
|
|
79
79
|
export declare const centered_frac: (val: number) => number;
|
|
80
80
|
export declare const vecs_equal: (vec_a?: Vec3, vec_b?: Vec3) => boolean;
|
|
81
|
-
|
|
81
|
+
type Normalized<T extends readonly number[]> = {
|
|
82
|
+
-readonly [K in keyof T]: number;
|
|
83
|
+
};
|
|
84
|
+
export declare function normalize_vec<T extends readonly number[]>(vec: T, fallback?: NoInfer<T>): Normalized<T>;
|
|
82
85
|
export declare function compute_in_plane_basis(normal: Vec3): [Vec3, Vec3];
|
|
83
86
|
export declare function are_coplanar(points: number[][], tolerance?: number): boolean;
|
|
84
87
|
export declare function merge_coplanar_triangles(positions: Float32Array, tolerance?: number): Float32Array;
|
|
@@ -99,3 +102,4 @@ export declare function solve_linear_system(A: number[][], // NxN coefficient ma
|
|
|
99
102
|
b: number[]): number[] | null;
|
|
100
103
|
export declare const cross_2d: (origin: Vec2, point_a: Vec2, point_b: Vec2) => number;
|
|
101
104
|
export declare function convex_hull_2d(points: Vec2[]): Vec2[];
|
|
105
|
+
export {};
|
package/dist/math.js
CHANGED
|
@@ -448,17 +448,19 @@ export const centered_frac = (val) => {
|
|
|
448
448
|
// Element-wise equality check for two optional Vec3s.
|
|
449
449
|
// Returns true if both are the same reference, or both are defined with equal components.
|
|
450
450
|
export const vecs_equal = (vec_a, vec_b) => vec_a === vec_b ||
|
|
451
|
-
(
|
|
452
|
-
|
|
451
|
+
(vec_a != null &&
|
|
452
|
+
vec_b != null &&
|
|
453
453
|
vec_a[0] === vec_b[0] &&
|
|
454
454
|
vec_a[1] === vec_b[1] &&
|
|
455
455
|
vec_a[2] === vec_b[2]);
|
|
456
|
-
// Normalize a
|
|
457
|
-
export function
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
456
|
+
// Normalize a vector of any length to unit length; returns `fallback` (or zeros) when ~zero.
|
|
457
|
+
export function normalize_vec(vec, fallback) {
|
|
458
|
+
let sum_sq = 0;
|
|
459
|
+
for (const coord of vec)
|
|
460
|
+
sum_sq += coord * coord;
|
|
461
|
+
const len = Math.sqrt(sum_sq);
|
|
462
|
+
const unit = len < EPS ? (fallback ?? vec.map(() => 0)) : vec.map((coord) => coord / len);
|
|
463
|
+
return unit;
|
|
462
464
|
}
|
|
463
465
|
// Compute orthonormal basis vectors in a plane perpendicular to `normal`.
|
|
464
466
|
// Uses Gram-Schmidt orthogonalization + cross product.
|
|
@@ -472,7 +474,7 @@ export function compute_in_plane_basis(normal) {
|
|
|
472
474
|
ref_vec[1] - dot_nr * normal[1],
|
|
473
475
|
ref_vec[2] - dot_nr * normal[2],
|
|
474
476
|
];
|
|
475
|
-
const u_vec =
|
|
477
|
+
const u_vec = normalize_vec(u_raw, [0, 1, 0]);
|
|
476
478
|
const v_vec = cross_3d(normal, u_vec);
|
|
477
479
|
return [u_vec, v_vec]; // u, v basis vectors
|
|
478
480
|
}
|
|
@@ -649,6 +651,7 @@ export function merge_coplanar_triangles(positions, tolerance = 1e-4) {
|
|
|
649
651
|
emit_tri(verts[0], verts[1], verts[2]);
|
|
650
652
|
}
|
|
651
653
|
};
|
|
654
|
+
const tri_area = (va, vb, vc) => 0.5 * Math.hypot(...cross_3d(subtract(vb, va), subtract(vc, va)));
|
|
652
655
|
for (const members of groups.values()) {
|
|
653
656
|
if (members.length === 1) {
|
|
654
657
|
emit_original(members);
|
|
@@ -692,6 +695,18 @@ export function merge_coplanar_triangles(positions, tolerance = 1e-4) {
|
|
|
692
695
|
}
|
|
693
696
|
return unique_verts[best_idx];
|
|
694
697
|
});
|
|
698
|
+
// Convex hull fills notches of concave patches, inventing area — keep originals then
|
|
699
|
+
let group_area = 0;
|
|
700
|
+
let fan_area = 0;
|
|
701
|
+
for (const tri_idx of members)
|
|
702
|
+
group_area += tri_area(...tri_planes[tri_idx].verts);
|
|
703
|
+
for (let idx = 1; idx < hull_3d.length - 1; idx++) {
|
|
704
|
+
fan_area += tri_area(hull_3d[0], hull_3d[idx], hull_3d[idx + 1]);
|
|
705
|
+
}
|
|
706
|
+
if (Math.abs(fan_area - group_area) > Math.max(group_area, 1e-12) * 1e-6) {
|
|
707
|
+
emit_original(members);
|
|
708
|
+
continue;
|
|
709
|
+
}
|
|
695
710
|
// Fan-triangulate from hull vertex 0
|
|
696
711
|
for (let idx = 1; idx < hull_3d.length - 1; idx++) {
|
|
697
712
|
emit_tri(hull_3d[0], hull_3d[idx], hull_3d[idx + 1]);
|
|
@@ -173,10 +173,10 @@
|
|
|
173
173
|
if (Date.now() - resize_end_time < 200) return
|
|
174
174
|
|
|
175
175
|
const target = event.target
|
|
176
|
-
const is_toggle_button = target instanceof Node &&
|
|
177
|
-
(target === toggle_pane_btn || toggle_pane_btn
|
|
178
|
-
const is_inside_pane = target instanceof Node &&
|
|
179
|
-
(target === pane_div || pane_div
|
|
176
|
+
const is_toggle_button = target instanceof Node &&
|
|
177
|
+
(target === toggle_pane_btn || (toggle_pane_btn?.contains(target) ?? false))
|
|
178
|
+
const is_inside_pane = target instanceof Node &&
|
|
179
|
+
(target === pane_div || (pane_div?.contains(target) ?? false))
|
|
180
180
|
|
|
181
181
|
if (!is_toggle_button && !is_inside_pane && !currently_dragging && !resizing) {
|
|
182
182
|
close_pane()
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
active_elements = $bindable([]),
|
|
31
31
|
gap = `0.3cqw`,
|
|
32
32
|
inner_transition_metal_offset = 0.5,
|
|
33
|
-
lanth_act_tiles = tile_props?.show_symbol
|
|
33
|
+
lanth_act_tiles = tile_props?.show_symbol === false
|
|
34
34
|
? []
|
|
35
35
|
: [...default_f_block_inset_tiles],
|
|
36
36
|
lanth_act_style = ``,
|
|
@@ -115,8 +115,8 @@
|
|
|
115
115
|
`each element possibly omitting elements at the end, got ${heatmap_values.length}`,
|
|
116
116
|
)
|
|
117
117
|
return []
|
|
118
|
-
}
|
|
119
|
-
} else if (typeof heatmap_values
|
|
118
|
+
}return heatmap_values
|
|
119
|
+
} else if (typeof heatmap_values === `object`) {
|
|
120
120
|
const bad_keys = Object.keys(heatmap_values).filter(
|
|
121
121
|
(key) => !ELEM_SYMBOLS.includes(key as ElementSymbol),
|
|
122
122
|
)
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
|
|
144
144
|
function handle_key(event: KeyboardEvent) {
|
|
145
145
|
if (disabled || !active_element) return
|
|
146
|
-
if (event.key
|
|
146
|
+
if (event.key === `Enter`) onenter?.(active_element)
|
|
147
147
|
|
|
148
148
|
const arrow_keys = [`ArrowUp`, `ArrowDown`, `ArrowLeft`, `ArrowRight`]
|
|
149
149
|
if (!arrow_keys.includes(event.key)) return
|
|
@@ -186,12 +186,12 @@
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
let color_scale_fn = $derived(
|
|
189
|
-
typeof color_scale
|
|
189
|
+
typeof color_scale === `string` ? d3_sc[color_scale] : color_scale,
|
|
190
190
|
)
|
|
191
191
|
|
|
192
192
|
let cs_min = $derived(
|
|
193
193
|
color_scale_range[0] ??
|
|
194
|
-
(heat_values.length
|
|
194
|
+
(heat_values.length > 0
|
|
195
195
|
? Math.min(
|
|
196
196
|
...heat_values.flat().filter((v): v is number => typeof v === `number`),
|
|
197
197
|
)
|
|
@@ -199,13 +199,20 @@
|
|
|
199
199
|
)
|
|
200
200
|
let cs_max = $derived(
|
|
201
201
|
color_scale_range[1] ??
|
|
202
|
-
(heat_values.length
|
|
202
|
+
(heat_values.length > 0
|
|
203
203
|
? Math.max(
|
|
204
204
|
...heat_values.flat().filter((v): v is number => typeof v === `number`),
|
|
205
205
|
)
|
|
206
206
|
: 1),
|
|
207
207
|
)
|
|
208
208
|
|
|
209
|
+
// smallest positive bound for log color mapping (matches the auto ColorBar's log scale)
|
|
210
|
+
let cs_min_pos = $derived.by(() => {
|
|
211
|
+
if (cs_min > 0) return cs_min
|
|
212
|
+
const pos = heat_values.flat().filter((v): v is number => typeof v === `number` && v > 0)
|
|
213
|
+
return pos.length > 0 ? Math.min(...pos) : cs_max
|
|
214
|
+
})
|
|
215
|
+
|
|
209
216
|
let bg_color = $derived(
|
|
210
217
|
(
|
|
211
218
|
value: number | number[] | string | string[] | false,
|
|
@@ -238,8 +245,12 @@
|
|
|
238
245
|
const span = cs_max - cs_min
|
|
239
246
|
if (span === 0) return color_scale_fn?.(0.5) // midpoint when all values equal
|
|
240
247
|
|
|
241
|
-
if (log)
|
|
242
|
-
|
|
248
|
+
if (log) {
|
|
249
|
+
// log mapping matching the log ColorBar (value <= 0 returned missing_color above)
|
|
250
|
+
const log_span = Math.log(cs_max) - Math.log(cs_min_pos)
|
|
251
|
+
if (log_span === 0) return color_scale_fn?.(0.5)
|
|
252
|
+
value = (Math.log(value as number) - Math.log(cs_min_pos)) / log_span
|
|
253
|
+
} else value = ((value as number) - cs_min) / span
|
|
243
254
|
return color_scale_fn?.(value as number)
|
|
244
255
|
},
|
|
245
256
|
)
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
import { sanitize_svg } from '../sanitize'
|
|
9
9
|
import { compute_bounding_box_2d, polygon_centroid, type Vec2 } from '../math'
|
|
10
10
|
import type { AxisConfig } from '../plot'
|
|
11
|
-
import { constrain_tooltip_position } from '../plot/layout'
|
|
11
|
+
import { constrain_tooltip_position } from '../plot/core/layout'
|
|
12
|
+
import { unique_id } from '../plot/core/utils'
|
|
12
13
|
import { scaleLinear } from 'd3-scale'
|
|
13
14
|
import type { ComponentProps, Snippet } from 'svelte'
|
|
14
15
|
import type { HTMLAttributes } from 'svelte/elements'
|
|
@@ -124,6 +125,11 @@
|
|
|
124
125
|
const pane_icon_style = `width: 14px; height: 14px`
|
|
125
126
|
const pane_toggle_props = { style: `padding: 0` }
|
|
126
127
|
|
|
128
|
+
// Instance-unique prefix for gradient ids: region ids come from user data (e.g.
|
|
129
|
+
// 'liquid'), so two diagrams on one page would otherwise cross-reference each
|
|
130
|
+
// other's gradients (first-in-document wins, with that instance's pixel coords)
|
|
131
|
+
const gradient_uid = unique_id(`pd-gradient`)
|
|
132
|
+
|
|
127
133
|
// Rebuild diagram data when diagram_input changes ($derived auto-recomputes)
|
|
128
134
|
const rebuilt_data = $derived.by(() => {
|
|
129
135
|
if (!diagram_input) return null
|
|
@@ -619,7 +625,7 @@
|
|
|
619
625
|
{#each transformed_regions as region (region.id)}
|
|
620
626
|
{#if region.gradient}
|
|
621
627
|
<linearGradient
|
|
622
|
-
id="
|
|
628
|
+
id="{gradient_uid}-{region.id}"
|
|
623
629
|
x1={region.x_min}
|
|
624
630
|
x2={region.x_max}
|
|
625
631
|
y1="0"
|
|
@@ -661,7 +667,7 @@
|
|
|
661
667
|
<path
|
|
662
668
|
d={region.svg_path}
|
|
663
669
|
fill={region.gradient
|
|
664
|
-
? `url(
|
|
670
|
+
? `url(#${gradient_uid}-${region.id})`
|
|
665
671
|
: (region.color || get_phase_color(region.name))}
|
|
666
672
|
stroke="none"
|
|
667
673
|
class:hovered={hovered_region?.id === region.id}
|
|
@@ -39,6 +39,6 @@ type $$ComponentProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
39
39
|
}
|
|
40
40
|
]>;
|
|
41
41
|
};
|
|
42
|
-
declare const IsobaricBinaryPhaseDiagram: import("svelte").Component<$$ComponentProps, {}, "
|
|
42
|
+
declare const IsobaricBinaryPhaseDiagram: import("svelte").Component<$$ComponentProps, {}, "fullscreen" | "controls_open" | "x_axis" | "y_axis" | "show_grid" | "show_boundaries" | "show_labels" | "show_special_points" | "show_component_labels" | "png_dpi" | "wrapper" | "config" | "export_pane_open" | "lever_rule_mode" | "editor_open" | "diagram_input" | "hovered_region" | "display_temp_unit">;
|
|
43
43
|
type IsobaricBinaryPhaseDiagram = ReturnType<typeof IsobaricBinaryPhaseDiagram>;
|
|
44
44
|
export default IsobaricBinaryPhaseDiagram;
|
|
@@ -25,6 +25,6 @@ type $$ComponentProps = Omit<ComponentProps<typeof DraggablePane>, `children`> &
|
|
|
25
25
|
controls_open: boolean;
|
|
26
26
|
}]>;
|
|
27
27
|
};
|
|
28
|
-
declare const PhaseDiagramControls: import("svelte").Component<$$ComponentProps, {}, "
|
|
28
|
+
declare const PhaseDiagramControls: import("svelte").Component<$$ComponentProps, {}, "controls_open" | "x_axis" | "y_axis" | "show_grid" | "show_boundaries" | "show_labels" | "show_special_points" | "show_component_labels" | "png_dpi" | "config" | "lever_rule_mode">;
|
|
29
29
|
type PhaseDiagramControls = ReturnType<typeof PhaseDiagramControls>;
|
|
30
30
|
export default PhaseDiagramControls;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { build_diagram } from './build-diagram'
|
|
7
7
|
import type { DiagramInput } from './diagram-input'
|
|
8
8
|
import type { PhaseDiagramData } from './types'
|
|
9
|
+
import { to_error } from '../utils'
|
|
9
10
|
|
|
10
11
|
let {
|
|
11
12
|
editor_open = $bindable(false),
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
build_diagram(updated as DiagramInput)
|
|
55
56
|
diagram_input = updated as DiagramInput
|
|
56
57
|
} catch (error) {
|
|
57
|
-
const msg = error
|
|
58
|
+
const msg = to_error(error).message
|
|
58
59
|
show_rejection(msg)
|
|
59
60
|
}
|
|
60
61
|
return
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
|
|
107
107
|
// Calculate distance to nearest phase boundary (liquidus/solidus)
|
|
108
108
|
const boundary_distance = $derived.by(() => {
|
|
109
|
-
if (
|
|
109
|
+
if (boundaries.length === 0) return null
|
|
110
110
|
const { composition, temperature } = hover_info
|
|
111
111
|
let min_dist: { type: string; delta_t: number } | null = null
|
|
112
112
|
|
|
@@ -22,8 +22,8 @@ export function parse_curve_ref(ref) {
|
|
|
22
22
|
const slice_match = /^(.+)\[(-?\d*):(-?\d*)\]$/.exec(name);
|
|
23
23
|
if (slice_match) {
|
|
24
24
|
name = slice_match[1];
|
|
25
|
-
start = slice_match[2] ? parseInt(slice_match[2]) : null;
|
|
26
|
-
end = slice_match[3] ? parseInt(slice_match[3]) : null;
|
|
25
|
+
start = slice_match[2] ? parseInt(slice_match[2], 10) : null;
|
|
26
|
+
end = slice_match[3] ? parseInt(slice_match[3], 10) : null;
|
|
27
27
|
}
|
|
28
28
|
return { name, reverse, start, end };
|
|
29
29
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// TDB (Thermodynamic Database) file parser
|
|
2
2
|
// Parses CALPHAD TDB files to extract metadata about elements, phases, and parameters
|
|
3
3
|
import { ELEM_SYMBOLS } from '../labels';
|
|
4
|
+
import { to_error } from '../utils';
|
|
4
5
|
// Default temperature bounds for TDB parsing (in Kelvin)
|
|
5
6
|
export const TDB_TEMP_DEFAULTS = {
|
|
6
7
|
min: 298.15, // Room temperature
|
|
@@ -20,21 +21,21 @@ export function parse_tdb(content) {
|
|
|
20
21
|
};
|
|
21
22
|
// Normalize line endings and join continuation lines
|
|
22
23
|
const normalized = content
|
|
23
|
-
.
|
|
24
|
-
.
|
|
24
|
+
.replaceAll('\r\n', `\n`)
|
|
25
|
+
.replaceAll('\r', `\n`)
|
|
25
26
|
// Join lines that don't end with ! (continuation)
|
|
26
27
|
.split(`\n`)
|
|
27
28
|
.reduce((acc, line) => {
|
|
28
29
|
const trimmed = line.trim();
|
|
29
30
|
if (trimmed.startsWith(`$`)) {
|
|
30
|
-
data.comments.push(trimmed.
|
|
31
|
+
data.comments.push(trimmed.slice(1).trim());
|
|
31
32
|
return acc;
|
|
32
33
|
}
|
|
33
34
|
if (acc.length === 0 || acc[acc.length - 1].endsWith(`!`)) {
|
|
34
35
|
acc.push(trimmed);
|
|
35
36
|
}
|
|
36
37
|
else {
|
|
37
|
-
acc[acc.length - 1] += `
|
|
38
|
+
acc[acc.length - 1] += ` ${trimmed}`;
|
|
38
39
|
}
|
|
39
40
|
return acc;
|
|
40
41
|
}, [])
|
|
@@ -76,7 +77,7 @@ export function parse_tdb(content) {
|
|
|
76
77
|
return {
|
|
77
78
|
success: false,
|
|
78
79
|
data: null,
|
|
79
|
-
error: exc
|
|
80
|
+
error: to_error(exc).message,
|
|
80
81
|
};
|
|
81
82
|
}
|
|
82
83
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Point2D, Vec2 } from '../math';
|
|
2
2
|
import type { LineStyle } from '../plot';
|
|
3
|
-
import type { Sides } from '../plot/layout';
|
|
3
|
+
import type { Sides } from '../plot/core/layout';
|
|
4
4
|
import type { TooltipConfig, TooltipProp } from '../tooltip';
|
|
5
5
|
export type TempUnit = `K` | `°C` | `°F`;
|
|
6
6
|
export type CompUnit = `at%` | `wt%` | `mol%` | `fraction`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Vec2 } from '../math';
|
|
2
|
-
import type { Sides } from '../plot/layout';
|
|
2
|
+
import type { Sides } from '../plot/core/layout';
|
|
3
3
|
import type { CompUnit, LeverRuleMode, LeverRuleResult, PhaseDiagramConfig, PhaseDiagramData, PhaseHoverInfo, PhaseRegion, TempUnit, VerticalLeverRuleResult } from './types';
|
|
4
4
|
export declare function convert_temp(value: number, from: TempUnit, to: TempUnit): number;
|
|
5
5
|
export declare const PHASE_DIAGRAM_DEFAULTS: Readonly<{
|
|
@@ -28,7 +28,7 @@ export declare const PHASE_DIAGRAM_DEFAULTS: Readonly<{
|
|
|
28
28
|
margin: Readonly<Required<Sides>>;
|
|
29
29
|
png_dpi: 150;
|
|
30
30
|
}>;
|
|
31
|
-
export declare
|
|
31
|
+
export declare const merge_phase_diagram_config: (config: Partial<PhaseDiagramConfig>) => {
|
|
32
32
|
margin: {
|
|
33
33
|
t: number;
|
|
34
34
|
b: number;
|
|
@@ -91,7 +91,7 @@ export declare function compute_label_properties(label: string, bounds: {
|
|
|
91
91
|
};
|
|
92
92
|
export declare const transform_vertices: (vertices: Vec2[], x_scale: (val: number) => number, y_scale: (val: number) => number) => Vec2[];
|
|
93
93
|
export declare function format_composition(value: number, unit?: CompUnit, include_unit?: boolean): string;
|
|
94
|
-
export declare
|
|
94
|
+
export declare const format_temperature: (value: number, unit?: TempUnit) => string;
|
|
95
95
|
export declare function calculate_lever_rule(region: PhaseRegion, composition: number, temperature: number): LeverRuleResult | null;
|
|
96
96
|
export declare function calculate_vertical_lever_rule(region: PhaseRegion, composition: number, temperature: number): VerticalLeverRuleResult | null;
|
|
97
97
|
export declare function format_hover_info_text(info: PhaseHoverInfo, temp_unit?: TempUnit, comp_unit?: CompUnit, component_a?: string, component_b?: string, data_temp_unit?: TempUnit, lever_rule_mode?: LeverRuleMode): string;
|
|
@@ -46,15 +46,13 @@ export const PHASE_DIAGRAM_DEFAULTS = Object.freeze({
|
|
|
46
46
|
png_dpi: 150,
|
|
47
47
|
});
|
|
48
48
|
// Merge partial config with defaults - single helper for consistent merging
|
|
49
|
-
export
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
};
|
|
57
|
-
}
|
|
49
|
+
export const merge_phase_diagram_config = (config) => ({
|
|
50
|
+
margin: { ...PHASE_DIAGRAM_DEFAULTS.margin, ...config.margin },
|
|
51
|
+
font_size: config.font_size ?? PHASE_DIAGRAM_DEFAULTS.font_size,
|
|
52
|
+
special_point_radius: config.special_point_radius ?? PHASE_DIAGRAM_DEFAULTS.special_point_radius,
|
|
53
|
+
tie_line: { ...PHASE_DIAGRAM_DEFAULTS.tie_line, ...config.tie_line },
|
|
54
|
+
colors: { ...PHASE_DIAGRAM_DEFAULTS.colors, ...config.colors },
|
|
55
|
+
});
|
|
58
56
|
// Phase colors as hex - single source of truth
|
|
59
57
|
// Extended palette supports 3+ phase regions (Greek letters α through λ)
|
|
60
58
|
export const PHASE_COLOR_HEX = {
|
|
@@ -231,9 +229,7 @@ export function format_composition(value, unit = `at%`, include_unit = true) {
|
|
|
231
229
|
return include_unit ? `${formatted} ${unit}` : formatted;
|
|
232
230
|
}
|
|
233
231
|
// Format temperature value for display
|
|
234
|
-
export
|
|
235
|
-
return `${format_num(value, `.0f`)} ${unit}`;
|
|
236
|
-
}
|
|
232
|
+
export const format_temperature = (value, unit = `K`) => `${format_num(value, `.0f`)} ${unit}`;
|
|
237
233
|
// Parse a two-phase region name into its two phase names
|
|
238
234
|
// Returns null if the region is not exactly a two-phase region
|
|
239
235
|
function parse_two_phases(name) {
|