matterviz 0.3.1 → 0.3.3
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 -2
- package/dist/FilePicker.svelte +154 -96
- package/dist/Icon.svelte +20 -14
- package/dist/MillerIndexInput.svelte +27 -21
- package/dist/api/optimade.js +6 -6
- package/dist/app.css +216 -178
- package/dist/brillouin/BrillouinZone.svelte +299 -198
- package/dist/brillouin/BrillouinZone.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneControls.svelte +32 -5
- package/dist/brillouin/BrillouinZoneExportPane.svelte +74 -55
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +99 -68
- package/dist/brillouin/BrillouinZoneScene.svelte +277 -165
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneTooltip.svelte +17 -7
- package/dist/brillouin/compute.js +11 -6
- package/dist/chempot-diagram/ChemPotDiagram.svelte +327 -0
- package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +13 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +847 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +3194 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte +11 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte.d.ts +7 -0
- package/dist/chempot-diagram/async-compute.svelte.d.ts +3 -0
- package/dist/chempot-diagram/async-compute.svelte.js +77 -0
- package/dist/chempot-diagram/chempot-worker.d.ts +1 -0
- package/dist/chempot-diagram/chempot-worker.js +11 -0
- package/dist/chempot-diagram/color.d.ts +10 -0
- package/dist/chempot-diagram/color.js +32 -0
- package/dist/chempot-diagram/compute.d.ts +48 -0
- package/dist/chempot-diagram/compute.js +812 -0
- package/dist/chempot-diagram/index.d.ts +6 -0
- package/dist/chempot-diagram/index.js +6 -0
- package/dist/chempot-diagram/pointer.d.ts +16 -0
- package/dist/chempot-diagram/pointer.js +40 -0
- package/dist/chempot-diagram/temperature.d.ts +15 -0
- package/dist/chempot-diagram/temperature.js +36 -0
- package/dist/chempot-diagram/types.d.ts +86 -0
- package/dist/chempot-diagram/types.js +28 -0
- package/dist/colors/index.d.ts +3 -1
- package/dist/colors/index.js +9 -3
- package/dist/composition/BarChart.svelte +141 -77
- package/dist/composition/BubbleChart.svelte +107 -52
- package/dist/composition/Composition.svelte +100 -79
- package/dist/composition/Formula.svelte +108 -62
- package/dist/composition/FormulaFilter.svelte +973 -353
- package/dist/composition/FormulaFilter.svelte.d.ts +35 -1
- package/dist/composition/PieChart.svelte +199 -99
- package/dist/composition/PieChart.svelte.d.ts +1 -1
- package/dist/composition/format.d.ts +5 -0
- package/dist/composition/format.js +20 -3
- package/dist/composition/parse.js +14 -9
- package/dist/convex-hull/ConvexHull.svelte +93 -38
- package/dist/convex-hull/ConvexHull2D.svelte +551 -393
- package/dist/convex-hull/ConvexHull3D.svelte +1303 -825
- package/dist/convex-hull/ConvexHull4D.svelte +1012 -686
- package/dist/convex-hull/ConvexHullControls.svelte +115 -28
- package/dist/convex-hull/ConvexHullInfoPane.svelte +29 -3
- package/dist/convex-hull/ConvexHullStats.svelte +821 -249
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +6 -1
- package/dist/convex-hull/ConvexHullTooltip.svelte +41 -16
- package/dist/convex-hull/GasPressureControls.svelte +104 -61
- package/dist/convex-hull/StructurePopup.svelte +25 -4
- package/dist/convex-hull/TemperatureSlider.svelte +45 -25
- package/dist/convex-hull/barycentric-coords.js +13 -7
- package/dist/convex-hull/demo-temperature.d.ts +6 -0
- package/dist/convex-hull/demo-temperature.js +40 -0
- package/dist/convex-hull/gas-thermodynamics.js +17 -12
- package/dist/convex-hull/helpers.d.ts +10 -1
- package/dist/convex-hull/helpers.js +79 -38
- package/dist/convex-hull/index.d.ts +1 -0
- package/dist/convex-hull/index.js +1 -0
- package/dist/convex-hull/thermodynamics.d.ts +8 -21
- package/dist/convex-hull/thermodynamics.js +163 -69
- package/dist/convex-hull/types.d.ts +12 -12
- package/dist/convex-hull/types.js +0 -12
- package/dist/coordination/CoordinationBarPlot.svelte +232 -176
- package/dist/element/BohrAtom.svelte +56 -13
- package/dist/element/ElementHeading.svelte +7 -2
- package/dist/element/ElementPhoto.svelte +15 -9
- package/dist/element/ElementStats.svelte +10 -4
- package/dist/element/ElementTile.svelte +137 -73
- package/dist/element/Nucleus.svelte +39 -11
- package/dist/element/data.js +2 -14
- package/dist/element/data.json.gz +0 -0
- package/dist/element/types.d.ts +1 -0
- package/dist/feedback/ClickFeedback.svelte +16 -5
- package/dist/feedback/DragOverlay.svelte +10 -2
- package/dist/feedback/Spinner.svelte +4 -2
- package/dist/feedback/StatusMessage.svelte +8 -2
- package/dist/fermi-surface/FermiSlice.svelte +118 -88
- package/dist/fermi-surface/FermiSurface.svelte +336 -239
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceControls.svelte +113 -46
- package/dist/fermi-surface/FermiSurfaceScene.svelte +536 -343
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +14 -5
- package/dist/fermi-surface/compute.js +16 -20
- package/dist/fermi-surface/parse.js +37 -33
- package/dist/fermi-surface/symmetry.js +2 -7
- package/dist/fermi-surface/types.d.ts +3 -5
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +1527 -0
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +110 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +225 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +30 -0
- package/dist/heatmap-matrix/index.d.ts +53 -0
- package/dist/heatmap-matrix/index.js +100 -0
- package/dist/heatmap-matrix/shared.d.ts +2 -0
- package/dist/heatmap-matrix/shared.js +4 -0
- package/dist/icons.d.ts +111 -0
- package/dist/icons.js +158 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -2
- package/dist/io/decompress.js +1 -1
- package/dist/io/export.d.ts +3 -0
- package/dist/io/export.js +138 -140
- package/dist/io/file-drop.d.ts +7 -0
- package/dist/io/file-drop.js +43 -0
- package/dist/io/index.d.ts +2 -2
- package/dist/io/index.js +2 -112
- package/dist/io/is-binary.js +2 -3
- package/dist/io/types.d.ts +1 -0
- package/dist/io/url-drop.d.ts +2 -0
- package/dist/io/url-drop.js +117 -0
- package/dist/isosurface/Isosurface.svelte +220 -110
- package/dist/isosurface/IsosurfaceControls.svelte +65 -28
- package/dist/isosurface/parse.js +104 -56
- package/dist/isosurface/slice.d.ts +2 -1
- package/dist/isosurface/slice.js +8 -13
- package/dist/isosurface/types.d.ts +14 -1
- package/dist/isosurface/types.js +152 -5
- package/dist/labels.d.ts +2 -1
- package/dist/labels.js +12 -8
- package/dist/layout/FullscreenToggle.svelte +11 -2
- package/dist/layout/InfoCard.svelte +38 -6
- package/dist/layout/InfoTag.svelte +125 -94
- package/dist/layout/PropertyFilter.svelte +82 -37
- package/dist/layout/SettingsSection.svelte +85 -55
- package/dist/layout/SubpageGrid.svelte +82 -0
- package/dist/layout/SubpageGrid.svelte.d.ts +14 -0
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/index.js +1 -0
- package/dist/layout/json-tree/JsonNode.svelte +266 -223
- package/dist/layout/json-tree/JsonTree.svelte +516 -429
- package/dist/layout/json-tree/JsonTree.svelte.d.ts +1 -1
- package/dist/layout/json-tree/JsonValue.svelte +281 -173
- package/dist/layout/json-tree/types.d.ts +10 -2
- package/dist/layout/json-tree/utils.d.ts +2 -0
- package/dist/layout/json-tree/utils.js +37 -2
- package/dist/marching-cubes.js +25 -2
- package/dist/math.d.ts +20 -17
- package/dist/math.js +474 -57
- package/dist/overlays/ContextMenu.svelte +66 -40
- package/dist/overlays/DraggablePane.svelte +331 -154
- package/dist/overlays/DraggablePane.svelte.d.ts +2 -0
- package/dist/periodic-table/PeriodicTable.svelte +278 -145
- package/dist/periodic-table/PeriodicTableControls.svelte +178 -128
- package/dist/periodic-table/PropertySelect.svelte +25 -7
- package/dist/periodic-table/TableInset.svelte +8 -3
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +559 -267
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -2
- package/dist/phase-diagram/PhaseDiagramControls.svelte +131 -51
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +3 -2
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +126 -0
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +15 -0
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +160 -110
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +8 -1
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +217 -86
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte.d.ts +6 -3
- package/dist/phase-diagram/TdbInfoPanel.svelte +28 -4
- package/dist/phase-diagram/build-diagram.js +9 -9
- package/dist/phase-diagram/colors.js +1 -3
- package/dist/phase-diagram/index.d.ts +2 -0
- package/dist/phase-diagram/index.js +2 -0
- package/dist/phase-diagram/parse.js +10 -9
- package/dist/phase-diagram/svg-to-diagram.d.ts +2 -0
- package/dist/phase-diagram/svg-to-diagram.js +869 -0
- package/dist/phase-diagram/types.d.ts +10 -0
- package/dist/phase-diagram/utils.d.ts +8 -4
- package/dist/phase-diagram/utils.js +219 -74
- package/dist/plot/AxisLabel.svelte +51 -0
- package/dist/plot/AxisLabel.svelte.d.ts +16 -0
- package/dist/plot/BarPlot.svelte +1461 -768
- package/dist/plot/BarPlot.svelte.d.ts +3 -3
- package/dist/plot/BarPlotControls.svelte +33 -6
- package/dist/plot/BarPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ColorBar.svelte +533 -383
- package/dist/plot/ColorBar.svelte.d.ts +1 -1
- package/dist/plot/ColorScaleSelect.svelte +28 -7
- package/dist/plot/ElementScatter.svelte +38 -16
- package/dist/plot/FillArea.svelte +152 -92
- package/dist/plot/Histogram.svelte +1162 -709
- package/dist/plot/Histogram.svelte.d.ts +1 -1
- package/dist/plot/HistogramControls.svelte +81 -18
- package/dist/plot/HistogramControls.svelte.d.ts +6 -2
- package/dist/plot/InteractiveAxisLabel.svelte +34 -11
- package/dist/plot/InteractiveAxisLabel.svelte.d.ts +1 -1
- package/dist/plot/Line.svelte +63 -28
- package/dist/plot/PlotControls.svelte +221 -96
- package/dist/plot/PlotControls.svelte.d.ts +1 -1
- package/dist/plot/PlotLegend.svelte +174 -91
- package/dist/plot/PlotTooltip.svelte +45 -6
- package/dist/plot/PortalSelect.svelte +175 -146
- package/dist/plot/ReferenceLine.svelte +77 -22
- package/dist/plot/ReferenceLine.svelte.d.ts +1 -0
- package/dist/plot/ReferenceLine3D.svelte +132 -107
- package/dist/plot/ReferencePlane.svelte +146 -123
- package/dist/plot/ScatterPlot.svelte +1880 -1156
- package/dist/plot/ScatterPlot.svelte.d.ts +3 -3
- package/dist/plot/ScatterPlot3D.svelte +256 -131
- package/dist/plot/ScatterPlot3D.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlot3DControls.svelte +300 -297
- package/dist/plot/ScatterPlot3DControls.svelte.d.ts +2 -1
- package/dist/plot/ScatterPlot3DScene.svelte +608 -406
- package/dist/plot/ScatterPlot3DScene.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlotControls.svelte +150 -70
- package/dist/plot/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ScatterPoint.svelte +98 -26
- package/dist/plot/ScatterPoint.svelte.d.ts +1 -0
- package/dist/plot/SpacegroupBarPlot.svelte +142 -85
- package/dist/plot/Surface3D.svelte +159 -108
- package/dist/plot/ZeroLines.svelte +96 -0
- package/dist/plot/ZeroLines.svelte.d.ts +32 -0
- package/dist/plot/ZoomRect.svelte +23 -0
- package/dist/plot/ZoomRect.svelte.d.ts +8 -0
- package/dist/plot/axis-utils.d.ts +1 -1
- package/dist/plot/axis-utils.js +1 -3
- package/dist/plot/data-cleaning.js +12 -28
- package/dist/plot/data-transform.js +2 -1
- package/dist/plot/fill-utils.js +2 -0
- package/dist/plot/index.d.ts +6 -2
- package/dist/plot/index.js +6 -2
- package/dist/plot/interactions.d.ts +8 -10
- package/dist/plot/interactions.js +2 -3
- package/dist/plot/layout.d.ts +11 -2
- package/dist/plot/layout.js +44 -17
- package/dist/plot/reference-line.d.ts +5 -22
- package/dist/plot/reference-line.js +12 -84
- package/dist/plot/scales.js +24 -36
- package/dist/plot/types.d.ts +53 -40
- package/dist/plot/types.js +12 -7
- package/dist/plot/utils/label-placement.d.ts +32 -15
- package/dist/plot/utils/label-placement.js +227 -63
- package/dist/plot/utils/series-visibility.js +2 -3
- package/dist/plot/utils.d.ts +1 -0
- package/dist/plot/utils.js +14 -0
- package/dist/rdf/RdfPlot.svelte +173 -132
- package/dist/rdf/calc-rdf.js +4 -5
- package/dist/sanitize.d.ts +4 -0
- package/dist/sanitize.js +107 -0
- package/dist/settings.d.ts +21 -6
- package/dist/settings.js +63 -19
- package/dist/spectral/Bands.svelte +963 -412
- package/dist/spectral/Bands.svelte.d.ts +22 -2
- package/dist/spectral/BandsAndDos.svelte +90 -49
- package/dist/spectral/BrillouinBandsDos.svelte +151 -93
- package/dist/spectral/Dos.svelte +389 -258
- package/dist/spectral/helpers.d.ts +23 -1
- package/dist/spectral/helpers.js +119 -51
- package/dist/spectral/types.d.ts +2 -0
- package/dist/state.svelte.d.ts +1 -1
- package/dist/state.svelte.js +3 -2
- package/dist/structure/Arrow.svelte +59 -20
- package/dist/structure/AtomLegend.svelte +231 -129
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/Bond.svelte +73 -47
- package/dist/structure/CanvasTooltip.svelte +10 -2
- package/dist/structure/CellSelect.svelte +148 -51
- package/dist/structure/Cylinder.svelte +33 -17
- package/dist/structure/Lattice.svelte +88 -33
- package/dist/structure/Structure.svelte +1077 -821
- package/dist/structure/Structure.svelte.d.ts +1 -1
- package/dist/structure/StructureControls.svelte +373 -139
- package/dist/structure/StructureControls.svelte.d.ts +1 -1
- package/dist/structure/StructureExportPane.svelte +124 -89
- package/dist/structure/StructureExportPane.svelte.d.ts +1 -1
- package/dist/structure/StructureInfoPane.svelte +304 -231
- package/dist/structure/StructureScene.svelte +919 -445
- package/dist/structure/StructureScene.svelte.d.ts +16 -7
- package/dist/structure/atom-properties.d.ts +6 -2
- package/dist/structure/atom-properties.js +42 -29
- package/dist/structure/bonding.js +6 -7
- package/dist/structure/export.js +22 -34
- package/dist/structure/ferrox-wasm-types.d.ts +3 -2
- package/dist/structure/ferrox-wasm-types.js +0 -3
- package/dist/structure/ferrox-wasm.d.ts +3 -2
- package/dist/structure/ferrox-wasm.js +2 -3
- package/dist/structure/index.d.ts +16 -0
- package/dist/structure/index.js +88 -6
- package/dist/structure/measure.d.ts +2 -2
- package/dist/structure/measure.js +4 -44
- package/dist/structure/parse.js +130 -155
- package/dist/structure/partial-occupancy.d.ts +25 -0
- package/dist/structure/partial-occupancy.js +99 -0
- package/dist/structure/pbc.d.ts +1 -0
- package/dist/structure/pbc.js +16 -6
- package/dist/structure/supercell.d.ts +2 -2
- package/dist/structure/supercell.js +12 -22
- package/dist/structure/validation.js +5 -3
- package/dist/symmetry/SymmetryStats.svelte +94 -37
- package/dist/symmetry/WyckoffTable.svelte +42 -14
- package/dist/symmetry/cell-transform.js +5 -3
- package/dist/symmetry/index.d.ts +7 -4
- package/dist/symmetry/index.js +87 -21
- package/dist/symmetry/spacegroups.js +148 -148
- package/dist/table/HeatmapTable.svelte +1112 -516
- package/dist/table/HeatmapTable.svelte.d.ts +12 -1
- package/dist/table/ToggleMenu.svelte +125 -90
- package/dist/table/index.d.ts +2 -0
- package/dist/table/index.js +2 -4
- package/dist/theme/ThemeControl.svelte +21 -12
- package/dist/time.js +4 -1
- package/dist/tooltip/TooltipContent.svelte +33 -8
- package/dist/trajectory/Trajectory.svelte +889 -687
- package/dist/trajectory/TrajectoryError.svelte +14 -3
- package/dist/trajectory/TrajectoryExportPane.svelte +148 -90
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +1 -1
- package/dist/trajectory/TrajectoryInfoPane.svelte +272 -143
- package/dist/trajectory/constants.d.ts +6 -0
- package/dist/trajectory/constants.js +7 -0
- package/dist/trajectory/extract.js +13 -31
- package/dist/trajectory/format-detect.d.ts +9 -0
- package/dist/trajectory/format-detect.js +76 -0
- package/dist/trajectory/frame-reader.d.ts +17 -0
- package/dist/trajectory/frame-reader.js +332 -0
- package/dist/trajectory/helpers.d.ts +14 -0
- package/dist/trajectory/helpers.js +172 -0
- package/dist/trajectory/index.d.ts +1 -0
- package/dist/trajectory/index.js +23 -14
- package/dist/trajectory/parse/ase.d.ts +2 -0
- package/dist/trajectory/parse/ase.js +77 -0
- package/dist/trajectory/parse/hdf5.d.ts +2 -0
- package/dist/trajectory/parse/hdf5.js +129 -0
- package/dist/trajectory/parse/index.d.ts +12 -0
- package/dist/trajectory/parse/index.js +299 -0
- package/dist/trajectory/parse/lammps.d.ts +5 -0
- package/dist/trajectory/parse/lammps.js +179 -0
- package/dist/trajectory/parse/vasp.d.ts +2 -0
- package/dist/trajectory/parse/vasp.js +68 -0
- package/dist/trajectory/parse/xyz.d.ts +2 -0
- package/dist/trajectory/parse/xyz.js +110 -0
- package/dist/trajectory/plotting.js +13 -8
- package/dist/trajectory/types.d.ts +11 -0
- package/dist/trajectory/types.js +1 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +17 -0
- package/dist/xrd/XrdPlot.svelte +337 -245
- package/dist/xrd/broadening.js +14 -9
- package/dist/xrd/calc-xrd.js +12 -19
- package/dist/xrd/parse.d.ts +1 -1
- package/dist/xrd/parse.js +17 -17
- package/package.json +103 -101
- package/readme.md +4 -4
- package/dist/trajectory/parse.d.ts +0 -42
- package/dist/trajectory/parse.js +0 -1267
- /package/dist/element/{data.json.d.ts → data.json.gz.d.ts} +0 -0
- /package/dist/theme/{themes.js → themes.mjs} +0 -0
|
@@ -1,112 +1,169 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { format_num, format_value } from '../labels'
|
|
3
|
+
import type { BarHandlerProps, BarSeries, TickConfig } from './'
|
|
4
|
+
import { BarPlot } from './'
|
|
5
|
+
import type { CrystalSystem } from '../symmetry'
|
|
6
|
+
import * as symmetry from '../symmetry'
|
|
7
|
+
import * as spg from '../symmetry/spacegroups'
|
|
8
|
+
import type { ComponentProps } from 'svelte'
|
|
9
|
+
import { SvelteMap } from 'svelte/reactivity'
|
|
10
|
+
|
|
11
|
+
// Merge tick config with default rotation, preserving user overrides
|
|
12
|
+
const with_rotation = (
|
|
13
|
+
tick: TickConfig | undefined,
|
|
14
|
+
default_rot: number,
|
|
15
|
+
): TickConfig => ({
|
|
8
16
|
...tick,
|
|
9
17
|
label: { ...tick?.label, rotation: tick?.label?.rotation ?? default_rot },
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
const MAX_SPACEGROUP = 230
|
|
21
|
+
let {
|
|
22
|
+
data,
|
|
23
|
+
show_counts = true,
|
|
24
|
+
orientation = `vertical`,
|
|
25
|
+
x_axis = {},
|
|
26
|
+
y_axis = {},
|
|
27
|
+
...rest
|
|
28
|
+
}: ComponentProps<typeof BarPlot> & {
|
|
29
|
+
data: (number | string)[]
|
|
30
|
+
show_counts?: boolean
|
|
31
|
+
} = $props()
|
|
32
|
+
|
|
33
|
+
// Normalize input data to space group numbers
|
|
34
|
+
const normalized_data = $derived(
|
|
35
|
+
data.map(spg.normalize_spacegroup).filter((sg): sg is number => sg !== null),
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
// Compute histogram of space group numbers
|
|
39
|
+
const histogram = $derived.by(() => {
|
|
40
|
+
const hist = new SvelteMap<number, number>()
|
|
41
|
+
|
|
18
42
|
// Count occurrences
|
|
19
43
|
for (const sg of normalized_data) {
|
|
20
|
-
|
|
44
|
+
hist.set(sg, (hist.get(sg) ?? 0) + 1)
|
|
21
45
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
46
|
+
|
|
47
|
+
return hist
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
// Group counts by crystal system
|
|
51
|
+
const crystal_system_stats = $derived.by(() => {
|
|
52
|
+
const stats = new SvelteMap<
|
|
53
|
+
CrystalSystem,
|
|
54
|
+
{ count: number; spacegroups: number[] }
|
|
55
|
+
>()
|
|
56
|
+
|
|
27
57
|
for (const system of symmetry.CRYSTAL_SYSTEMS) {
|
|
28
|
-
|
|
58
|
+
stats.set(system, { count: 0, spacegroups: [] })
|
|
29
59
|
}
|
|
60
|
+
|
|
30
61
|
for (const [sg, count] of histogram) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
62
|
+
const system = spg.spacegroup_to_crystal_sys(sg)
|
|
63
|
+
if (!system) continue
|
|
64
|
+
const stat = stats.get(system)
|
|
65
|
+
if (!stat) continue
|
|
66
|
+
stat.count += count
|
|
67
|
+
stat.spacegroups.push(sg)
|
|
37
68
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
//
|
|
43
|
-
const
|
|
44
|
-
|
|
69
|
+
|
|
70
|
+
return stats
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
// Create sorted list of space groups for x-axis
|
|
74
|
+
const sorted_spacegroups = $derived(
|
|
75
|
+
Array.from(histogram.keys()).sort((a, b) => a - b),
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
// Smart tick selection: thin out ticks for dense data
|
|
79
|
+
const x_axis_ticks = $derived.by(() => {
|
|
80
|
+
const non_zero_count = sorted_spacegroups.filter(
|
|
81
|
+
(sg) => (histogram.get(sg) ?? 0) > 0,
|
|
82
|
+
).length
|
|
83
|
+
|
|
45
84
|
// If data is dense (>40 space groups with data), show only multiples of 5
|
|
46
85
|
return non_zero_count > 40
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
86
|
+
? sorted_spacegroups.filter((sg) => sg % 5 === 0)
|
|
87
|
+
: sorted_spacegroups
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
// Build BarSeries - one series per crystal system for proper coloring
|
|
91
|
+
const bar_series = $derived.by<BarSeries[]>(() => {
|
|
92
|
+
const series_by_system = new SvelteMap<
|
|
93
|
+
CrystalSystem,
|
|
94
|
+
{ x: number[]; y: number[] }
|
|
95
|
+
>()
|
|
96
|
+
|
|
53
97
|
// Group data by crystal system
|
|
54
98
|
for (const sg of sorted_spacegroups) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
series.x.push(sg);
|
|
63
|
-
series.y.push(histogram.get(sg) ?? 0);
|
|
99
|
+
const system = spg.spacegroup_to_crystal_sys(sg)
|
|
100
|
+
if (system) {
|
|
101
|
+
let series = series_by_system.get(system)
|
|
102
|
+
if (!series) {
|
|
103
|
+
series = { x: [], y: [] }
|
|
104
|
+
series_by_system.set(system, series)
|
|
64
105
|
}
|
|
106
|
+
series.x.push(sg)
|
|
107
|
+
series.y.push(histogram.get(sg) ?? 0)
|
|
108
|
+
}
|
|
65
109
|
}
|
|
110
|
+
|
|
66
111
|
// Convert to BarSeries array, maintaining order of crystal systems
|
|
67
|
-
const result = []
|
|
112
|
+
const result: BarSeries[] = []
|
|
68
113
|
for (const system of symmetry.CRYSTAL_SYSTEMS) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
114
|
+
const data = series_by_system.get(system)
|
|
115
|
+
if (data) {
|
|
116
|
+
const { x, y } = data
|
|
117
|
+
const color = symmetry.CRYSTAL_SYSTEM_COLORS[system]
|
|
118
|
+
result.push({ x, y, color, label: system, bar_width: 0.9, visible: true })
|
|
119
|
+
}
|
|
75
120
|
}
|
|
76
|
-
return result
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
121
|
+
return result
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
// Always show full space group range (1-230)
|
|
125
|
+
const x_range: [number, number] = [0.5, MAX_SPACEGROUP + 0.5]
|
|
126
|
+
|
|
127
|
+
// Calculate crystal system region boundaries using full theoretical ranges
|
|
128
|
+
const crystal_system_regions = $derived.by(() => {
|
|
129
|
+
const [range_min, range_max] = x_range
|
|
130
|
+
|
|
83
131
|
return symmetry.CRYSTAL_SYSTEMS.map((system) => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}).filter(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
132
|
+
const [sg_start, sg_end] = symmetry.CRYSTAL_SYSTEM_RANGES[system]
|
|
133
|
+
const stats = crystal_system_stats.get(system)
|
|
134
|
+
const count = stats?.count ?? 0
|
|
135
|
+
const color = symmetry.CRYSTAL_SYSTEM_COLORS[system]
|
|
136
|
+
return { system, sg_start, sg_end, count, color }
|
|
137
|
+
}).filter(
|
|
138
|
+
(region) => region.sg_end >= range_min && region.sg_start <= range_max, // Only visible systems
|
|
139
|
+
)
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
const total_count = $derived(normalized_data.length)
|
|
143
|
+
|
|
144
|
+
// Build axis configurations based on orientation
|
|
145
|
+
const x_axis_config = $derived(
|
|
146
|
+
orientation === `horizontal` ? { ...x_axis, label: x_axis.label ?? `Counts` } : {
|
|
147
|
+
...x_axis,
|
|
148
|
+
label: x_axis.label ?? `International Spacegroup Number`,
|
|
149
|
+
range: x_range,
|
|
150
|
+
ticks: x_axis_ticks,
|
|
151
|
+
tick: with_rotation(x_axis.tick, 90), // Rotate ticks 90° to avoid overlap
|
|
152
|
+
label_shift: { x: 0, y: 20, ...x_axis.label_shift }, // Move label down for rotated ticks
|
|
153
|
+
},
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
const y_axis_config = $derived(
|
|
157
|
+
orientation === `horizontal`
|
|
158
|
+
? {
|
|
103
159
|
...y_axis,
|
|
104
160
|
label: y_axis.label ?? `International Spacegroup Number`,
|
|
105
161
|
range: x_range,
|
|
106
162
|
ticks: x_axis_ticks,
|
|
107
163
|
tick: with_rotation(y_axis.tick, 0),
|
|
108
|
-
|
|
109
|
-
|
|
164
|
+
}
|
|
165
|
+
: { ...y_axis, label: y_axis.label ?? `Counts` },
|
|
166
|
+
)
|
|
110
167
|
</script>
|
|
111
168
|
|
|
112
169
|
{#snippet tooltip(info: BarHandlerProps)}
|
|
@@ -1,137 +1,188 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Surface3DConfig } from './types'
|
|
3
|
+
import { T } from '@threlte/core'
|
|
4
|
+
import * as THREE from 'three'
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
config,
|
|
8
|
+
x_range = [0, 1],
|
|
9
|
+
y_range = [0, 1],
|
|
10
|
+
z_range = [0, 1],
|
|
11
|
+
scene_x = 10,
|
|
12
|
+
scene_y = 10,
|
|
13
|
+
scene_z = 5,
|
|
14
|
+
}: {
|
|
15
|
+
config: Surface3DConfig
|
|
16
|
+
x_range?: [number, number]
|
|
17
|
+
y_range?: [number, number]
|
|
18
|
+
z_range?: [number, number]
|
|
19
|
+
scene_x?: number
|
|
20
|
+
scene_y?: number
|
|
21
|
+
scene_z?: number
|
|
22
|
+
} = $props()
|
|
23
|
+
|
|
24
|
+
// Normalize value to scene coordinates (centered around 0)
|
|
25
|
+
function normalize(
|
|
26
|
+
value: number,
|
|
27
|
+
[min_val, max_val]: [number, number],
|
|
28
|
+
scene_size: number,
|
|
29
|
+
): number {
|
|
30
|
+
return ((value - min_val) / (max_val - min_val || 1) - 0.5) * scene_size
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Parse color to THREE.Color with fallback
|
|
34
|
+
function parse_color(color: string): THREE.Color {
|
|
10
35
|
try {
|
|
11
|
-
|
|
36
|
+
return new THREE.Color(color)
|
|
37
|
+
} catch {
|
|
38
|
+
return new THREE.Color(0x4488ff)
|
|
12
39
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (config.
|
|
22
|
-
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Calculate vertex color based on config
|
|
43
|
+
function get_vertex_color(
|
|
44
|
+
x_val: number,
|
|
45
|
+
y_val: number,
|
|
46
|
+
z_val: number,
|
|
47
|
+
): THREE.Color {
|
|
48
|
+
if (config.color_fn) return parse_color(config.color_fn(x_val, y_val, z_val))
|
|
49
|
+
if (config.color) return parse_color(config.color)
|
|
23
50
|
// Default: color by z value (blue to red gradient)
|
|
24
|
-
const z_norm = (z_val - z_range[0]) / (z_range[1] - z_range[0] || 1)
|
|
25
|
-
return new THREE.Color().setHSL(0.66 - z_norm * 0.66, 0.8, 0.5)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
51
|
+
const z_norm = (z_val - z_range[0]) / (z_range[1] - z_range[0] || 1)
|
|
52
|
+
return new THREE.Color().setHSL(0.66 - z_norm * 0.66, 0.8, 0.5)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Add vertex position (with Y/Z swap for Three.js) and color to arrays
|
|
56
|
+
function add_vertex(
|
|
57
|
+
positions: number[],
|
|
58
|
+
colors: number[],
|
|
59
|
+
x_val: number,
|
|
60
|
+
y_val: number,
|
|
61
|
+
z_val: number,
|
|
62
|
+
): void {
|
|
63
|
+
positions.push(
|
|
64
|
+
normalize(x_val, x_range, scene_x),
|
|
65
|
+
normalize(z_val, z_range, scene_z), // user Z → Three.js Y (vertical)
|
|
66
|
+
normalize(y_val, y_range, scene_y), // user Y → Three.js Z (depth)
|
|
67
|
+
)
|
|
68
|
+
const color = get_vertex_color(x_val, y_val, z_val)
|
|
69
|
+
colors.push(color.r, color.g, color.b)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Build geometry from positions/colors arrays with optional grid indices
|
|
73
|
+
function build_geometry(
|
|
74
|
+
positions: number[],
|
|
75
|
+
colors: number[],
|
|
76
|
+
res_a?: number,
|
|
77
|
+
res_b?: number,
|
|
78
|
+
triangles?: number[][],
|
|
79
|
+
): THREE.BufferGeometry {
|
|
80
|
+
const geom = new THREE.BufferGeometry()
|
|
81
|
+
geom.setAttribute(`position`, new THREE.Float32BufferAttribute(positions, 3))
|
|
82
|
+
geom.setAttribute(`color`, new THREE.Float32BufferAttribute(colors, 3))
|
|
39
83
|
// Set indices: either from explicit triangles or generate grid
|
|
40
84
|
if (triangles?.length) {
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
for (let
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
indices.push(tl, tl + res_a, tl + 1, tl + 1, tl + res_a, tl + res_a + 1);
|
|
49
|
-
}
|
|
85
|
+
geom.setIndex(triangles.flat())
|
|
86
|
+
} else if (res_a && res_b && res_a >= 2 && res_b >= 2) {
|
|
87
|
+
const indices: number[] = []
|
|
88
|
+
for (let ib = 0; ib < res_b - 1; ib++) {
|
|
89
|
+
for (let ia = 0; ia < res_a - 1; ia++) {
|
|
90
|
+
const tl = ib * res_a + ia
|
|
91
|
+
indices.push(tl, tl + res_a, tl + 1, tl + 1, tl + res_a, tl + res_a + 1)
|
|
50
92
|
}
|
|
51
|
-
|
|
93
|
+
}
|
|
94
|
+
geom.setIndex(indices)
|
|
52
95
|
}
|
|
53
|
-
geom.computeVertexNormals()
|
|
54
|
-
return geom
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
96
|
+
geom.computeVertexNormals()
|
|
97
|
+
return geom
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Parse resolution config into [res_a, res_b]
|
|
101
|
+
function get_resolution(): [number, number] {
|
|
58
102
|
return Array.isArray(config.resolution)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
const
|
|
103
|
+
? config.resolution
|
|
104
|
+
: [config.resolution ?? 20, config.resolution ?? 20]
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function create_geometry(): THREE.BufferGeometry | null {
|
|
108
|
+
const [res_a, res_b] = get_resolution()
|
|
109
|
+
const positions: number[] = []
|
|
110
|
+
const colors: number[] = []
|
|
111
|
+
|
|
66
112
|
if (config.type === `grid` && config.z_fn) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
for (let
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
add_vertex(positions, colors, x_val, y_val, config.z_fn(x_val, y_val));
|
|
78
|
-
}
|
|
113
|
+
if (res_a < 2 || res_b < 2) return new THREE.BufferGeometry()
|
|
114
|
+
const [x0, x1] = config.x_range ?? x_range
|
|
115
|
+
const [y0, y1] = config.y_range ?? y_range
|
|
116
|
+
const x_step = (x1 - x0) / (res_a - 1)
|
|
117
|
+
const y_step = (y1 - y0) / (res_b - 1)
|
|
118
|
+
for (let ib = 0; ib < res_b; ib++) {
|
|
119
|
+
for (let ia = 0; ia < res_a; ia++) {
|
|
120
|
+
const x_val = x0 + ia * x_step
|
|
121
|
+
const y_val = y0 + ib * y_step
|
|
122
|
+
add_vertex(positions, colors, x_val, y_val, config.z_fn(x_val, y_val))
|
|
79
123
|
}
|
|
80
|
-
|
|
124
|
+
}
|
|
125
|
+
return build_geometry(positions, colors, res_a, res_b)
|
|
81
126
|
}
|
|
127
|
+
|
|
82
128
|
if (config.type === `parametric` && config.parametric_fn) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
for (let
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
add_vertex(positions, colors, pt.x, pt.y, pt.z);
|
|
93
|
-
}
|
|
129
|
+
if (res_a < 2 || res_b < 2) return new THREE.BufferGeometry()
|
|
130
|
+
const [u0, u1] = config.u_range ?? [0, 1]
|
|
131
|
+
const [v0, v1] = config.v_range ?? [0, 1]
|
|
132
|
+
const u_step = (u1 - u0) / (res_a - 1)
|
|
133
|
+
const v_step = (v1 - v0) / (res_b - 1)
|
|
134
|
+
for (let ib = 0; ib < res_b; ib++) {
|
|
135
|
+
for (let ia = 0; ia < res_a; ia++) {
|
|
136
|
+
const pt = config.parametric_fn(u0 + ia * u_step, v0 + ib * v_step)
|
|
137
|
+
add_vertex(positions, colors, pt.x, pt.y, pt.z)
|
|
94
138
|
}
|
|
95
|
-
|
|
139
|
+
}
|
|
140
|
+
return build_geometry(positions, colors, res_a, res_b)
|
|
96
141
|
}
|
|
142
|
+
|
|
97
143
|
if (config.type === `triangulated` && config.points?.length) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
144
|
+
for (const pt of config.points) {
|
|
145
|
+
add_vertex(positions, colors, pt.x, pt.y, pt.z)
|
|
146
|
+
}
|
|
147
|
+
return build_geometry(positions, colors, undefined, undefined, config.triangles)
|
|
102
148
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
$
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
149
|
+
|
|
150
|
+
return null
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Geometry with proper disposal on change/unmount
|
|
154
|
+
let geometry: THREE.BufferGeometry | null = $state(null)
|
|
155
|
+
let wireframe_geometry: THREE.WireframeGeometry | null = $state(null)
|
|
156
|
+
|
|
157
|
+
$effect(() => {
|
|
158
|
+
const new_geom = create_geometry()
|
|
159
|
+
const new_wireframe = new_geom ? new THREE.WireframeGeometry(new_geom) : null
|
|
160
|
+
geometry = new_geom
|
|
161
|
+
wireframe_geometry = new_wireframe
|
|
113
162
|
return () => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
let
|
|
163
|
+
new_geom?.dispose()
|
|
164
|
+
new_wireframe?.dispose()
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
// Material properties
|
|
169
|
+
let is_transparent = $derived((config.opacity ?? 1) < 1)
|
|
170
|
+
let material_props = $derived({
|
|
121
171
|
transparent: is_transparent,
|
|
122
172
|
opacity: config.opacity ?? 1,
|
|
123
173
|
side: (config.double_sided ?? is_transparent)
|
|
124
|
-
|
|
125
|
-
|
|
174
|
+
? THREE.DoubleSide
|
|
175
|
+
: THREE.FrontSide,
|
|
126
176
|
vertexColors: true,
|
|
127
177
|
depthWrite: true,
|
|
128
|
-
})
|
|
129
|
-
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
let wireframe_props = $derived({
|
|
130
181
|
color: config.wireframe_color ?? `#333`,
|
|
131
182
|
linewidth: config.wireframe_width ?? 1,
|
|
132
183
|
transparent: true,
|
|
133
184
|
opacity: 0.5,
|
|
134
|
-
})
|
|
185
|
+
})
|
|
135
186
|
</script>
|
|
136
187
|
|
|
137
188
|
{#if geometry}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Vec2 } from '../math'
|
|
3
|
+
import { get_scale_type_name, type ScaleType, type Sides } from './'
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
display,
|
|
7
|
+
x_scale_fn,
|
|
8
|
+
x2_scale_fn,
|
|
9
|
+
y_scale_fn,
|
|
10
|
+
y2_scale_fn,
|
|
11
|
+
x_range,
|
|
12
|
+
x2_range,
|
|
13
|
+
y_range,
|
|
14
|
+
y2_range,
|
|
15
|
+
x_scale_type,
|
|
16
|
+
x2_scale_type,
|
|
17
|
+
y_scale_type,
|
|
18
|
+
y2_scale_type,
|
|
19
|
+
x_is_time = false,
|
|
20
|
+
x2_is_time = false,
|
|
21
|
+
has_x2 = false,
|
|
22
|
+
has_y2 = false,
|
|
23
|
+
width,
|
|
24
|
+
height,
|
|
25
|
+
pad,
|
|
26
|
+
}: {
|
|
27
|
+
display: {
|
|
28
|
+
x_zero_line?: boolean
|
|
29
|
+
x2_zero_line?: boolean
|
|
30
|
+
y_zero_line?: boolean
|
|
31
|
+
y2_zero_line?: boolean
|
|
32
|
+
}
|
|
33
|
+
x_scale_fn: (val: number) => number
|
|
34
|
+
x2_scale_fn?: (val: number) => number
|
|
35
|
+
y_scale_fn: (val: number) => number
|
|
36
|
+
y2_scale_fn?: (val: number) => number
|
|
37
|
+
x_range: Vec2
|
|
38
|
+
x2_range?: Vec2
|
|
39
|
+
y_range: Vec2
|
|
40
|
+
y2_range?: Vec2
|
|
41
|
+
x_scale_type?: ScaleType
|
|
42
|
+
x2_scale_type?: ScaleType
|
|
43
|
+
y_scale_type?: ScaleType
|
|
44
|
+
y2_scale_type?: ScaleType
|
|
45
|
+
x_is_time?: boolean
|
|
46
|
+
x2_is_time?: boolean
|
|
47
|
+
has_x2?: boolean
|
|
48
|
+
has_y2?: boolean
|
|
49
|
+
width: number
|
|
50
|
+
height: number
|
|
51
|
+
pad: Required<Sides>
|
|
52
|
+
} = $props()
|
|
53
|
+
|
|
54
|
+
const spans_zero = (range: Vec2): boolean =>
|
|
55
|
+
Math.min(range[0], range[1]) <= 0 && Math.max(range[0], range[1]) >= 0
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
{#if display.x_zero_line && get_scale_type_name(x_scale_type) !== `log` &&
|
|
59
|
+
!x_is_time && spans_zero(x_range)}
|
|
60
|
+
{@const zero_x = x_scale_fn(0)}
|
|
61
|
+
{#if isFinite(zero_x)}
|
|
62
|
+
<line class="zero-line" x1={zero_x} x2={zero_x} y1={pad.t} y2={height - pad.b} />
|
|
63
|
+
{/if}
|
|
64
|
+
{/if}
|
|
65
|
+
|
|
66
|
+
{#if display.x2_zero_line && has_x2 && x2_scale_fn && x2_range &&
|
|
67
|
+
get_scale_type_name(x2_scale_type) !== `log` && !x2_is_time && spans_zero(x2_range)}
|
|
68
|
+
{@const zero_x2 = x2_scale_fn(0)}
|
|
69
|
+
{#if isFinite(zero_x2)}
|
|
70
|
+
<line class="zero-line" x1={zero_x2} x2={zero_x2} y1={pad.t} y2={height - pad.b} />
|
|
71
|
+
{/if}
|
|
72
|
+
{/if}
|
|
73
|
+
|
|
74
|
+
{#if display.y_zero_line && get_scale_type_name(y_scale_type) !== `log` &&
|
|
75
|
+
spans_zero(y_range)}
|
|
76
|
+
{@const zero_y = y_scale_fn(0)}
|
|
77
|
+
{#if isFinite(zero_y)}
|
|
78
|
+
<line class="zero-line" x1={pad.l} x2={width - pad.r} y1={zero_y} y2={zero_y} />
|
|
79
|
+
{/if}
|
|
80
|
+
{/if}
|
|
81
|
+
|
|
82
|
+
{#if display.y2_zero_line && has_y2 && y2_scale_fn && y2_range &&
|
|
83
|
+
get_scale_type_name(y2_scale_type) !== `log` && spans_zero(y2_range)}
|
|
84
|
+
{@const zero_y2 = y2_scale_fn(0)}
|
|
85
|
+
{#if isFinite(zero_y2)}
|
|
86
|
+
<line class="zero-line" x1={pad.l} x2={width - pad.r} y1={zero_y2} y2={zero_y2} />
|
|
87
|
+
{/if}
|
|
88
|
+
{/if}
|
|
89
|
+
|
|
90
|
+
<style>
|
|
91
|
+
.zero-line {
|
|
92
|
+
stroke: var(--plot-zero-line-color, light-dark(black, white));
|
|
93
|
+
stroke-width: var(--plot-zero-line-width, 1);
|
|
94
|
+
opacity: var(--plot-zero-line-opacity, 0.3);
|
|
95
|
+
}
|
|
96
|
+
</style>
|