@macrostrat/column-views 3.12.0 → 3.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/dist/age-axis.cjs +1 -2
- package/dist/age-axis.cjs.map +1 -1
- package/dist/age-axis.js +1 -2
- package/dist/age-axis.js.map +1 -1
- package/dist/age-model/details.cjs +2 -3
- package/dist/age-model/details.cjs.map +1 -1
- package/dist/age-model/details.js +2 -3
- package/dist/age-model/details.js.map +1 -1
- package/dist/age-model/surfaces.cjs +1 -2
- package/dist/age-model/surfaces.cjs.map +1 -1
- package/dist/age-model/surfaces.js +1 -2
- package/dist/age-model/surfaces.js.map +1 -1
- package/dist/column-views.css +17 -17
- package/dist/column.cjs +11 -1
- package/dist/column.cjs.map +1 -1
- package/dist/column.js +11 -1
- package/dist/column.js.map +1 -1
- package/dist/index.cjs +25 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/prepare-units/composite-scale.cjs +16 -6
- package/dist/prepare-units/composite-scale.cjs.map +1 -1
- package/dist/prepare-units/composite-scale.d.ts +1 -1
- package/dist/prepare-units/composite-scale.js +16 -6
- package/dist/prepare-units/composite-scale.js.map +1 -1
- package/dist/prepare-units/density.cjs +21 -13
- package/dist/prepare-units/density.cjs.map +1 -1
- package/dist/prepare-units/density.d.ts +18 -11
- package/dist/prepare-units/density.js +21 -13
- package/dist/prepare-units/density.js.map +1 -1
- package/dist/prepare-units/helpers.cjs +16 -1
- package/dist/prepare-units/helpers.cjs.map +1 -1
- package/dist/prepare-units/helpers.js +16 -1
- package/dist/prepare-units/helpers.js.map +1 -1
- package/dist/prepare-units/index.cjs.map +1 -1
- package/dist/prepare-units/index.js.map +1 -1
- package/dist/unit-details/age-range.cjs +14 -44
- package/dist/unit-details/age-range.cjs.map +1 -1
- package/dist/unit-details/age-range.d.ts +2 -18
- package/dist/unit-details/age-range.js +6 -44
- package/dist/unit-details/age-range.js.map +1 -1
- package/dist/unit-details/utils.cjs +0 -5
- package/dist/unit-details/utils.cjs.map +1 -1
- package/dist/unit-details/utils.js +0 -5
- package/dist/unit-details/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/age-model/details.ts +2 -2
- package/src/age-model/surfaces.ts +2 -2
- package/src/column.ts +17 -1
- package/src/prepare-units/composite-scale.ts +22 -9
- package/src/prepare-units/density.ts +36 -25
- package/src/prepare-units/helpers.ts +35 -1
- package/src/prepare-units/index.ts +0 -1
- package/src/unit-details/age-range.ts +13 -59
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DataField,
|
|
3
|
+
IntervalProportion,
|
|
3
4
|
IntervalShort,
|
|
4
5
|
IntervalTag,
|
|
5
6
|
type IntervalTagProps,
|
|
@@ -8,9 +9,17 @@ import {
|
|
|
8
9
|
} from "@macrostrat/data-components";
|
|
9
10
|
import { useMacrostratDefs } from "@macrostrat/data-provider";
|
|
10
11
|
import h from "./age-range.module.sass";
|
|
11
|
-
import {
|
|
12
|
+
import { formatRange } from "./utils";
|
|
12
13
|
import classNames from "classnames";
|
|
13
|
-
import {
|
|
14
|
+
import { useMemo } from "react";
|
|
15
|
+
|
|
16
|
+
// The interval tag, its proportion and single-age label live in
|
|
17
|
+
// `@macrostrat/data-components`; re-exported under their names here.
|
|
18
|
+
export {
|
|
19
|
+
AgeLabel,
|
|
20
|
+
getAge,
|
|
21
|
+
IntervalProportion as Proportion,
|
|
22
|
+
} from "@macrostrat/data-components";
|
|
14
23
|
|
|
15
24
|
export function AgeField({ unit, children, ...rest }) {
|
|
16
25
|
const [_b_age, _t_age, _unit] = getAgeRange(unit);
|
|
@@ -46,30 +55,6 @@ export function AgeRange({
|
|
|
46
55
|
});
|
|
47
56
|
}
|
|
48
57
|
|
|
49
|
-
export function AgeLabel({
|
|
50
|
-
age,
|
|
51
|
-
maximumFractionDigits = 2,
|
|
52
|
-
minimumFractionDigits = 0,
|
|
53
|
-
className,
|
|
54
|
-
}: {
|
|
55
|
-
age: number;
|
|
56
|
-
className?: string;
|
|
57
|
-
maximumFractionDigits?: number;
|
|
58
|
-
minimumFractionDigits?: number;
|
|
59
|
-
}) {
|
|
60
|
-
/** Component to display a single age value with unit conversion from
|
|
61
|
-
* Ma to ka or Ga as appropriate.
|
|
62
|
-
*/
|
|
63
|
-
const [value, unit] = getAge(age);
|
|
64
|
-
|
|
65
|
-
const _value = value.toLocaleString("en-US", {
|
|
66
|
-
maximumFractionDigits,
|
|
67
|
-
minimumFractionDigits,
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
return h(Value, { value: _value, unit, className });
|
|
71
|
-
}
|
|
72
|
-
|
|
73
58
|
export function Duration({
|
|
74
59
|
value,
|
|
75
60
|
maximumFractionDigits = 2,
|
|
@@ -179,11 +164,11 @@ export function IntervalProportions({
|
|
|
179
164
|
let p1: any = null;
|
|
180
165
|
|
|
181
166
|
if (_showProps !== false) {
|
|
182
|
-
p1 = h(
|
|
167
|
+
p1 = h(IntervalProportion, { value: t_prop });
|
|
183
168
|
|
|
184
169
|
if (i0 !== i1 || b_prop !== 0 || t_prop !== 1) {
|
|
185
170
|
// We have a single interval with undefined proportions
|
|
186
|
-
p0 = h(
|
|
171
|
+
p0 = h(IntervalProportion, { value: b_prop });
|
|
187
172
|
}
|
|
188
173
|
|
|
189
174
|
if (i0 === i1 && (b_prop !== 0 || t_prop !== 1)) {
|
|
@@ -221,19 +206,6 @@ function getProportion(age: number, interval: IntervalShort): number | null {
|
|
|
221
206
|
return (interval.b_age - age) / (interval.b_age - interval.t_age);
|
|
222
207
|
}
|
|
223
208
|
|
|
224
|
-
export function Proportion({ value }: { value: number }) {
|
|
225
|
-
let content: ReactNode | null = null;
|
|
226
|
-
if (value == 0) {
|
|
227
|
-
content = "base";
|
|
228
|
-
} else if (value == 1) {
|
|
229
|
-
content = "top";
|
|
230
|
-
} else {
|
|
231
|
-
content = formatProportion(value * 100) + "%";
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
return h("span.proportion", content);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
209
|
export function getAgeRange(_unit) {
|
|
238
210
|
let b_age = _unit.b_age;
|
|
239
211
|
let t_age = _unit.t_age;
|
|
@@ -251,21 +223,3 @@ export function getAgeRange(_unit) {
|
|
|
251
223
|
|
|
252
224
|
return [b_age, t_age, unit];
|
|
253
225
|
}
|
|
254
|
-
|
|
255
|
-
export function getAge(value) {
|
|
256
|
-
/** Get the age value in Ma, ka, or Ga as appropriate */
|
|
257
|
-
let unit = "Ma";
|
|
258
|
-
if (value < 0.8) {
|
|
259
|
-
unit = "ka";
|
|
260
|
-
value *= 1000;
|
|
261
|
-
if (value < 5) {
|
|
262
|
-
unit = "yr";
|
|
263
|
-
value *= 1000;
|
|
264
|
-
}
|
|
265
|
-
} else if (value > 1000) {
|
|
266
|
-
unit = "Ga";
|
|
267
|
-
value /= 1000;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
return [value, unit];
|
|
271
|
-
}
|