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,39 +1,23 @@
1
- import { DraggablePane } from '..';
2
- import type { BarMode, BarSeries, BarTooltipProps, LegendConfig, Orientation, Sides } from './';
3
- import type { TicksOption } from './scales';
4
- import type { ComponentProps, Snippet } from 'svelte';
1
+ import type { AxisConfig, BarMode, BarSeries, BarStyle, BarTooltipProps, BasePlotProps, DisplayConfig, LegendConfig, LineStyle, Orientation, UserContentProps } from './';
2
+ import type { Snippet } from 'svelte';
5
3
  import type { HTMLAttributes } from 'svelte/elements';
6
- interface Props extends HTMLAttributes<HTMLDivElement> {
4
+ type $$ComponentProps = HTMLAttributes<HTMLDivElement> & BasePlotProps & {
7
5
  series?: BarSeries[];
6
+ x_axis?: AxisConfig;
7
+ y_axis?: AxisConfig;
8
+ y2_axis?: AxisConfig;
9
+ display?: DisplayConfig;
10
+ hovered?: boolean;
11
+ show_controls?: boolean;
12
+ controls_open?: boolean;
8
13
  orientation?: Orientation;
9
14
  mode?: BarMode;
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;
15
- x_label?: string;
16
- x_label_shift?: {
17
- x?: number;
18
- y?: number;
19
- };
20
- y_label?: string;
21
- y_label_shift?: {
22
- x?: number;
23
- y?: number;
24
- };
25
- x_format?: string;
26
- y_format?: string;
27
- x_ticks?: TicksOption;
28
- y_ticks?: TicksOption;
29
- x_grid?: boolean | Record<string, unknown>;
30
- y_grid?: boolean | Record<string, unknown>;
31
- show_zero_lines?: boolean;
32
15
  legend?: LegendConfig | null;
33
- padding?: Sides;
34
- default_bar_color?: string;
16
+ show_legend?: boolean;
17
+ bar?: BarStyle;
18
+ line?: LineStyle;
35
19
  tooltip?: Snippet<[BarTooltipProps]>;
36
- hovered?: boolean;
20
+ user_content?: Snippet<[UserContentProps]>;
37
21
  change?: (data: BarTooltipProps | null) => void;
38
22
  on_bar_click?: (data: BarTooltipProps & {
39
23
  event: MouseEvent | KeyboardEvent;
@@ -41,12 +25,7 @@ interface Props extends HTMLAttributes<HTMLDivElement> {
41
25
  on_bar_hover?: (data: BarTooltipProps & {
42
26
  event: MouseEvent;
43
27
  } | null) => void;
44
- show_controls?: boolean;
45
- controls_open?: boolean;
46
- plot_controls?: Snippet<[]>;
47
- controls_toggle_props?: ComponentProps<typeof DraggablePane>[`toggle_props`];
48
- children?: Snippet<[]>;
49
- }
50
- declare const BarPlot: import("svelte").Component<Props, {}, "orientation" | "mode" | "show_controls" | "show_zero_lines" | "x_grid" | "y_grid" | "x_format" | "y_format" | "x_ticks" | "y_ticks" | "controls_open" | "hovered" | "series" | "x_label" | "y_label" | "x_label_shift" | "y_label_shift">;
28
+ };
29
+ declare const BarPlot: import("svelte").Component<$$ComponentProps, {}, "display" | "line" | "orientation" | "mode" | "bar" | "show_controls" | "y_axis" | "y2_axis" | "series" | "x_axis" | "hovered" | "controls_open">;
51
30
  type BarPlot = ReturnType<typeof BarPlot>;
52
31
  export default BarPlot;
@@ -1,204 +1,36 @@
1
- <script lang="ts">import { DraggablePane, SettingsSection } from '..';
2
- import { DEFAULTS } from '../settings';
3
- let { show_controls = $bindable(false), controls_open = $bindable(false), orientation = $bindable(`vertical`), mode = $bindable(`overlay`), x_grid = $bindable(true), y_grid = $bindable(true), x_ticks = $bindable(8), y_ticks = $bindable(6), x_format = $bindable(``), y_format = $bindable(``), x_range = $bindable(undefined), y_range = $bindable(undefined), auto_x_range = [0, 1], auto_y_range = [0, 1], plot_controls, toggle_props, pane_props, } = $props();
4
- function set_auto_ranges() {
5
- x_range = [...auto_x_range];
6
- y_range = [...auto_y_range];
7
- }
8
- // Handlers similar to Histogram/Scatter controls
9
- const ticks_input_handler = (axis) => (event) => {
10
- const input = event.target;
11
- const value = parseInt(input.value, 10);
12
- if (!Number.isNaN(value) && value > 0) {
13
- if (axis === `x`)
14
- x_ticks = value;
15
- else
16
- y_ticks = value;
17
- }
18
- };
19
- // Element refs for per-instance range inputs
20
- const range_inputs = $state({
21
- x: { min: null, max: null },
22
- y: { min: null, max: null },
23
- });
24
- // Applies the min/max inputs for the given axis after blur/Enter.
25
- // - Validates the pair (min < max)
26
- // - When both inputs are empty, clears the bound range to fall back to auto
27
- // - If one side is empty, substitutes the corresponding auto bound
28
- const range_complete = (axis) => {
29
- const min_el = range_inputs[axis].min;
30
- const max_el = range_inputs[axis].max;
31
- if (!min_el || !max_el)
32
- return;
33
- [min_el, max_el].forEach((el) => el.classList.remove(`invalid`));
34
- const parse = (el) => (el.value === `` ? null : Number(el.value));
35
- const min_val = parse(min_el);
36
- const max_val = parse(max_el);
37
- if (min_val !== null && max_val !== null && min_val >= max_val) {
38
- min_el.classList.add(`invalid`);
39
- max_el.classList.add(`invalid`);
40
- return;
41
- }
42
- const final_range = min_val === null && max_val === null
43
- ? undefined
44
- : [min_val, max_val];
45
- if (axis === `x`)
46
- x_range = final_range;
47
- else
48
- y_range = final_range;
49
- };
50
- const input_props = (axis, bound, range) => ({
51
- type: `number`,
52
- value: range?.[bound === `min` ? 0 : 1] ?? ``,
53
- placeholder: `auto`,
54
- class: `range-input`,
55
- onblur: () => range_complete(axis),
56
- onkeydown: (e) => e.key === `Enter` && e.target.blur(),
57
- });
1
+ <script lang="ts">import { SettingsSection } from '..';
2
+ import { PlotControls } from './';
3
+ let { orientation = $bindable(`vertical`), mode = $bindable(`overlay`), x_axis = $bindable({}), y_axis = $bindable({}), y2_axis = $bindable({}), display = $bindable({}), show_controls = $bindable(false), controls_open = $bindable(false), ...rest } = $props();
58
4
  </script>
59
5
 
60
- {#if show_controls}
61
- {@const toggle_style =
62
- `position: absolute; top: var(--ctrl-btn-top, 1ex); right: var(--ctrl-btn-right, 1ex); background-color: transparent;`}
63
- <DraggablePane
64
- bind:show={controls_open}
65
- closed_icon="Settings"
66
- open_icon="Cross"
67
- toggle_props={{
68
- title: `${controls_open ? `Close` : `Open`} bar plot controls`,
69
- ...toggle_props,
70
- class: `bar-controls-toggle ${toggle_props?.class ?? ``}`,
71
- style: `${toggle_style} ${toggle_props?.style ?? ``}`,
72
- }}
73
- pane_props={{
74
- ...pane_props,
75
- class: `bar-controls-pane ${pane_props?.class ?? ``}`,
76
- style: `--pane-padding: 4px; --pane-gap: 4px; ${pane_props?.style ?? ``}`,
77
- }}
6
+ <PlotControls
7
+ bind:show_controls
8
+ bind:controls_open
9
+ bind:x_axis
10
+ bind:y_axis
11
+ bind:y2_axis
12
+ bind:display
13
+ {...rest}
14
+ >
15
+ <SettingsSection
16
+ title="Layout"
17
+ current_values={{ orientation, mode }}
18
+ style="display: flex; gap: 2ex"
78
19
  >
79
- {#if plot_controls}
80
- {@render plot_controls()}
81
- {:else}
82
- <SettingsSection
83
- title="Display"
84
- current_values={{ x_grid, y_grid }}
85
- on_reset={() => {
86
- x_grid = DEFAULTS.plot.x_grid
87
- y_grid = DEFAULTS.plot.y_grid
88
- }}
89
- >
90
- <label>
91
- <input type="checkbox" bind:checked={x_grid as boolean} /> X-axis grid
92
- </label>
93
- <label>
94
- <input type="checkbox" bind:checked={y_grid as boolean} /> Y-axis grid
95
- </label>
96
- </SettingsSection>
97
-
98
- <SettingsSection
99
- title="Layout"
100
- current_values={{ orientation, mode }}
101
- >
102
- <label>Orientation:
103
- <select bind:value={orientation} id="orientation-select">
104
- <option value="vertical">Vertical</option>
105
- <option value="horizontal">Horizontal</option>
106
- </select>
107
- </label>
108
- <label>Mode:
109
- <select bind:value={mode} id="mode-select">
110
- <option value="overlay">Overlay</option>
111
- <option value="stacked">Stacked</option>
112
- <option value="grouped">Grouped (Side-by-Side)</option>
113
- </select>
114
- </label>
115
- </SettingsSection>
116
-
117
- <SettingsSection
118
- title="Axis Range"
119
- current_values={{ x_range, y_range }}
120
- on_reset={() => {
121
- x_range = undefined
122
- y_range = undefined
123
- }}
124
- >
125
- <label>X-axis:
126
- <input
127
- {...input_props(`x`, `min`, x_range)}
128
- bind:this={range_inputs.x.min}
129
- />
130
- &nbsp;to
131
- <input
132
- {...input_props(`x`, `max`, x_range)}
133
- bind:this={range_inputs.x.max}
134
- />
135
- </label>
136
- <label>Y-axis:
137
- <input
138
- {...input_props(`y`, `min`, y_range)}
139
- bind:this={range_inputs.y.min}
140
- />
141
- &nbsp;to
142
- <input
143
- {...input_props(`y`, `max`, y_range)}
144
- bind:this={range_inputs.y.max}
145
- />
146
- </label>
147
- <button onclick={set_auto_ranges} style="margin-left: 8px">auto</button>
148
- </SettingsSection>
149
-
150
- <SettingsSection
151
- title="Ticks"
152
- current_values={{ x_ticks, y_ticks }}
153
- on_reset={() => {
154
- x_ticks = DEFAULTS.plot.x_ticks
155
- y_ticks = DEFAULTS.plot.y_ticks
156
- }}
157
- >
158
- <label>X-axis:
159
- <input
160
- type="number"
161
- min="2"
162
- max="20"
163
- step="1"
164
- value={typeof x_ticks === `number` ? x_ticks : 8}
165
- oninput={ticks_input_handler(`x`)}
166
- />
167
- </label>
168
- <label>Y-axis:
169
- <input
170
- type="number"
171
- min="2"
172
- max="20"
173
- step="1"
174
- value={typeof y_ticks === `number` ? y_ticks : 6}
175
- oninput={ticks_input_handler(`y`)}
176
- />
177
- </label>
178
- </SettingsSection>
179
-
180
- <SettingsSection
181
- title="Tick Format"
182
- current_values={{ x_format, y_format }}
183
- on_reset={() => {
184
- x_format = DEFAULTS.plot.x_format
185
- y_format = DEFAULTS.plot.y_format
186
- }}
187
- >
188
- <label>X-axis:
189
- <input type="text" bind:value={x_format} placeholder=".2~s / .0%" />
190
- </label>
191
- <label>Y-axis:
192
- <input type="text" bind:value={y_format} placeholder="d / .1e" />
193
- </label>
194
- </SettingsSection>
195
- {/if}
196
- </DraggablePane>
197
- {/if}
198
-
199
- <style>
200
- label {
201
- display: inline-flex !important;
202
- margin: 0 0 0 5pt;
203
- }
204
- </style>
20
+ <label style="flex: 1">
21
+ Orientation:
22
+ <select bind:value={orientation} id="orientation-select">
23
+ <option value="vertical">Vertical</option>
24
+ <option value="horizontal">Horizontal</option>
25
+ </select>
26
+ </label>
27
+ <label style="flex: 1">
28
+ Mode:
29
+ <select bind:value={mode} id="mode-select">
30
+ <option value="overlay">Overlay</option>
31
+ <option value="stacked">Stacked</option>
32
+ <option value="grouped">Grouped (Side-by-Side)</option>
33
+ </select>
34
+ </label>
35
+ </SettingsSection>
36
+ </PlotControls>
@@ -1,26 +1,15 @@
1
- import { DraggablePane } from '..';
2
- import type { BarMode, Orientation } from './';
3
- import type { TicksOption } from './scales';
4
- import type { ComponentProps, Snippet } from 'svelte';
5
- interface Props {
6
- show_controls?: boolean;
7
- controls_open?: boolean;
1
+ import type { AxisConfig, BarMode, DisplayConfig } from './';
2
+ import type { Orientation, PlotControlsProps } from './types';
3
+ type $$ComponentProps = Omit<PlotControlsProps, `children` | `post_children`> & {
8
4
  orientation?: Orientation;
9
5
  mode?: BarMode;
10
- x_grid?: boolean | Record<string, unknown>;
11
- y_grid?: boolean | Record<string, unknown>;
12
- x_ticks?: TicksOption;
13
- y_ticks?: TicksOption;
14
- x_format?: string;
15
- y_format?: string;
16
- x_range?: [number | null, number | null] | undefined;
17
- y_range?: [number | null, number | null] | undefined;
18
- auto_x_range?: [number, number];
19
- auto_y_range?: [number, number];
20
- plot_controls?: Snippet<[]> | undefined;
21
- toggle_props?: ComponentProps<typeof DraggablePane>[`toggle_props`];
22
- pane_props?: ComponentProps<typeof DraggablePane>[`pane_props`];
23
- }
24
- declare const BarPlotControls: import("svelte").Component<Props, {}, "orientation" | "mode" | "show_controls" | "x_grid" | "y_grid" | "x_format" | "y_format" | "x_ticks" | "y_ticks" | "controls_open" | "x_range" | "y_range">;
6
+ x_axis?: AxisConfig;
7
+ y_axis?: AxisConfig;
8
+ y2_axis?: AxisConfig;
9
+ display?: DisplayConfig;
10
+ show_controls?: boolean;
11
+ controls_open?: boolean;
12
+ };
13
+ declare const BarPlotControls: import("svelte").Component<$$ComponentProps, {}, "display" | "orientation" | "mode" | "show_controls" | "y_axis" | "y2_axis" | "x_axis" | "controls_open">;
25
14
  type BarPlotControls = ReturnType<typeof BarPlotControls>;
26
15
  export default BarPlotControls;
@@ -1,6 +1,6 @@
1
1
  import { type Orientation } from '..';
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
- interface Props extends HTMLAttributes<HTMLDivElement> {
3
+ type $$ComponentProps = HTMLAttributes<HTMLDivElement> & {
4
4
  title?: string;
5
5
  color_scale?: ((x: number) => string) | string | null;
6
6
  title_side?: `left` | `right` | `top` | `bottom`;
@@ -18,7 +18,7 @@ interface Props extends HTMLAttributes<HTMLDivElement> {
18
18
  scale_type?: `linear` | `log`;
19
19
  color_scale_fn?: (value: number) => string;
20
20
  color_scale_domain?: [number, number];
21
- }
22
- declare const ColorBar: import("svelte").Component<Props, {}, "color_scale" | "tick_labels" | "nice_range">;
21
+ };
22
+ declare const ColorBar: import("svelte").Component<$$ComponentProps, {}, "color_scale" | "tick_labels" | "nice_range">;
23
23
  type ColorBar = ReturnType<typeof ColorBar>;
24
24
  export default ColorBar;
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">import { ColorBar } from '..';
2
2
  import * as d3_sc from 'd3-scale-chromatic';
3
3
  import Select from 'svelte-multiselect';
4
- let { options = Object.keys(d3_sc).filter((key) => key.startsWith(`interpolate`)), value = $bindable(options[0]), selected = $bindable([]), minSelect = 0, placeholder = `Select a color scale`, colorbar = {}, ...rest } = $props();
4
+ let { options = Object.keys(d3_sc).filter((key) => key.startsWith(`interpolate`)), value = $bindable(options[0]), selected = $bindable([]), minSelect = 1, placeholder = `Select a color scale`, colorbar = {}, ...rest } = $props();
5
5
  </script>
6
6
 
7
7
  <Select
@@ -2,14 +2,14 @@ import { ColorBar } from '..';
2
2
  import type { ComponentProps } from 'svelte';
3
3
  import Select from 'svelte-multiselect';
4
4
  import type { D3InterpolateName } from '../colors';
5
- interface Props extends Omit<ComponentProps<typeof Select>, `options`> {
5
+ type $$ComponentProps = Omit<ComponentProps<typeof Select>, `options`> & {
6
6
  options?: D3InterpolateName[];
7
7
  value?: D3InterpolateName;
8
8
  selected?: D3InterpolateName[];
9
9
  minSelect?: number;
10
10
  placeholder?: string;
11
11
  colorbar?: ComponentProps<typeof ColorBar>;
12
- }
13
- declare const ColorScaleSelect: import("svelte").Component<Props, {}, "value" | "selected">;
12
+ };
13
+ declare const ColorScaleSelect: import("svelte").Component<$$ComponentProps, {}, "value" | "selected">;
14
14
  type ColorScaleSelect = ReturnType<typeof ColorScaleSelect>;
15
15
  export default ColorScaleSelect;
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">import { element_data, format_num, ScatterPlot } from '..';
2
2
  import { selected } from '../state.svelte';
3
- let { y, x_label = `Atomic Number`, y_label = ``, y_unit = ``, tooltip_point = $bindable(null), hovered = $bindable(false), y_format = `~s`, ...rest } = $props();
3
+ let { y, x_axis = $bindable({ label: `Atomic Number` }), y_axis = $bindable({ label: ``, format: `~s` }), y_unit = ``, tooltip_point = $bindable(null), hovered = $bindable(false), ...rest } = $props();
4
4
  // update tooltip on hover element tile
5
5
  $effect.pre(() => {
6
6
  if (selected.element?.number && !hovered) {
@@ -25,14 +25,14 @@ $effect.pre(() => {
25
25
  ]}
26
26
  bind:tooltip_point
27
27
  bind:hovered
28
- {x_label}
29
- {y_label}
30
- {y_format}
28
+ {x_axis}
29
+ {y_axis}
31
30
  color_bar={null}
31
+ padding={{ l: 45, r: 10, t: 0, b: 40 }}
32
32
  {...rest}
33
33
  >
34
34
  {#snippet tooltip({ x, y })}
35
35
  <strong>{x} - {element_data[x - 1]?.name}</strong><br />
36
- {y_label} = {format_num(y, y_format)}{y_unit ?? ``}
36
+ {y_axis.label} = {format_num(y, y_axis.format ?? `~s`)}{y_unit ?? ``}
37
37
  {/snippet}
38
38
  </ScatterPlot>
@@ -1,14 +1,14 @@
1
- import { type InternalPoint, ScatterPlot } from '..';
1
+ import type { AxisConfig, InternalPoint } from '..';
2
+ import { ScatterPlot } from '..';
2
3
  import type { ComponentProps } from 'svelte';
3
- interface Props extends ComponentProps<typeof ScatterPlot> {
4
+ type $$ComponentProps = ComponentProps<typeof ScatterPlot> & {
4
5
  y: number[];
5
- x_label?: string;
6
- y_label?: string;
7
- y_unit?: string;
6
+ x_axis?: AxisConfig;
7
+ y_axis?: AxisConfig;
8
+ y_unit?: string | null;
8
9
  tooltip_point?: InternalPoint | null;
9
10
  hovered?: boolean;
10
- y_format?: string;
11
- }
12
- declare const ElementScatter: import("svelte").Component<Props, {}, "hovered" | "tooltip_point">;
11
+ };
12
+ declare const ElementScatter: import("svelte").Component<$$ComponentProps, {}, "y_axis" | "x_axis" | "hovered" | "tooltip_point">;
13
13
  type ElementScatter = ReturnType<typeof ElementScatter>;
14
14
  export default ElementScatter;