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
|
@@ -20,21 +20,13 @@
|
|
|
20
20
|
import type { AxisChangeState } from '../core/axis-utils'
|
|
21
21
|
import { AXIS_DEFAULTS, create_axis_loader } from '../core/axis-utils'
|
|
22
22
|
import { extract_series_color, prepare_legend_data } from '../core/data-transform'
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
create_hover_lock,
|
|
26
|
-
} from '../core/hover-lock.svelte'
|
|
23
|
+
import { create_placed_tween } from '../core/placed-tween.svelte'
|
|
24
|
+
import { create_pan_zoom } from '../core/pan-zoom.svelte'
|
|
27
25
|
import { create_legend_visibility } from '../core/utils/series-visibility'
|
|
28
26
|
import {
|
|
29
|
-
|
|
30
|
-
MIN_TOUCH_DISTANCE_PIXELS,
|
|
31
|
-
pan_range_by_pixels,
|
|
32
|
-
PINCH_ZOOM_THRESHOLD,
|
|
33
|
-
remove_drag_listeners,
|
|
27
|
+
invert_rect_range,
|
|
34
28
|
resolve_axis_ranges,
|
|
35
|
-
sorted_range,
|
|
36
29
|
vec2_equal,
|
|
37
|
-
zoom_range_by_factor,
|
|
38
30
|
} from '../core/interactions'
|
|
39
31
|
import {
|
|
40
32
|
calc_auto_padding,
|
|
@@ -49,6 +41,7 @@
|
|
|
49
41
|
has_explicit_position,
|
|
50
42
|
measured_footprint,
|
|
51
43
|
place_decorations,
|
|
44
|
+
placed_coords,
|
|
52
45
|
} from '../core/auto-place'
|
|
53
46
|
import type { IndexedRefLine } from '../core/reference-line'
|
|
54
47
|
import { group_ref_lines_by_z, index_ref_lines } from '../core/reference-line'
|
|
@@ -61,7 +54,6 @@
|
|
|
61
54
|
import type {
|
|
62
55
|
BasePlotProps,
|
|
63
56
|
DataSeries,
|
|
64
|
-
InitialRanges,
|
|
65
57
|
LegendConfig,
|
|
66
58
|
PlotConfig,
|
|
67
59
|
ScaleType,
|
|
@@ -74,7 +66,6 @@
|
|
|
74
66
|
import type { Snippet } from 'svelte'
|
|
75
67
|
import { onDestroy, untrack } from 'svelte'
|
|
76
68
|
import type { HTMLAttributes } from 'svelte/elements'
|
|
77
|
-
import { Tween } from 'svelte/motion'
|
|
78
69
|
import type { Vec2 } from '../../math'
|
|
79
70
|
import PlotTooltip from '../core/components/PlotTooltip.svelte'
|
|
80
71
|
import { bar_path } from '../core/svg'
|
|
@@ -208,31 +199,10 @@
|
|
|
208
199
|
// Compute ref_lines with index and group by z-index (using shared utilities)
|
|
209
200
|
let indexed_ref_lines = $derived(index_ref_lines(ref_lines))
|
|
210
201
|
let ref_lines_by_z = $derived(group_ref_lines_by_z(indexed_ref_lines))
|
|
211
|
-
let drag_state = $state<{
|
|
212
|
-
start: { x: number; y: number } | null
|
|
213
|
-
current: { x: number; y: number } | null
|
|
214
|
-
bounds: DOMRect | null
|
|
215
|
-
}>({ start: null, current: null, bounds: null })
|
|
216
|
-
|
|
217
|
-
// Pan state
|
|
218
|
-
let is_focused = $state(false)
|
|
219
|
-
let shift_held = $state(false)
|
|
220
|
-
let pan_drag_state = $state<
|
|
221
|
-
InitialRanges & { start: { x: number; y: number } } | null
|
|
222
|
-
>(null)
|
|
223
|
-
let touch_state = $state<
|
|
224
|
-
InitialRanges & { start_touches: { x: number; y: number }[] } | null
|
|
225
|
-
>(null)
|
|
226
202
|
|
|
227
203
|
// Legend placement stability state
|
|
228
204
|
let legend_element = $state<HTMLDivElement | undefined>()
|
|
229
205
|
let hovered_legend_series_idx = $state<number | null>(null)
|
|
230
|
-
const legend_hover = create_hover_lock()
|
|
231
|
-
const dim_tracker = create_dimension_tracker()
|
|
232
|
-
let has_initial_legend_placement = $state(false)
|
|
233
|
-
|
|
234
|
-
// Clear pending hover lock timeout on unmount
|
|
235
|
-
$effect(() => () => legend_hover.cleanup())
|
|
236
206
|
|
|
237
207
|
// Derived data
|
|
238
208
|
type IndexedSeries = { series_data: DataSeries; series_idx: number }
|
|
@@ -644,249 +614,59 @@
|
|
|
644
614
|
return result
|
|
645
615
|
})
|
|
646
616
|
|
|
647
|
-
// Tweened legend coordinates
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
{
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
// Update legend position with stability checks
|
|
655
|
-
$effect(() => {
|
|
656
|
-
if (!width || !height || !legend_placement) return
|
|
657
|
-
|
|
658
|
-
// Track dimensions for resize detection
|
|
659
|
-
const dims_changed = dim_tracker.has_changed(width, height)
|
|
660
|
-
if (dims_changed) dim_tracker.update(width, height)
|
|
661
|
-
|
|
662
|
-
// Only update if: resize occurred, OR (not hover-locked AND (responsive OR not yet initially placed))
|
|
663
|
-
const is_responsive = legend?.responsive ?? false
|
|
664
|
-
const should_update = dims_changed || (!legend_hover.is_locked.current &&
|
|
665
|
-
(is_responsive || !has_initial_legend_placement))
|
|
666
|
-
|
|
667
|
-
if (should_update) {
|
|
668
|
-
tweened_legend_coords.set(
|
|
669
|
-
{ x: legend_placement.x, y: legend_placement.y },
|
|
670
|
-
// Skip animation on initial placement to avoid jump from (0, 0)
|
|
671
|
-
has_initial_legend_placement ? undefined : { duration: 0 },
|
|
672
|
-
)
|
|
673
|
-
// Only lock position after we have actual measured size
|
|
674
|
-
if (legend_element) {
|
|
675
|
-
has_initial_legend_placement = true
|
|
676
|
-
}
|
|
677
|
-
}
|
|
617
|
+
// Tweened legend coordinates with shared placement stability gating
|
|
618
|
+
const legend_tween = create_placed_tween({
|
|
619
|
+
placement: () => legend_placement,
|
|
620
|
+
dims: () => ({ width, height }),
|
|
621
|
+
responsive: () => legend?.responsive ?? false,
|
|
622
|
+
element: () => legend_element,
|
|
623
|
+
tween: () => legend?.tween,
|
|
678
624
|
})
|
|
679
625
|
|
|
680
|
-
//
|
|
681
|
-
const
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
626
|
+
// Shared pan/zoom/touch/drag-rect interaction controller
|
|
627
|
+
const pan_zoom = create_pan_zoom({
|
|
628
|
+
ranges: () => ranges.current,
|
|
629
|
+
scale_type: (axis) =>
|
|
630
|
+
({ x: final_x_axis, x2: final_x2_axis, y: final_y_axis, y2: final_y2_axis })[axis]
|
|
631
|
+
.scale_type,
|
|
632
|
+
// Clamp to at least 1 to avoid Infinity deltas when padding equals container size
|
|
633
|
+
plot_dims: () => ({
|
|
634
|
+
width: Math.max(1, width - pad.l - pad.r),
|
|
635
|
+
height: Math.max(1, height - pad.t - pad.b),
|
|
636
|
+
}),
|
|
637
|
+
pan: () => pan,
|
|
638
|
+
set_range: (axis, range) => (ranges.current[axis] = range),
|
|
639
|
+
svg: () => svg_element,
|
|
640
|
+
on_rect_zoom: (start, current) => {
|
|
641
|
+
// Update axis ranges to trigger reactivity and prevent effect from overriding
|
|
642
|
+
const next_x = invert_rect_range(scales.x, start.x, current.x)
|
|
643
|
+
if (!next_x) return
|
|
644
|
+
x_axis = { ...x_axis, range: next_x }
|
|
645
|
+
// gate x2/y2 on series presence: their scales are [0, 1] sentinels otherwise,
|
|
646
|
+
// so inverting would store a phantom range in the bindable prop
|
|
647
|
+
const next_x2 = x2_series.length > 0 ? invert_rect_range(scales.x2, start.x, current.x) : null
|
|
648
|
+
if (next_x2) x2_axis = { ...x2_axis, range: next_x2 }
|
|
649
|
+
const next_y = invert_rect_range(scales.y, start.y, current.y)
|
|
650
|
+
if (next_y) y_axis = { ...y_axis, range: next_y }
|
|
651
|
+
const next_y2 = y2_series.length > 0 ? invert_rect_range(scales.y2, start.y, current.y) : null
|
|
652
|
+
if (next_y2) y2_axis = { ...y2_axis, range: next_y2 }
|
|
653
|
+
},
|
|
654
|
+
on_reset: () => {
|
|
655
|
+
// Reset zoom to initial ranges (undo any pan/zoom)
|
|
656
|
+
ranges.current = {
|
|
657
|
+
x: [...ranges.initial.x] as Vec2,
|
|
658
|
+
x2: [...ranges.initial.x2] as Vec2,
|
|
659
|
+
y: [...ranges.initial.y] as Vec2,
|
|
660
|
+
y2: [...ranges.initial.y2] as Vec2,
|
|
707
661
|
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
x: evt.clientX - drag_state.bounds.left,
|
|
715
|
-
y: evt.clientY - drag_state.bounds.top,
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
const on_window_mouse_up = () => {
|
|
720
|
-
handle_zoom()
|
|
721
|
-
drag_state = { start: null, current: null, bounds: null }
|
|
722
|
-
window.removeEventListener(`mousemove`, on_window_mouse_move)
|
|
723
|
-
window.removeEventListener(`mouseup`, on_window_mouse_up)
|
|
724
|
-
document.body.style.cursor = `default`
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
// Pan/zoom all four axes from an interaction-start snapshot, each in its own
|
|
728
|
-
// scale's transform space (log axes pan by a constant factor, linear by a shift).
|
|
729
|
-
// Plot dims clamped to 1px so degenerate containers can't produce Infinity deltas.
|
|
730
|
-
const pan_all_axes = (init: InitialRanges, dx_px: number, dy_px: number) => {
|
|
731
|
-
const plot_width = Math.max(1, width - pad.l - pad.r)
|
|
732
|
-
const plot_height = Math.max(1, height - pad.t - pad.b)
|
|
733
|
-
ranges.current.x = pan_range_by_pixels(init.initial_x_range, dx_px, plot_width, final_x_axis.scale_type)
|
|
734
|
-
ranges.current.x2 = pan_range_by_pixels(init.initial_x2_range, dx_px, plot_width, final_x2_axis.scale_type)
|
|
735
|
-
ranges.current.y = pan_range_by_pixels(init.initial_y_range, dy_px, plot_height, final_y_axis.scale_type)
|
|
736
|
-
ranges.current.y2 = pan_range_by_pixels(init.initial_y2_range, dy_px, plot_height, final_y2_axis.scale_type)
|
|
737
|
-
}
|
|
738
|
-
const zoom_all_axes = (init: InitialRanges, factor: number) => {
|
|
739
|
-
ranges.current.x = zoom_range_by_factor(init.initial_x_range, factor, final_x_axis.scale_type)
|
|
740
|
-
ranges.current.x2 = zoom_range_by_factor(init.initial_x2_range, factor, final_x2_axis.scale_type)
|
|
741
|
-
ranges.current.y = zoom_range_by_factor(init.initial_y_range, factor, final_y_axis.scale_type)
|
|
742
|
-
ranges.current.y2 = zoom_range_by_factor(init.initial_y2_range, factor, final_y2_axis.scale_type)
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
// Pan drag handler (drag direction inverted on x for natural pan feel)
|
|
746
|
-
const on_pan_move = (evt: MouseEvent) => {
|
|
747
|
-
if (!pan_drag_state) return
|
|
748
|
-
const sensitivity = pan?.drag_sensitivity ?? 1
|
|
749
|
-
pan_all_axes(
|
|
750
|
-
pan_drag_state,
|
|
751
|
-
-(evt.clientX - pan_drag_state.start.x) * sensitivity,
|
|
752
|
-
(evt.clientY - pan_drag_state.start.y) * sensitivity,
|
|
753
|
-
)
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
const on_pan_end = () => {
|
|
757
|
-
pan_drag_state = null
|
|
758
|
-
document.body.style.cursor = ``
|
|
759
|
-
window.removeEventListener(`mousemove`, on_pan_move)
|
|
760
|
-
window.removeEventListener(`mouseup`, on_pan_end)
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
// Tear down any window listeners + cursor override if the component unmounts mid-drag
|
|
764
|
-
// (mouseup/panend would otherwise never fire, leaking listeners and a stuck cursor).
|
|
765
|
-
// onDestroy also runs during SSR teardown, where window/document don't exist.
|
|
766
|
-
onDestroy(() => {
|
|
767
|
-
remove_drag_listeners([on_window_mouse_move, on_pan_move], [on_window_mouse_up, on_pan_end])
|
|
768
|
-
drag_state = { start: null, current: null, bounds: null }
|
|
769
|
-
pan_drag_state = null
|
|
662
|
+
// Also reset axis props so future data changes recalculate auto ranges
|
|
663
|
+
x_axis = { ...x_axis, range: [null, null] }
|
|
664
|
+
x2_axis = { ...x2_axis, range: [null, null] }
|
|
665
|
+
y_axis = { ...y_axis, range: [null, null] }
|
|
666
|
+
y2_axis = { ...y2_axis, range: [null, null] }
|
|
667
|
+
},
|
|
770
668
|
})
|
|
771
|
-
|
|
772
|
-
function handle_mouse_down(evt: MouseEvent) {
|
|
773
|
-
const coords = get_relative_coords(evt)
|
|
774
|
-
if (!coords || !svg_element) return
|
|
775
|
-
|
|
776
|
-
// Check if pan is enabled and shift is held for pan mode
|
|
777
|
-
const pan_enabled = pan?.enabled !== false
|
|
778
|
-
if (pan_enabled && evt.shiftKey) {
|
|
779
|
-
evt.preventDefault()
|
|
780
|
-
pan_drag_state = {
|
|
781
|
-
start: { x: evt.clientX, y: evt.clientY },
|
|
782
|
-
initial_x_range: [...ranges.current.x] as [number, number],
|
|
783
|
-
initial_x2_range: [...ranges.current.x2] as [number, number],
|
|
784
|
-
initial_y_range: [...ranges.current.y] as [number, number],
|
|
785
|
-
initial_y2_range: [...ranges.current.y2] as [number, number],
|
|
786
|
-
}
|
|
787
|
-
document.body.style.cursor = `grabbing`
|
|
788
|
-
window.addEventListener(`mousemove`, on_pan_move)
|
|
789
|
-
window.addEventListener(`mouseup`, on_pan_end)
|
|
790
|
-
return
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
drag_state = {
|
|
794
|
-
start: coords,
|
|
795
|
-
current: coords,
|
|
796
|
-
bounds: svg_element.getBoundingClientRect(),
|
|
797
|
-
}
|
|
798
|
-
window.addEventListener(`mousemove`, on_window_mouse_move)
|
|
799
|
-
window.addEventListener(`mouseup`, on_window_mouse_up)
|
|
800
|
-
evt.preventDefault()
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
// Wheel handler for pan (requires focus and shift)
|
|
804
|
-
function handle_wheel(evt: WheelEvent) {
|
|
805
|
-
const pan_enabled = pan?.enabled !== false
|
|
806
|
-
// Only capture wheel when focused AND Shift is held
|
|
807
|
-
// Use shift_held state (tracked via keydown/keyup) for compatibility with synthetic events
|
|
808
|
-
if (!pan_enabled || !is_focused || !shift_held) return
|
|
809
|
-
|
|
810
|
-
evt.preventDefault()
|
|
811
|
-
|
|
812
|
-
// Clamp to at least 1 to avoid Infinity deltas when padding equals container size
|
|
813
|
-
const plot_width = Math.max(1, width - pad.l - pad.r)
|
|
814
|
-
const plot_height = Math.max(1, height - pad.t - pad.b)
|
|
815
|
-
const sensitivity = pan?.wheel_sensitivity ?? 1
|
|
816
|
-
|
|
817
|
-
// Pan along the dominant wheel direction
|
|
818
|
-
if (Math.abs(evt.deltaX) > Math.abs(evt.deltaY)) {
|
|
819
|
-
const dx = evt.deltaX * sensitivity
|
|
820
|
-
ranges.current.x = pan_range_by_pixels(ranges.current.x, dx, plot_width, final_x_axis.scale_type)
|
|
821
|
-
ranges.current.x2 = pan_range_by_pixels(ranges.current.x2, dx, plot_width, final_x2_axis.scale_type)
|
|
822
|
-
} else {
|
|
823
|
-
const dy = evt.deltaY * sensitivity
|
|
824
|
-
ranges.current.y = pan_range_by_pixels(ranges.current.y, dy, plot_height, final_y_axis.scale_type)
|
|
825
|
-
ranges.current.y2 = pan_range_by_pixels(ranges.current.y2, dy, plot_height, final_y2_axis.scale_type)
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
// Touch handlers for pinch-zoom and two-finger pan
|
|
830
|
-
function handle_touch_start(evt: TouchEvent) {
|
|
831
|
-
const touch_enabled = pan?.enabled !== false && pan?.touch_enabled !== false
|
|
832
|
-
if (!touch_enabled || evt.touches.length !== 2) return
|
|
833
|
-
|
|
834
|
-
evt.preventDefault()
|
|
835
|
-
const touches = Array.from(evt.touches)
|
|
836
|
-
touch_state = {
|
|
837
|
-
start_touches: touches.map((touch) => ({ x: touch.clientX, y: touch.clientY })),
|
|
838
|
-
initial_x_range: [...ranges.current.x] as [number, number],
|
|
839
|
-
initial_x2_range: [...ranges.current.x2] as [number, number],
|
|
840
|
-
initial_y_range: [...ranges.current.y] as [number, number],
|
|
841
|
-
initial_y2_range: [...ranges.current.y2] as [number, number],
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
function handle_touch_move(evt: TouchEvent) {
|
|
846
|
-
if (!touch_state || evt.touches.length !== 2) return
|
|
847
|
-
evt.preventDefault()
|
|
848
|
-
|
|
849
|
-
const [t1, t2] = Array.from(evt.touches)
|
|
850
|
-
const [s1, s2] = touch_state.start_touches
|
|
851
|
-
|
|
852
|
-
// Calculate center movement for pan
|
|
853
|
-
const start_center = { x: (s1.x + s2.x) / 2, y: (s1.y + s2.y) / 2 }
|
|
854
|
-
const curr_center = {
|
|
855
|
-
x: (t1.clientX + t2.clientX) / 2,
|
|
856
|
-
y: (t1.clientY + t2.clientY) / 2,
|
|
857
|
-
}
|
|
858
|
-
const dx = curr_center.x - start_center.x
|
|
859
|
-
const dy = curr_center.y - start_center.y
|
|
860
|
-
|
|
861
|
-
// Calculate pinch scale (curr/start so spread = zoom out, pinch = zoom in)
|
|
862
|
-
const start_dist = Math.hypot(s2.x - s1.x, s2.y - s1.y)
|
|
863
|
-
// ignore near-coincident touches so curr_dist / start_dist can't blow up the scale
|
|
864
|
-
if (start_dist < MIN_TOUCH_DISTANCE_PIXELS) return
|
|
865
|
-
const curr_dist = Math.hypot(t2.clientX - t1.clientX, t2.clientY - t1.clientY)
|
|
866
|
-
const scale = curr_dist / start_dist
|
|
867
|
-
|
|
868
|
-
// Pinch zoom about the view center (spread = zoom in, pinch = zoom out)
|
|
869
|
-
if (Math.abs(scale - 1) > PINCH_ZOOM_THRESHOLD && scale > Number.EPSILON) {
|
|
870
|
-
zoom_all_axes(touch_state, scale)
|
|
871
|
-
} else pan_all_axes(touch_state, -dx, dy)
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
function handle_touch_end() {
|
|
875
|
-
touch_state = null
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
function handle_double_click() {
|
|
879
|
-
// Reset zoom to initial ranges (undo any pan/zoom)
|
|
880
|
-
ranges.current.x = [...ranges.initial.x] as [number, number]
|
|
881
|
-
ranges.current.x2 = [...ranges.initial.x2] as [number, number]
|
|
882
|
-
ranges.current.y = [...ranges.initial.y] as [number, number]
|
|
883
|
-
ranges.current.y2 = [...ranges.initial.y2] as [number, number]
|
|
884
|
-
// Also reset axis props so future data changes recalculate auto ranges
|
|
885
|
-
x_axis = { ...x_axis, range: [null, null] }
|
|
886
|
-
x2_axis = { ...x2_axis, range: [null, null] }
|
|
887
|
-
y_axis = { ...y_axis, range: [null, null] }
|
|
888
|
-
y2_axis = { ...y2_axis, range: [null, null] }
|
|
889
|
-
}
|
|
669
|
+
onDestroy(() => pan_zoom.destroy())
|
|
890
670
|
|
|
891
671
|
function handle_mouse_move(
|
|
892
672
|
evt: MouseEvent,
|
|
@@ -988,11 +768,9 @@
|
|
|
988
768
|
evt.preventDefault()
|
|
989
769
|
fullscreen = false
|
|
990
770
|
}
|
|
991
|
-
|
|
992
|
-
}}
|
|
993
|
-
onkeyup={(evt) => {
|
|
994
|
-
if (evt.key === `Shift`) shift_held = false
|
|
771
|
+
pan_zoom.on_window_key_down(evt)
|
|
995
772
|
}}
|
|
773
|
+
onkeyup={pan_zoom.on_window_key_up}
|
|
996
774
|
/>
|
|
997
775
|
|
|
998
776
|
<div
|
|
@@ -1020,35 +798,23 @@
|
|
|
1020
798
|
([final_x_axis.label, final_y_axis.label].filter(Boolean).join(` vs `) ||
|
|
1021
799
|
`Histogram`)}
|
|
1022
800
|
tabindex="0"
|
|
1023
|
-
onfocusin={() => (
|
|
1024
|
-
onfocusout={() => (
|
|
801
|
+
onfocusin={() => pan_zoom.set_focused(true)}
|
|
802
|
+
onfocusout={() => pan_zoom.set_focused(false)}
|
|
1025
803
|
onmouseenter={() => (hovered = true)}
|
|
1026
|
-
onmousedown={
|
|
804
|
+
onmousedown={pan_zoom.on_mouse_down}
|
|
1027
805
|
onmouseleave={() => {
|
|
1028
806
|
hovered = false
|
|
1029
807
|
hover_info = null
|
|
1030
808
|
on_bar_hover?.(null)
|
|
1031
809
|
}}
|
|
1032
|
-
ondblclick={
|
|
1033
|
-
onwheel={
|
|
1034
|
-
ontouchstart={
|
|
1035
|
-
ontouchmove={
|
|
1036
|
-
ontouchend={
|
|
1037
|
-
ontouchcancel={
|
|
1038
|
-
style:cursor={
|
|
1039
|
-
|
|
1040
|
-
: shift_held && pan?.enabled !== false
|
|
1041
|
-
? `grab`
|
|
1042
|
-
: `crosshair`}
|
|
1043
|
-
onkeydown={(event) => {
|
|
1044
|
-
if (event.key === `Escape` && drag_state.start) {
|
|
1045
|
-
drag_state = { start: null, current: null, bounds: null }
|
|
1046
|
-
}
|
|
1047
|
-
if ([`Enter`, ` `].includes(event.key)) {
|
|
1048
|
-
event.preventDefault()
|
|
1049
|
-
handle_double_click()
|
|
1050
|
-
}
|
|
1051
|
-
}}
|
|
810
|
+
ondblclick={pan_zoom.reset_view}
|
|
811
|
+
onwheel={pan_zoom.on_wheel}
|
|
812
|
+
ontouchstart={pan_zoom.on_touch_start}
|
|
813
|
+
ontouchmove={pan_zoom.on_touch_move}
|
|
814
|
+
ontouchend={pan_zoom.on_touch_end}
|
|
815
|
+
ontouchcancel={pan_zoom.on_touch_end}
|
|
816
|
+
style:cursor={pan_zoom.cursor}
|
|
817
|
+
onkeydown={pan_zoom.on_key_down}
|
|
1052
818
|
>
|
|
1053
819
|
<!-- Define clip path for chart area -->
|
|
1054
820
|
<defs>
|
|
@@ -1065,7 +831,7 @@
|
|
|
1065
831
|
<!-- Reference lines: below grid (must render first to appear behind grid) -->
|
|
1066
832
|
{@render ref_lines_layer(ref_lines_by_z.below_grid)}
|
|
1067
833
|
|
|
1068
|
-
<ZoomRect start={
|
|
834
|
+
<ZoomRect start={pan_zoom.drag_start} current={pan_zoom.drag_current} />
|
|
1069
835
|
|
|
1070
836
|
<ZeroLines
|
|
1071
837
|
{display}
|
|
@@ -1300,16 +1066,13 @@
|
|
|
1300
1066
|
{/if}
|
|
1301
1067
|
|
|
1302
1068
|
{#if show_legend && legend != null && series.length > 1}
|
|
1303
|
-
{@const
|
|
1304
|
-
|
|
1305
|
-
:
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
{
|
|
1309
|
-
|
|
1310
|
-
: legend_placement
|
|
1311
|
-
? tweened_legend_coords.current.y
|
|
1312
|
-
: pad.t + 10}
|
|
1069
|
+
{@const legend_pos = placed_coords(
|
|
1070
|
+
legend_auto_outside,
|
|
1071
|
+
{ x: legend_outside_x, y: legend_outside_y },
|
|
1072
|
+
legend_placement,
|
|
1073
|
+
legend_tween.coords.current,
|
|
1074
|
+
{ x: pad.l + 10, y: pad.t + 10 },
|
|
1075
|
+
)}
|
|
1313
1076
|
<PlotLegend
|
|
1314
1077
|
bind:root_element={legend_element}
|
|
1315
1078
|
{...legend}
|
|
@@ -1320,7 +1083,7 @@
|
|
|
1320
1083
|
on_series_toggle(series_idx)
|
|
1321
1084
|
})}
|
|
1322
1085
|
on_double_click={legend?.on_double_click ?? legend_vis.on_double_click}
|
|
1323
|
-
on_hover_change={
|
|
1086
|
+
on_hover_change={legend_tween.set_locked}
|
|
1324
1087
|
on_item_hover={(item) =>
|
|
1325
1088
|
(hovered_legend_series_idx = item != null && item.series_idx >= 0
|
|
1326
1089
|
? item.series_idx
|
|
@@ -1328,8 +1091,8 @@
|
|
|
1328
1091
|
active_series_idx={hover_info?.series_idx ?? hovered_legend_series_idx}
|
|
1329
1092
|
style={`
|
|
1330
1093
|
position: absolute;
|
|
1331
|
-
left: ${
|
|
1332
|
-
top: ${
|
|
1094
|
+
left: ${legend_pos.x}px;
|
|
1095
|
+
top: ${legend_pos.y}px;
|
|
1333
1096
|
pointer-events: auto;
|
|
1334
1097
|
${legend?.style || ``}
|
|
1335
1098
|
`}
|
|
@@ -17,6 +17,6 @@ type $$ComponentProps = Omit<PlotControlsProps, `children` | `post_children`> &
|
|
|
17
17
|
has_y2_points?: boolean;
|
|
18
18
|
children?: Snippet<[Required<PlotConfig>]>;
|
|
19
19
|
};
|
|
20
|
-
declare const HistogramControls: import("svelte").Component<$$ComponentProps, {}, "display" | "mode" | "show_controls" | "
|
|
20
|
+
declare const HistogramControls: import("svelte").Component<$$ComponentProps, {}, "display" | "mode" | "show_controls" | "x2_axis" | "y_axis" | "y2_axis" | "bins" | "show_legend" | "selected_property" | "controls_open" | "x_axis" | "bar">;
|
|
21
21
|
type HistogramControls = ReturnType<typeof HistogramControls>;
|
|
22
22
|
export default HistogramControls;
|
|
@@ -20,11 +20,8 @@
|
|
|
20
20
|
import { closest_data_idx } from '../core/interactions'
|
|
21
21
|
import { compute_element_placement, constrain_tooltip_position, filter_padding } from '../core/layout'
|
|
22
22
|
import type { Sides } from '../core/layout'
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
type PositionedLink,
|
|
26
|
-
type PositionedNode,
|
|
27
|
-
} from './sankey'
|
|
23
|
+
import { compute_sankey_layout } from './sankey'
|
|
24
|
+
import type { PositionedLink, PositionedNode} from './sankey'
|
|
28
25
|
import { unique_id } from '../core/utils'
|
|
29
26
|
import { DEFAULTS } from '../../settings'
|
|
30
27
|
import { type Snippet, untrack } from 'svelte'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BasePlotProps, LegendConfig, SankeyData, SankeyHandlerProps, SankeyLinkColorMode, SankeyLinkHandlerProps, SankeyNodeAlign, SankeyNodeHandlerProps, SankeyOrientation } from '..';
|
|
2
2
|
import type { Sides } from '../core/layout';
|
|
3
|
-
import {
|
|
3
|
+
import type { PositionedLink, PositionedNode } from './sankey';
|
|
4
4
|
import { type Snippet } from 'svelte';
|
|
5
5
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
6
6
|
declare function $$render<Metadata extends Record<string, unknown> = Record<string, unknown>>(): {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Single source of truth for node/link positioning math so the component stays
|
|
3
3
|
// declarative and the layout is independently unit-testable.
|
|
4
4
|
import { sankey as d3_sankey, sankeyCenter, sankeyJustify, sankeyLeft, sankeyRight, } from 'd3-sankey';
|
|
5
|
+
import { DEFAULTS } from '../../settings';
|
|
5
6
|
const ALIGN_FNS = {
|
|
6
7
|
left: sankeyLeft,
|
|
7
8
|
right: sankeyRight,
|
|
@@ -75,7 +76,8 @@ function horizontal_link_path(link) {
|
|
|
75
76
|
// Compute node boxes and link ribbon paths in screen space.
|
|
76
77
|
// Clones input so the (reactive) user data is never mutated by d3-sankey.
|
|
77
78
|
export function compute_sankey_layout(data, opts) {
|
|
78
|
-
|
|
79
|
+
// Fallbacks derive from DEFAULTS.sankey so component and helper defaults can't drift
|
|
80
|
+
const { width, height, node_width = DEFAULTS.sankey.node_width, node_padding = DEFAULTS.sankey.node_padding, node_align = DEFAULTS.sankey.node_align, orientation = DEFAULTS.sankey.orientation, iterations = DEFAULTS.sankey.iterations, } = opts;
|
|
79
81
|
// All-zero link values would make d3-sankey divide by zero (NaN ribbon paths)
|
|
80
82
|
const has_flow = data.links.some((link) => link.value > 0);
|
|
81
83
|
if (!(width > 0) || !(height > 0) || data.nodes.length === 0 || !has_flow)
|
|
@@ -28,18 +28,16 @@
|
|
|
28
28
|
scale_bin_transform,
|
|
29
29
|
series_extents,
|
|
30
30
|
should_render_points,
|
|
31
|
-
type DensityBin,
|
|
32
|
-
type DenseInternalPoint,
|
|
33
|
-
type DensePointSeries,
|
|
34
31
|
} from './adaptive-density'
|
|
32
|
+
import type { DensityBin, DenseInternalPoint, DensePointSeries } from './adaptive-density'
|
|
35
33
|
import { create_color_scale, create_scale, create_size_scale, generate_ticks } from '../core/scales'
|
|
36
34
|
import type { AxisConfig, DataSeries, InternalPoint, ScatterHandlerProps } from '../core/types'
|
|
37
35
|
import {
|
|
38
36
|
compute_label_positions,
|
|
39
37
|
estimate_label_size,
|
|
40
38
|
label_leader_segment,
|
|
41
|
-
type LabelSize,
|
|
42
39
|
} from '../core/utils/label-placement'
|
|
40
|
+
import type { LabelSize } from '../core/utils/label-placement'
|
|
43
41
|
import type { ComponentProps, Snippet } from 'svelte'
|
|
44
42
|
import { onMount, tick } from 'svelte'
|
|
45
43
|
import type { HTMLAttributes } from 'svelte/elements'
|
|
@@ -75,7 +73,7 @@
|
|
|
75
73
|
scheme: `interpolateViridis`,
|
|
76
74
|
} satisfies Exclude<BinnedColorScaleConfig, string>
|
|
77
75
|
const default_pad = { l: 64, r: 24, t: 24, b: 56 }
|
|
78
|
-
const default_point_radius_range:
|
|
76
|
+
const default_point_radius_range: Vec2 = [4, 12]
|
|
79
77
|
const default_pick_radius = default_point_radius_range[1]
|
|
80
78
|
const default_size_scale = {
|
|
81
79
|
type: `linear`,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Sides } from '../core/layout';
|
|
2
|
-
import {
|
|
2
|
+
import type { DensityBin, DenseInternalPoint, DensePointSeries } from './adaptive-density';
|
|
3
3
|
import type { AxisConfig, ScatterHandlerProps } from '../core/types';
|
|
4
4
|
import type { Snippet } from 'svelte';
|
|
5
5
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
@@ -27,7 +27,7 @@ declare function $$render<Metadata extends Record<string, unknown> = Record<stri
|
|
|
27
27
|
bin: DensityBin;
|
|
28
28
|
event: MouseEvent;
|
|
29
29
|
}) => void;
|
|
30
|
-
render_mode?: "
|
|
30
|
+
render_mode?: "points" | "density";
|
|
31
31
|
wrapper?: HTMLDivElement;
|
|
32
32
|
fullscreen?: boolean;
|
|
33
33
|
fullscreen_toggle?: boolean;
|
|
@@ -43,7 +43,7 @@ declare function $$render<Metadata extends Record<string, unknown> = Record<stri
|
|
|
43
43
|
}]>;
|
|
44
44
|
};
|
|
45
45
|
exports: {};
|
|
46
|
-
bindings: "fullscreen" | "
|
|
46
|
+
bindings: "fullscreen" | "wrapper" | "render_mode";
|
|
47
47
|
slots: {};
|
|
48
48
|
events: {};
|
|
49
49
|
};
|
|
@@ -51,7 +51,7 @@ declare class __sveltets_Render<Metadata extends Record<string, unknown> = Recor
|
|
|
51
51
|
props(): ReturnType<typeof $$render<Metadata, PointData>>['props'];
|
|
52
52
|
events(): ReturnType<typeof $$render<Metadata, PointData>>['events'];
|
|
53
53
|
slots(): ReturnType<typeof $$render<Metadata, PointData>>['slots'];
|
|
54
|
-
bindings(): "fullscreen" | "
|
|
54
|
+
bindings(): "fullscreen" | "wrapper" | "render_mode";
|
|
55
55
|
exports(): {};
|
|
56
56
|
}
|
|
57
57
|
interface $$IsomorphicComponent {
|