matterviz 0.1.12 → 0.1.13

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.
Files changed (195) hide show
  1. package/dist/ContextMenu.svelte +1 -1
  2. package/dist/ContextMenu.svelte.d.ts +3 -3
  3. package/dist/DraggablePane.svelte +10 -5
  4. package/dist/DraggablePane.svelte.d.ts +3 -3
  5. package/dist/FilePicker.svelte.d.ts +3 -3
  6. package/dist/Icon.svelte.d.ts +3 -3
  7. package/dist/Nav.svelte +76 -31
  8. package/dist/SettingsSection.svelte.d.ts +3 -3
  9. package/dist/Spinner.svelte +18 -29
  10. package/dist/Spinner.svelte.d.ts +3 -3
  11. package/dist/app.css +4 -0
  12. package/dist/bands/Bands.svelte +216 -0
  13. package/dist/bands/Bands.svelte.d.ts +16 -0
  14. package/dist/bands/BandsAndDos.svelte +26 -0
  15. package/dist/bands/BandsAndDos.svelte.d.ts +16 -0
  16. package/dist/bands/Dos.svelte +124 -0
  17. package/dist/bands/Dos.svelte.d.ts +18 -0
  18. package/dist/bands/helpers.d.ts +11 -0
  19. package/dist/bands/helpers.js +195 -0
  20. package/dist/bands/index.d.ts +5 -0
  21. package/dist/bands/index.js +6 -0
  22. package/dist/bands/types.d.ts +54 -0
  23. package/dist/bands/types.js +2 -0
  24. package/dist/brillouin/BrillouinZone.svelte +373 -0
  25. package/dist/brillouin/BrillouinZone.svelte.d.ts +57 -0
  26. package/dist/brillouin/BrillouinZoneControls.svelte +88 -0
  27. package/dist/brillouin/BrillouinZoneControls.svelte.d.ts +14 -0
  28. package/dist/brillouin/BrillouinZoneExportPane.svelte +129 -0
  29. package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +15 -0
  30. package/dist/brillouin/BrillouinZoneInfoPane.svelte +115 -0
  31. package/dist/brillouin/BrillouinZoneInfoPane.svelte.d.ts +13 -0
  32. package/dist/brillouin/BrillouinZoneScene.svelte +180 -0
  33. package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +34 -0
  34. package/dist/brillouin/compute.d.ts +7 -0
  35. package/dist/brillouin/compute.js +215 -0
  36. package/dist/brillouin/index.d.ts +7 -0
  37. package/dist/brillouin/index.js +7 -0
  38. package/dist/brillouin/types.d.ts +23 -0
  39. package/dist/brillouin/types.js +1 -0
  40. package/dist/composition/BarChart.svelte.d.ts +3 -3
  41. package/dist/composition/BubbleChart.svelte +7 -6
  42. package/dist/composition/BubbleChart.svelte.d.ts +3 -3
  43. package/dist/composition/Composition.svelte.d.ts +3 -3
  44. package/dist/composition/PieChart.svelte +1 -1
  45. package/dist/composition/PieChart.svelte.d.ts +3 -3
  46. package/dist/composition/parse.d.ts +3 -3
  47. package/dist/coordination/CoordinationBarPlot.svelte +241 -0
  48. package/dist/coordination/CoordinationBarPlot.svelte.d.ts +29 -0
  49. package/dist/coordination/calc-coordination.d.ts +15 -0
  50. package/dist/coordination/calc-coordination.js +66 -0
  51. package/dist/coordination/index.d.ts +8 -0
  52. package/dist/coordination/index.js +7 -0
  53. package/dist/element/BohrAtom.svelte.d.ts +3 -3
  54. package/dist/element/ElementHeading.svelte.d.ts +3 -3
  55. package/dist/element/ElementPhoto.svelte.d.ts +3 -3
  56. package/dist/element/ElementStats.svelte.d.ts +3 -3
  57. package/dist/element/ElementTile.svelte +1 -1
  58. package/dist/element/ElementTile.svelte.d.ts +4 -4
  59. package/dist/element/Nucleus.svelte.d.ts +3 -3
  60. package/dist/icons.d.ts +4 -0
  61. package/dist/icons.js +4 -0
  62. package/dist/index.d.ts +5 -1
  63. package/dist/index.js +5 -1
  64. package/dist/io/export.d.ts +1 -6
  65. package/dist/io/export.js +12 -12
  66. package/dist/labels.d.ts +19 -0
  67. package/dist/labels.js +59 -0
  68. package/dist/math.d.ts +7 -2
  69. package/dist/math.js +24 -12
  70. package/dist/periodic-table/PeriodicTable.svelte.d.ts +3 -3
  71. package/dist/periodic-table/PeriodicTableControls.svelte.d.ts +3 -3
  72. package/dist/periodic-table/PropertySelect.svelte +1 -1
  73. package/dist/periodic-table/PropertySelect.svelte.d.ts +5 -4
  74. package/dist/periodic-table/TableInset.svelte.d.ts +3 -3
  75. package/dist/phase-diagram/PhaseDiagram2D.svelte +44 -107
  76. package/dist/phase-diagram/PhaseDiagram2D.svelte.d.ts +7 -27
  77. package/dist/phase-diagram/PhaseDiagram3D.svelte +67 -170
  78. package/dist/phase-diagram/PhaseDiagram3D.svelte.d.ts +7 -31
  79. package/dist/phase-diagram/PhaseDiagram4D.svelte +87 -145
  80. package/dist/phase-diagram/PhaseDiagram4D.svelte.d.ts +5 -28
  81. package/dist/phase-diagram/PhaseDiagramControls.svelte +9 -9
  82. package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +6 -6
  83. package/dist/phase-diagram/PhaseDiagramInfoPane.svelte +4 -4
  84. package/dist/phase-diagram/PhaseDiagramInfoPane.svelte.d.ts +5 -5
  85. package/dist/phase-diagram/PhaseDiagramStats.svelte +9 -16
  86. package/dist/phase-diagram/PhaseDiagramStats.svelte.d.ts +3 -3
  87. package/dist/phase-diagram/StructurePopup.svelte.d.ts +3 -3
  88. package/dist/phase-diagram/barycentric-coords.js +13 -24
  89. package/dist/phase-diagram/helpers.d.ts +12 -14
  90. package/dist/phase-diagram/helpers.js +70 -23
  91. package/dist/phase-diagram/index.d.ts +58 -0
  92. package/dist/phase-diagram/index.js +44 -0
  93. package/dist/phase-diagram/thermodynamics.js +2 -3
  94. package/dist/phase-diagram/types.d.ts +3 -8
  95. package/dist/plot/BarPlot.svelte +474 -240
  96. package/dist/plot/BarPlot.svelte.d.ts +16 -37
  97. package/dist/plot/BarPlotControls.svelte +33 -201
  98. package/dist/plot/BarPlotControls.svelte.d.ts +11 -22
  99. package/dist/plot/ColorBar.svelte.d.ts +3 -3
  100. package/dist/plot/ColorScaleSelect.svelte +1 -1
  101. package/dist/plot/ColorScaleSelect.svelte.d.ts +3 -3
  102. package/dist/plot/ElementScatter.svelte +5 -5
  103. package/dist/plot/ElementScatter.svelte.d.ts +8 -8
  104. package/dist/plot/Histogram.svelte +318 -170
  105. package/dist/plot/Histogram.svelte.d.ts +21 -41
  106. package/dist/plot/HistogramControls.svelte +115 -347
  107. package/dist/plot/HistogramControls.svelte.d.ts +13 -28
  108. package/dist/plot/Line.svelte +1 -1
  109. package/dist/plot/Line.svelte.d.ts +4 -4
  110. package/dist/plot/PlotControls.svelte +280 -0
  111. package/dist/plot/PlotControls.svelte.d.ts +4 -0
  112. package/dist/plot/PlotLegend.svelte +9 -24
  113. package/dist/plot/PlotLegend.svelte.d.ts +3 -3
  114. package/dist/plot/ScatterPlot.svelte +536 -571
  115. package/dist/plot/ScatterPlot.svelte.d.ts +18 -90
  116. package/dist/plot/ScatterPlotControls.svelte +108 -316
  117. package/dist/plot/ScatterPlotControls.svelte.d.ts +11 -38
  118. package/dist/plot/ScatterPoint.svelte +1 -1
  119. package/dist/plot/ScatterPoint.svelte.d.ts +5 -5
  120. package/dist/plot/SpacegroupBarPlot.svelte +235 -0
  121. package/dist/plot/SpacegroupBarPlot.svelte.d.ts +9 -0
  122. package/dist/plot/data-transform.d.ts +2 -2
  123. package/dist/plot/data-transform.js +1 -5
  124. package/dist/plot/index.d.ts +12 -200
  125. package/dist/plot/index.js +14 -6
  126. package/dist/plot/layout.d.ts +10 -16
  127. package/dist/plot/layout.js +40 -25
  128. package/dist/plot/scales.d.ts +7 -8
  129. package/dist/plot/scales.js +22 -7
  130. package/dist/plot/types.d.ts +303 -0
  131. package/dist/plot/types.js +1 -0
  132. package/dist/rdf/RdfPlot.svelte +156 -0
  133. package/dist/rdf/RdfPlot.svelte.d.ts +20 -0
  134. package/dist/rdf/calc-rdf.d.ts +4 -0
  135. package/dist/rdf/calc-rdf.js +107 -0
  136. package/dist/rdf/index.d.ts +22 -0
  137. package/dist/rdf/index.js +2 -0
  138. package/dist/settings.d.ts +86 -75
  139. package/dist/settings.js +257 -155
  140. package/dist/structure/Bond.svelte +126 -110
  141. package/dist/structure/Bond.svelte.d.ts +7 -20
  142. package/dist/structure/CanvasTooltip.svelte.d.ts +4 -4
  143. package/dist/structure/Cylinder.svelte +29 -0
  144. package/dist/structure/Cylinder.svelte.d.ts +10 -0
  145. package/dist/structure/Lattice.svelte +1 -2
  146. package/dist/structure/Lattice.svelte.d.ts +3 -3
  147. package/dist/structure/Structure.svelte +23 -8
  148. package/dist/structure/Structure.svelte.d.ts +10 -7
  149. package/dist/structure/StructureControls.svelte +25 -134
  150. package/dist/structure/StructureControls.svelte.d.ts +4 -9
  151. package/dist/structure/StructureExportPane.svelte +188 -0
  152. package/dist/structure/StructureExportPane.svelte.d.ts +17 -0
  153. package/dist/structure/StructureInfoPane.svelte.d.ts +3 -3
  154. package/dist/structure/StructureLegend.svelte +91 -27
  155. package/dist/structure/StructureLegend.svelte.d.ts +5 -4
  156. package/dist/structure/StructureScene.svelte +93 -100
  157. package/dist/structure/StructureScene.svelte.d.ts +15 -12
  158. package/dist/structure/Vector.svelte +19 -25
  159. package/dist/structure/Vector.svelte.d.ts +3 -3
  160. package/dist/structure/bonding.d.ts +16 -14
  161. package/dist/structure/bonding.js +207 -216
  162. package/dist/structure/export.d.ts +3 -0
  163. package/dist/structure/export.js +120 -0
  164. package/dist/structure/index.d.ts +15 -1
  165. package/dist/structure/index.js +2 -0
  166. package/dist/symmetry/WyckoffTable.svelte.d.ts +3 -3
  167. package/dist/symmetry/index.d.ts +1 -0
  168. package/dist/symmetry/index.js +1 -0
  169. package/dist/symmetry/spacegroups.d.ts +9 -0
  170. package/dist/symmetry/spacegroups.js +397 -0
  171. package/dist/theme/ThemeControl.svelte.d.ts +3 -3
  172. package/dist/theme/themes.js +2 -16
  173. package/dist/trajectory/Trajectory.svelte +52 -78
  174. package/dist/trajectory/Trajectory.svelte.d.ts +5 -5
  175. package/dist/trajectory/TrajectoryError.svelte.d.ts +3 -3
  176. package/dist/trajectory/TrajectoryExportPane.svelte +1 -1
  177. package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +5 -5
  178. package/dist/trajectory/TrajectoryInfoPane.svelte +1 -1
  179. package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +3 -3
  180. package/dist/trajectory/extract.js +2 -1
  181. package/dist/trajectory/index.d.ts +1 -1
  182. package/dist/trajectory/index.js +1 -1
  183. package/dist/trajectory/parse.js +21 -14
  184. package/dist/utils.d.ts +1 -0
  185. package/dist/utils.js +17 -0
  186. package/dist/xrd/XrdPlot.svelte +14 -11
  187. package/dist/xrd/XrdPlot.svelte.d.ts +6 -5
  188. package/package.json +20 -12
  189. package/readme.md +1 -1
  190. package/dist/material/MaterialCard.svelte +0 -123
  191. package/dist/material/MaterialCard.svelte.d.ts +0 -9
  192. package/dist/material/index.d.ts +0 -1
  193. package/dist/material/index.js +0 -1
  194. package/dist/plot/formatting.d.ts +0 -7
  195. package/dist/plot/formatting.js +0 -53
