Skip to content

Commit e85a508

Browse files
authored
Merge pull request #183 from UW-Macrostrat/column-updates
Column updates
2 parents ff48742 + 168f620 commit e85a508

File tree

125 files changed

+2759
-1191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+2759
-1191
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"publish:storybook": "./scripts/publish-storybook.sh",
1717
"format": "prettier --write .",
1818
"check-types": "tsc --noEmit",
19-
"check-circular": "madge --circular --extensions ts,tsx ."
19+
"check-circular": "madge --exclude __archive --circular --extensions ts,tsx ."
2020
},
2121
"author": "Daven Quinn",
2222
"license": "ISC",

packages/api-types/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to
77
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

9+
## [1.1.3] - 2025-11-28
10+
11+
- Update `MacrostratInterval` and `Interval` types
12+
913
## [1.1.2] - 2025-08-22
1014

1115
- Added types for `StratName` and `StratNameConcept`

packages/api-types/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@macrostrat/api-types",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"description": "Type definitions for Macrostrat's API",
55
"main": "./src/index.d.ts",
66
"types": "./src/index.d.ts",

packages/api-types/src/defs.d.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,22 @@ export interface MacrostratRef {
2323
t_units: number;
2424
}
2525

26-
export type Interval = {
26+
export type TimescaleRef = {
27+
timescale_id: number;
28+
name: string;
29+
};
30+
31+
export type MacrostratInterval = {
2732
int_id: number;
2833
name: string;
2934
abbrev?: string;
3035
t_age?: number;
3136
b_age?: number;
32-
timescales?: string[];
37+
int_type?: string;
38+
timescales?: TimescaleRef[];
3339
color: string;
3440
};
41+
42+
type Interval = MacrostratInterval;
43+
44+
export type { Interval };

packages/color-utils/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to
77
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

9+
## [1.1.2] - 2025-11-28
10+
11+
Updated Parcel bundler
12+
913
## [1.1.1] - 2025-06-25
1014

1115
Add `delta` parameter to `getLuminanceAdjustedColorScheme` to control the

packages/color-utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@macrostrat/color-utils",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "Color utility functions",
55
"type": "module",
66
"main": "dist/index.js",

packages/column-components/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format
44
is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this
55
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.3.1] - 2025-11-28
8+
9+
- Update axis components
10+
- Improve handling on nonlinear and discontinuous axes
11+
712
## [1.3.0] - 2025-10-29
813

914
- Switch to `@visx/axis` for axis rendering

packages/column-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@macrostrat/column-components",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "React rendering primitives for stratigraphic columns",
55
"keywords": [
66
"geology",

packages/column-components/src/axis.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useContext, useEffect, useRef } from "react";
22
import h from "./hyper";
33
import { select } from "d3-selection";
44
import { axisLeft } from "d3-axis";
5-
import { scaleLinear, ScaleLinear } from "d3-scale";
5+
import { ScaleContinuousNumeric, scaleLinear, ScaleLinear } from "d3-scale";
66
import { useColumn } from "./context";
77

88
interface ColumnAxisProps {
@@ -21,7 +21,8 @@ interface ColumnAxisProps {
2121
}
2222

2323
interface AgeAxisProps extends ColumnAxisProps {
24-
scale?: ScaleLinear<number, number>;
24+
scale?: ScaleContinuousNumeric<number, number>;
25+
minTickSpacing?: number;
2526
}
2627

2728
const __d3axisKeys = [
@@ -46,23 +47,33 @@ export function AgeAxis(props: AgeAxisProps) {
4647
className,
4748
showDomain = true,
4849
tickSpacing = 60,
50+
minTickSpacing = 20,
4951
scale,
5052
} = props;
5153

5254
const range = scale.range();
53-
const pixelHeight = Math.abs(range[0] - range[1]);
55+
56+
const pixelHeight = Math.abs(range[0] - range[range.length - 1]);
5457

5558
let tickValues: number[] = undefined;
5659

60+
let ticks = Math.max(Math.round(pixelHeight / tickSpacing), 2);
5761
if (pixelHeight < 3 * tickSpacing || scale.ticks(2).length < 2) {
5862
// Push ticks towards extrema
5963
const t0 = scale.ticks(4);
6064

6165
tickValues = [t0[0], t0[t0.length - 1]];
6266
}
6367

68+
if (pixelHeight < minTickSpacing) {
69+
ticks = 1;
70+
tickValues = scale.ticks(1);
71+
// Get the last tick value only
72+
tickValues = [tickValues[0]];
73+
}
74+
6475
const defaultProps = {
65-
ticks: Math.max(Math.round(pixelHeight / tickSpacing), 2),
76+
ticks,
6677
// Suppress domain endpoints
6778
tickSizeOuter: 0,
6879
tickValues,

packages/column-components/src/context/column.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { scaleLinear, ScaleContinuousNumeric, ScaleLinear } from "d3-scale";
22
import React, { createContext, useContext, useMemo } from "react";
33
import h from "@macrostrat/hyper";
44

5-
type HeightRange = [number, number];
5+
type HeightRange = number;
66
type ColumnScale = ScaleContinuousNumeric<HeightRange, number> | any;
77

8-
type ColumnScaleClamped = ScaleLinear<number, number>;
8+
type ColumnScaleClamped = ScaleContinuousNumeric<number, number>;
99

1010
export declare interface ColumnDivision {
1111
section_id: string;
@@ -55,6 +55,7 @@ export interface ColumnProviderProps<T extends ColumnDivision> {
5555
width?: number;
5656
axisType?: ColumnAxisType;
5757
children?: any;
58+
scale?: ColumnScale;
5859
}
5960

6061
function ColumnProvider<T extends ColumnDivision>(
@@ -75,6 +76,7 @@ function ColumnProvider<T extends ColumnDivision>(
7576
divisions = [],
7677
width = 150,
7778
axisType = ColumnAxisType.HEIGHT,
79+
scale: _scale,
7880
...rest
7981
} = props;
8082

@@ -103,9 +105,17 @@ function ColumnProvider<T extends ColumnDivision>(
103105
}
104106

105107
// same as the old `innerHeight`
106-
const pixelHeight = height * pixelsPerMeter * zoom;
107-
108-
const scale = scaleLinear().domain(range).range([pixelHeight, 0]);
108+
let scale = _scale;
109+
let pixelHeight: number;
110+
if (scale == null) {
111+
pixelHeight = height * pixelsPerMeter * zoom;
112+
scale = scaleLinear().domain(range).range([pixelHeight, 0]);
113+
} else {
114+
pixelHeight = Math.abs(scale.range()[1] - scale.range()[0]);
115+
// Remove any offset that might exist from paddings, scale breaks, etc.
116+
const r1 = scale.range().map((d) => d - scale.range()[0]);
117+
scale = _scale.copy().range(r1);
118+
}
109119
const scaleClamped = scale.copy().clamp(true);
110120

111121
return {

0 commit comments

Comments
 (0)