matterviz 0.3.5 → 0.3.7
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/MillerIndexInput.svelte +5 -5
- package/dist/api/optimade.js +3 -3
- package/dist/brillouin/BrillouinZone.svelte +5 -2
- package/dist/brillouin/BrillouinZone.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneExportPane.svelte +1 -3
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +1 -1
- package/dist/brillouin/BrillouinZoneScene.svelte +5 -5
- package/dist/brillouin/compute.js +21 -21
- package/dist/brillouin/index.d.ts +1 -1
- package/dist/brillouin/index.js +0 -1
- package/dist/brillouin/types.d.ts +8 -13
- package/dist/chempot-diagram/ChemPotDiagram.svelte +3 -3
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +3 -4
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +33 -34
- package/dist/chempot-diagram/compute.js +1 -7
- package/dist/chempot-diagram/temperature.d.ts +1 -1
- package/dist/chempot-diagram/temperature.js +1 -3
- package/dist/chempot-diagram/types.d.ts +4 -9
- package/dist/colors/index.js +5 -5
- package/dist/composition/Composition.svelte +2 -1
- package/dist/composition/Formula.svelte +7 -4
- package/dist/composition/FormulaFilter.svelte +1 -3
- package/dist/composition/format.js +4 -4
- package/dist/composition/parse.d.ts +2 -1
- package/dist/composition/parse.js +61 -46
- package/dist/convex-hull/ConvexHull2D.svelte +62 -51
- package/dist/convex-hull/ConvexHull3D.svelte +101 -90
- package/dist/convex-hull/ConvexHull4D.svelte +70 -58
- package/dist/convex-hull/ConvexHullControls.svelte +24 -35
- package/dist/convex-hull/ConvexHullInfoPane.svelte +8 -5
- package/dist/convex-hull/ConvexHullInfoPane.svelte.d.ts +2 -0
- package/dist/convex-hull/ConvexHullStats.svelte +9 -2
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +2 -0
- package/dist/convex-hull/GasPressureControls.svelte +7 -7
- package/dist/convex-hull/StructurePopup.svelte +65 -30
- package/dist/convex-hull/StructurePopup.svelte.d.ts +6 -6
- package/dist/convex-hull/TemperatureSlider.svelte +8 -5
- package/dist/convex-hull/barycentric-coords.d.ts +2 -2
- package/dist/convex-hull/barycentric-coords.js +2 -2
- package/dist/convex-hull/gas-thermodynamics.js +2 -4
- package/dist/convex-hull/helpers.d.ts +13 -2
- package/dist/convex-hull/helpers.js +37 -16
- package/dist/convex-hull/index.d.ts +1 -0
- package/dist/convex-hull/index.js +1 -0
- package/dist/convex-hull/thermodynamics.d.ts +2 -1
- package/dist/convex-hull/thermodynamics.js +7 -7
- package/dist/convex-hull/types.d.ts +15 -15
- package/dist/effects.svelte.d.ts +12 -0
- package/dist/effects.svelte.js +37 -0
- package/dist/element/BohrAtom.svelte +4 -4
- package/dist/element/data.json.gz.d.ts +3 -1
- package/dist/element/index.d.ts +1 -1
- package/dist/element/index.js +0 -1
- package/dist/fermi-surface/FermiSurface.svelte +4 -4
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceControls.svelte +15 -19
- package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte +8 -6
- package/dist/fermi-surface/compute.js +2 -2
- package/dist/fermi-surface/export.js +13 -26
- package/dist/fermi-surface/parse.js +8 -12
- package/dist/fermi-surface/types.d.ts +2 -5
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +21 -3
- package/dist/heatmap-matrix/index.js +6 -6
- package/dist/io/decompress.d.ts +2 -1
- package/dist/io/decompress.js +1 -1
- package/dist/io/export.js +1 -1
- package/dist/io/index.d.ts +1 -1
- package/dist/io/index.js +0 -1
- package/dist/io/url-drop.js +7 -1
- package/dist/isosurface/IsosurfaceControls.svelte +11 -25
- package/dist/isosurface/slice.js +1 -1
- package/dist/isosurface/types.js +12 -12
- package/dist/labels.d.ts +1 -1
- package/dist/labels.js +14 -11
- package/dist/layout/InfoTag.svelte +6 -4
- package/dist/layout/PropertyFilter.svelte +4 -2
- package/dist/layout/json-tree/JsonTree.svelte +22 -14
- package/dist/layout/json-tree/JsonValue.svelte +2 -2
- package/dist/layout/json-tree/types.d.ts +3 -2
- package/dist/layout/json-tree/types.js +0 -1
- package/dist/layout/json-tree/utils.d.ts +4 -4
- package/dist/layout/json-tree/utils.js +12 -20
- package/dist/marching-cubes.js +13 -15
- package/dist/math.d.ts +11 -1
- package/dist/math.js +15 -6
- package/dist/overlays/DragControlTab.svelte +98 -0
- package/dist/overlays/DragControlTab.svelte.d.ts +8 -0
- package/dist/overlays/DraggablePane.svelte +7 -84
- package/dist/overlays/index.d.ts +1 -0
- package/dist/overlays/index.js +1 -0
- package/dist/periodic-table/PeriodicTable.svelte +11 -11
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +4 -2
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramControls.svelte +4 -9
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +2 -10
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +2 -3
- package/dist/phase-diagram/TdbInfoPanel.svelte +3 -3
- package/dist/phase-diagram/build-diagram.js +11 -18
- package/dist/phase-diagram/diagram-input.d.ts +5 -9
- package/dist/phase-diagram/index.d.ts +2 -2
- package/dist/phase-diagram/index.js +0 -2
- package/dist/phase-diagram/parse.d.ts +2 -2
- package/dist/phase-diagram/parse.js +6 -10
- package/dist/phase-diagram/svg-to-diagram.js +15 -15
- package/dist/phase-diagram/types.d.ts +5 -11
- package/dist/phase-diagram/utils.d.ts +2 -2
- package/dist/phase-diagram/utils.js +9 -11
- package/dist/plot/BarPlot.svelte +162 -314
- package/dist/plot/BarPlot.svelte.d.ts +5 -4
- package/dist/plot/BarPlotControls.svelte.d.ts +1 -1
- package/dist/plot/BinnedScatterPlot.svelte +1114 -0
- package/dist/plot/BinnedScatterPlot.svelte.d.ts +66 -0
- package/dist/plot/ColorBar.svelte +19 -17
- package/dist/plot/ColorBar.svelte.d.ts +1 -1
- package/dist/plot/FillArea.svelte +2 -4
- package/dist/plot/FillArea.svelte.d.ts +1 -1
- package/dist/plot/Histogram.svelte +167 -281
- package/dist/plot/Histogram.svelte.d.ts +1 -1
- package/dist/plot/HistogramControls.svelte.d.ts +1 -1
- package/dist/plot/InteractiveAxisLabel.svelte +5 -3
- package/dist/plot/InteractiveAxisLabel.svelte.d.ts +1 -1
- package/dist/plot/PlotAxis.svelte +169 -0
- package/dist/plot/PlotAxis.svelte.d.ts +24 -0
- package/dist/plot/PlotControls.svelte.d.ts +1 -1
- package/dist/plot/ReferenceLine3D.svelte +53 -51
- package/dist/plot/ReferencePlane.svelte +39 -42
- package/dist/plot/ScatterPlot.svelte +300 -367
- package/dist/plot/ScatterPlot.svelte.d.ts +8 -5
- package/dist/plot/ScatterPlot3D.svelte +33 -6
- package/dist/plot/ScatterPlot3D.svelte.d.ts +3 -2
- package/dist/plot/ScatterPlot3DControls.svelte +9 -9
- package/dist/plot/ScatterPlotControls.svelte +3 -4
- package/dist/plot/ScatterPoint.svelte +18 -27
- package/dist/plot/ScatterPoint.svelte.d.ts +4 -3
- package/dist/plot/Surface3D.svelte +4 -7
- package/dist/plot/ZeroLines.svelte +2 -1
- package/dist/plot/ZeroLines.svelte.d.ts +2 -1
- package/dist/plot/ZoomRect.svelte +2 -2
- package/dist/plot/ZoomRect.svelte.d.ts +3 -3
- package/dist/plot/adaptive-density.d.ts +69 -0
- package/dist/plot/adaptive-density.js +191 -0
- package/dist/plot/auto-place.d.ts +43 -0
- package/dist/plot/auto-place.js +122 -0
- package/dist/plot/axis-utils.js +3 -5
- package/dist/plot/binned-scatter-types.d.ts +59 -0
- package/dist/plot/binned-scatter-types.js +1 -0
- package/dist/plot/data-cleaning.js +1 -1
- package/dist/plot/data-transform.js +1 -1
- package/dist/plot/fill-utils.d.ts +4 -9
- package/dist/plot/fill-utils.js +29 -44
- package/dist/plot/index.d.ts +4 -0
- package/dist/plot/index.js +2 -0
- package/dist/plot/interactions.d.ts +4 -4
- package/dist/plot/interactions.js +4 -3
- package/dist/plot/layout.d.ts +20 -2
- package/dist/plot/layout.js +59 -16
- package/dist/plot/reference-line.d.ts +1 -1
- package/dist/plot/reference-line.js +9 -11
- package/dist/plot/scales.d.ts +1 -1
- package/dist/plot/scales.js +20 -23
- package/dist/plot/types.d.ts +30 -58
- package/dist/plot/types.js +2 -6
- package/dist/plot/utils/label-placement.d.ts +24 -3
- package/dist/plot/utils/label-placement.js +82 -12
- package/dist/plot/utils/series-visibility.d.ts +8 -2
- package/dist/plot/utils/series-visibility.js +23 -5
- package/dist/rdf/RdfPlot.svelte +5 -5
- package/dist/rdf/calc-rdf.js +3 -3
- package/dist/sanitize.d.ts +2 -0
- package/dist/sanitize.js +2 -0
- package/dist/spectral/Bands.svelte +1 -1
- package/dist/spectral/BandsAndDos.svelte +22 -16
- package/dist/spectral/BrillouinBandsDos.svelte +20 -16
- package/dist/spectral/Dos.svelte +1 -1
- package/dist/spectral/helpers.d.ts +4 -2
- package/dist/spectral/helpers.js +44 -35
- package/dist/spectral/index.d.ts +1 -1
- package/dist/spectral/index.js +0 -1
- package/dist/structure/AtomLegend.svelte +23 -6
- package/dist/structure/AtomLegend.svelte.d.ts +1 -0
- package/dist/structure/CanvasTooltip.svelte +9 -9
- package/dist/structure/CanvasTooltip.svelte.d.ts +1 -1
- package/dist/structure/CellSelect.svelte +14 -16
- package/dist/structure/Structure.svelte +317 -68
- package/dist/structure/Structure.svelte.d.ts +4 -2
- package/dist/structure/StructureControls.svelte +20 -45
- package/dist/structure/StructureExportPane.svelte +2 -1
- package/dist/structure/StructureInfoPane.svelte +10 -8
- package/dist/structure/StructureScene.svelte +527 -177
- package/dist/structure/StructureScene.svelte.d.ts +5 -2
- package/dist/structure/atom-properties.js +4 -4
- package/dist/structure/bond-order-perception.js +115 -98
- package/dist/structure/bonding.d.ts +27 -1
- package/dist/structure/bonding.js +187 -16
- package/dist/structure/export.js +1 -1
- package/dist/structure/index.d.ts +3 -2
- package/dist/structure/index.js +0 -2
- package/dist/structure/parse.js +88 -59
- package/dist/symmetry/WyckoffTable.svelte +7 -0
- package/dist/symmetry/index.js +13 -14
- package/dist/table/HeatmapTable.svelte +45 -66
- package/dist/table/HeatmapTable.svelte.d.ts +1 -1
- package/dist/table/ToggleMenu.svelte +19 -10
- package/dist/theme/themes.mjs +12 -0
- package/dist/tooltip/index.d.ts +1 -1
- package/dist/tooltip/index.js +0 -1
- package/dist/trajectory/Trajectory.svelte +43 -15
- package/dist/trajectory/TrajectoryInfoPane.svelte +2 -2
- package/dist/trajectory/extract.js +1 -1
- package/dist/trajectory/frame-reader.js +4 -4
- package/dist/trajectory/helpers.d.ts +5 -4
- package/dist/trajectory/helpers.js +9 -17
- package/dist/trajectory/index.d.ts +2 -2
- package/dist/trajectory/index.js +2 -2
- package/dist/trajectory/parse/ase.js +4 -4
- package/dist/trajectory/parse/hdf5.js +1 -1
- package/dist/trajectory/parse/index.js +2 -3
- package/dist/trajectory/parse/lammps.js +1 -1
- package/dist/trajectory/parse/vasp.js +1 -1
- package/dist/trajectory/plotting.d.ts +1 -1
- package/dist/trajectory/plotting.js +38 -38
- package/dist/trajectory/types.d.ts +1 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +9 -0
- package/dist/xrd/calc-xrd.js +3 -4
- package/dist/xrd/parse.js +1 -1
- package/package.json +42 -22
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export type
|
|
1
|
+
import type { Vec2 } from '../math';
|
|
2
|
+
import type { CompUnit, PseudoBinaryMetadata, SpecialPoint, TempUnit } from './types';
|
|
3
|
+
export type DiagramPoint = Vec2;
|
|
4
|
+
export type TempRange = Vec2;
|
|
4
5
|
export type BoundElement = string | DiagramPoint;
|
|
5
6
|
export interface DiagramInputMeta {
|
|
6
7
|
components: [string, string];
|
|
@@ -19,12 +20,7 @@ export interface RegionInput {
|
|
|
19
20
|
bounds: BoundElement[];
|
|
20
21
|
label_position?: DiagramPoint;
|
|
21
22
|
}
|
|
22
|
-
export
|
|
23
|
-
id: string;
|
|
24
|
-
type: SpecialPointType;
|
|
25
|
-
position: DiagramPoint;
|
|
26
|
-
label?: string;
|
|
27
|
-
}
|
|
23
|
+
export type SpecialPointInput = SpecialPoint;
|
|
28
24
|
export interface DiagramInput {
|
|
29
25
|
meta: DiagramInputMeta;
|
|
30
26
|
curves: Record<string, DiagramPoint[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { build_diagram } from './build-diagram';
|
|
2
2
|
export * from './colors';
|
|
3
|
-
export * from './diagram-input';
|
|
3
|
+
export type * from './diagram-input';
|
|
4
4
|
export { default as IsobaricBinaryPhaseDiagram } from './IsobaricBinaryPhaseDiagram.svelte';
|
|
5
5
|
export * from './parse';
|
|
6
6
|
export { default as PhaseDiagramControls } from './PhaseDiagramControls.svelte';
|
|
@@ -9,5 +9,5 @@ export { default as PhaseDiagramExportPane } from './PhaseDiagramExportPane.svel
|
|
|
9
9
|
export { default as PhaseDiagramTooltip } from './PhaseDiagramTooltip.svelte';
|
|
10
10
|
export { parse_phase_diagram_svg } from './svg-to-diagram';
|
|
11
11
|
export { default as TdbInfoPanel } from './TdbInfoPanel.svelte';
|
|
12
|
-
export * from './types';
|
|
12
|
+
export type * from './types';
|
|
13
13
|
export * from './utils';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { build_diagram } from './build-diagram';
|
|
2
2
|
export * from './colors';
|
|
3
|
-
export * from './diagram-input';
|
|
4
3
|
export { default as IsobaricBinaryPhaseDiagram } from './IsobaricBinaryPhaseDiagram.svelte';
|
|
5
4
|
export * from './parse';
|
|
6
5
|
export { default as PhaseDiagramControls } from './PhaseDiagramControls.svelte';
|
|
@@ -9,5 +8,4 @@ export { default as PhaseDiagramExportPane } from './PhaseDiagramExportPane.svel
|
|
|
9
8
|
export { default as PhaseDiagramTooltip } from './PhaseDiagramTooltip.svelte';
|
|
10
9
|
export { parse_phase_diagram_svg } from './svg-to-diagram';
|
|
11
10
|
export { default as TdbInfoPanel } from './TdbInfoPanel.svelte';
|
|
12
|
-
export * from './types';
|
|
13
11
|
export * from './utils';
|
|
@@ -50,6 +50,6 @@ export interface TdbParseResult {
|
|
|
50
50
|
temperature_range?: [number, number];
|
|
51
51
|
}
|
|
52
52
|
export declare function parse_tdb(content: string): TdbParseResult;
|
|
53
|
-
export declare
|
|
54
|
-
export declare
|
|
53
|
+
export declare const get_system_name: (elements: string[]) => string;
|
|
54
|
+
export declare const is_binary_system: (tdb_data: TdbData) => boolean;
|
|
55
55
|
export declare function normalize_system_name(input: string): string;
|
|
@@ -207,17 +207,13 @@ function parse_tdb_line(line, data) {
|
|
|
207
207
|
// TYPE_DEFINITION, DEFINE_SYSTEM_DEFAULT, etc. are ignored
|
|
208
208
|
}
|
|
209
209
|
// Get a normalized system name from elements (e.g., "AL-ZN" always alphabetically sorted)
|
|
210
|
-
export
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
.join(`-`);
|
|
216
|
-
}
|
|
210
|
+
export const get_system_name = (elements) => elements
|
|
211
|
+
.filter(is_real_element)
|
|
212
|
+
.map((el) => el.toUpperCase())
|
|
213
|
+
.sort()
|
|
214
|
+
.join(`-`);
|
|
217
215
|
// Check if a TDB file represents a binary system
|
|
218
|
-
export
|
|
219
|
-
return tdb_data.elements.map((el) => el.symbol).filter(is_real_element).length === 2;
|
|
220
|
-
}
|
|
216
|
+
export const is_binary_system = (tdb_data) => tdb_data.elements.map((el) => el.symbol).filter(is_real_element).length === 2;
|
|
221
217
|
// Predicate to filter out non-real elements (VA = vacancy, /- = electron)
|
|
222
218
|
const is_real_element = (sym) => sym !== `VA` && sym !== `/-`;
|
|
223
219
|
// Known element symbols for parsing concatenated system names (e.g., "CuMg" -> ["CU", "MG"])
|
|
@@ -124,10 +124,10 @@ function extract_mpds_scales(doc) {
|
|
|
124
124
|
// Note: value 100 appears in both filters (valid as 100 at% and 100°C).
|
|
125
125
|
// This is intentional — only endpoints are used for scale mapping.
|
|
126
126
|
const comp_vals = [
|
|
127
|
-
...new Set(numbers.filter((
|
|
127
|
+
...new Set(numbers.filter((value) => value >= 0 && value <= 100 && value % 10 === 0)),
|
|
128
128
|
].toSorted((a, b) => a - b);
|
|
129
129
|
const temp_vals = [
|
|
130
|
-
...new Set(numbers.filter((
|
|
130
|
+
...new Set(numbers.filter((value) => value >= 100 && value % 100 === 0 && value <= 3000)),
|
|
131
131
|
].toSorted((a, b) => a - b);
|
|
132
132
|
if (comp_vals.length < 2 || temp_vals.length < 2) {
|
|
133
133
|
throw new Error(`MPDS SVG: could not infer axis ranges (found ${comp_vals.length} composition, ${temp_vals.length} temperature values)`);
|
|
@@ -164,10 +164,10 @@ function extract_mpds_scales(doc) {
|
|
|
164
164
|
}
|
|
165
165
|
// Deduplicate and sort
|
|
166
166
|
const x_ticks_sorted = [
|
|
167
|
-
...new Set(x_major_ticks.map((
|
|
167
|
+
...new Set(x_major_ticks.map((value) => Math.round(value * 10) / 10)),
|
|
168
168
|
].toSorted((a, b) => a - b);
|
|
169
169
|
const y_ticks_sorted = [
|
|
170
|
-
...new Set(y_major_ticks.map((
|
|
170
|
+
...new Set(y_major_ticks.map((value) => Math.round(value * 10) / 10)),
|
|
171
171
|
].toSorted((a, b) => a - b);
|
|
172
172
|
if (x_ticks_sorted.length < 2 || y_ticks_sorted.length < 2) {
|
|
173
173
|
throw new Error(`MPDS SVG: could not find tick marks (found ${x_ticks_sorted.length} x-ticks, ${y_ticks_sorted.length} y-ticks)`);
|
|
@@ -432,45 +432,45 @@ function extract_simple_labels(doc, labels) {
|
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
434
|
// === Component Inference ===
|
|
435
|
+
const split_phase_label = (label) => label.text.split(/\s*\+\s*/);
|
|
435
436
|
// Infer binary components from region labels
|
|
436
437
|
function infer_components(labels) {
|
|
437
438
|
// Sort labels by x position, split each into phases
|
|
438
439
|
const sorted = labels.toSorted((a, b) => a.px_x - b.px_x);
|
|
439
440
|
if (sorted.length < 2)
|
|
440
441
|
return [`A`, `B`];
|
|
441
|
-
const
|
|
442
|
-
const
|
|
443
|
-
const rightmost = split(sorted[sorted.length - 1]);
|
|
442
|
+
const leftmost = split_phase_label(sorted[0]);
|
|
443
|
+
const rightmost = split_phase_label(sorted[sorted.length - 1]);
|
|
444
444
|
// Component A: the unique phase in the leftmost region that doesn't appear on the right
|
|
445
445
|
// For "La2NiO4 + La2O3", La2O3 is the pure A endpoint
|
|
446
446
|
let comp_a = `A`;
|
|
447
447
|
if (leftmost.length === 2) {
|
|
448
|
-
const right_phases = new Set(sorted.slice(-3).flatMap(
|
|
449
|
-
comp_a = leftmost.find((
|
|
448
|
+
const right_phases = new Set(sorted.slice(-3).flatMap(split_phase_label));
|
|
449
|
+
comp_a = leftmost.find((phase) => !right_phases.has(phase)) ?? leftmost[1] ?? `A`;
|
|
450
450
|
}
|
|
451
451
|
// Component B: the unique phase in the rightmost region that doesn't appear on the left
|
|
452
452
|
let comp_b = `B`;
|
|
453
453
|
if (rightmost.length === 2) {
|
|
454
|
-
const left_phases = new Set(sorted.slice(0, 3).flatMap(
|
|
455
|
-
comp_b = rightmost.find((
|
|
454
|
+
const left_phases = new Set(sorted.slice(0, 3).flatMap(split_phase_label));
|
|
455
|
+
comp_b = rightmost.find((phase) => !left_phases.has(phase)) ?? rightmost[1] ?? `B`;
|
|
456
456
|
}
|
|
457
457
|
return [comp_a, comp_b];
|
|
458
458
|
}
|
|
459
459
|
// === Region Inference ===
|
|
460
460
|
// Infer phase regions from orthogonal boundaries using flood-fill on a cell grid
|
|
461
461
|
function infer_regions(boundaries, labels, x_scale, y_scale) {
|
|
462
|
-
const verticals = boundaries.filter((
|
|
463
|
-
const horizontals = boundaries.filter((
|
|
462
|
+
const verticals = boundaries.filter((boundary) => boundary.orientation === `vertical`);
|
|
463
|
+
const horizontals = boundaries.filter((boundary) => boundary.orientation === `horizontal`);
|
|
464
464
|
// Collect all unique x and y coordinates (boundaries + domain edges)
|
|
465
465
|
const x_coords = collect_unique_sorted([
|
|
466
466
|
x_scale.domain[0],
|
|
467
467
|
x_scale.domain[1],
|
|
468
|
-
...verticals.map((
|
|
468
|
+
...verticals.map((boundary) => boundary.x1), // x1 === x2 for vertical
|
|
469
469
|
]);
|
|
470
470
|
const y_coords = collect_unique_sorted([
|
|
471
471
|
y_scale.domain[0],
|
|
472
472
|
y_scale.domain[1],
|
|
473
|
-
...horizontals.map((
|
|
473
|
+
...horizontals.map((boundary) => boundary.y1), // y1 === y2 for horizontal
|
|
474
474
|
]);
|
|
475
475
|
// Build cell grid: cells[col][row]
|
|
476
476
|
const n_cols = x_coords.length - 1;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Point2D, Vec2 } from '../math';
|
|
2
|
+
import type { LineStyle } from '../plot';
|
|
3
|
+
import type { Sides } from '../plot/layout';
|
|
2
4
|
import type { TooltipConfig, TooltipProp } from '../tooltip';
|
|
3
|
-
import type { Vec2 } from '../math.ts';
|
|
4
5
|
export type TempUnit = `K` | `°C` | `°F`;
|
|
5
6
|
export type CompUnit = `at%` | `wt%` | `mol%` | `fraction`;
|
|
6
7
|
export interface PhaseRegion {
|
|
@@ -15,11 +16,7 @@ export interface PhaseBoundary {
|
|
|
15
16
|
id: string;
|
|
16
17
|
type: BoundaryType;
|
|
17
18
|
points: Vec2[];
|
|
18
|
-
style?:
|
|
19
|
-
color?: string;
|
|
20
|
-
width?: number;
|
|
21
|
-
dash?: string;
|
|
22
|
-
};
|
|
19
|
+
style?: LineStyle;
|
|
23
20
|
label?: string;
|
|
24
21
|
}
|
|
25
22
|
export type SpecialPointType = `eutectic` | `peritectic` | `eutectoid` | `peritectoid` | `congruent` | `melting_point` | `custom`;
|
|
@@ -87,10 +84,7 @@ export interface PhaseHoverInfo {
|
|
|
87
84
|
region: PhaseRegion;
|
|
88
85
|
composition: number;
|
|
89
86
|
temperature: number;
|
|
90
|
-
position:
|
|
91
|
-
x: number;
|
|
92
|
-
y: number;
|
|
93
|
-
};
|
|
87
|
+
position: Point2D;
|
|
94
88
|
lever_rule?: LeverRuleResult;
|
|
95
89
|
vertical_lever_rule?: VerticalLeverRuleResult;
|
|
96
90
|
special_point?: SpecialPoint;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Vec2 } from '../math';
|
|
2
|
-
import type { Sides } from '../plot';
|
|
2
|
+
import type { Sides } from '../plot/layout';
|
|
3
3
|
import type { CompUnit, LeverRuleMode, LeverRuleResult, PhaseDiagramConfig, PhaseDiagramData, PhaseHoverInfo, PhaseRegion, TempUnit, VerticalLeverRuleResult } from './types';
|
|
4
4
|
export declare function convert_temp(value: number, from: TempUnit, to: TempUnit): number;
|
|
5
5
|
export declare const PHASE_DIAGRAM_DEFAULTS: Readonly<{
|
|
@@ -89,7 +89,7 @@ export declare function compute_label_properties(label: string, bounds: {
|
|
|
89
89
|
lines: string[];
|
|
90
90
|
scale: number;
|
|
91
91
|
};
|
|
92
|
-
export declare
|
|
92
|
+
export declare const transform_vertices: (vertices: Vec2[], x_scale: (val: number) => number, y_scale: (val: number) => number) => Vec2[];
|
|
93
93
|
export declare function format_composition(value: number, unit?: CompUnit, include_unit?: boolean): string;
|
|
94
94
|
export declare function format_temperature(value: number, unit?: TempUnit): string;
|
|
95
95
|
export declare function calculate_lever_rule(region: PhaseRegion, composition: number, temperature: number): LeverRuleResult | null;
|
|
@@ -76,10 +76,10 @@ export const PHASE_COLOR_HEX = {
|
|
|
76
76
|
};
|
|
77
77
|
// Derive RGB string format (e.g. "135, 206, 250") for custom alpha usage
|
|
78
78
|
export const PHASE_COLOR_RGB = Object.freeze(Object.fromEntries(Object.entries(PHASE_COLOR_HEX).map(([key, hex]) => {
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
return [key, `${
|
|
79
|
+
const red = parseInt(hex.slice(1, 3), 16);
|
|
80
|
+
const green = parseInt(hex.slice(3, 5), 16);
|
|
81
|
+
const blue = parseInt(hex.slice(5, 7), 16);
|
|
82
|
+
return [key, `${red}, ${green}, ${blue}`];
|
|
83
83
|
})));
|
|
84
84
|
// Derive rgba() format with default alpha using add_alpha
|
|
85
85
|
const PHASE_ALPHA = { two_phase: 0.5, default: 0.5, tie_line: 1 };
|
|
@@ -109,7 +109,7 @@ export function get_phase_color_key(name) {
|
|
|
109
109
|
if (lower === `l`)
|
|
110
110
|
return `liquid`; // exact match for shorthand "L"
|
|
111
111
|
for (const [patterns, key, prefix] of PHASE_PATTERNS) {
|
|
112
|
-
if (patterns.some((
|
|
112
|
+
if (patterns.some((pattern) => lower.includes(pattern)))
|
|
113
113
|
return key;
|
|
114
114
|
if (prefix && lower.startsWith(prefix))
|
|
115
115
|
return key;
|
|
@@ -129,7 +129,7 @@ export function get_multi_phase_gradient(name) {
|
|
|
129
129
|
return null;
|
|
130
130
|
const phases = name
|
|
131
131
|
.split(`+`)
|
|
132
|
-
.map((
|
|
132
|
+
.map((phase) => phase.trim())
|
|
133
133
|
.filter(Boolean);
|
|
134
134
|
if (phases.length < 2)
|
|
135
135
|
return null;
|
|
@@ -152,8 +152,8 @@ export function find_phase_at_point(composition, temperature, data) {
|
|
|
152
152
|
}
|
|
153
153
|
// SVG path generator using d3-shape
|
|
154
154
|
const path_line = line()
|
|
155
|
-
.x((
|
|
156
|
-
.y((
|
|
155
|
+
.x((point) => point[0])
|
|
156
|
+
.y((point) => point[1]);
|
|
157
157
|
// Generate closed SVG path for polygon regions (min 3 points)
|
|
158
158
|
export const generate_region_path = (vertices) => vertices.length < 3 ? `` : `${path_line(vertices)} Z`;
|
|
159
159
|
// Generate open SVG path for boundary curves (min 2 points)
|
|
@@ -222,9 +222,7 @@ function wrap_text(text, max_chars) {
|
|
|
222
222
|
return lines;
|
|
223
223
|
}
|
|
224
224
|
// Transform data coordinates to SVG coordinates using scale functions
|
|
225
|
-
export
|
|
226
|
-
return vertices.map(([comp, temp]) => [x_scale(comp), y_scale(temp)]);
|
|
227
|
-
}
|
|
225
|
+
export const transform_vertices = (vertices, x_scale, y_scale) => vertices.map(([comp, temp]) => [x_scale(comp), y_scale(temp)]);
|
|
228
226
|
// Format composition value for display
|
|
229
227
|
export function format_composition(value, unit = `at%`, include_unit = true) {
|
|
230
228
|
if (unit === `fraction`)
|