@@ -1,48 +1,32 @@
1
- import { DraggablePane } from '..';
2
- import type { DataSeries } from './';
1
+ import type { AxisConfig, BarStyle } from './';
3
2
  import { PlotLegend } from './';
3
+ import type { BasePlotProps, DataSeries, DisplayConfig } from './types';
4
4
  import type { ComponentProps, Snippet } from 'svelte';
5
5
  import type { HTMLAttributes } from 'svelte/elements';
6
- import type { ScaleType, TicksOption } from './scales';
7
6
  type LegendConfig = ComponentProps<typeof PlotLegend>;
8
- interface Props extends HTMLAttributes<HTMLDivElement> {
7
+ type $$ComponentProps = HTMLAttributes<HTMLDivElement> & BasePlotProps & {
9
8
  series: DataSeries[];
10
- x_lim?: [number | null, number | null];
11
- y_lim?: [number | null, number | null];
12
- x_range?: [number | null, number | null];
13
- y_range?: [number | null, number | null];
14
- range_padding?: number;
9
+ x_axis?: AxisConfig;
10
+ y_axis?: AxisConfig;
11
+ y2_axis?: AxisConfig;
12
+ display?: DisplayConfig;
13
+ hovered?: boolean;
14
+ show_controls?: boolean;
15
+ controls_open?: boolean;
15
16
  bins?: number;
16
- x_label?: string;
17
- y_label?: string;
18
- x_format?: string;
19
- y_format?: string;
20
- x_scale_type?: ScaleType;
21
- y_scale_type?: ScaleType;
22
- padding?: {
23
- t: number;
24
- b: number;
25
- l: number;
26
- r: number;
27
- };
28
17
  show_legend?: boolean;
29
18
  legend?: LegendConfig | null;
30
- bar_opacity?: number;
31
- bar_stroke_width?: number;
32
- bar_color?: string;
19
+ bar?: BarStyle;
33
20
  selected_property?: string;
34
21
  mode?: `single` | `overlay`;
35
- show_zero_lines?: boolean;
36
- x_grid?: boolean | Record<string, unknown>;
37
- y_grid?: boolean | Record<string, unknown>;
38
- x_ticks?: TicksOption;
39
- y_ticks?: TicksOption;
40
- tooltip?: Snippet<[{
41
- value: number;
42
- count: number;
43
- property: string;
44
- }]>;
45
- hovered?: boolean;
22
+ tooltip?: Snippet<[
23
+ {
24
+ value: number;
25
+ count: number;
26
+ property: string;
27
+ axis: `y1` | `y2`;
28
+ }
29
+ ]>;
46
30
  change?: (data: {
47
31
  value: number;
48
32
  count: number;
@@ -60,12 +44,8 @@ interface Props extends HTMLAttributes<HTMLDivElement> {
60
44
  property: string;
61
45
  event: MouseEvent;
62
46
  } | null) => void;
63
- show_controls?: boolean;
64
- controls_open?: boolean;
65
- plot_controls?: Snippet<[]>;
66
47
  on_series_toggle?: (series_idx: number) => void;
67
- controls_toggle_props?: ComponentProps<typeof DraggablePane>[`toggle_props`];
68
- }
69
- declare const Histogram: import("svelte").Component<Props, {}, "mode" | "show_controls" | "show_zero_lines" | "x_grid" | "y_grid" | "x_format" | "y_format" | "x_scale_type" | "y_scale_type" | "x_ticks" | "y_ticks" | "show_legend" | "controls_open" | "hovered" | "series" | "bins" | "bar_opacity" | "bar_stroke_width" | "bar_color" | "selected_property">;
48
+ };
49
+ declare const Histogram: import("svelte").Component<$$ComponentProps, {}, "display" | "mode" | "bar" | "show_controls" | "show_legend" | "y_axis" | "y2_axis" | "series" | "x_axis" | "hovered" | "controls_open" | "bins" | "selected_property">;
70
50
  type Histogram = ReturnType<typeof Histogram>;
71
51
  export default Histogram;
@@ -1,371 +1,139 @@
1
- <script lang="ts">import { DraggablePane, SettingsSection } from '..';
1
+ <script lang="ts">import { SettingsSection } from '..';
2
+ import { PlotControls } from './';
2
3
  import { DEFAULTS } from '../settings';
3
- import { format } from 'd3-format';
4
- import { timeFormat } from 'd3-time-format';
5
- let { show_controls = $bindable(false), controls_open = $bindable(false), plot_controls, series = [], bins = $bindable(DEFAULTS.trajectory.histogram_bin_count), mode = $bindable(DEFAULTS.trajectory.histogram_mode), bar_opacity = $bindable(DEFAULTS.trajectory.histogram_bar_opacity), bar_stroke_width = $bindable(DEFAULTS.trajectory.histogram_bar_stroke_width), bar_color = $bindable(`#4682b4`), show_legend = $bindable(DEFAULTS.trajectory.histogram_show_legend),
6
- // Display controls
7
- show_zero_lines = $bindable(DEFAULTS.plot.show_zero_lines), x_grid = $bindable(DEFAULTS.plot.x_grid), y_grid = $bindable(DEFAULTS.plot.y_grid),
8
- // Scale type controls
9
- x_scale_type = $bindable(DEFAULTS.plot.x_scale_type), y_scale_type = $bindable(DEFAULTS.plot.y_scale_type),
10
- // Range controls
11
- x_range = $bindable(undefined), y_range = $bindable(undefined), auto_x_range = [0, 1], auto_y_range = [0, 1],
12
- // Tick controls
13
- x_ticks = $bindable(DEFAULTS.plot.x_ticks), y_ticks = $bindable(DEFAULTS.plot.y_ticks),
14
- // Format controls
15
- x_format = $bindable(DEFAULTS.plot.x_format), y_format = $bindable(DEFAULTS.plot.y_format), selected_property = $bindable(``), toggle_props, pane_props, } = $props();
16
- // Local variables for format inputs to prevent invalid values from reaching props
17
- let x_format_input = $state(x_format);
18
- let y_format_input = $state(y_format);
4
+ let { series = [], bins = $bindable(DEFAULTS.histogram.bin_count), mode = $bindable(DEFAULTS.histogram.mode), bar = $bindable({}), show_legend = $bindable(DEFAULTS.histogram.show_legend), selected_property = $bindable(``), x_axis = $bindable({}), y_axis = $bindable({}), y2_axis = $bindable({}), display = $bindable({}), show_controls = $bindable(false), controls_open = $bindable(false), auto_y2_range = undefined, ...rest } = $props();
5
+ // Initialize bar styles with defaults (runs once)
6
+ bar = { ...DEFAULTS.histogram.bar, ...bar };
19
7
  // Derived state
20
8
  let has_multiple_series = $derived(series.filter(Boolean).length > 1);
21
- let visible_series = $derived(series.filter((s) => s && (s.visible ?? true)));
22
- let series_options = $derived(visible_series.map((s) => s.label || `Series`));
23
- // Validation function for format specifiers
24
- function is_valid_format(format_string) {
25
- if (!format_string)
26
- return true; // Empty string is valid (uses default formatting)
27
- try {
28
- if (format_string.startsWith(`%`)) { // Time format validation
29
- timeFormat(format_string)(new Date());
30
- return true;
31
- }
32
- else { // Number format validation
33
- format(format_string)(123.456);
34
- return true;
35
- }
36
- }
37
- catch {
38
- return false;
39
- }
40
- }
41
- // Handle format input changes - only update prop if valid
42
- const format_input_handler = (format_type) => (event) => {
43
- const input = event.target;
44
- // Update local variable
45
- if (format_type === `x`)
46
- x_format_input = input.value;
47
- else if (format_type === `y`)
48
- y_format_input = input.value;
49
- // Only update prop if valid
50
- if (is_valid_format(input.value)) {
51
- input.classList.remove(`invalid`);
52
- if (format_type === `x`)
53
- x_format = input.value;
54
- else if (format_type === `y`)
55
- y_format = input.value;
56
- }
57
- else
58
- input.classList.add(`invalid`);
59
- };
60
- // Handle ticks input changes
61
- const ticks_input_handler = (axis) => (event) => {
62
- const input = event.target;
63
- const value = parseInt(input.value, 10);
64
- if (!isNaN(value) && value > 0) {
65
- if (axis === `x`)
66
- x_ticks = value;
67
- else if (axis === `y`)
68
- y_ticks = value;
69
- }
70
- };
71
- // Range control helpers
72
- const range_complete = (axis) => {
73
- const [min_el, max_el] = [`min`, `max`].map((b) => document.getElementById(`${axis}-range-${b}`));
74
- if (!min_el || !max_el)
75
- return;
76
- const [min, max] = [min_el, max_el].map((el) => (el.classList.remove(`invalid`), el.value === `` ? null : +el.value));
77
- const auto = { x: auto_x_range, y: auto_y_range }[axis];
78
- if (min !== null && max !== null && min >= max) {
79
- ;
80
- [min_el, max_el].forEach((el) => el.classList.add(`invalid`));
81
- return;
82
- }
83
- const ranges = {
84
- x: (r) => x_range = r,
85
- y: (r) => y_range = r,
86
- };
87
- ranges[axis](min === null && max === null ? undefined : [min ?? auto[0], max ?? auto[1]]);
88
- };
89
- const input_props = (axis, bound, range) => ({
90
- id: `${axis}-range-${bound}`,
91
- type: `number`,
92
- value: range?.[bound === `min` ? 0 : 1] ?? ``,
93
- placeholder: `auto`,
94
- class: `range-input`,
95
- onblur: () => range_complete(axis),
96
- onkeydown: (e) => e.key === `Enter` && e.target.blur(),
97
- });
98
- // Sync local format inputs with props
99
- $effect(() => {
100
- x_format_input = x_format;
101
- y_format_input = y_format;
102
- });
103
- // Update range inputs when ranges change
104
- $effect(() => [[x_range, `x`], [y_range, `y`]].forEach(([range, axis]) => {
105
- if (!range) {
106
- ;
107
- [`min`, `max`].forEach((b) => {
108
- const el = document.getElementById(`${axis}-range-${b}`);
109
- if (el)
110
- el.value = ``;
111
- });
112
- }
113
- }));
9
+ let visible_series = $derived(series.filter((srs) => srs && (srs.visible ?? true)));
10
+ let series_options = $derived(visible_series.map((srs) => srs.label || `Series`));
114
11
  </script>
115
12
 
116
- {#if show_controls}
117
- {@const toggle_style =
118
- `position: absolute; top: var(--ctrl-btn-top, 1ex); right: var(--ctrl-btn-right, 1ex); background-color: transparent;`}
119
- <DraggablePane
120
- bind:show={controls_open}
121
- closed_icon="Settings"
122
- open_icon="Cross"
123
- toggle_props={{
124
- title: `${controls_open ? `Close` : `Open`} histogram controls`,
125
- ...toggle_props,
126
- class: `histogram-controls-toggle ${toggle_props?.class ?? ``}`,
127
- style: `${toggle_style} ${toggle_props?.style ?? ``}`,
128
- }}
129
- pane_props={{
130
- ...pane_props,
131
- class: `histogram-controls-pane ${pane_props?.class ?? ``}`,
13
+ <PlotControls
14
+ bind:show_controls
15
+ bind:controls_open
16
+ bind:x_axis
17
+ bind:y_axis
18
+ bind:y2_axis
19
+ bind:display
20
+ {auto_y2_range}
21
+ {...rest}
22
+ >
23
+ <SettingsSection
24
+ title="Histogram"
25
+ current_values={{ bins, mode, show_legend }}
26
+ on_reset={() => {
27
+ ;({ bin_count: bins, mode, show_legend } = DEFAULTS.histogram)
132
28
  }}
133
29
  >
134
- {#if plot_controls}
135
- {@render plot_controls()}
136
- {:else}
137
- <SettingsSection
138
- title="Display"
139
- current_values={{ show_zero_lines, x_grid, y_grid }}
140
- on_reset={() => {
141
- show_zero_lines = DEFAULTS.plot.show_zero_lines
142
- x_grid = DEFAULTS.plot.x_grid
143
- y_grid = DEFAULTS.plot.y_grid
144
- }}
145
- style="display: flex; flex-wrap: wrap; gap: 1ex"
146
- >
147
- <label>
148
- <input type="checkbox" bind:checked={show_zero_lines} />
149
- Show zero lines
150
- </label>
151
- <label>
152
- <input type="checkbox" bind:checked={x_grid as boolean} />
153
- X-axis grid
154
- </label>
155
- <label>
156
- <input type="checkbox" bind:checked={y_grid as boolean} />
157
- Y-axis grid
30
+ <div class="pane-row">
31
+ <label>Bins:
32
+ <input
33
+ type="range"
34
+ min="5"
35
+ max="100"
36
+ step="5"
37
+ bind:value={bins}
38
+ />
39
+ </label>
40
+ <input type="number" min="5" max="100" step="5" bind:value={bins} />
41
+ </div>
42
+ {#if has_multiple_series}
43
+ <div class="pane-row">
44
+ <label>Mode:
45
+ <select bind:value={mode}>
46
+ <option value="single">Single</option>
47
+ <option value="overlay">Overlay</option>
48
+ </select>
158
49
  </label>
159
- </SettingsSection>
160
-
161
- <SettingsSection
162
- title="Axis Range"
163
- current_values={{ x_range, y_range }}
164
- on_reset={() => {
165
- x_range = undefined
166
- y_range = undefined
167
- }}
168
- class="pane-grid"
169
- style="grid-template-columns: repeat(4, max-content)"
170
- >
171
- <label for="x-range-min">X-axis:</label>
172
- <input {...input_props(`x`, `min`, x_range)} />
173
- &nbsp;to
174
- <input {...input_props(`x`, `max`, x_range)} />
175
- <label for="y-range-min">Y-axis:</label>
176
- <input {...input_props(`y`, `min`, y_range)} />
177
- &nbsp;to
178
- <input {...input_props(`y`, `max`, y_range)} />
179
- </SettingsSection>
180
-
181
- <SettingsSection
182
- title="Histogram"
183
- current_values={{ bins, mode, show_legend }}
184
- on_reset={() => {
185
- bins = DEFAULTS.trajectory.histogram_bin_count
186
- mode = DEFAULTS.trajectory.histogram_mode
187
- show_legend = DEFAULTS.trajectory.histogram_show_legend
188
- }}
189
- >
50
+ </div>
51
+ {#if mode === `single`}
190
52
  <div class="pane-row">
191
- <label for="bins-input">Bins:</label>
192
- <input
193
- id="bins-input"
194
- type="range"
195
- min="5"
196
- max="100"
197
- step="5"
198
- bind:value={bins}
199
- />
200
- <input
201
- type="number"
202
- min="5"
203
- max="100"
204
- step="5"
205
- bind:value={bins}
206
- />
207
- </div>
208
- {#if has_multiple_series}
209
- <div class="pane-row">
210
- <label for="mode-select">Mode:</label>
211
- <select bind:value={mode} id="mode-select">
212
- <option value="single">Single</option>
213
- <option value="overlay">Overlay</option>
53
+ <label>Property:
54
+ <select bind:value={selected_property}>
55
+ <option value="">All</option>
56
+ {#each series_options as option (option)}
57
+ <option value={option}>{option}</option>
58
+ {/each}
214
59
  </select>
215
- </div>
216
- {#if mode === `single`}
217
- <div class="pane-row">
218
- <label for="property-select">Property:</label>
219
- <select bind:value={selected_property} id="property-select">
220
- <option value="">All</option>
221
- {#each series_options as option (option)}
222
- <option value={option}>{option}</option>
223
- {/each}
224
- </select>
225
- </div>
226
- {/if}
227
- {/if}
228
- <label>
229
- <input type="checkbox" bind:checked={show_legend} />
230
- Show legend
231
- </label>
232
- </SettingsSection>
60
+ </label>
61
+ </div>
62
+ {/if}
63
+ {/if}
64
+ <label>
65
+ <input type="checkbox" bind:checked={show_legend} />
66
+ Show legend
67
+ </label>
68
+ </SettingsSection>
233
69
 
234
- <SettingsSection
235
- title="Bar Style"
236
- current_values={{ bar_opacity, bar_stroke_width, bar_color }}
237
- on_reset={() => {
238
- bar_opacity = DEFAULTS.trajectory.histogram_bar_opacity
239
- bar_stroke_width = DEFAULTS.trajectory.histogram_bar_stroke_width
240
- bar_color = `#4682b4`
241
- }}
242
- class="pane-grid"
243
- style="grid-template-columns: auto 1fr auto"
244
- >
245
- <label for="bar-opacity-range">Opacity:</label>
70
+ <SettingsSection
71
+ title="Bar Style"
72
+ current_values={bar}
73
+ on_reset={() => {
74
+ bar = { ...DEFAULTS.histogram.bar }
75
+ }}
76
+ class="pane-grid"
77
+ >
78
+ {#if bar}
79
+ {#if visible_series.length === 1}
80
+ <label>Fill: <input type="color" bind:value={bar.color} /></label>
81
+ {/if}
82
+ <label>Opacity:
83
+ <input type="range" min="0" max="1" step="0.05" bind:value={bar.opacity} />
84
+ <input type="number" min="0" max="1" step="0.05" bind:value={bar.opacity} />
85
+ </label>
86
+ <label>Stroke Width:
87
+ <input type="range" min="0" max="5" step="0.1" bind:value={bar.stroke_width} />
88
+ <input type="number" min="0" max="5" step="0.1" bind:value={bar.stroke_width} />
89
+ </label>
90
+ <label>Stroke Color:
91
+ <input type="color" bind:value={bar.stroke_color} />
246
92
  <input
247
- id="bar-opacity-range"
248
93
  type="range"
249
94
  min="0"
250
95
  max="1"
251
96
  step="0.05"
252
- bind:value={bar_opacity}
97
+ bind:value={bar.stroke_opacity}
98
+ title="Opacity"
253
99
  />
254
100
  <input
255
101
  type="number"
256
102
  min="0"
257
103
  max="1"
258
104
  step="0.05"
259
- bind:value={bar_opacity}
260
- />
261
- <label for="bar-stroke-width-range">Stroke Width:</label>
262
- <input
263
- id="bar-stroke-width-range"
264
- type="range"
265
- min="0"
266
- max="5"
267
- step="0.1"
268
- bind:value={bar_stroke_width}
105
+ bind:value={bar.stroke_opacity}
269
106
  />
270
- <input
271
- type="number"
272
- min="0"
273
- max="5"
274
- step="0.1"
275
- bind:value={bar_stroke_width}
276
- />
277
- {#if visible_series.length === 1}
278
- <label for="bar-color-input">Color:</label>
279
- <input
280
- id="bar-color-input"
281
- type="color"
282
- bind:value={bar_color}
283
- style="grid-column: 2 / 4"
284
- />
285
- {/if}
286
- </SettingsSection>
287
-
288
- <SettingsSection
289
- title="Scale Type"
290
- current_values={{ x_scale_type, y_scale_type }}
291
- on_reset={() => {
292
- x_scale_type = DEFAULTS.plot.x_scale_type as `linear` | `log`
293
- y_scale_type = DEFAULTS.plot.y_scale_type as `linear` | `log`
294
- }}
295
- class="pane-grid"
296
- style="grid-template-columns: auto 1fr"
297
- >
298
- <label for="x-scale-select">X-axis:</label>
299
- <select bind:value={x_scale_type} id="x-scale-select">
300
- <option value="linear">Linear</option>
301
- <option value="log">Log</option>
302
- </select>
303
- <label for="y-scale-select">Y-axis:</label>
304
- <select bind:value={y_scale_type} id="y-scale-select">
305
- <option value="linear">Linear</option>
306
- <option value="log">Log</option>
307
- </select>
308
- </SettingsSection>
309
-
310
- <SettingsSection
311
- title="Ticks"
312
- current_values={{ x_ticks, y_ticks }}
313
- on_reset={() => {
314
- x_ticks = DEFAULTS.plot.x_ticks
315
- y_ticks = DEFAULTS.plot.y_ticks
316
- }}
317
- class="pane-grid"
318
- style="grid-template-columns: auto 1fr"
319
- >
320
- <label for="x-ticks-input">X-axis:</label>
321
- <input
322
- id="x-ticks-input"
323
- type="number"
324
- min="2"
325
- max="20"
326
- step="1"
327
- value={typeof x_ticks === `number` ? x_ticks : 8}
328
- oninput={ticks_input_handler(`x`)}
329
- />
330
- <label for="y-ticks-input">Y-axis:</label>
331
- <input
332
- id="y-ticks-input"
333
- type="number"
334
- min="2"
335
- max="20"
336
- step="1"
337
- value={typeof y_ticks === `number` ? y_ticks : 6}
338
- oninput={ticks_input_handler(`y`)}
339
- />
340
- </SettingsSection>
341
-
342
- <SettingsSection
343
- title="Tick Format"
344
- current_values={{ x_format, y_format }}
345
- on_reset={() => {
346
- x_format = DEFAULTS.plot.x_format
347
- y_format = DEFAULTS.plot.y_format
348
- }}
349
- class="pane-grid"
350
- style="grid-template-columns: auto 1fr"
351
- >
352
- <label for="x-format">X-axis:</label>
353
- <input
354
- id="x-format"
355
- type="text"
356
- bind:value={x_format_input}
357
- placeholder=".2~s / .0% / %Y-%m-%d"
358
- oninput={format_input_handler(`x`)}
359
- />
360
- <label for="y-format">Y-axis:</label>
361
- <input
362
- id="y-format"
363
- type="text"
364
- bind:value={y_format_input}
365
- placeholder="d / .1e / .0%"
366
- oninput={format_input_handler(`y`)}
367
- />
368
- </SettingsSection>
107
+ </label>
369
108
  {/if}
370
- </DraggablePane>
371
- {/if}
109
+ </SettingsSection>
110
+
111
+ <SettingsSection
112
+ title="Scale Type"
113
+ current_values={{
114
+ x_scale_type: x_axis.scale_type,
115
+ y_scale_type: y_axis.scale_type,
116
+ y2_scale_type: y2_axis.scale_type,
117
+ }}
118
+ on_reset={() => {
119
+ x_axis.scale_type = DEFAULTS.plot.x_scale_type as `linear` | `log`
120
+ y_axis.scale_type = DEFAULTS.plot.y_scale_type as `linear` | `log`
121
+ y2_axis.scale_type = DEFAULTS.plot.y_scale_type as `linear` | `log`
122
+ }}
123
+ class="pane-grid"
124
+ style="grid-template-columns: 1fr 1fr"
125
+ >
126
+ <label>X: <select bind:value={x_axis.scale_type}>
127
+ <option value="linear">Linear</option>
128
+ <option value="log">Log</option>
129
+ </select></label>
130
+ <label>Y: <select bind:value={y_axis.scale_type}>
131
+ <option value="linear">Linear</option>
132
+ <option value="log">Log</option>
133
+ </select></label>
134
+ <label>Y2: <select bind:value={y2_axis.scale_type}>
135
+ <option value="linear">Linear</option>
136
+ <option value="log">Log</option>
137
+ </select></label>
138
+ </SettingsSection>
139
+ </PlotControls>
@@ -1,35 +1,20 @@
1
- import { DraggablePane } from '..';
2
- import type { DataSeries } from './';
3
- import type { ComponentProps, Snippet } from 'svelte';
4
- import type { TicksOption } from './scales';
5
- interface Props {
6
- show_controls?: boolean;
7
- controls_open?: boolean;
8
- plot_controls?: Snippet<[]>;
1
+ import type { AxisConfig, BarStyle, DataSeries } from './';
2
+ import type { DisplayConfig, PlotControlsProps } from './types';
3
+ type $$ComponentProps = Omit<PlotControlsProps, `children` | `post_children`> & {
9
4
  series?: readonly DataSeries[];
10
5
  bins?: number;
11
6
  mode?: `single` | `overlay`;
12
- bar_opacity?: number;
13
- bar_stroke_width?: number;
14
- bar_color?: string;
7
+ bar?: BarStyle;
15
8
  show_legend?: boolean;
16
- show_zero_lines?: boolean;
17
- x_grid?: boolean | Record<string, unknown>;
18
- y_grid?: boolean | Record<string, unknown>;
19
- x_scale_type?: `linear` | `log`;
20
- y_scale_type?: `linear` | `log`;
21
- x_range?: [number | null, number | null];
22
- y_range?: [number | null, number | null];
23
- auto_x_range?: [number, number];
24
- auto_y_range?: [number, number];
25
- x_ticks?: TicksOption;
26
- y_ticks?: TicksOption;
27
- x_format?: string;
28
- y_format?: string;
29
9
  selected_property?: string;
30
- toggle_props?: ComponentProps<typeof DraggablePane>[`toggle_props`];
31
- pane_props?: ComponentProps<typeof DraggablePane>[`pane_props`];
32
- }
33
- declare const HistogramControls: import("svelte").Component<Props, {}, "mode" | "show_controls" | "show_zero_lines" | "x_grid" | "y_grid" | "x_format" | "y_format" | "x_scale_type" | "y_scale_type" | "x_ticks" | "y_ticks" | "show_legend" | "controls_open" | "bins" | "bar_opacity" | "bar_stroke_width" | "bar_color" | "selected_property" | "x_range" | "y_range">;
10
+ x_axis?: AxisConfig;
11
+ y_axis?: AxisConfig;
12
+ y2_axis?: AxisConfig;
13
+ display?: DisplayConfig;
14
+ show_controls?: boolean;
15
+ controls_open?: boolean;
16
+ auto_y2_range?: [number, number];
17
+ };
18
+ declare const HistogramControls: import("svelte").Component<$$ComponentProps, {}, "display" | "mode" | "bar" | "show_controls" | "show_legend" | "y_axis" | "y2_axis" | "x_axis" | "controls_open" | "bins" | "selected_property">;
34
19
  type HistogramControls = ReturnType<typeof HistogramControls>;
35
20
  export default HistogramControls;
@@ -4,7 +4,7 @@ import { interpolatePath } from 'd3-interpolate-path';
4
4
  import { curveMonotoneX, line } from 'd3-shape';
5
5
  import { linear } from 'svelte/easing';
6
6
  import { Tween } from 'svelte/motion';
7
- let { points, origin = [0, 0], line_color = `rgba(255, 255, 255, 0.5)`, line_width = 2, area_color = `rgba(255, 255, 255, 0.1)`, area_stroke = null, line_tween = {}, line_dash = DEFAULTS.scatter.line_dash, ...rest } = $props();
7
+ let { points, origin = [0, 0], line_color = `rgba(255, 255, 255, 0.5)`, line_width = 2, area_color = `rgba(255, 255, 255, 0.1)`, area_stroke = null, line_tween = {}, line_dash = DEFAULTS.scatter.line.dash, ...rest } = $props();
8
8
  const lineGenerator = line()
9
9
  .x((point) => point[0])
10
10
  .y((point) => point[1])
@@ -1,6 +1,6 @@
1
+ import type { TweenedOptions } from './';
1
2
  import type { SVGAttributes } from 'svelte/elements';
2
- import { type TweenedOptions } from 'svelte/motion';
3
- interface Props extends Omit<SVGAttributes<SVGPathElement>, `origin` | `points`> {
3
+ type $$ComponentProps = Omit<SVGAttributes<SVGPathElement>, `origin` | `points`> & {
4
4
  points: readonly [number, number][];
5
5
  origin: [number, number];
6
6
  line_color?: string;
@@ -9,7 +9,7 @@ interface Props extends Omit<SVGAttributes<SVGPathElement>, `origin` | `points`>
9
9
  area_stroke?: string | null;
10
10
  line_tween?: TweenedOptions<string>;
11
11
  line_dash?: string;
12
- }
13
- declare const Line: import("svelte").Component<Props, {}, "">;
12
+ };
13
+ declare const Line: import("svelte").Component<$$ComponentProps, {}, "">;
14
14
  type Line = ReturnType<typeof Line>;
15
15
  export default Line;