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
|
@@ -51,7 +51,7 @@ declare function $$render<Metadata extends Record<string, unknown> = Record<stri
|
|
|
51
51
|
height?: number;
|
|
52
52
|
};
|
|
53
53
|
exports: {};
|
|
54
|
-
bindings: "
|
|
54
|
+
bindings: "camera" | "hovered_point" | "scene" | "orbit_controls";
|
|
55
55
|
slots: {};
|
|
56
56
|
events: {};
|
|
57
57
|
};
|
|
@@ -59,7 +59,7 @@ declare class __sveltets_Render<Metadata extends Record<string, unknown> = Recor
|
|
|
59
59
|
props(): ReturnType<typeof $$render<Metadata>>['props'];
|
|
60
60
|
events(): ReturnType<typeof $$render<Metadata>>['events'];
|
|
61
61
|
slots(): ReturnType<typeof $$render<Metadata>>['slots'];
|
|
62
|
-
bindings(): "
|
|
62
|
+
bindings(): "camera" | "hovered_point" | "scene" | "orbit_controls";
|
|
63
63
|
exports(): {};
|
|
64
64
|
}
|
|
65
65
|
interface $$IsomorphicComponent {
|
|
@@ -1,46 +1,116 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
on_touch?.(key);
|
|
17
|
-
};
|
|
18
|
-
</script>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { SettingsSection } from '../layout'
|
|
3
|
+
import { PlotControls } from './'
|
|
4
|
+
import type {
|
|
5
|
+
DataSeries,
|
|
6
|
+
PlotConfig,
|
|
7
|
+
PlotControlsProps,
|
|
8
|
+
StyleOverrides,
|
|
9
|
+
} from './types'
|
|
10
|
+
import { DEFAULTS } from '../settings'
|
|
11
|
+
import type { Snippet } from 'svelte'
|
|
12
|
+
import { tooltip } from 'svelte-multiselect/attachments'
|
|
13
|
+
|
|
14
|
+
// Unique ID prefix to avoid conflicts when multiple instances on same page
|
|
15
|
+
const uid = crypto.randomUUID().slice(0, 8)
|
|
19
16
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
17
|
+
let {
|
|
18
|
+
series = [],
|
|
19
|
+
x_axis = $bindable({}),
|
|
20
|
+
x2_axis = $bindable({}),
|
|
21
|
+
y_axis = $bindable({}),
|
|
22
|
+
y2_axis = $bindable({}),
|
|
23
|
+
display = $bindable({}),
|
|
24
|
+
styles = $bindable({}),
|
|
25
|
+
selected_series_idx = $bindable(0),
|
|
26
|
+
on_touch,
|
|
27
|
+
children,
|
|
28
|
+
...rest
|
|
29
|
+
}: Omit<PlotControlsProps, `children` | `post_children`> & {
|
|
30
|
+
series?: readonly DataSeries[]
|
|
31
|
+
styles?: StyleOverrides
|
|
32
|
+
selected_series_idx?: number
|
|
33
|
+
on_touch?: (key: string) => void
|
|
34
|
+
children?: Snippet<
|
|
35
|
+
[{ styles: StyleOverrides; selected_series_idx: number } & Required<PlotConfig>]
|
|
33
36
|
>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
} = $props()
|
|
38
|
+
|
|
39
|
+
let non_null_series = $derived(series.filter((srs) => srs != null))
|
|
40
|
+
let visible_series = $derived(
|
|
41
|
+
non_null_series.filter((srs) => (srs.visible ?? true)),
|
|
42
|
+
)
|
|
43
|
+
let has_multiple_series = $derived(non_null_series.length > 1)
|
|
44
|
+
|
|
45
|
+
// Derive what marker types are present, and whether color/size are data-driven
|
|
46
|
+
const markers_include = (mode: string) =>
|
|
47
|
+
visible_series.some((srs) => (srs?.markers ?? `line+points`).includes(mode))
|
|
48
|
+
let has_any_lines = $derived(markers_include(`line`))
|
|
49
|
+
let has_any_points = $derived(markers_include(`points`))
|
|
50
|
+
let has_color_data = $derived(
|
|
51
|
+
visible_series.some((srs) => srs?.color_values?.some((val) => val != null)),
|
|
52
|
+
)
|
|
53
|
+
let has_size_data = $derived(
|
|
54
|
+
visible_series.some((srs) => srs?.size_values?.some((val) => val != null)),
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
$effect(() => { // Initialize show_points/show_lines from defaults
|
|
58
|
+
styles.show_points ??= DEFAULTS.scatter.show_points
|
|
59
|
+
styles.show_lines ??= DEFAULTS.scatter.show_lines
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
const touch = ({ target }: Event) => {
|
|
63
|
+
const key = (target as Element)?.closest(`[data-key]`)?.getAttribute(`data-key`)
|
|
64
|
+
if (key) on_touch?.(key)
|
|
65
|
+
}
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<PlotControls
|
|
69
|
+
bind:x_axis
|
|
70
|
+
bind:x2_axis
|
|
71
|
+
bind:y_axis
|
|
72
|
+
bind:y2_axis
|
|
73
|
+
bind:display
|
|
74
|
+
show_controls
|
|
75
|
+
{...rest}
|
|
76
|
+
>
|
|
77
|
+
{@render children?.({
|
|
78
|
+
x_axis,
|
|
79
|
+
x2_axis,
|
|
80
|
+
y_axis,
|
|
81
|
+
y2_axis,
|
|
82
|
+
display,
|
|
83
|
+
styles,
|
|
84
|
+
selected_series_idx,
|
|
85
|
+
})}
|
|
86
|
+
{#if has_any_points || has_any_lines}
|
|
87
|
+
<SettingsSection
|
|
88
|
+
title="Markers"
|
|
89
|
+
current_values={{ show_points: styles.show_points, show_lines: styles.show_lines }}
|
|
90
|
+
on_reset={() => {
|
|
91
|
+
styles.show_points = DEFAULTS.scatter.show_points
|
|
92
|
+
styles.show_lines = DEFAULTS.scatter.show_lines
|
|
93
|
+
}}
|
|
94
|
+
style="display: flex; flex-wrap: wrap; gap: 1ex"
|
|
40
95
|
>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
96
|
+
{#if has_any_points}
|
|
97
|
+
<label
|
|
98
|
+
{@attach tooltip({ content: `Toggle visibility of data points in the scatter plot` })}
|
|
99
|
+
>
|
|
100
|
+
<input type="checkbox" bind:checked={styles.show_points} /> Show points
|
|
101
|
+
</label>
|
|
102
|
+
{/if}
|
|
103
|
+
{#if has_any_lines}
|
|
104
|
+
<label
|
|
105
|
+
{@attach tooltip({
|
|
106
|
+
content: `Toggle visibility of connecting lines between data points`,
|
|
107
|
+
})}
|
|
108
|
+
>
|
|
109
|
+
<input type="checkbox" bind:checked={styles.show_lines} /> Show lines
|
|
110
|
+
</label>
|
|
111
|
+
{/if}
|
|
112
|
+
</SettingsSection>
|
|
113
|
+
{/if}
|
|
44
114
|
|
|
45
115
|
{#snippet post_children()}
|
|
46
116
|
<!-- Series Selection (for multi-series style controls) -->
|
|
@@ -59,8 +129,8 @@ const touch = ({ target }) => {
|
|
|
59
129
|
</div>
|
|
60
130
|
{/if}
|
|
61
131
|
|
|
62
|
-
<!-- Point Style Controls -->
|
|
63
|
-
{#if styles.show_points}
|
|
132
|
+
<!-- Point Style Controls: only when points exist and are visible -->
|
|
133
|
+
{#if has_any_points && styles.show_points}
|
|
64
134
|
<SettingsSection
|
|
65
135
|
title="Point Style"
|
|
66
136
|
current_values={styles.point ?? {}}
|
|
@@ -71,28 +141,36 @@ const touch = ({ target }) => {
|
|
|
71
141
|
oninput={touch}
|
|
72
142
|
>
|
|
73
143
|
{#if styles.point}
|
|
74
|
-
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
144
|
+
{#if !has_size_data}
|
|
145
|
+
<div class="pane-row" data-key="point.size">
|
|
146
|
+
<label for="{uid}-point-size">Size:</label>
|
|
147
|
+
<input
|
|
148
|
+
id="{uid}-point-size"
|
|
149
|
+
type="range"
|
|
150
|
+
min="1"
|
|
151
|
+
max="20"
|
|
152
|
+
step="0.5"
|
|
153
|
+
bind:value={styles.point.size}
|
|
154
|
+
/>
|
|
155
|
+
<input
|
|
156
|
+
type="number"
|
|
157
|
+
min="1"
|
|
158
|
+
max="20"
|
|
159
|
+
step="0.5"
|
|
160
|
+
bind:value={styles.point.size}
|
|
161
|
+
/>
|
|
162
|
+
</div>
|
|
163
|
+
{/if}
|
|
164
|
+
{#if !has_color_data}
|
|
165
|
+
<div class="pane-row" data-key="point.color">
|
|
166
|
+
<label for="{uid}-point-color">Color:</label>
|
|
167
|
+
<input
|
|
168
|
+
id="{uid}-point-color"
|
|
169
|
+
type="color"
|
|
170
|
+
bind:value={styles.point.color}
|
|
171
|
+
/>
|
|
172
|
+
</div>
|
|
173
|
+
{/if}
|
|
96
174
|
<div class="pane-row" data-key="point.opacity">
|
|
97
175
|
<label for="{uid}-point-opacity">Opacity:</label>
|
|
98
176
|
<input
|
|
@@ -159,8 +237,8 @@ const touch = ({ target }) => {
|
|
|
159
237
|
</SettingsSection>
|
|
160
238
|
{/if}
|
|
161
239
|
|
|
162
|
-
<!-- Line Style Controls -->
|
|
163
|
-
{#if styles.show_lines}
|
|
240
|
+
<!-- Line Style Controls: only when lines exist and are visible -->
|
|
241
|
+
{#if has_any_lines && styles.show_lines}
|
|
164
242
|
<SettingsSection
|
|
165
243
|
title="Line Style"
|
|
166
244
|
current_values={styles.line ?? {}}
|
|
@@ -189,10 +267,12 @@ const touch = ({ target }) => {
|
|
|
189
267
|
bind:value={styles.line.width}
|
|
190
268
|
/>
|
|
191
269
|
</div>
|
|
192
|
-
|
|
193
|
-
<
|
|
194
|
-
|
|
195
|
-
|
|
270
|
+
{#if !has_color_data}
|
|
271
|
+
<div class="pane-row" data-key="line.color">
|
|
272
|
+
<label for="{uid}-line-color">Color:</label>
|
|
273
|
+
<input id="{uid}-line-color" type="color" bind:value={styles.line.color} />
|
|
274
|
+
</div>
|
|
275
|
+
{/if}
|
|
196
276
|
<div class="pane-row" data-key="line.opacity">
|
|
197
277
|
<label for="{uid}-line-opacity">Opacity:</label>
|
|
198
278
|
<input
|
|
@@ -12,6 +12,6 @@ type $$ComponentProps = Omit<PlotControlsProps, `children` | `post_children`> &
|
|
|
12
12
|
} & Required<PlotConfig>
|
|
13
13
|
]>;
|
|
14
14
|
};
|
|
15
|
-
declare const ScatterPlotControls: import("svelte").Component<$$ComponentProps, {}, "display" | "x_axis" | "y_axis" | "y2_axis" | "selected_series_idx" | "styles">;
|
|
15
|
+
declare const ScatterPlotControls: import("svelte").Component<$$ComponentProps, {}, "display" | "x_axis" | "y_axis" | "x2_axis" | "y2_axis" | "selected_series_idx" | "styles">;
|
|
16
16
|
type ScatterPlotControls = ReturnType<typeof ScatterPlotControls>;
|
|
17
17
|
export default ScatterPlotControls;
|
|
@@ -1,27 +1,61 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { type D3SymbolName, symbol_map } from '../labels'
|
|
3
|
+
import type { HoverStyle, LabelStyle, Point } from './'
|
|
4
|
+
import type { PointStyle, TweenedOptions, XyObj } from './types'
|
|
5
|
+
import { DEFAULTS } from '../settings'
|
|
6
|
+
import * as d3_symbols from 'd3-shape'
|
|
7
|
+
import { symbol } from 'd3-shape'
|
|
8
|
+
import { cubicOut } from 'svelte/easing'
|
|
9
|
+
import type { SVGAttributes } from 'svelte/elements'
|
|
10
|
+
import { Tween } from 'svelte/motion'
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
x,
|
|
14
|
+
y,
|
|
15
|
+
style = {},
|
|
16
|
+
hover = {},
|
|
17
|
+
label = {},
|
|
18
|
+
offset = { x: 0, y: 0 },
|
|
19
|
+
point_tween = $bindable({}),
|
|
20
|
+
origin = $bindable({ x: 0, y: 0 }),
|
|
21
|
+
is_hovered = false,
|
|
22
|
+
is_selected = false,
|
|
23
|
+
leader_line_threshold = 15,
|
|
24
|
+
...rest
|
|
25
|
+
}: Omit<SVGAttributes<SVGGElement>, `style` | `offset` | `origin` | `transform`> & {
|
|
26
|
+
x: number
|
|
27
|
+
y: number
|
|
28
|
+
style?: PointStyle
|
|
29
|
+
hover?: HoverStyle
|
|
30
|
+
label?: LabelStyle
|
|
31
|
+
offset?: Point[`offset`]
|
|
32
|
+
point_tween?: TweenedOptions<XyObj>
|
|
33
|
+
origin?: XyObj
|
|
34
|
+
is_hovered?: boolean
|
|
35
|
+
is_selected?: boolean
|
|
36
|
+
leader_line_threshold?: number
|
|
37
|
+
} = $props()
|
|
38
|
+
|
|
39
|
+
// get the SVG path data as 'd' attribute
|
|
40
|
+
function get_symbol_path(): string {
|
|
41
|
+
const symbol_key: D3SymbolName = style.symbol_type ?? DEFAULTS.scatter.symbol_type
|
|
42
|
+
const symbol_type = symbol_map[symbol_key] ?? d3_symbols.symbolCircle
|
|
43
|
+
const size = style.symbol_size ?? Math.PI * Math.pow(style.radius ?? 2, 2)
|
|
44
|
+
return symbol().type(symbol_type).size(size)() || ``
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let marker_path = $derived.by(get_symbol_path)
|
|
48
|
+
|
|
49
|
+
const default_tween_props: TweenedOptions<XyObj> = {
|
|
17
50
|
duration: 600,
|
|
18
51
|
easing: cubicOut,
|
|
19
|
-
}
|
|
20
|
-
// Single tween for {x, y} coordinates
|
|
21
|
-
const tweened_coords = new Tween(origin, { ...default_tween_props, ...point_tween })
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
52
|
+
}
|
|
53
|
+
// Single tween for {x, y} coordinates
|
|
54
|
+
const tweened_coords = new Tween(origin, { ...default_tween_props, ...point_tween })
|
|
55
|
+
|
|
56
|
+
$effect.pre(() => {
|
|
57
|
+
tweened_coords.target = { x: x + offset.x, y: y + offset.y }
|
|
58
|
+
})
|
|
25
59
|
</script>
|
|
26
60
|
|
|
27
61
|
<g
|
|
@@ -61,11 +95,46 @@ $effect.pre(() => {
|
|
|
61
95
|
style:cursor={style.cursor}
|
|
62
96
|
/>
|
|
63
97
|
{#if label.text}
|
|
98
|
+
{@const offset_x = label.offset?.x ?? 10}
|
|
99
|
+
{@const offset_y = label.offset?.y ?? 0}
|
|
100
|
+
{@const displacement = Math.hypot(offset_x, offset_y)}
|
|
101
|
+
{#if displacement > leader_line_threshold}
|
|
102
|
+
{@const marker_radius = style.radius ?? 3}
|
|
103
|
+
{@const angle = Math.atan2(offset_y, offset_x)}
|
|
104
|
+
{@const cos_a = Math.cos(angle)}
|
|
105
|
+
{@const sin_a = Math.sin(angle)}
|
|
106
|
+
{@const start_x = cos_a * (marker_radius + 2)}
|
|
107
|
+
{@const start_y = sin_a * (marker_radius + 2)}
|
|
108
|
+
{@const font_px = parseFloat(label.font_size ?? `10`) || 10}
|
|
109
|
+
{@const half_w = (label.text?.length ?? 1) * font_px * 0.2}
|
|
110
|
+
{@const half_h = font_px * 0.5}
|
|
111
|
+
{@const edge_dist = Math.min(
|
|
112
|
+
Math.abs(cos_a) > 0.01 ? half_w / Math.abs(cos_a) : Infinity,
|
|
113
|
+
Math.abs(sin_a) > 0.01 ? half_h / Math.abs(sin_a) : Infinity,
|
|
114
|
+
)}
|
|
115
|
+
{@const end_x = offset_x - cos_a * (edge_dist + 1)}
|
|
116
|
+
{@const end_y = offset_y - sin_a * (edge_dist + 1)}
|
|
117
|
+
{@const line_len = Math.hypot(end_x - start_x, end_y - start_y)}
|
|
118
|
+
{#if line_len > 6}
|
|
119
|
+
<line
|
|
120
|
+
x1={start_x}
|
|
121
|
+
y1={start_y}
|
|
122
|
+
x2={end_x}
|
|
123
|
+
y2={end_y}
|
|
124
|
+
class="leader-line"
|
|
125
|
+
stroke="var(--scatter-leader-line-color, #888)"
|
|
126
|
+
stroke-width="var(--scatter-leader-line-width, 0.8)"
|
|
127
|
+
stroke-dasharray="var(--scatter-leader-line-dash, 2 2)"
|
|
128
|
+
stroke-opacity="var(--scatter-leader-line-opacity, 0.6)"
|
|
129
|
+
/>
|
|
130
|
+
{/if}
|
|
131
|
+
{/if}
|
|
64
132
|
<text
|
|
65
|
-
x={
|
|
66
|
-
y={
|
|
67
|
-
|
|
68
|
-
style:font-
|
|
133
|
+
x={offset_x}
|
|
134
|
+
y={offset_y}
|
|
135
|
+
text-anchor={label.auto_placement ? `middle` : undefined}
|
|
136
|
+
style:font-size={label.font_size ?? `10px`}
|
|
137
|
+
style:font-family={label.font_family ?? `sans-serif`}
|
|
69
138
|
fill="var(--scatter-point-label-fill, currentColor)"
|
|
70
139
|
dominant-baseline="middle"
|
|
71
140
|
class="label-text"
|
|
@@ -110,4 +179,7 @@ $effect.pre(() => {
|
|
|
110
179
|
.label-text {
|
|
111
180
|
pointer-events: var(--scatter-point-label-pointer-events, none);
|
|
112
181
|
}
|
|
182
|
+
.leader-line {
|
|
183
|
+
pointer-events: none;
|
|
184
|
+
}
|
|
113
185
|
</style>
|
|
@@ -12,6 +12,7 @@ type $$ComponentProps = Omit<SVGAttributes<SVGGElement>, `style` | `offset` | `o
|
|
|
12
12
|
origin?: XyObj;
|
|
13
13
|
is_hovered?: boolean;
|
|
14
14
|
is_selected?: boolean;
|
|
15
|
+
leader_line_threshold?: number;
|
|
15
16
|
};
|
|
16
17
|
declare const ScatterPoint: import("svelte").Component<$$ComponentProps, {}, "origin" | "point_tween">;
|
|
17
18
|
type ScatterPoint = ReturnType<typeof ScatterPoint>;
|