matterviz 0.4.0 → 0.4.1
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/brillouin/BrillouinZone.svelte +68 -145
- package/dist/brillouin/BrillouinZone.svelte.d.ts +5 -14
- package/dist/brillouin/BrillouinZoneExportPane.svelte +43 -96
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +9 -32
- package/dist/brillouin/BrillouinZoneInfoPane.svelte.d.ts +2 -3
- package/dist/brillouin/BrillouinZoneScene.svelte +49 -203
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +3 -23
- package/dist/brillouin/ReciprocalVectors.svelte +39 -0
- package/dist/brillouin/ReciprocalVectors.svelte.d.ts +9 -0
- package/dist/brillouin/compute.d.ts +2 -0
- package/dist/brillouin/compute.js +80 -77
- package/dist/brillouin/geometry.d.ts +8 -0
- package/dist/brillouin/geometry.js +57 -0
- package/dist/brillouin/index.d.ts +2 -0
- package/dist/brillouin/index.js +2 -0
- package/dist/brillouin/types.d.ts +2 -2
- package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +1 -1
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +100 -191
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +4 -1
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +176 -464
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +7 -1
- package/dist/chempot-diagram/color.d.ts +3 -6
- package/dist/chempot-diagram/color.js +5 -5
- package/dist/chempot-diagram/compute.d.ts +3 -3
- package/dist/chempot-diagram/compute.js +3 -1
- package/dist/chempot-diagram/controls-state.svelte.d.ts +10 -0
- package/dist/chempot-diagram/controls-state.svelte.js +42 -0
- package/dist/chempot-diagram/export.d.ts +47 -0
- package/dist/chempot-diagram/export.js +133 -0
- package/dist/chempot-diagram/index.d.ts +1 -0
- package/dist/chempot-diagram/index.js +1 -0
- package/dist/chempot-diagram/pointer.d.ts +0 -10
- package/dist/chempot-diagram/pointer.js +4 -4
- package/dist/chempot-diagram/types.d.ts +3 -3
- package/dist/colors/index.js +2 -2
- package/dist/composition/FormulaFilter.svelte +6 -5
- package/dist/composition/PieChart.svelte +5 -5
- package/dist/composition/chem-sys.js +3 -2
- package/dist/composition/format.js +3 -2
- package/dist/composition/parse.d.ts +0 -1
- package/dist/composition/parse.js +17 -19
- package/dist/controls.d.ts +1 -0
- package/dist/controls.js +0 -1
- package/dist/convex-hull/ConvexHull.svelte +8 -10
- package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -4
- package/dist/convex-hull/ConvexHull2D.svelte +94 -175
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull3D.svelte +176 -680
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull4D.svelte +180 -680
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullChrome.svelte +268 -0
- package/dist/convex-hull/ConvexHullChrome.svelte.d.ts +30 -0
- package/dist/convex-hull/ConvexHullControls.svelte +88 -7
- package/dist/convex-hull/ConvexHullControls.svelte.d.ts +7 -6
- package/dist/convex-hull/ConvexHullInfoPane.svelte +18 -5
- package/dist/convex-hull/ConvexHullInfoPane.svelte.d.ts +6 -5
- package/dist/convex-hull/ConvexHullStats.svelte +29 -168
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +3 -1
- package/dist/convex-hull/ConvexHullTooltip.svelte +11 -2
- package/dist/convex-hull/ConvexHullTooltip.svelte.d.ts +2 -1
- package/dist/convex-hull/barycentric-coords.d.ts +2 -4
- package/dist/convex-hull/barycentric-coords.js +6 -33
- package/dist/convex-hull/canvas-interactions.svelte.d.ts +79 -0
- package/dist/convex-hull/canvas-interactions.svelte.js +278 -0
- package/dist/convex-hull/helpers.d.ts +39 -7
- package/dist/convex-hull/helpers.js +154 -69
- package/dist/convex-hull/hull-state.svelte.d.ts +44 -0
- package/dist/convex-hull/hull-state.svelte.js +124 -0
- package/dist/convex-hull/index.d.ts +9 -7
- package/dist/convex-hull/index.js +7 -2
- package/dist/convex-hull/thermodynamics.js +91 -920
- package/dist/convex-hull/types.d.ts +12 -4
- package/dist/convex-hull/types.js +12 -0
- package/dist/coordination/CoordinationBarPlot.svelte +4 -11
- package/dist/element/BohrAtom.svelte +2 -1
- package/dist/element/ElementTile.svelte.d.ts +1 -1
- package/dist/element/index.d.ts +4 -0
- package/dist/element/index.js +18 -0
- package/dist/feedback/DragOverlay.svelte +3 -1
- package/dist/feedback/DragOverlay.svelte.d.ts +1 -0
- package/dist/feedback/StatusMessage.svelte +13 -3
- package/dist/fermi-surface/FermiSurface.svelte +67 -146
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +5 -14
- package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte +72 -224
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +3 -23
- package/dist/fermi-surface/compute.js +11 -10
- package/dist/fermi-surface/export.js +4 -15
- package/dist/fermi-surface/index.d.ts +0 -1
- package/dist/fermi-surface/index.js +0 -1
- package/dist/fermi-surface/parse.d.ts +1 -1
- package/dist/fermi-surface/parse.js +64 -75
- package/dist/fermi-surface/types.d.ts +2 -2
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +55 -40
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +4 -3
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +3 -2
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +5 -5
- package/dist/heatmap-matrix/index.d.ts +3 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/io/ExportPane.svelte +166 -0
- package/dist/io/ExportPane.svelte.d.ts +17 -0
- package/dist/io/decompress.js +1 -2
- package/dist/io/export.d.ts +5 -1
- package/dist/io/export.js +32 -28
- package/dist/io/fetch.d.ts +2 -1
- package/dist/io/file-drop.d.ts +7 -0
- package/dist/io/file-drop.js +13 -0
- package/dist/io/index.d.ts +2 -0
- package/dist/io/index.js +10 -0
- package/dist/io/types.d.ts +13 -0
- package/dist/isosurface/parse.js +46 -44
- package/dist/labels.js +1 -1
- package/dist/layout/FullscreenButton.svelte +33 -0
- package/dist/layout/FullscreenButton.svelte.d.ts +10 -0
- package/dist/layout/FullscreenToggle.svelte +8 -14
- package/dist/layout/ViewerChrome.svelte +116 -0
- package/dist/layout/ViewerChrome.svelte.d.ts +17 -0
- package/dist/layout/fullscreen.d.ts +4 -0
- package/dist/layout/fullscreen.svelte.d.ts +8 -0
- package/dist/layout/fullscreen.svelte.js +37 -0
- package/dist/layout/index.d.ts +3 -0
- package/dist/layout/index.js +3 -0
- package/dist/math.d.ts +7 -3
- package/dist/math.js +18 -21
- package/dist/overlays/index.d.ts +4 -0
- package/dist/periodic-table/PeriodicTable.svelte +9 -8
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramControls.svelte +3 -2
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +4 -3
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +2 -1
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +2 -3
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +47 -132
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +3 -4
- package/dist/phase-diagram/colors.js +1 -1
- package/dist/phase-diagram/parse.d.ts +2 -1
- package/dist/plot/bar/BarPlot.svelte +79 -316
- package/dist/plot/bar/BarPlot.svelte.d.ts +7 -15
- package/dist/plot/bar/BarPlotControls.svelte.d.ts +1 -1
- package/dist/plot/bar/SpacegroupBarPlot.svelte +2 -1
- package/dist/plot/box/BoxPlot.svelte +76 -246
- package/dist/plot/box/BoxPlot.svelte.d.ts +4 -3
- package/dist/plot/box/BoxPlotControls.svelte.d.ts +1 -1
- package/dist/plot/box/Violin.svelte.d.ts +1 -1
- package/dist/plot/box/box-plot.d.ts +3 -2
- package/dist/plot/box/box-plot.js +5 -2
- package/dist/plot/box/kde.d.ts +2 -1
- package/dist/plot/box/kde.js +4 -4
- package/dist/plot/core/auto-place.d.ts +1 -1
- package/dist/plot/core/auto-place.js +4 -1
- package/dist/plot/core/components/ColorBar.svelte +5 -5
- package/dist/plot/core/components/ColorBar.svelte.d.ts +5 -4
- package/dist/plot/core/components/Line.svelte +3 -2
- package/dist/plot/core/components/Line.svelte.d.ts +3 -2
- package/dist/plot/core/components/PlotAxis.svelte +2 -1
- package/dist/plot/core/components/PlotAxis.svelte.d.ts +2 -1
- package/dist/plot/core/components/PlotControls.svelte.d.ts +1 -1
- package/dist/plot/core/components/ReferenceLine3D.svelte +2 -2
- package/dist/plot/core/components/ReferenceLine3D.svelte.d.ts +4 -4
- package/dist/plot/core/components/ReferencePlane.svelte +2 -2
- package/dist/plot/core/components/ReferencePlane.svelte.d.ts +4 -4
- package/dist/plot/core/data-cleaning.js +18 -18
- package/dist/plot/core/fill-utils.d.ts +4 -3
- package/dist/plot/core/fill-utils.js +6 -3
- package/dist/plot/core/interactions.d.ts +5 -1
- package/dist/plot/core/interactions.js +14 -0
- package/dist/plot/core/pan-zoom.svelte.d.ts +35 -0
- package/dist/plot/core/pan-zoom.svelte.js +221 -0
- package/dist/plot/core/placed-tween.svelte.d.ts +21 -0
- package/dist/plot/core/placed-tween.svelte.js +68 -0
- package/dist/plot/core/reference-line.d.ts +10 -10
- package/dist/plot/core/reference-line.js +6 -6
- package/dist/plot/core/scales.d.ts +17 -25
- package/dist/plot/core/scales.js +10 -8
- package/dist/plot/core/svg.d.ts +2 -1
- package/dist/plot/core/types.d.ts +18 -7
- package/dist/plot/core/utils/label-placement.d.ts +1 -1
- package/dist/plot/core/utils/label-placement.js +3 -3
- package/dist/plot/core/utils.d.ts +2 -1
- package/dist/plot/histogram/Histogram.svelte +77 -314
- package/dist/plot/histogram/HistogramControls.svelte.d.ts +1 -1
- package/dist/plot/sankey/Sankey.svelte +2 -5
- package/dist/plot/sankey/Sankey.svelte.d.ts +1 -1
- package/dist/plot/sankey/sankey.js +3 -1
- package/dist/plot/scatter/BinnedScatterPlot.svelte +3 -5
- package/dist/plot/scatter/BinnedScatterPlot.svelte.d.ts +4 -4
- package/dist/plot/scatter/ScatterPlot.svelte +160 -450
- package/dist/plot/scatter/ScatterPlot.svelte.d.ts +7 -15
- package/dist/plot/scatter/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/scatter/binned-scatter-types.d.ts +4 -11
- package/dist/plot/scatter/index.d.ts +1 -1
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte +15 -26
- package/dist/plot/scatter-3d/ScatterPlot3D.svelte.d.ts +6 -14
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte +9 -10
- package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte.d.ts +5 -5
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte +122 -121
- package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte.d.ts +5 -14
- package/dist/plot/scatter-3d/Surface3D.svelte +6 -5
- package/dist/plot/scatter-3d/Surface3D.svelte.d.ts +4 -3
- package/dist/plot/sunburst/Sunburst.svelte +16 -20
- package/dist/plot/sunburst/Sunburst.svelte.d.ts +4 -3
- package/dist/plot/sunburst/SunburstControls.svelte.d.ts +1 -1
- package/dist/plot/sunburst/sunburst.js +4 -1
- package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
- package/dist/sanitize.js +13 -2
- package/dist/scene/SceneCamera.svelte +62 -0
- package/dist/scene/SceneCamera.svelte.d.ts +19 -0
- package/dist/scene/bind-renderer.svelte.d.ts +2 -0
- package/dist/scene/bind-renderer.svelte.js +14 -0
- package/dist/scene/index.d.ts +4 -0
- package/dist/scene/index.js +5 -0
- package/dist/scene/props.js +52 -0
- package/dist/scene/types.d.ts +26 -0
- package/dist/scene/types.js +1 -0
- package/dist/settings.d.ts +14 -2
- package/dist/settings.js +59 -1
- package/dist/spectral/Bands.svelte +8 -7
- package/dist/spectral/Bands.svelte.d.ts +3 -2
- package/dist/spectral/BandsAndDos.svelte +22 -24
- package/dist/spectral/BrillouinBandsDos.svelte +3 -3
- package/dist/spectral/Dos.svelte +5 -4
- package/dist/spectral/Dos.svelte.d.ts +2 -1
- package/dist/spectral/helpers.d.ts +6 -6
- package/dist/spectral/helpers.js +43 -37
- package/dist/state.svelte.d.ts +0 -7
- package/dist/state.svelte.js +0 -6
- package/dist/structure/Arrow.svelte +2 -4
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/CanvasTooltip.svelte +1 -0
- package/dist/structure/CellSelect.svelte +11 -3
- package/dist/structure/CellSelect.svelte.d.ts +2 -1
- package/dist/structure/Lattice.svelte +2 -2
- package/dist/structure/Structure.svelte +291 -355
- package/dist/structure/Structure.svelte.d.ts +5 -15
- package/dist/structure/StructureControls.svelte +217 -2
- package/dist/structure/StructureControls.svelte.d.ts +5 -3
- package/dist/structure/StructureExportPane.svelte +54 -156
- package/dist/structure/StructureExportPane.svelte.d.ts +4 -5
- package/dist/structure/StructureInfoPane.svelte +5 -3
- package/dist/structure/StructureInfoPane.svelte.d.ts +5 -5
- package/dist/structure/StructureScene.svelte +365 -198
- package/dist/structure/StructureScene.svelte.d.ts +22 -20
- package/dist/structure/{label-placement.d.ts → atom-label-placement.d.ts} +3 -3
- package/dist/structure/{label-placement.js → atom-label-placement.js} +12 -2
- package/dist/structure/atom-properties.d.ts +1 -1
- package/dist/structure/atom-properties.js +11 -16
- package/dist/structure/bond-order-perception.js +2 -4
- package/dist/structure/bonding.d.ts +3 -0
- package/dist/structure/bonding.js +91 -48
- package/dist/structure/export.d.ts +24 -4
- package/dist/structure/export.js +64 -122
- package/dist/structure/index.d.ts +2 -0
- package/dist/structure/index.js +2 -0
- package/dist/structure/parse.d.ts +3 -2
- package/dist/structure/parse.js +333 -370
- package/dist/structure/partial-occupancy.d.ts +0 -1
- package/dist/structure/partial-occupancy.js +1 -1
- package/dist/structure/pbc.d.ts +1 -1
- package/dist/structure/pbc.js +186 -13
- package/dist/structure/polyhedra.d.ts +41 -0
- package/dist/structure/polyhedra.js +602 -0
- package/dist/structure/site.d.ts +4 -0
- package/dist/structure/site.js +1 -0
- package/dist/structure/supercell.js +3 -2
- package/dist/structure/validation.js +5 -6
- package/dist/symmetry/SymmetryElementControls.svelte +69 -0
- package/dist/symmetry/SymmetryElementControls.svelte.d.ts +9 -0
- package/dist/symmetry/SymmetryElements.svelte +354 -0
- package/dist/symmetry/SymmetryElements.svelte.d.ts +24 -0
- package/dist/symmetry/SymmetryStats.svelte +111 -6
- package/dist/symmetry/WyckoffTable.svelte +68 -7
- package/dist/symmetry/WyckoffTable.svelte.d.ts +3 -0
- package/dist/symmetry/cell-transform.js +7 -14
- package/dist/symmetry/index.d.ts +14 -4
- package/dist/symmetry/index.js +301 -80
- package/dist/symmetry/spacegroups.d.ts +5 -1
- package/dist/symmetry/spacegroups.js +15 -1
- package/dist/symmetry/symmetry-elements.d.ts +33 -0
- package/dist/symmetry/symmetry-elements.js +521 -0
- package/dist/symmetry/wyckoff-db.d.ts +9 -0
- package/dist/symmetry/wyckoff-db.js +87 -0
- package/dist/table/HeatmapTable.svelte +4 -15
- package/dist/table/HeatmapTable.svelte.d.ts +1 -1
- package/dist/trajectory/Trajectory.svelte +58 -61
- package/dist/trajectory/Trajectory.svelte.d.ts +10 -22
- package/dist/trajectory/TrajectoryExportPane.svelte +15 -24
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +4 -5
- package/dist/trajectory/TrajectoryInfoPane.svelte +3 -2
- package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +3 -2
- package/dist/trajectory/constants.js +6 -2
- package/dist/trajectory/extract.js +17 -37
- package/dist/trajectory/format-detect.d.ts +0 -1
- package/dist/trajectory/format-detect.js +3 -9
- package/dist/trajectory/frame-reader.d.ts +0 -1
- package/dist/trajectory/frame-reader.js +62 -128
- package/dist/trajectory/helpers.d.ts +10 -2
- package/dist/trajectory/helpers.js +56 -36
- package/dist/trajectory/parse/ase.d.ts +9 -1
- package/dist/trajectory/parse/ase.js +47 -32
- package/dist/trajectory/parse/diagnostics.d.ts +3 -0
- package/dist/trajectory/parse/diagnostics.js +14 -0
- package/dist/trajectory/parse/index.d.ts +1 -1
- package/dist/trajectory/parse/index.js +54 -102
- package/dist/trajectory/parse/lammps.d.ts +0 -2
- package/dist/trajectory/parse/lammps.js +8 -6
- package/dist/trajectory/parse/pymatgen.d.ts +2 -0
- package/dist/trajectory/parse/pymatgen.js +74 -0
- package/dist/trajectory/parse/vasp.js +4 -3
- package/dist/trajectory/parse/xyz.d.ts +9 -21
- package/dist/trajectory/parse/xyz.js +28 -33
- package/dist/trajectory/plotting.d.ts +0 -1
- package/dist/trajectory/plotting.js +3 -100
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +1 -1
- package/dist/xrd/XrdPlot.svelte +14 -29
- package/dist/xrd/broadening.d.ts +2 -1
- package/dist/xrd/calc-xrd.js +6 -11
- package/dist/xrd/index.d.ts +2 -2
- package/package.json +29 -16
- package/dist/element/data.json +0 -11864
- package/dist/fermi-surface/marching-cubes.d.ts +0 -2
- package/dist/fermi-surface/marching-cubes.js +0 -2
- package/dist/plot/core/hover-lock.svelte.d.ts +0 -14
- package/dist/plot/core/hover-lock.svelte.js +0 -45
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
lang="ts"
|
|
3
3
|
generics="Metadata extends Record<string, unknown> = Record<string, unknown>"
|
|
4
4
|
>
|
|
5
|
-
import type {
|
|
5
|
+
import type { D3InterpolateName } from '../../colors'
|
|
6
6
|
import { format_value } from '../../labels'
|
|
7
7
|
import { sanitize_html } from '../../sanitize'
|
|
8
8
|
import { FullscreenToggle, set_fullscreen_bg } from '../../layout'
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
BarSeries,
|
|
15
15
|
BarStyle,
|
|
16
16
|
BasePlotProps,
|
|
17
|
+
ColorScaleConfig,
|
|
17
18
|
DataLoaderFn,
|
|
18
|
-
InitialRanges,
|
|
19
19
|
InternalPoint,
|
|
20
20
|
LegendConfig,
|
|
21
21
|
LegendItem,
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
PlotConfig,
|
|
26
26
|
RefLine,
|
|
27
27
|
RefLineEvent,
|
|
28
|
-
|
|
28
|
+
SizeScaleConfig,
|
|
29
29
|
UserContentProps,
|
|
30
30
|
} from '..'
|
|
31
31
|
import {
|
|
@@ -38,22 +38,13 @@
|
|
|
38
38
|
} from '..'
|
|
39
39
|
import type { AxisChangeState } from '../core/axis-utils'
|
|
40
40
|
import { create_axis_loader } from '../core/axis-utils'
|
|
41
|
-
import {
|
|
42
|
-
|
|
43
|
-
create_hover_lock,
|
|
44
|
-
} from '../core/hover-lock.svelte'
|
|
41
|
+
import { create_placed_tween } from '../core/placed-tween.svelte'
|
|
42
|
+
import { create_pan_zoom } from '../core/pan-zoom.svelte'
|
|
45
43
|
import { create_legend_visibility } from '../core/utils/series-visibility'
|
|
46
44
|
import {
|
|
47
45
|
axis_ranges_equal,
|
|
48
|
-
|
|
49
|
-
MIN_TOUCH_DISTANCE_PIXELS,
|
|
50
|
-
pan_range_by_pixels,
|
|
51
|
-
PINCH_ZOOM_THRESHOLD,
|
|
52
|
-
remove_drag_listeners,
|
|
46
|
+
invert_rect_range,
|
|
53
47
|
resolve_axis_ranges,
|
|
54
|
-
sorted_range,
|
|
55
|
-
to_epoch_num,
|
|
56
|
-
zoom_range_by_factor,
|
|
57
48
|
} from '../core/interactions'
|
|
58
49
|
import type { IndexedRefLine } from '../core/reference-line'
|
|
59
50
|
import { group_ref_lines_by_z, index_ref_lines } from '../core/reference-line'
|
|
@@ -70,13 +61,14 @@
|
|
|
70
61
|
import type { Snippet } from 'svelte'
|
|
71
62
|
import { onDestroy, untrack } from 'svelte'
|
|
72
63
|
import type { HTMLAttributes } from 'svelte/elements'
|
|
73
|
-
import {
|
|
64
|
+
import type { TweenOptions } from 'svelte/motion'
|
|
74
65
|
import {
|
|
75
66
|
build_obstacles_norm,
|
|
76
67
|
clip_bar,
|
|
77
68
|
has_explicit_position,
|
|
78
69
|
measured_footprint,
|
|
79
70
|
place_decorations,
|
|
71
|
+
placed_coords,
|
|
80
72
|
} from '../core/auto-place'
|
|
81
73
|
import {
|
|
82
74
|
calc_auto_padding,
|
|
@@ -177,26 +169,14 @@
|
|
|
177
169
|
data: BarHandlerProps<Metadata> & { event: MouseEvent | KeyboardEvent },
|
|
178
170
|
) => void
|
|
179
171
|
on_bar_hover?: (
|
|
180
|
-
data:
|
|
181
|
-
| (BarHandlerProps<Metadata> & {
|
|
182
|
-
event: MouseEvent | FocusEvent | KeyboardEvent
|
|
183
|
-
})
|
|
184
|
-
| null,
|
|
172
|
+
data: (BarHandlerProps<Metadata> & { event: MouseEvent | FocusEvent | KeyboardEvent }) | null,
|
|
185
173
|
) => void
|
|
186
174
|
// Line marker props (matching ScatterPlot)
|
|
187
175
|
// Note: For line series with markers, BOTH on_bar_* AND on_point_* events fire.
|
|
188
176
|
// Use on_point_* for marker-specific data (includes `point` with InternalPoint details)
|
|
189
177
|
// or on_bar_* for backward compatibility with bar-style event handling.
|
|
190
|
-
color_scale?:
|
|
191
|
-
|
|
192
|
-
scheme?: D3ColorSchemeName | D3InterpolateName
|
|
193
|
-
value_range?: [number, number]
|
|
194
|
-
} | D3InterpolateName
|
|
195
|
-
size_scale?: {
|
|
196
|
-
type?: ScaleType
|
|
197
|
-
radius_range?: [number, number]
|
|
198
|
-
value_range?: [number, number]
|
|
199
|
-
}
|
|
178
|
+
color_scale?: ColorScaleConfig | D3InterpolateName
|
|
179
|
+
size_scale?: SizeScaleConfig
|
|
200
180
|
point_tween?: TweenOptions<Point2D>
|
|
201
181
|
on_point_click?: (
|
|
202
182
|
data: LineMarkerHandlerProps & { event: MouseEvent | KeyboardEvent },
|
|
@@ -489,7 +469,7 @@
|
|
|
489
469
|
)
|
|
490
470
|
|
|
491
471
|
// Create auto color range (safely handle empty arrays or undefined extent results)
|
|
492
|
-
let auto_color_range:
|
|
472
|
+
let auto_color_range: Vec2 = $derived.by(() => {
|
|
493
473
|
if (all_color_values.length === 0) return [0, 1]
|
|
494
474
|
const [min_val, max_val] = extent(all_color_values)
|
|
495
475
|
return [min_val ?? 0, max_val ?? 1]
|
|
@@ -581,212 +561,44 @@
|
|
|
581
561
|
x2_max: measure_max_tick_width(ticks.x2, x2_axis.format ?? ``),
|
|
582
562
|
})
|
|
583
563
|
|
|
584
|
-
//
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
const y2_1 = scales.y2.invert(drag_state.start.y)
|
|
614
|
-
const y2_2 = scales.y2.invert(drag_state.current.y)
|
|
615
|
-
const x2a_1_raw = scales.x2.invert(drag_state.start.x) as number | Date
|
|
616
|
-
const x2a_2_raw = scales.x2.invert(drag_state.current.x) as number | Date
|
|
617
|
-
const dx = Math.abs(drag_state.start.x - drag_state.current.x)
|
|
618
|
-
const dy = Math.abs(drag_state.start.y - drag_state.current.y)
|
|
619
|
-
|
|
620
|
-
// Same scale inverts both coords, so each pair is all-number or all-Date
|
|
621
|
-
const [xr1, xr2] = [to_epoch_num(x1_raw), to_epoch_num(x2_raw)]
|
|
622
|
-
const [x2r1, x2r2] = [to_epoch_num(x2a_1_raw), to_epoch_num(x2a_2_raw)]
|
|
623
|
-
|
|
624
|
-
if (dx > 5 && dy > 5 && Number.isFinite(xr1) && Number.isFinite(xr2)) {
|
|
625
|
-
// Update axis ranges to trigger reactivity and prevent effect from overriding
|
|
626
|
-
x_axis = { ...x_axis, range: sorted_range(xr1, xr2) }
|
|
627
|
-
if (x2_series.length > 0 && Number.isFinite(x2r1) && Number.isFinite(x2r2)) {
|
|
628
|
-
x2_axis_prop = { ...x2_axis_prop, range: sorted_range(x2r1, x2r2) }
|
|
629
|
-
}
|
|
630
|
-
y_axis = { ...y_axis, range: sorted_range(y1, y2) }
|
|
631
|
-
// gate on y2 series presence (like x2): the y2 scale is a [0, 1] sentinel
|
|
632
|
-
// otherwise, so inverting would store a phantom range in the bindable prop
|
|
633
|
-
if (y2_series.length > 0) {
|
|
634
|
-
y2_axis_prop = { ...y2_axis_prop, range: sorted_range(y2_1, y2_2) }
|
|
635
|
-
}
|
|
564
|
+
// Shared pan/zoom/touch/drag-rect interaction controller
|
|
565
|
+
const pan_zoom = create_pan_zoom({
|
|
566
|
+
ranges: () => ranges.current,
|
|
567
|
+
scale_type: (axis) => ({ x: x_axis, x2: x2_axis, y: y_axis, y2: y2_axis })[axis].scale_type,
|
|
568
|
+
plot_dims: () => ({ width: chart_width, height: chart_height }),
|
|
569
|
+
pan: () => pan,
|
|
570
|
+
set_range: (axis, range) => (ranges.current[axis] = range),
|
|
571
|
+
svg: () => svg_element,
|
|
572
|
+
on_rect_zoom: (start, current) => {
|
|
573
|
+
// Update axis ranges to trigger reactivity and prevent effect from overriding
|
|
574
|
+
const next_x = invert_rect_range(scales.x, start.x, current.x)
|
|
575
|
+
if (!next_x) return
|
|
576
|
+
x_axis = { ...x_axis, range: next_x }
|
|
577
|
+
// gate x2/y2 on series presence: their scales are [0, 1] sentinels otherwise,
|
|
578
|
+
// so inverting would store a phantom range in the bindable prop
|
|
579
|
+
const next_x2 = x2_series.length > 0 ? invert_rect_range(scales.x2, start.x, current.x) : null
|
|
580
|
+
if (next_x2) x2_axis_prop = { ...x2_axis_prop, range: next_x2 }
|
|
581
|
+
const next_y = invert_rect_range(scales.y, start.y, current.y)
|
|
582
|
+
if (next_y) y_axis = { ...y_axis, range: next_y }
|
|
583
|
+
const next_y2 = y2_series.length > 0 ? invert_rect_range(scales.y2, start.y, current.y) : null
|
|
584
|
+
if (next_y2) y2_axis_prop = { ...y2_axis_prop, range: next_y2 }
|
|
585
|
+
},
|
|
586
|
+
on_reset: () => {
|
|
587
|
+
// Reset zoom to initial ranges (undo any pan/zoom)
|
|
588
|
+
ranges.current = {
|
|
589
|
+
x: [...ranges.initial.x] as Vec2,
|
|
590
|
+
x2: [...ranges.initial.x2] as Vec2,
|
|
591
|
+
y: [...ranges.initial.y] as Vec2,
|
|
592
|
+
y2: [...ranges.initial.y2] as Vec2,
|
|
636
593
|
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
// Pan/zoom all four axes from an interaction-start snapshot, each in its own
|
|
645
|
-
// scale's transform space (log axes pan by a constant factor, linear by a shift)
|
|
646
|
-
const pan_all_axes = (init: InitialRanges, dx_px: number, dy_px: number) => {
|
|
647
|
-
ranges.current.x = pan_range_by_pixels(init.initial_x_range, dx_px, chart_width, x_axis.scale_type)
|
|
648
|
-
ranges.current.x2 = pan_range_by_pixels(init.initial_x2_range, dx_px, chart_width, x2_axis.scale_type)
|
|
649
|
-
ranges.current.y = pan_range_by_pixels(init.initial_y_range, dy_px, chart_height, y_axis.scale_type)
|
|
650
|
-
ranges.current.y2 = pan_range_by_pixels(init.initial_y2_range, dy_px, chart_height, y2_axis.scale_type)
|
|
651
|
-
}
|
|
652
|
-
const zoom_all_axes = (init: InitialRanges, factor: number) => {
|
|
653
|
-
ranges.current.x = zoom_range_by_factor(init.initial_x_range, factor, x_axis.scale_type)
|
|
654
|
-
ranges.current.x2 = zoom_range_by_factor(init.initial_x2_range, factor, x2_axis.scale_type)
|
|
655
|
-
ranges.current.y = zoom_range_by_factor(init.initial_y_range, factor, y_axis.scale_type)
|
|
656
|
-
ranges.current.y2 = zoom_range_by_factor(init.initial_y2_range, factor, y2_axis.scale_type)
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
// Pan drag handler (drag direction inverted on x for natural pan feel)
|
|
660
|
-
const on_pan_move = (evt: MouseEvent) => {
|
|
661
|
-
if (!pan_drag_state) return
|
|
662
|
-
const sensitivity = pan?.drag_sensitivity ?? 1
|
|
663
|
-
pan_all_axes(
|
|
664
|
-
pan_drag_state,
|
|
665
|
-
-(evt.clientX - pan_drag_state.start.x) * sensitivity,
|
|
666
|
-
(evt.clientY - pan_drag_state.start.y) * sensitivity,
|
|
667
|
-
)
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
const on_pan_end = () => {
|
|
671
|
-
pan_drag_state = null
|
|
672
|
-
document.body.style.cursor = ``
|
|
673
|
-
window.removeEventListener(`mousemove`, on_pan_move)
|
|
674
|
-
window.removeEventListener(`mouseup`, on_pan_end)
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
// Tear down any window listeners + cursor override if the component unmounts mid-drag
|
|
678
|
-
// (mouseup/panend would otherwise never fire, leaking listeners and a stuck cursor).
|
|
679
|
-
// onDestroy also runs during SSR teardown, where window/document don't exist.
|
|
680
|
-
onDestroy(() => {
|
|
681
|
-
remove_drag_listeners([on_window_mouse_move, on_pan_move], [on_window_mouse_up, on_pan_end])
|
|
682
|
-
drag_state = { start: null, current: null, bounds: null }
|
|
683
|
-
pan_drag_state = null
|
|
594
|
+
// Also reset axis props so future data changes recalculate auto ranges
|
|
595
|
+
x_axis = { ...x_axis, range: [null, null] }
|
|
596
|
+
x2_axis_prop = { ...x2_axis_prop, range: [null, null] }
|
|
597
|
+
y_axis = { ...y_axis, range: [null, null] }
|
|
598
|
+
y2_axis_prop = { ...y2_axis_prop, range: [null, null] }
|
|
599
|
+
},
|
|
684
600
|
})
|
|
685
|
-
|
|
686
|
-
function handle_mouse_down(evt: MouseEvent) {
|
|
687
|
-
const coords = get_relative_coords(evt)
|
|
688
|
-
if (!coords || !svg_element) return
|
|
689
|
-
|
|
690
|
-
// Check if pan is enabled and shift is held for pan mode
|
|
691
|
-
const pan_enabled = pan?.enabled !== false
|
|
692
|
-
if (pan_enabled && evt.shiftKey) {
|
|
693
|
-
evt.preventDefault()
|
|
694
|
-
pan_drag_state = {
|
|
695
|
-
start: { x: evt.clientX, y: evt.clientY },
|
|
696
|
-
initial_x_range: [...ranges.current.x] as [number, number],
|
|
697
|
-
initial_x2_range: [...ranges.current.x2] as [number, number],
|
|
698
|
-
initial_y_range: [...ranges.current.y] as [number, number],
|
|
699
|
-
initial_y2_range: [...ranges.current.y2] as [number, number],
|
|
700
|
-
}
|
|
701
|
-
document.body.style.cursor = `grabbing`
|
|
702
|
-
window.addEventListener(`mousemove`, on_pan_move)
|
|
703
|
-
window.addEventListener(`mouseup`, on_pan_end)
|
|
704
|
-
return
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
drag_state = {
|
|
708
|
-
start: coords,
|
|
709
|
-
current: coords,
|
|
710
|
-
bounds: svg_element.getBoundingClientRect(),
|
|
711
|
-
}
|
|
712
|
-
window.addEventListener(`mousemove`, on_window_mouse_move)
|
|
713
|
-
window.addEventListener(`mouseup`, on_window_mouse_up)
|
|
714
|
-
evt.preventDefault()
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
// Wheel handler for pan (requires focus and shift)
|
|
718
|
-
function handle_wheel(evt: WheelEvent) {
|
|
719
|
-
const pan_enabled = pan?.enabled !== false
|
|
720
|
-
// Only capture wheel when focused AND Shift is held
|
|
721
|
-
// Use shift_held state (tracked via keydown/keyup) for compatibility with synthetic events
|
|
722
|
-
if (!pan_enabled || !is_focused || !shift_held) return
|
|
723
|
-
|
|
724
|
-
evt.preventDefault()
|
|
725
|
-
|
|
726
|
-
const sensitivity = pan?.wheel_sensitivity ?? 1
|
|
727
|
-
|
|
728
|
-
// Pan along the dominant wheel direction
|
|
729
|
-
if (Math.abs(evt.deltaX) > Math.abs(evt.deltaY)) {
|
|
730
|
-
const dx = evt.deltaX * sensitivity
|
|
731
|
-
ranges.current.x = pan_range_by_pixels(ranges.current.x, dx, chart_width, x_axis.scale_type)
|
|
732
|
-
ranges.current.x2 = pan_range_by_pixels(ranges.current.x2, dx, chart_width, x2_axis.scale_type)
|
|
733
|
-
} else {
|
|
734
|
-
const dy = evt.deltaY * sensitivity
|
|
735
|
-
ranges.current.y = pan_range_by_pixels(ranges.current.y, dy, chart_height, y_axis.scale_type)
|
|
736
|
-
ranges.current.y2 = pan_range_by_pixels(ranges.current.y2, dy, chart_height, y2_axis.scale_type)
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
// Touch handlers for pinch-zoom and two-finger pan
|
|
741
|
-
function handle_touch_start(evt: TouchEvent) {
|
|
742
|
-
const touch_enabled = pan?.enabled !== false && pan?.touch_enabled !== false
|
|
743
|
-
if (!touch_enabled || evt.touches.length !== 2) return
|
|
744
|
-
|
|
745
|
-
evt.preventDefault()
|
|
746
|
-
const touches = Array.from(evt.touches)
|
|
747
|
-
touch_state = {
|
|
748
|
-
start_touches: touches.map((touch) => ({ x: touch.clientX, y: touch.clientY })),
|
|
749
|
-
initial_x_range: [...ranges.current.x] as [number, number],
|
|
750
|
-
initial_x2_range: [...ranges.current.x2] as [number, number],
|
|
751
|
-
initial_y_range: [...ranges.current.y] as [number, number],
|
|
752
|
-
initial_y2_range: [...ranges.current.y2] as [number, number],
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
function handle_touch_move(evt: TouchEvent) {
|
|
757
|
-
if (!touch_state || evt.touches.length !== 2) return
|
|
758
|
-
evt.preventDefault()
|
|
759
|
-
|
|
760
|
-
const [t1, t2] = Array.from(evt.touches)
|
|
761
|
-
const [s1, s2] = touch_state.start_touches
|
|
762
|
-
|
|
763
|
-
// Calculate center movement for pan
|
|
764
|
-
const start_center = { x: (s1.x + s2.x) / 2, y: (s1.y + s2.y) / 2 }
|
|
765
|
-
const curr_center = {
|
|
766
|
-
x: (t1.clientX + t2.clientX) / 2,
|
|
767
|
-
y: (t1.clientY + t2.clientY) / 2,
|
|
768
|
-
}
|
|
769
|
-
const dx = curr_center.x - start_center.x
|
|
770
|
-
const dy = curr_center.y - start_center.y
|
|
771
|
-
|
|
772
|
-
// Calculate pinch scale (curr/start so spread = zoom out, pinch = zoom in)
|
|
773
|
-
const start_dist = Math.hypot(s2.x - s1.x, s2.y - s1.y)
|
|
774
|
-
// ignore near-coincident touches so curr_dist / start_dist can't blow up the scale
|
|
775
|
-
if (start_dist < MIN_TOUCH_DISTANCE_PIXELS) return
|
|
776
|
-
const curr_dist = Math.hypot(t2.clientX - t1.clientX, t2.clientY - t1.clientY)
|
|
777
|
-
const scale = curr_dist / start_dist
|
|
778
|
-
|
|
779
|
-
// If scale changed significantly, treat as pinch-zoom
|
|
780
|
-
// Also guard against scale being too small to avoid division by zero
|
|
781
|
-
// Pinch zoom about the view center (spread = zoom in, pinch = zoom out)
|
|
782
|
-
if (Math.abs(scale - 1) > PINCH_ZOOM_THRESHOLD && scale > Number.EPSILON) {
|
|
783
|
-
zoom_all_axes(touch_state, scale)
|
|
784
|
-
} else pan_all_axes(touch_state, -dx, dy)
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
function handle_touch_end() {
|
|
788
|
-
touch_state = null
|
|
789
|
-
}
|
|
601
|
+
onDestroy(() => pan_zoom.destroy())
|
|
790
602
|
|
|
791
603
|
// Legend data and handlers
|
|
792
604
|
let legend_data = $derived.by<LegendItem[]>(() =>
|
|
@@ -876,12 +688,6 @@
|
|
|
876
688
|
|
|
877
689
|
// Legend placement stability state (legend_element declared above for the auto-place block)
|
|
878
690
|
let hovered_legend_series_idx = $state<number | null>(null)
|
|
879
|
-
const legend_hover = create_hover_lock()
|
|
880
|
-
const dim_tracker = create_dimension_tracker()
|
|
881
|
-
let has_initial_legend_placement = $state(false)
|
|
882
|
-
|
|
883
|
-
// Clear pending hover lock timeout on unmount
|
|
884
|
-
$effect(() => () => legend_hover.cleanup())
|
|
885
691
|
|
|
886
692
|
// Calculate best legend placement using continuous grid sampling
|
|
887
693
|
let legend_placement = $derived.by(() => {
|
|
@@ -900,37 +706,13 @@
|
|
|
900
706
|
return result
|
|
901
707
|
})
|
|
902
708
|
|
|
903
|
-
// Tweened legend coordinates
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
{
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
// Update legend position with stability checks
|
|
911
|
-
$effect(() => {
|
|
912
|
-
if (!width || !height || !legend_placement) return
|
|
913
|
-
|
|
914
|
-
// Track dimensions for resize detection
|
|
915
|
-
const dims_changed = dim_tracker.has_changed(width, height)
|
|
916
|
-
if (dims_changed) dim_tracker.update(width, height)
|
|
917
|
-
|
|
918
|
-
const is_responsive = legend?.responsive ?? false
|
|
919
|
-
// Only update if: resize occurred, OR (not hover-locked AND (responsive OR not yet initially placed))
|
|
920
|
-
const should_update = dims_changed || (!legend_hover.is_locked.current &&
|
|
921
|
-
(is_responsive || !has_initial_legend_placement))
|
|
922
|
-
|
|
923
|
-
if (should_update) {
|
|
924
|
-
tweened_legend_coords.set(
|
|
925
|
-
{ x: legend_placement.x, y: legend_placement.y },
|
|
926
|
-
// Skip animation on initial placement to avoid jump from (0, 0)
|
|
927
|
-
has_initial_legend_placement ? undefined : { duration: 0 },
|
|
928
|
-
)
|
|
929
|
-
// Only lock position after we have actual measured size
|
|
930
|
-
if (legend_element) {
|
|
931
|
-
has_initial_legend_placement = true
|
|
932
|
-
}
|
|
933
|
-
}
|
|
709
|
+
// Tweened legend coordinates with shared placement stability gating
|
|
710
|
+
const legend_tween = create_placed_tween({
|
|
711
|
+
placement: () => legend_placement,
|
|
712
|
+
dims: () => ({ width, height }),
|
|
713
|
+
responsive: () => legend?.responsive ?? false,
|
|
714
|
+
element: () => legend_element,
|
|
715
|
+
tween: () => legend?.tween,
|
|
934
716
|
})
|
|
935
717
|
|
|
936
718
|
// Tooltip state
|
|
@@ -1085,11 +867,9 @@
|
|
|
1085
867
|
evt.preventDefault()
|
|
1086
868
|
fullscreen = false
|
|
1087
869
|
}
|
|
1088
|
-
|
|
1089
|
-
}}
|
|
1090
|
-
onkeyup={(evt) => {
|
|
1091
|
-
if (evt.key === `Shift`) shift_held = false
|
|
870
|
+
pan_zoom.on_window_key_down(evt)
|
|
1092
871
|
}}
|
|
872
|
+
onkeyup={pan_zoom.on_window_key_up}
|
|
1093
873
|
/>
|
|
1094
874
|
|
|
1095
875
|
<div
|
|
@@ -1115,39 +895,25 @@
|
|
|
1115
895
|
aria-label={rest[`aria-label`] ??
|
|
1116
896
|
([x_axis.label, y_axis.label].filter(Boolean).join(` vs `) || `Bar chart`)}
|
|
1117
897
|
tabindex="0"
|
|
1118
|
-
onfocusin={() => (
|
|
1119
|
-
onfocusout={() => (
|
|
1120
|
-
onmousedown={
|
|
1121
|
-
ondblclick={
|
|
1122
|
-
|
|
1123
|
-
ranges.current.x = [...ranges.initial.x] as [number, number]
|
|
1124
|
-
ranges.current.x2 = [...ranges.initial.x2] as [number, number]
|
|
1125
|
-
ranges.current.y = [...ranges.initial.y] as [number, number]
|
|
1126
|
-
ranges.current.y2 = [...ranges.initial.y2] as [number, number]
|
|
1127
|
-
// Also reset axis props so future data changes recalculate auto ranges
|
|
1128
|
-
x_axis = { ...x_axis, range: [null, null] }
|
|
1129
|
-
x2_axis_prop = { ...x2_axis_prop, range: [null, null] }
|
|
1130
|
-
y_axis = { ...y_axis, range: [null, null] }
|
|
1131
|
-
y2_axis_prop = { ...y2_axis_prop, range: [null, null] }
|
|
1132
|
-
}}
|
|
898
|
+
onfocusin={() => pan_zoom.set_focused(true)}
|
|
899
|
+
onfocusout={() => pan_zoom.set_focused(false)}
|
|
900
|
+
onmousedown={pan_zoom.on_mouse_down}
|
|
901
|
+
ondblclick={pan_zoom.reset_view}
|
|
902
|
+
onkeydown={pan_zoom.on_key_down}
|
|
1133
903
|
onmouseleave={() => {
|
|
1134
904
|
hovered = false
|
|
1135
905
|
hover_info = null
|
|
1136
906
|
change(null)
|
|
1137
907
|
on_bar_hover?.(null)
|
|
1138
908
|
}}
|
|
1139
|
-
onwheel={
|
|
1140
|
-
ontouchstart={
|
|
1141
|
-
ontouchmove={
|
|
1142
|
-
ontouchend={
|
|
1143
|
-
ontouchcancel={
|
|
1144
|
-
style:cursor={
|
|
1145
|
-
? `grabbing`
|
|
1146
|
-
: shift_held && pan?.enabled !== false
|
|
1147
|
-
? `grab`
|
|
1148
|
-
: `crosshair`}
|
|
909
|
+
onwheel={pan_zoom.on_wheel}
|
|
910
|
+
ontouchstart={pan_zoom.on_touch_start}
|
|
911
|
+
ontouchmove={pan_zoom.on_touch_move}
|
|
912
|
+
ontouchend={pan_zoom.on_touch_end}
|
|
913
|
+
ontouchcancel={pan_zoom.on_touch_end}
|
|
914
|
+
style:cursor={pan_zoom.cursor}
|
|
1149
915
|
>
|
|
1150
|
-
<ZoomRect start={
|
|
916
|
+
<ZoomRect start={pan_zoom.drag_start} current={pan_zoom.drag_current} />
|
|
1151
917
|
|
|
1152
918
|
<!-- User content (custom overlays, reference lines, etc.) -->
|
|
1153
919
|
{@render user_content?.({
|
|
@@ -1572,16 +1338,13 @@
|
|
|
1572
1338
|
|
|
1573
1339
|
<!-- Legend -->
|
|
1574
1340
|
{#if legend && (show_legend !== undefined ? show_legend : series.length > 1)}
|
|
1575
|
-
{@const
|
|
1576
|
-
|
|
1577
|
-
:
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
{
|
|
1581
|
-
|
|
1582
|
-
: legend_placement
|
|
1583
|
-
? tweened_legend_coords.current.y
|
|
1584
|
-
: pad.t + 10}
|
|
1341
|
+
{@const legend_pos = placed_coords(
|
|
1342
|
+
legend_auto_outside,
|
|
1343
|
+
{ x: legend_outside_x, y: legend_outside_y },
|
|
1344
|
+
legend_placement,
|
|
1345
|
+
legend_tween.coords.current,
|
|
1346
|
+
{ x: pad.l + 10, y: pad.t + 10 },
|
|
1347
|
+
)}
|
|
1585
1348
|
<PlotLegend
|
|
1586
1349
|
bind:root_element={legend_element}
|
|
1587
1350
|
{...legend}
|
|
@@ -1589,7 +1352,7 @@
|
|
|
1589
1352
|
on_toggle={legend?.on_toggle ?? legend_vis.on_toggle}
|
|
1590
1353
|
on_group_toggle={legend?.on_group_toggle ?? legend_vis.on_group_toggle}
|
|
1591
1354
|
on_double_click={legend?.on_double_click ?? legend_vis.on_double_click}
|
|
1592
|
-
on_hover_change={
|
|
1355
|
+
on_hover_change={legend_tween.set_locked}
|
|
1593
1356
|
on_item_hover={(item) =>
|
|
1594
1357
|
(hovered_legend_series_idx = item != null && item.series_idx >= 0
|
|
1595
1358
|
? item.series_idx
|
|
@@ -1597,8 +1360,8 @@
|
|
|
1597
1360
|
active_series_idx={hover_info?.series_idx ?? hovered_legend_series_idx}
|
|
1598
1361
|
style={`
|
|
1599
1362
|
position: absolute;
|
|
1600
|
-
left: ${
|
|
1601
|
-
top: ${
|
|
1363
|
+
left: ${legend_pos.x}px;
|
|
1364
|
+
top: ${legend_pos.y}px;
|
|
1602
1365
|
pointer-events: auto;
|
|
1603
1366
|
${legend?.style || ``}
|
|
1604
1367
|
`}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { D3InterpolateName } from '../../colors';
|
|
2
2
|
import type { Point2D } from '../../math';
|
|
3
|
-
import type { AxisLoadError, BarHandlerProps, BarMode, BarSeries, BarStyle, BasePlotProps, DataLoaderFn, InternalPoint, LegendConfig, LineStyle, Orientation, PanConfig, PlotConfig, RefLine, RefLineEvent,
|
|
3
|
+
import type { AxisLoadError, BarHandlerProps, BarMode, BarSeries, BarStyle, BasePlotProps, ColorScaleConfig, DataLoaderFn, InternalPoint, LegendConfig, LineStyle, Orientation, PanConfig, PlotConfig, RefLine, RefLineEvent, SizeScaleConfig, UserContentProps } from '..';
|
|
4
4
|
import type { Snippet } from 'svelte';
|
|
5
5
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
6
|
-
import {
|
|
6
|
+
import type { TweenOptions } from 'svelte/motion';
|
|
7
7
|
declare function $$render<Metadata extends Record<string, unknown> = Record<string, unknown>>(): {
|
|
8
8
|
props: HTMLAttributes<HTMLDivElement> & BasePlotProps & PlotConfig & {
|
|
9
9
|
series?: BarSeries<Metadata>[];
|
|
@@ -31,16 +31,8 @@ declare function $$render<Metadata extends Record<string, unknown> = Record<stri
|
|
|
31
31
|
on_bar_hover?: (data: (BarHandlerProps<Metadata> & {
|
|
32
32
|
event: MouseEvent | FocusEvent | KeyboardEvent;
|
|
33
33
|
}) | null) => void;
|
|
34
|
-
color_scale?:
|
|
35
|
-
|
|
36
|
-
scheme?: D3ColorSchemeName | D3InterpolateName;
|
|
37
|
-
value_range?: [number, number];
|
|
38
|
-
} | D3InterpolateName;
|
|
39
|
-
size_scale?: {
|
|
40
|
-
type?: ScaleType;
|
|
41
|
-
radius_range?: [number, number];
|
|
42
|
-
value_range?: [number, number];
|
|
43
|
-
};
|
|
34
|
+
color_scale?: ColorScaleConfig | D3InterpolateName;
|
|
35
|
+
size_scale?: SizeScaleConfig;
|
|
44
36
|
point_tween?: TweenOptions<Point2D>;
|
|
45
37
|
on_point_click?: (data: (BarHandlerProps<Metadata> & {
|
|
46
38
|
point: InternalPoint<Metadata>;
|
|
@@ -61,7 +53,7 @@ declare function $$render<Metadata extends Record<string, unknown> = Record<stri
|
|
|
61
53
|
pan?: PanConfig;
|
|
62
54
|
};
|
|
63
55
|
exports: {};
|
|
64
|
-
bindings: "
|
|
56
|
+
bindings: "display" | "mode" | "orientation" | "show_controls" | "x2_axis" | "y_axis" | "y2_axis" | "fullscreen" | "series" | "hovered" | "ref_lines" | "controls_open" | "x_axis";
|
|
65
57
|
slots: {};
|
|
66
58
|
events: {};
|
|
67
59
|
};
|
|
@@ -69,7 +61,7 @@ declare class __sveltets_Render<Metadata extends Record<string, unknown> = Recor
|
|
|
69
61
|
props(): ReturnType<typeof $$render<Metadata>>['props'];
|
|
70
62
|
events(): ReturnType<typeof $$render<Metadata>>['events'];
|
|
71
63
|
slots(): ReturnType<typeof $$render<Metadata>>['slots'];
|
|
72
|
-
bindings(): "
|
|
64
|
+
bindings(): "display" | "mode" | "orientation" | "show_controls" | "x2_axis" | "y_axis" | "y2_axis" | "fullscreen" | "series" | "hovered" | "ref_lines" | "controls_open" | "x_axis";
|
|
73
65
|
exports(): {};
|
|
74
66
|
}
|
|
75
67
|
interface $$IsomorphicComponent {
|
|
@@ -13,6 +13,6 @@ type $$ComponentProps = Omit<PlotControlsProps, `children` | `post_children`> &
|
|
|
13
13
|
} & Required<PlotConfig>
|
|
14
14
|
]>;
|
|
15
15
|
};
|
|
16
|
-
declare const BarPlotControls: import("svelte").Component<$$ComponentProps, {}, "
|
|
16
|
+
declare const BarPlotControls: import("svelte").Component<$$ComponentProps, {}, "display" | "mode" | "orientation" | "show_controls" | "x2_axis" | "y_axis" | "y2_axis" | "controls_open" | "x_axis">;
|
|
17
17
|
type BarPlotControls = ReturnType<typeof BarPlotControls>;
|
|
18
18
|
export default BarPlotControls;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { format_num, format_value } from '../../labels'
|
|
3
|
+
import type { Vec2 } from '../../math'
|
|
3
4
|
import type { BarHandlerProps, BarSeries, TickConfig } from '..'
|
|
4
5
|
import { BarPlot } from '..'
|
|
5
6
|
import type { CrystalSystem } from '../../symmetry'
|
|
@@ -123,7 +124,7 @@
|
|
|
123
124
|
})
|
|
124
125
|
|
|
125
126
|
// Always show full space group range (1-230)
|
|
126
|
-
const x_range:
|
|
127
|
+
const x_range: Vec2 = [0.5, MAX_SPACEGROUP + 0.5]
|
|
127
128
|
|
|
128
129
|
// Calculate crystal system region boundaries using full theoretical ranges
|
|
129
130
|
const crystal_system_regions = $derived.by(() => {
|