matterviz 0.3.0 → 0.3.2
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/FilePicker.svelte +37 -20
- package/dist/Icon.svelte +2 -2
- package/dist/MillerIndexInput.svelte +60 -0
- package/dist/MillerIndexInput.svelte.d.ts +7 -0
- package/dist/app.css +38 -2
- package/dist/brillouin/BrillouinZone.svelte +20 -62
- package/dist/brillouin/BrillouinZone.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneExportPane.svelte +12 -20
- package/dist/brillouin/BrillouinZoneScene.svelte +2 -2
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -1
- package/dist/chempot-diagram/ChemPotDiagram.svelte +192 -0
- package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +13 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +677 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +2688 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte +8 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte.d.ts +7 -0
- package/dist/chempot-diagram/color.d.ts +10 -0
- package/dist/chempot-diagram/color.js +33 -0
- package/dist/chempot-diagram/compute.d.ts +38 -0
- package/dist/chempot-diagram/compute.js +650 -0
- package/dist/chempot-diagram/index.d.ts +5 -0
- package/dist/chempot-diagram/index.js +5 -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 +37 -0
- package/dist/chempot-diagram/types.d.ts +83 -0
- package/dist/chempot-diagram/types.js +27 -0
- package/dist/colors/index.d.ts +3 -1
- package/dist/colors/index.js +4 -0
- package/dist/composition/BarChart.svelte +13 -22
- package/dist/composition/BubbleChart.svelte +5 -3
- package/dist/composition/FormulaFilter.svelte +770 -90
- package/dist/composition/FormulaFilter.svelte.d.ts +37 -1
- package/dist/composition/PieChart.svelte +43 -18
- package/dist/composition/PieChart.svelte.d.ts +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +2 -0
- package/dist/convex-hull/ConvexHull.svelte +14 -1
- package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull2D.svelte +14 -45
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull3D.svelte +396 -134
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull4D.svelte +93 -42
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullControls.svelte +94 -31
- package/dist/convex-hull/ConvexHullControls.svelte.d.ts +4 -2
- package/dist/convex-hull/ConvexHullStats.svelte +697 -128
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +6 -1
- package/dist/convex-hull/ConvexHullTooltip.svelte +1 -0
- package/dist/convex-hull/GasPressureControls.svelte +72 -38
- package/dist/convex-hull/GasPressureControls.svelte.d.ts +2 -1
- package/dist/convex-hull/TemperatureSlider.svelte +46 -19
- package/dist/convex-hull/TemperatureSlider.svelte.d.ts +2 -1
- package/dist/convex-hull/demo-temperature.d.ts +6 -0
- package/dist/convex-hull/demo-temperature.js +36 -0
- package/dist/convex-hull/gas-thermodynamics.js +16 -5
- package/dist/convex-hull/helpers.d.ts +7 -1
- package/dist/convex-hull/helpers.js +45 -15
- package/dist/convex-hull/index.d.ts +15 -1
- package/dist/convex-hull/index.js +1 -0
- package/dist/convex-hull/thermodynamics.d.ts +8 -21
- package/dist/convex-hull/thermodynamics.js +106 -17
- package/dist/convex-hull/types.d.ts +7 -0
- package/dist/convex-hull/types.js +11 -0
- package/dist/coordination/CoordinationBarPlot.svelte +29 -46
- package/dist/element/BohrAtom.svelte +1 -1
- package/dist/element/data.js +2 -14
- package/dist/element/data.json.gz +0 -0
- package/dist/element/index.d.ts +1 -1
- package/dist/element/index.js +1 -0
- package/dist/element/types.d.ts +1 -0
- package/dist/fermi-surface/FermiSurface.svelte +21 -65
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
- package/dist/fermi-surface/compute.js +1 -21
- package/dist/fermi-surface/marching-cubes.d.ts +2 -13
- package/dist/fermi-surface/marching-cubes.js +2 -519
- package/dist/fermi-surface/parse.js +17 -23
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +1273 -0
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +110 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +171 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +31 -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 +119 -0
- package/dist/icons.js +119 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -1
- package/dist/io/export.js +15 -3
- 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/types.d.ts +1 -0
- package/dist/io/url-drop.d.ts +2 -0
- package/dist/io/url-drop.js +118 -0
- package/dist/isosurface/Isosurface.svelte +231 -0
- package/dist/isosurface/Isosurface.svelte.d.ts +8 -0
- package/dist/isosurface/IsosurfaceControls.svelte +273 -0
- package/dist/isosurface/IsosurfaceControls.svelte.d.ts +9 -0
- package/dist/isosurface/index.d.ts +5 -0
- package/dist/isosurface/index.js +6 -0
- package/dist/isosurface/parse.d.ts +6 -0
- package/dist/isosurface/parse.js +548 -0
- package/dist/isosurface/slice.d.ts +11 -0
- package/dist/isosurface/slice.js +145 -0
- package/dist/isosurface/types.d.ts +55 -0
- package/dist/isosurface/types.js +178 -0
- package/dist/labels.d.ts +2 -1
- package/dist/labels.js +1 -0
- package/dist/layout/InfoTag.svelte +62 -62
- package/dist/layout/SubpageGrid.svelte +74 -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 +226 -53
- package/dist/layout/json-tree/JsonTree.svelte +425 -51
- package/dist/layout/json-tree/JsonTree.svelte.d.ts +1 -1
- package/dist/layout/json-tree/JsonValue.svelte +218 -97
- package/dist/layout/json-tree/types.d.ts +27 -2
- package/dist/layout/json-tree/utils.d.ts +14 -1
- package/dist/layout/json-tree/utils.js +254 -0
- package/dist/marching-cubes.d.ts +14 -0
- package/dist/marching-cubes.js +519 -0
- package/dist/math.d.ts +8 -0
- package/dist/math.js +374 -7
- package/dist/overlays/ContextMenu.svelte +3 -2
- package/dist/overlays/DraggablePane.svelte +163 -58
- package/dist/overlays/DraggablePane.svelte.d.ts +2 -0
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +232 -77
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -2
- package/dist/phase-diagram/PhaseDiagramControls.svelte +32 -11
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +3 -2
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +103 -0
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +15 -0
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +102 -95
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +7 -0
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +100 -26
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte.d.ts +6 -3
- package/dist/phase-diagram/index.d.ts +2 -0
- package/dist/phase-diagram/index.js +2 -0
- package/dist/phase-diagram/svg-to-diagram.d.ts +2 -0
- package/dist/phase-diagram/svg-to-diagram.js +865 -0
- package/dist/phase-diagram/types.d.ts +10 -0
- package/dist/phase-diagram/utils.d.ts +7 -4
- package/dist/phase-diagram/utils.js +149 -59
- package/dist/plot/AxisLabel.svelte +26 -0
- package/dist/plot/AxisLabel.svelte.d.ts +16 -0
- package/dist/plot/BarPlot.svelte +473 -228
- package/dist/plot/BarPlot.svelte.d.ts +3 -3
- package/dist/plot/BarPlotControls.svelte +3 -2
- package/dist/plot/BarPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ColorBar.svelte +54 -54
- package/dist/plot/ColorBar.svelte.d.ts +1 -1
- package/dist/plot/ElementScatter.svelte +4 -3
- package/dist/plot/FillArea.svelte +4 -1
- package/dist/plot/Histogram.svelte +320 -230
- package/dist/plot/Histogram.svelte.d.ts +2 -2
- package/dist/plot/HistogramControls.svelte +29 -10
- package/dist/plot/HistogramControls.svelte.d.ts +6 -2
- package/dist/plot/InteractiveAxisLabel.svelte.d.ts +2 -2
- package/dist/plot/PlotControls.svelte +109 -27
- package/dist/plot/PlotControls.svelte.d.ts +1 -1
- package/dist/plot/PlotLegend.svelte +1 -1
- package/dist/plot/PortalSelect.svelte +2 -1
- package/dist/plot/ReferenceLine.svelte +2 -1
- package/dist/plot/ReferenceLine.svelte.d.ts +1 -0
- package/dist/plot/ReferencePlane.svelte +1 -3
- package/dist/plot/ScatterPlot.svelte +343 -209
- package/dist/plot/ScatterPlot.svelte.d.ts +3 -3
- package/dist/plot/ScatterPlot3D.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlot3DControls.svelte +203 -250
- package/dist/plot/ScatterPlot3DScene.svelte +4 -7
- package/dist/plot/ScatterPlot3DScene.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlotControls.svelte +95 -55
- package/dist/plot/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ZeroLines.svelte +44 -0
- package/dist/plot/ZeroLines.svelte.d.ts +32 -0
- package/dist/plot/ZoomRect.svelte +21 -0
- package/dist/plot/ZoomRect.svelte.d.ts +8 -0
- package/dist/plot/axis-utils.d.ts +1 -1
- package/dist/plot/data-cleaning.js +1 -5
- 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 +10 -19
- package/dist/plot/layout.d.ts +7 -1
- package/dist/plot/layout.js +12 -4
- package/dist/plot/reference-line.d.ts +4 -21
- package/dist/plot/reference-line.js +7 -81
- package/dist/plot/types.d.ts +42 -17
- package/dist/plot/types.js +10 -0
- package/dist/plot/utils/label-placement.js +14 -11
- package/dist/plot/utils.d.ts +1 -0
- package/dist/plot/utils.js +14 -0
- package/dist/rdf/RdfPlot.svelte +55 -66
- package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
- package/dist/rdf/index.d.ts +1 -1
- package/dist/rdf/index.js +1 -1
- package/dist/settings.d.ts +5 -0
- package/dist/settings.js +37 -3
- package/dist/spectral/Bands.svelte +515 -143
- package/dist/spectral/Bands.svelte.d.ts +22 -2
- package/dist/spectral/helpers.d.ts +23 -1
- package/dist/spectral/helpers.js +65 -9
- package/dist/spectral/types.d.ts +2 -0
- package/dist/structure/AtomLegend.svelte +31 -10
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/CellSelect.svelte +92 -22
- package/dist/structure/Lattice.svelte +2 -0
- package/dist/structure/Structure.svelte +716 -173
- package/dist/structure/Structure.svelte.d.ts +7 -2
- package/dist/structure/StructureControls.svelte +26 -14
- package/dist/structure/StructureControls.svelte.d.ts +5 -1
- package/dist/structure/StructureInfoPane.svelte +7 -1
- package/dist/structure/StructureScene.svelte +386 -95
- package/dist/structure/StructureScene.svelte.d.ts +15 -4
- package/dist/structure/atom-properties.d.ts +6 -2
- package/dist/structure/atom-properties.js +38 -25
- package/dist/structure/export.js +10 -7
- 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 +1 -2
- package/dist/structure/index.d.ts +7 -0
- package/dist/structure/index.js +22 -0
- package/dist/structure/parse.js +19 -16
- package/dist/structure/partial-occupancy.d.ts +25 -0
- package/dist/structure/partial-occupancy.js +102 -0
- package/dist/structure/validation.js +6 -3
- package/dist/symmetry/SymmetryStats.svelte +18 -4
- package/dist/symmetry/WyckoffTable.svelte +18 -10
- package/dist/symmetry/index.d.ts +7 -4
- package/dist/symmetry/index.js +83 -18
- package/dist/table/HeatmapTable.svelte +468 -69
- package/dist/table/HeatmapTable.svelte.d.ts +13 -1
- package/dist/table/ToggleMenu.svelte +291 -44
- package/dist/table/ToggleMenu.svelte.d.ts +4 -1
- package/dist/table/index.d.ts +3 -0
- package/dist/tooltip/index.d.ts +1 -1
- package/dist/tooltip/index.js +1 -0
- package/dist/trajectory/Trajectory.svelte +147 -145
- package/dist/trajectory/TrajectoryExportPane.svelte +13 -9
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +1 -1
- package/dist/trajectory/constants.d.ts +6 -0
- package/dist/trajectory/constants.js +7 -0
- package/dist/trajectory/extract.js +3 -5
- 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 +339 -0
- package/dist/trajectory/helpers.d.ts +15 -0
- package/dist/trajectory/helpers.js +187 -0
- package/dist/trajectory/index.d.ts +1 -0
- package/dist/trajectory/index.js +11 -4
- package/dist/trajectory/parse/ase.d.ts +2 -0
- package/dist/trajectory/parse/ase.js +76 -0
- package/dist/trajectory/parse/hdf5.d.ts +2 -0
- package/dist/trajectory/parse/hdf5.js +121 -0
- package/dist/trajectory/parse/index.d.ts +12 -0
- package/dist/trajectory/parse/index.js +304 -0
- package/dist/trajectory/parse/lammps.d.ts +5 -0
- package/dist/trajectory/parse/lammps.js +169 -0
- package/dist/trajectory/parse/vasp.d.ts +2 -0
- package/dist/trajectory/parse/vasp.js +65 -0
- package/dist/trajectory/parse/xyz.d.ts +2 -0
- package/dist/trajectory/parse/xyz.js +109 -0
- package/dist/trajectory/types.d.ts +11 -0
- package/dist/trajectory/types.js +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +4 -0
- package/dist/xrd/XrdPlot.svelte +6 -4
- package/dist/xrd/calc-xrd.js +0 -1
- package/package.json +33 -23
- 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
|
@@ -4,8 +4,16 @@ import { DEFAULTS } from '../settings';
|
|
|
4
4
|
import { tooltip } from 'svelte-multiselect/attachments';
|
|
5
5
|
// Unique ID prefix to avoid conflicts when multiple instances on same page
|
|
6
6
|
const uid = crypto.randomUUID().slice(0, 8);
|
|
7
|
-
let { series = [], x_axis = $bindable({}), y_axis = $bindable({}), y2_axis = $bindable({}), display = $bindable({}), styles = $bindable({}), selected_series_idx = $bindable(0), on_touch, children, ...rest } = $props();
|
|
8
|
-
let
|
|
7
|
+
let { series = [], x_axis = $bindable({}), x2_axis = $bindable({}), y_axis = $bindable({}), y2_axis = $bindable({}), display = $bindable({}), styles = $bindable({}), selected_series_idx = $bindable(0), on_touch, children, ...rest } = $props();
|
|
8
|
+
let non_null_series = $derived(series.filter((srs) => srs != null));
|
|
9
|
+
let visible_series = $derived(non_null_series.filter((srs) => (srs.visible ?? true)));
|
|
10
|
+
let has_multiple_series = $derived(non_null_series.length > 1);
|
|
11
|
+
// Derive what marker types are present, and whether color/size are data-driven
|
|
12
|
+
const markers_include = (mode) => visible_series.some((srs) => (srs?.markers ?? `line+points`).includes(mode));
|
|
13
|
+
let has_any_lines = $derived(markers_include(`line`));
|
|
14
|
+
let has_any_points = $derived(markers_include(`points`));
|
|
15
|
+
let has_color_data = $derived(visible_series.some((srs) => srs?.color_values?.some((val) => val != null)));
|
|
16
|
+
let has_size_data = $derived(visible_series.some((srs) => srs?.size_values?.some((val) => val != null)));
|
|
9
17
|
$effect(() => {
|
|
10
18
|
styles.show_points ??= DEFAULTS.scatter.show_points;
|
|
11
19
|
styles.show_lines ??= DEFAULTS.scatter.show_lines;
|
|
@@ -17,30 +25,52 @@ const touch = ({ target }) => {
|
|
|
17
25
|
};
|
|
18
26
|
</script>
|
|
19
27
|
|
|
20
|
-
<PlotControls
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
<PlotControls
|
|
29
|
+
bind:x_axis
|
|
30
|
+
bind:x2_axis
|
|
31
|
+
bind:y_axis
|
|
32
|
+
bind:y2_axis
|
|
33
|
+
bind:display
|
|
34
|
+
show_controls
|
|
35
|
+
{...rest}
|
|
36
|
+
>
|
|
37
|
+
{@render children?.({
|
|
38
|
+
x_axis,
|
|
39
|
+
x2_axis,
|
|
40
|
+
y_axis,
|
|
41
|
+
y2_axis,
|
|
42
|
+
display,
|
|
43
|
+
styles,
|
|
44
|
+
selected_series_idx,
|
|
45
|
+
})}
|
|
46
|
+
{#if has_any_points || has_any_lines}
|
|
47
|
+
<SettingsSection
|
|
48
|
+
title="Markers"
|
|
49
|
+
current_values={{ show_points: styles.show_points, show_lines: styles.show_lines }}
|
|
50
|
+
on_reset={() => {
|
|
51
|
+
styles.show_points = DEFAULTS.scatter.show_points
|
|
52
|
+
styles.show_lines = DEFAULTS.scatter.show_lines
|
|
53
|
+
}}
|
|
54
|
+
style="display: flex; flex-wrap: wrap; gap: 1ex"
|
|
33
55
|
>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
56
|
+
{#if has_any_points}
|
|
57
|
+
<label
|
|
58
|
+
{@attach tooltip({ content: `Toggle visibility of data points in the scatter plot` })}
|
|
59
|
+
>
|
|
60
|
+
<input type="checkbox" bind:checked={styles.show_points} /> Show points
|
|
61
|
+
</label>
|
|
62
|
+
{/if}
|
|
63
|
+
{#if has_any_lines}
|
|
64
|
+
<label
|
|
65
|
+
{@attach tooltip({
|
|
66
|
+
content: `Toggle visibility of connecting lines between data points`,
|
|
67
|
+
})}
|
|
68
|
+
>
|
|
69
|
+
<input type="checkbox" bind:checked={styles.show_lines} /> Show lines
|
|
70
|
+
</label>
|
|
71
|
+
{/if}
|
|
72
|
+
</SettingsSection>
|
|
73
|
+
{/if}
|
|
44
74
|
|
|
45
75
|
{#snippet post_children()}
|
|
46
76
|
<!-- Series Selection (for multi-series style controls) -->
|
|
@@ -59,8 +89,8 @@ const touch = ({ target }) => {
|
|
|
59
89
|
</div>
|
|
60
90
|
{/if}
|
|
61
91
|
|
|
62
|
-
<!-- Point Style Controls -->
|
|
63
|
-
{#if styles.show_points}
|
|
92
|
+
<!-- Point Style Controls: only when points exist and are visible -->
|
|
93
|
+
{#if has_any_points && styles.show_points}
|
|
64
94
|
<SettingsSection
|
|
65
95
|
title="Point Style"
|
|
66
96
|
current_values={styles.point ?? {}}
|
|
@@ -71,28 +101,36 @@ const touch = ({ target }) => {
|
|
|
71
101
|
oninput={touch}
|
|
72
102
|
>
|
|
73
103
|
{#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
|
-
|
|
104
|
+
{#if !has_size_data}
|
|
105
|
+
<div class="pane-row" data-key="point.size">
|
|
106
|
+
<label for="{uid}-point-size">Size:</label>
|
|
107
|
+
<input
|
|
108
|
+
id="{uid}-point-size"
|
|
109
|
+
type="range"
|
|
110
|
+
min="1"
|
|
111
|
+
max="20"
|
|
112
|
+
step="0.5"
|
|
113
|
+
bind:value={styles.point.size}
|
|
114
|
+
/>
|
|
115
|
+
<input
|
|
116
|
+
type="number"
|
|
117
|
+
min="1"
|
|
118
|
+
max="20"
|
|
119
|
+
step="0.5"
|
|
120
|
+
bind:value={styles.point.size}
|
|
121
|
+
/>
|
|
122
|
+
</div>
|
|
123
|
+
{/if}
|
|
124
|
+
{#if !has_color_data}
|
|
125
|
+
<div class="pane-row" data-key="point.color">
|
|
126
|
+
<label for="{uid}-point-color">Color:</label>
|
|
127
|
+
<input
|
|
128
|
+
id="{uid}-point-color"
|
|
129
|
+
type="color"
|
|
130
|
+
bind:value={styles.point.color}
|
|
131
|
+
/>
|
|
132
|
+
</div>
|
|
133
|
+
{/if}
|
|
96
134
|
<div class="pane-row" data-key="point.opacity">
|
|
97
135
|
<label for="{uid}-point-opacity">Opacity:</label>
|
|
98
136
|
<input
|
|
@@ -159,8 +197,8 @@ const touch = ({ target }) => {
|
|
|
159
197
|
</SettingsSection>
|
|
160
198
|
{/if}
|
|
161
199
|
|
|
162
|
-
<!-- Line Style Controls -->
|
|
163
|
-
{#if styles.show_lines}
|
|
200
|
+
<!-- Line Style Controls: only when lines exist and are visible -->
|
|
201
|
+
{#if has_any_lines && styles.show_lines}
|
|
164
202
|
<SettingsSection
|
|
165
203
|
title="Line Style"
|
|
166
204
|
current_values={styles.line ?? {}}
|
|
@@ -189,10 +227,12 @@ const touch = ({ target }) => {
|
|
|
189
227
|
bind:value={styles.line.width}
|
|
190
228
|
/>
|
|
191
229
|
</div>
|
|
192
|
-
|
|
193
|
-
<
|
|
194
|
-
|
|
195
|
-
|
|
230
|
+
{#if !has_color_data}
|
|
231
|
+
<div class="pane-row" data-key="line.color">
|
|
232
|
+
<label for="{uid}-line-color">Color:</label>
|
|
233
|
+
<input id="{uid}-line-color" type="color" bind:value={styles.line.color} />
|
|
234
|
+
</div>
|
|
235
|
+
{/if}
|
|
196
236
|
<div class="pane-row" data-key="line.opacity">
|
|
197
237
|
<label for="{uid}-line-opacity">Opacity:</label>
|
|
198
238
|
<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" | "x2_axis" | "y_axis" | "y2_axis" | "selected_series_idx" | "styles">;
|
|
16
16
|
type ScatterPlotControls = ReturnType<typeof ScatterPlotControls>;
|
|
17
17
|
export default ScatterPlotControls;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script lang="ts">import { get_scale_type_name } from './';
|
|
2
|
+
let { display, x_scale_fn, x2_scale_fn, y_scale_fn, y2_scale_fn, x_range, x2_range, y_range, y2_range, x_scale_type, x2_scale_type, y_scale_type, y2_scale_type, x_is_time = false, x2_is_time = false, has_x2 = false, has_y2 = false, width, height, pad, } = $props();
|
|
3
|
+
const spans_zero = (range) => Math.min(range[0], range[1]) <= 0 && Math.max(range[0], range[1]) >= 0;
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
{#if display.x_zero_line && get_scale_type_name(x_scale_type) !== `log` &&
|
|
7
|
+
!x_is_time && spans_zero(x_range)}
|
|
8
|
+
{@const zero_x = x_scale_fn(0)}
|
|
9
|
+
{#if isFinite(zero_x)}
|
|
10
|
+
<line class="zero-line" x1={zero_x} x2={zero_x} y1={pad.t} y2={height - pad.b} />
|
|
11
|
+
{/if}
|
|
12
|
+
{/if}
|
|
13
|
+
|
|
14
|
+
{#if display.x2_zero_line && has_x2 && x2_scale_fn && x2_range &&
|
|
15
|
+
get_scale_type_name(x2_scale_type) !== `log` && !x2_is_time && spans_zero(x2_range)}
|
|
16
|
+
{@const zero_x2 = x2_scale_fn(0)}
|
|
17
|
+
{#if isFinite(zero_x2)}
|
|
18
|
+
<line class="zero-line" x1={zero_x2} x2={zero_x2} y1={pad.t} y2={height - pad.b} />
|
|
19
|
+
{/if}
|
|
20
|
+
{/if}
|
|
21
|
+
|
|
22
|
+
{#if display.y_zero_line && get_scale_type_name(y_scale_type) !== `log` &&
|
|
23
|
+
spans_zero(y_range)}
|
|
24
|
+
{@const zero_y = y_scale_fn(0)}
|
|
25
|
+
{#if isFinite(zero_y)}
|
|
26
|
+
<line class="zero-line" x1={pad.l} x2={width - pad.r} y1={zero_y} y2={zero_y} />
|
|
27
|
+
{/if}
|
|
28
|
+
{/if}
|
|
29
|
+
|
|
30
|
+
{#if display.y2_zero_line && has_y2 && y2_scale_fn && y2_range &&
|
|
31
|
+
get_scale_type_name(y2_scale_type) !== `log` && spans_zero(y2_range)}
|
|
32
|
+
{@const zero_y2 = y2_scale_fn(0)}
|
|
33
|
+
{#if isFinite(zero_y2)}
|
|
34
|
+
<line class="zero-line" x1={pad.l} x2={width - pad.r} y1={zero_y2} y2={zero_y2} />
|
|
35
|
+
{/if}
|
|
36
|
+
{/if}
|
|
37
|
+
|
|
38
|
+
<style>
|
|
39
|
+
.zero-line {
|
|
40
|
+
stroke: var(--plot-zero-line-color, light-dark(black, white));
|
|
41
|
+
stroke-width: var(--plot-zero-line-width, 1);
|
|
42
|
+
opacity: var(--plot-zero-line-opacity, 0.3);
|
|
43
|
+
}
|
|
44
|
+
</style>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Vec2 } from '../math';
|
|
2
|
+
import { type ScaleType, type Sides } from './';
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
display: {
|
|
5
|
+
x_zero_line?: boolean;
|
|
6
|
+
x2_zero_line?: boolean;
|
|
7
|
+
y_zero_line?: boolean;
|
|
8
|
+
y2_zero_line?: boolean;
|
|
9
|
+
};
|
|
10
|
+
x_scale_fn: (val: number) => number;
|
|
11
|
+
x2_scale_fn?: (val: number) => number;
|
|
12
|
+
y_scale_fn: (val: number) => number;
|
|
13
|
+
y2_scale_fn?: (val: number) => number;
|
|
14
|
+
x_range: Vec2;
|
|
15
|
+
x2_range?: Vec2;
|
|
16
|
+
y_range: Vec2;
|
|
17
|
+
y2_range?: Vec2;
|
|
18
|
+
x_scale_type?: ScaleType;
|
|
19
|
+
x2_scale_type?: ScaleType;
|
|
20
|
+
y_scale_type?: ScaleType;
|
|
21
|
+
y2_scale_type?: ScaleType;
|
|
22
|
+
x_is_time?: boolean;
|
|
23
|
+
x2_is_time?: boolean;
|
|
24
|
+
has_x2?: boolean;
|
|
25
|
+
has_y2?: boolean;
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
pad: Required<Sides>;
|
|
29
|
+
};
|
|
30
|
+
declare const ZeroLines: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
31
|
+
type ZeroLines = ReturnType<typeof ZeroLines>;
|
|
32
|
+
export default ZeroLines;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts">let { start, current } = $props();
|
|
2
|
+
export {};
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
{#if start && current && isFinite(start.x) && isFinite(start.y) &&
|
|
6
|
+
isFinite(current.x) && isFinite(current.y)}
|
|
7
|
+
{@const x = Math.min(start.x, current.x)}
|
|
8
|
+
{@const y = Math.min(start.y, current.y)}
|
|
9
|
+
{@const rect_width = Math.abs(start.x - current.x)}
|
|
10
|
+
{@const rect_height = Math.abs(start.y - current.y)}
|
|
11
|
+
<rect class="zoom-rect" {x} {y} width={rect_width} height={rect_height} />
|
|
12
|
+
{/if}
|
|
13
|
+
|
|
14
|
+
<style>
|
|
15
|
+
.zoom-rect {
|
|
16
|
+
fill: var(--plot-zoom-rect-fill, rgba(100, 100, 255, 0.2));
|
|
17
|
+
stroke: var(--plot-zoom-rect-stroke, rgba(100, 100, 255, 0.8));
|
|
18
|
+
stroke-width: var(--plot-zoom-rect-stroke-width, 1);
|
|
19
|
+
pointer-events: none;
|
|
20
|
+
}
|
|
21
|
+
</style>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { XyObj } from './';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
start: XyObj | null;
|
|
4
|
+
current: XyObj | null;
|
|
5
|
+
};
|
|
6
|
+
declare const ZoomRect: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type ZoomRect = ReturnType<typeof ZoomRect>;
|
|
8
|
+
export default ZoomRect;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AxisConfig, AxisLoadError, BarSeries, DataLoaderFn, DataSeries } from './types';
|
|
2
|
-
type AxisType = `x` | `y` | `y2`;
|
|
2
|
+
type AxisType = `x` | `x2` | `y` | `y2`;
|
|
3
3
|
export declare function merge_series_state<T extends DataSeries | BarSeries>(old_series: T[], new_series: T[]): T[];
|
|
4
4
|
export interface AxisChangeState<T extends DataSeries | BarSeries> {
|
|
5
5
|
get_axis: (axis: AxisType) => AxisConfig;
|
|
@@ -264,7 +264,7 @@ function compute_savgol_coefficients(window, order) {
|
|
|
264
264
|
}
|
|
265
265
|
// Compute (V^T V)^-1 V^T using simple pseudoinverse
|
|
266
266
|
// For smoothing, we only need the first row (constant term coefficients)
|
|
267
|
-
const vtv =
|
|
267
|
+
const vtv = multiply_matrices(transpose(vandermonde), vandermonde);
|
|
268
268
|
const vtv_inv = invert_matrix(vtv);
|
|
269
269
|
if (!vtv_inv) {
|
|
270
270
|
// Fallback to uniform weights
|
|
@@ -815,10 +815,6 @@ function transpose(matrix) {
|
|
|
815
815
|
}
|
|
816
816
|
return result;
|
|
817
817
|
}
|
|
818
|
-
function multiply_transpose(a, b) {
|
|
819
|
-
const at = transpose(a);
|
|
820
|
-
return multiply_matrices(at, b);
|
|
821
|
-
}
|
|
822
818
|
function multiply_matrices(a, b) {
|
|
823
819
|
const rows_a = a.length;
|
|
824
820
|
const cols_a = a[0]?.length ?? 0;
|
package/dist/plot/index.d.ts
CHANGED
|
@@ -4,17 +4,19 @@ export interface TweenedOptions<T> {
|
|
|
4
4
|
easing?: (t: number) => number;
|
|
5
5
|
interpolate?: (a: T, b: T) => (t: number) => T;
|
|
6
6
|
}
|
|
7
|
+
export { default as AxisLabel } from './AxisLabel.svelte';
|
|
7
8
|
export { default as BarPlot } from './BarPlot.svelte';
|
|
8
9
|
export { default as BarPlotControls } from './BarPlotControls.svelte';
|
|
9
10
|
export { default as ColorBar } from './ColorBar.svelte';
|
|
10
11
|
export { default as ColorScaleSelect } from './ColorScaleSelect.svelte';
|
|
12
|
+
export * from './data-cleaning';
|
|
11
13
|
export { default as ElementScatter } from './ElementScatter.svelte';
|
|
12
14
|
export * from './fill-utils';
|
|
13
15
|
export { default as FillArea } from './FillArea.svelte';
|
|
14
16
|
export { default as Histogram } from './Histogram.svelte';
|
|
15
17
|
export { default as HistogramControls } from './HistogramControls.svelte';
|
|
16
|
-
export { default as InteractiveAxisLabel } from './InteractiveAxisLabel.svelte';
|
|
17
18
|
export * from './interactions';
|
|
19
|
+
export { default as InteractiveAxisLabel } from './InteractiveAxisLabel.svelte';
|
|
18
20
|
export * from './layout';
|
|
19
21
|
export { default as Line } from './Line.svelte';
|
|
20
22
|
export { default as PlotControls } from './PlotControls.svelte';
|
|
@@ -36,4 +38,6 @@ export { default as SpacegroupBarPlot } from './SpacegroupBarPlot.svelte';
|
|
|
36
38
|
export { default as Surface3D } from './Surface3D.svelte';
|
|
37
39
|
export * from './svg';
|
|
38
40
|
export * from './types';
|
|
39
|
-
export * from './
|
|
41
|
+
export * from './utils';
|
|
42
|
+
export { default as ZeroLines } from './ZeroLines.svelte';
|
|
43
|
+
export { default as ZoomRect } from './ZoomRect.svelte';
|
package/dist/plot/index.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
export { default as AxisLabel } from './AxisLabel.svelte';
|
|
1
2
|
export { default as BarPlot } from './BarPlot.svelte';
|
|
2
3
|
export { default as BarPlotControls } from './BarPlotControls.svelte';
|
|
3
4
|
export { default as ColorBar } from './ColorBar.svelte';
|
|
4
5
|
export { default as ColorScaleSelect } from './ColorScaleSelect.svelte';
|
|
6
|
+
export * from './data-cleaning';
|
|
5
7
|
export { default as ElementScatter } from './ElementScatter.svelte';
|
|
6
8
|
export * from './fill-utils';
|
|
7
9
|
export { default as FillArea } from './FillArea.svelte';
|
|
8
10
|
export { default as Histogram } from './Histogram.svelte';
|
|
9
11
|
export { default as HistogramControls } from './HistogramControls.svelte';
|
|
10
|
-
export { default as InteractiveAxisLabel } from './InteractiveAxisLabel.svelte';
|
|
11
12
|
export * from './interactions';
|
|
13
|
+
export { default as InteractiveAxisLabel } from './InteractiveAxisLabel.svelte';
|
|
12
14
|
export * from './layout';
|
|
13
15
|
export { default as Line } from './Line.svelte';
|
|
14
16
|
export { default as PlotControls } from './PlotControls.svelte';
|
|
@@ -30,4 +32,6 @@ export { default as SpacegroupBarPlot } from './SpacegroupBarPlot.svelte';
|
|
|
30
32
|
export { default as Surface3D } from './Surface3D.svelte';
|
|
31
33
|
export * from './svg';
|
|
32
34
|
export * from './types';
|
|
33
|
-
export * from './
|
|
35
|
+
export * from './utils';
|
|
36
|
+
export { default as ZeroLines } from './ZeroLines.svelte';
|
|
37
|
+
export { default as ZoomRect } from './ZoomRect.svelte';
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
y: number;
|
|
5
|
-
} | null;
|
|
1
|
+
import type { Vec2 } from '../math';
|
|
2
|
+
import type { XyObj, Y2SyncConfig, Y2SyncMode } from './types';
|
|
3
|
+
export declare function get_relative_coords(evt: MouseEvent): XyObj | null;
|
|
6
4
|
export declare function normalize_y2_sync(sync: Y2SyncConfig | Y2SyncMode | undefined): Y2SyncConfig;
|
|
7
|
-
export declare function sync_y2_range(y1_range:
|
|
8
|
-
export declare function pan_range(current:
|
|
9
|
-
export declare function pixels_to_data_delta(pixel_delta: number, data_range:
|
|
5
|
+
export declare function sync_y2_range(y1_range: Vec2, y2_base_range: Vec2, sync: Y2SyncConfig): Vec2;
|
|
6
|
+
export declare function pan_range(current: Vec2, delta: number): Vec2;
|
|
7
|
+
export declare function pixels_to_data_delta(pixel_delta: number, data_range: Vec2, pixel_range: number): number;
|
|
10
8
|
export declare const PINCH_ZOOM_THRESHOLD = 0.1;
|
|
11
|
-
export declare function expand_range_if_needed(current:
|
|
12
|
-
range:
|
|
9
|
+
export declare function expand_range_if_needed(current: Vec2, new_range: Vec2): {
|
|
10
|
+
range: Vec2;
|
|
13
11
|
changed: boolean;
|
|
14
12
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// Get relative coordinates from a mouse event
|
|
2
2
|
export function get_relative_coords(evt) {
|
|
3
3
|
const current_target = evt.currentTarget;
|
|
4
|
-
if (!current_target
|
|
4
|
+
if (!(current_target instanceof SVGElement))
|
|
5
5
|
return null;
|
|
6
|
-
}
|
|
7
6
|
const svg_box = current_target.getBoundingClientRect();
|
|
8
7
|
if (!svg_box)
|
|
9
8
|
return null;
|
|
@@ -27,7 +26,7 @@ export function sync_y2_range(y1_range, y2_base_range, sync) {
|
|
|
27
26
|
return y2_base_range;
|
|
28
27
|
// Synced: Y2 has exact same range as Y1
|
|
29
28
|
if (sync.mode === `synced`) {
|
|
30
|
-
return [
|
|
29
|
+
return [y1_range[0], y1_range[1]];
|
|
31
30
|
}
|
|
32
31
|
// Align: Position so align_val (default 0) is at same relative position on both axes
|
|
33
32
|
// Y2 range expands as needed to show all data while maintaining alignment
|
|
@@ -77,8 +76,7 @@ export const PINCH_ZOOM_THRESHOLD = 0.1;
|
|
|
77
76
|
// Helper to check if range is the default [0, 1] sentinel (no data)
|
|
78
77
|
// Note: min === 0 handles -0 correctly since -0 === 0 in JavaScript
|
|
79
78
|
const is_default_range = ([min, max]) => min === 0 && max === 1;
|
|
80
|
-
//
|
|
81
|
-
// Never shrink when data is hidden (preserves user's view context).
|
|
79
|
+
// Adopt the new data range, unless all series were hidden (sentinel [0, 1] fallback).
|
|
82
80
|
// NOTE: [0, 1] is the "no data" sentinel - when all series are hidden, auto ranges
|
|
83
81
|
// fall back to [0, 1]. Actual data spanning exactly [0, 1] is a rare edge case.
|
|
84
82
|
export function expand_range_if_needed(current, new_range) {
|
|
@@ -91,19 +89,12 @@ export function expand_range_if_needed(current, new_range) {
|
|
|
91
89
|
return { range: current, changed: false };
|
|
92
90
|
if (!current_valid)
|
|
93
91
|
return { range: new_range, changed: true };
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return current_is_default
|
|
99
|
-
? { range: new_range, changed: true }
|
|
100
|
-
: { range: current, changed: false };
|
|
92
|
+
// When all series are hidden, auto ranges fall back to [0, 1] sentinel.
|
|
93
|
+
// Don't shrink to that — preserve the current view so it doesn't jump.
|
|
94
|
+
if (!is_default_range(current) && is_default_range(new_range)) {
|
|
95
|
+
return { range: current, changed: false };
|
|
101
96
|
}
|
|
102
|
-
//
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
Math.max(current[1], new_range[1]),
|
|
106
|
-
];
|
|
107
|
-
const changed = expanded[0] !== current[0] || expanded[1] !== current[1];
|
|
108
|
-
return { range: expanded, changed };
|
|
97
|
+
// Otherwise adopt the new range directly (both expand and shrink)
|
|
98
|
+
const changed = new_range[0] !== current[0] || new_range[1] !== current[1];
|
|
99
|
+
return { range: new_range, changed };
|
|
109
100
|
}
|
package/dist/plot/layout.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ export declare function measure_text_width(text: string, font?: string): number;
|
|
|
5
5
|
export interface AutoPaddingConfig {
|
|
6
6
|
padding: Partial<Sides>;
|
|
7
7
|
default_padding: Required<Sides>;
|
|
8
|
+
x2_axis?: AxisConfig & {
|
|
9
|
+
tick_values?: (string | number)[];
|
|
10
|
+
};
|
|
8
11
|
y_axis?: AxisConfig & {
|
|
9
12
|
tick_values?: (string | number)[];
|
|
10
13
|
};
|
|
@@ -13,7 +16,10 @@ export interface AutoPaddingConfig {
|
|
|
13
16
|
};
|
|
14
17
|
label_gap?: number;
|
|
15
18
|
}
|
|
16
|
-
export declare const
|
|
19
|
+
export declare const measure_max_tick_width: (ticks: (string | number)[], format?: string) => number;
|
|
20
|
+
export declare const TICK_LABEL_HEIGHT = 16;
|
|
21
|
+
export declare const AXIS_LABEL_HEIGHT = 20;
|
|
22
|
+
export declare const calc_auto_padding: ({ padding, default_padding, x2_axis, y_axis, y2_axis, label_gap, }: AutoPaddingConfig) => Required<Sides>;
|
|
17
23
|
export declare function constrain_tooltip_position(cursor_x: number, cursor_y: number, tooltip_width: number, tooltip_height: number, viewport_width: number, viewport_height: number, options?: {
|
|
18
24
|
offset?: number;
|
|
19
25
|
offset_x?: number;
|
package/dist/plot/layout.js
CHANGED
|
@@ -22,18 +22,26 @@ export function measure_text_width(text, font = `12px sans-serif`) {
|
|
|
22
22
|
ctx.font = font;
|
|
23
23
|
return ctx.measureText(text).width;
|
|
24
24
|
}
|
|
25
|
-
//
|
|
26
|
-
const measure_max_tick_width = (ticks, format = ``) => ticks.length === 0 ? 0 : Math.max(...ticks.map((tick) => {
|
|
25
|
+
// Measure the widest formatted tick label. Used for auto-padding and label placement.
|
|
26
|
+
export const measure_max_tick_width = (ticks, format = ``) => ticks.length === 0 ? 0 : Math.max(...ticks.map((tick) => {
|
|
27
27
|
const label = typeof tick === `string` ? tick : format_value(tick, format);
|
|
28
28
|
return measure_text_width(label, `12px sans-serif`);
|
|
29
29
|
}));
|
|
30
|
-
|
|
30
|
+
// Estimated height of a single tick label line (font-size 0.8em ≈ 12px + leading)
|
|
31
|
+
export const TICK_LABEL_HEIGHT = 16;
|
|
32
|
+
// Estimated height of an axis label (font-size ~14px + margin)
|
|
33
|
+
export const AXIS_LABEL_HEIGHT = 20;
|
|
34
|
+
export const calc_auto_padding = ({ padding, default_padding, x2_axis = {}, y_axis = {}, y2_axis = {}, label_gap = LABEL_GAP_DEFAULT, }) => {
|
|
35
|
+
const x2_ticks = x2_axis.tick_values ?? [];
|
|
31
36
|
const y_ticks = y_axis.tick_values ?? [];
|
|
32
37
|
const y_format = y_axis.format ?? ``;
|
|
33
38
|
const y2_ticks = y2_axis.tick_values ?? [];
|
|
34
39
|
const y2_format = y2_axis.format ?? ``;
|
|
35
40
|
return {
|
|
36
|
-
t: padding.t ??
|
|
41
|
+
t: padding.t ??
|
|
42
|
+
(x2_ticks.length > 0
|
|
43
|
+
? Math.max(default_padding.t, TICK_LABEL_HEIGHT + label_gap + (x2_axis.label ? AXIS_LABEL_HEIGHT : 0))
|
|
44
|
+
: default_padding.t),
|
|
37
45
|
b: padding.b ?? default_padding.b,
|
|
38
46
|
l: padding.l ??
|
|
39
47
|
Math.max(default_padding.l, measure_max_tick_width(y_ticks, y_format) + label_gap),
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { RefLine, RefLine3D, RefLine3DBase, RefLineBase, RefLineValue, RefPlane, RefPlaneBase } from './types';
|
|
1
|
+
import type { RefLine, RefLineValue } from './types';
|
|
3
2
|
export type IndexedRefLine = RefLine & {
|
|
4
3
|
idx: number;
|
|
5
4
|
};
|
|
@@ -12,31 +11,15 @@ export interface RefLinesByZIndex {
|
|
|
12
11
|
}
|
|
13
12
|
export declare function group_ref_lines_by_z(lines: IndexedRefLine[]): RefLinesByZIndex;
|
|
14
13
|
export declare function normalize_value(value: RefLineValue): number;
|
|
15
|
-
export declare
|
|
16
|
-
export declare function horizontal_line(y_value: RefLineValue, opts?: Partial<RefLineBase>): RefLine;
|
|
17
|
-
export declare function vertical_line(x_value: RefLineValue, opts?: Partial<RefLineBase>): RefLine;
|
|
18
|
-
export declare function diagonal_line(slope: number, intercept: number, opts?: Partial<RefLineBase>): RefLine;
|
|
19
|
-
export declare function line_segment(p1: [RefLineValue, RefLineValue], p2: [RefLineValue, RefLineValue], opts?: Partial<RefLineBase>): RefLine;
|
|
20
|
-
export declare function line_through(p1: [RefLineValue, RefLineValue], p2: [RefLineValue, RefLineValue], opts?: Partial<RefLineBase>): RefLine;
|
|
21
|
-
export declare function horizontal_lines(values: RefLineValue[], opts?: Partial<RefLineBase>): RefLine[];
|
|
22
|
-
export declare function vertical_lines(values: RefLineValue[], opts?: Partial<RefLineBase>): RefLine[];
|
|
23
|
-
export declare function plane_xy(z_value: number, opts?: Partial<RefPlaneBase>): RefPlane;
|
|
24
|
-
export declare function plane_xz(y_value: number, opts?: Partial<RefPlaneBase>): RefPlane;
|
|
25
|
-
export declare function plane_yz(x_value: number, opts?: Partial<RefPlaneBase>): RefPlane;
|
|
26
|
-
export declare function plane_normal(normal: Vec3, point: Vec3, opts?: Partial<RefPlaneBase>): RefPlane;
|
|
27
|
-
export declare function plane_through_points(p1: Vec3, p2: Vec3, p3: Vec3, opts?: Partial<RefPlaneBase>): RefPlane;
|
|
28
|
-
export declare function line_x_axis(y_value: number, z_value: number, opts?: Partial<RefLine3DBase>): RefLine3D;
|
|
29
|
-
export declare function line_y_axis(x_value: number, z_value: number, opts?: Partial<RefLine3DBase>): RefLine3D;
|
|
30
|
-
export declare function line_z_axis(x_value: number, y_value: number, opts?: Partial<RefLine3DBase>): RefLine3D;
|
|
31
|
-
export declare function line_segment_3d(p1: [number, number, number], p2: [number, number, number], opts?: Partial<RefLine3DBase>): RefLine3D;
|
|
32
|
-
export declare function line_through_3d(p1: [number, number, number], p2: [number, number, number], opts?: Partial<RefLine3DBase>): RefLine3D;
|
|
14
|
+
export declare const normalize_point: (point: [RefLineValue, RefLineValue]) => [number, number];
|
|
33
15
|
export declare function resolve_line_endpoints(ref_line: RefLine, { x_min, x_max, y_min, y_max }: {
|
|
34
16
|
x_min: number;
|
|
35
17
|
x_max: number;
|
|
36
18
|
y_min: number;
|
|
37
19
|
y_max: number;
|
|
38
|
-
}, { x_scale, y_scale, y2_scale }: {
|
|
20
|
+
}, { x_scale, x2_scale, y_scale, y2_scale }: {
|
|
39
21
|
x_scale: (val: number) => number;
|
|
22
|
+
x2_scale?: (val: number) => number;
|
|
40
23
|
y_scale: (val: number) => number;
|
|
41
24
|
y2_scale?: (val: number) => number;
|
|
42
25
|
}): [number, number, number, number] | null;
|