@macrostrat/column-views 3.9.0 → 3.11.0

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 (138) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/column-views.css +10 -0
  3. package/dist/correlation-chart/main.cjs +11 -3
  4. package/dist/correlation-chart/main.cjs.map +1 -1
  5. package/dist/correlation-chart/main.d.ts +1 -1
  6. package/dist/correlation-chart/main.js +11 -3
  7. package/dist/correlation-chart/main.js.map +1 -1
  8. package/dist/index.cjs +18 -42
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.ts +2 -1
  11. package/dist/index.js +4 -34
  12. package/dist/index.js.map +1 -1
  13. package/dist/unit-details/age-window-tag.cjs +68 -0
  14. package/dist/unit-details/age-window-tag.cjs.map +1 -0
  15. package/dist/unit-details/age-window-tag.d.ts +26 -0
  16. package/dist/unit-details/age-window-tag.js +66 -0
  17. package/dist/unit-details/age-window-tag.js.map +1 -0
  18. package/dist/unit-details/age-window-tag.module.sass.cjs +12 -0
  19. package/dist/unit-details/age-window-tag.module.sass.cjs.map +1 -0
  20. package/dist/unit-details/age-window-tag.module.sass.js +11 -0
  21. package/dist/unit-details/age-window-tag.module.sass.js.map +1 -0
  22. package/dist/unit-details/index.d.ts +1 -0
  23. package/dist/units/boxes.cjs +3 -3
  24. package/dist/units/boxes.cjs.map +1 -1
  25. package/dist/units/boxes.js +3 -3
  26. package/dist/units/boxes.js.map +1 -1
  27. package/dist/units/index.cjs +7 -11
  28. package/dist/units/index.cjs.map +1 -1
  29. package/dist/units/index.d.ts +0 -1
  30. package/dist/units/index.js +4 -9
  31. package/dist/units/index.js.map +1 -1
  32. package/package.json +6 -27
  33. package/src/correlation-chart/main.ts +14 -2
  34. package/src/index.ts +3 -1
  35. package/src/unit-details/age-window-tag.module.sass +10 -0
  36. package/src/unit-details/age-window-tag.ts +102 -0
  37. package/src/unit-details/index.ts +1 -0
  38. package/src/units/boxes.ts +7 -4
  39. package/src/units/index.ts +9 -26
  40. package/dist/maps/column-correlation/core.cjs +0 -288
  41. package/dist/maps/column-correlation/core.cjs.map +0 -1
  42. package/dist/maps/column-correlation/core.d.ts +0 -9
  43. package/dist/maps/column-correlation/core.js +0 -286
  44. package/dist/maps/column-correlation/core.js.map +0 -1
  45. package/dist/maps/column-correlation/index.d.ts +0 -2
  46. package/dist/maps/column-correlation/state.cjs +0 -193
  47. package/dist/maps/column-correlation/state.cjs.map +0 -1
  48. package/dist/maps/column-correlation/state.d.ts +0 -62
  49. package/dist/maps/column-correlation/state.js +0 -190
  50. package/dist/maps/column-correlation/state.js.map +0 -1
  51. package/dist/maps/column-navigation/index.d.ts +0 -2
  52. package/dist/maps/column-navigation/mapbox/index.cjs +0 -215
  53. package/dist/maps/column-navigation/mapbox/index.cjs.map +0 -1
  54. package/dist/maps/column-navigation/mapbox/index.d.ts +0 -38
  55. package/dist/maps/column-navigation/mapbox/index.js +0 -213
  56. package/dist/maps/column-navigation/mapbox/index.js.map +0 -1
  57. package/dist/maps/column-navigation/mapbox/keyboard-navigation.cjs +0 -105
  58. package/dist/maps/column-navigation/mapbox/keyboard-navigation.cjs.map +0 -1
  59. package/dist/maps/column-navigation/mapbox/keyboard-navigation.d.ts +0 -8
  60. package/dist/maps/column-navigation/mapbox/keyboard-navigation.js +0 -105
  61. package/dist/maps/column-navigation/mapbox/keyboard-navigation.js.map +0 -1
  62. package/dist/maps/column-navigation/mapbox/state.cjs +0 -73
  63. package/dist/maps/column-navigation/mapbox/state.cjs.map +0 -1
  64. package/dist/maps/column-navigation/mapbox/state.d.ts +0 -23
  65. package/dist/maps/column-navigation/mapbox/state.js +0 -71
  66. package/dist/maps/column-navigation/mapbox/state.js.map +0 -1
  67. package/dist/maps/column-navigation/svg/animated.d.ts +0 -1
  68. package/dist/maps/column-navigation/svg/data-fetcher.cjs +0 -25
  69. package/dist/maps/column-navigation/svg/data-fetcher.cjs.map +0 -1
  70. package/dist/maps/column-navigation/svg/data-fetcher.d.ts +0 -6
  71. package/dist/maps/column-navigation/svg/data-fetcher.js +0 -25
  72. package/dist/maps/column-navigation/svg/data-fetcher.js.map +0 -1
  73. package/dist/maps/column-navigation/svg/index.cjs +0 -94
  74. package/dist/maps/column-navigation/svg/index.cjs.map +0 -1
  75. package/dist/maps/column-navigation/svg/index.d.ts +0 -9
  76. package/dist/maps/column-navigation/svg/index.js +0 -93
  77. package/dist/maps/column-navigation/svg/index.js.map +0 -1
  78. package/dist/maps/column-navigation/svg/layers.cjs +0 -177
  79. package/dist/maps/column-navigation/svg/layers.cjs.map +0 -1
  80. package/dist/maps/column-navigation/svg/layers.d.ts +0 -54
  81. package/dist/maps/column-navigation/svg/layers.js +0 -174
  82. package/dist/maps/column-navigation/svg/layers.js.map +0 -1
  83. package/dist/maps/column-navigation/utils/keyboard-navigation.cjs +0 -50
  84. package/dist/maps/column-navigation/utils/keyboard-navigation.cjs.map +0 -1
  85. package/dist/maps/column-navigation/utils/keyboard-navigation.d.ts +0 -10
  86. package/dist/maps/column-navigation/utils/keyboard-navigation.js +0 -50
  87. package/dist/maps/column-navigation/utils/keyboard-navigation.js.map +0 -1
  88. package/dist/maps/index.d.ts +0 -4
  89. package/dist/maps/inset-map/index.cjs +0 -71
  90. package/dist/maps/inset-map/index.cjs.map +0 -1
  91. package/dist/maps/inset-map/index.d.ts +0 -16
  92. package/dist/maps/inset-map/index.js +0 -69
  93. package/dist/maps/inset-map/index.js.map +0 -1
  94. package/dist/maps/layers/columns.cjs +0 -165
  95. package/dist/maps/layers/columns.cjs.map +0 -1
  96. package/dist/maps/layers/columns.d.ts +0 -28
  97. package/dist/maps/layers/columns.js +0 -165
  98. package/dist/maps/layers/columns.js.map +0 -1
  99. package/dist/maps/layers/index.d.ts +0 -2
  100. package/dist/maps/layers/units.cjs +0 -207
  101. package/dist/maps/layers/units.cjs.map +0 -1
  102. package/dist/maps/layers/units.d.ts +0 -14
  103. package/dist/maps/layers/units.js +0 -204
  104. package/dist/maps/layers/units.js.map +0 -1
  105. package/dist/units/colors.cjs +0 -115
  106. package/dist/units/colors.cjs.map +0 -1
  107. package/dist/units/colors.d.ts +0 -20
  108. package/dist/units/colors.js +0 -113
  109. package/dist/units/colors.js.map +0 -1
  110. package/dist/units/resolvers.cjs +0 -125
  111. package/dist/units/resolvers.cjs.map +0 -1
  112. package/dist/units/resolvers.d.ts +0 -8
  113. package/dist/units/resolvers.js +0 -125
  114. package/dist/units/resolvers.js.map +0 -1
  115. package/src/maps/column-correlation/column-correlation-map.stories.ts +0 -108
  116. package/src/maps/column-correlation/core.ts +0 -342
  117. package/src/maps/column-correlation/index.ts +0 -2
  118. package/src/maps/column-correlation/state.ts +0 -315
  119. package/src/maps/column-navigation/index.ts +0 -2
  120. package/src/maps/column-navigation/mapbox/column-navigation-map.stories.ts +0 -278
  121. package/src/maps/column-navigation/mapbox/index.ts +0 -276
  122. package/src/maps/column-navigation/mapbox/keyboard-navigation.ts +0 -133
  123. package/src/maps/column-navigation/mapbox/state.ts +0 -119
  124. package/src/maps/column-navigation/svg/animated.ts +0 -78
  125. package/src/maps/column-navigation/svg/column-navigation-svg-map.stories.ts +0 -46
  126. package/src/maps/column-navigation/svg/data-fetcher.ts +0 -34
  127. package/src/maps/column-navigation/svg/index.ts +0 -96
  128. package/src/maps/column-navigation/svg/layers.ts +0 -233
  129. package/src/maps/column-navigation/utils/keyboard-navigation.ts +0 -58
  130. package/src/maps/index.ts +0 -4
  131. package/src/maps/inset-map/index.ts +0 -87
  132. package/src/maps/inset-map/inset-map.stories.ts +0 -20
  133. package/src/maps/layers/columns.ts +0 -216
  134. package/src/maps/layers/index.ts +0 -2
  135. package/src/maps/layers/units.ts +0 -286
  136. package/src/maps/unit-map.stories.ts +0 -79
  137. package/src/units/colors.ts +0 -183
  138. package/src/units/resolvers.ts +0 -141
@@ -1,183 +0,0 @@
1
- import chroma from "chroma-js";
2
- import {
3
- Environment,
4
- Lithology,
5
- UnitLithology,
6
- UnitLong,
7
- } from "@macrostrat/api-types";
8
-
9
- interface KeyOptions {
10
- key?: "lith" | "environ";
11
- id_key?: "lith_id" | "environ_id";
12
- }
13
-
14
- export function getMixedUnitColor(
15
- unit: UnitLong,
16
- lithMap: Map<number, { color: string }>,
17
- inDarkMode = false,
18
- asBackground = true,
19
- keyOpts: KeyOptions = null,
20
- ): string | null {
21
- const { key = "lith", id_key = "lith_id" } = keyOpts ?? {};
22
- const liths = unit[key];
23
- const getColor = (data: UnitLithology): string | null => {
24
- return lithMap?.get(data[id_key])?.color ?? null;
25
- };
26
-
27
- return getMixedColorForData(liths, getColor, {
28
- inDarkMode,
29
- asBackground,
30
- key: id_key,
31
- });
32
- }
33
-
34
- interface ColorBuilderOptions {
35
- key?: "lith_id" | "environ_id";
36
- inDarkMode?: boolean;
37
- asBackground?: boolean;
38
- }
39
-
40
- export function flattenLithologies<
41
- T extends { prop: number | null; lith_id?: number; environ_id?: number },
42
- >(liths: T[][], normalize: boolean = true): T[] {
43
- /** Unify proportions in lithology/environment data across several units, normalizing if needed.
44
- * If normalize is true, proportions are scaled to sum to 1 within each unit (with remaining proportions
45
- * distributed equally among liths without specified proportions). This helps ensure that units with a
46
- * few lithologies with specified proportions don't skew the color mixing.
47
- *
48
- * Lithologies are deduplicated based on their identifying property (lith_id or environ_id) if that is present.
49
- */
50
- if (liths == null || liths.length === 0) {
51
- return [];
52
- }
53
-
54
- const unitCount = liths.length;
55
-
56
- let newLiths: T[] = [];
57
- for (const unitLiths of liths) {
58
- let l1 = unitLiths;
59
- if (normalize) {
60
- l1 = addProportionsToAllData(unitLiths);
61
- }
62
- // Divide proportions by number of units to balance influence
63
- for (const lith of l1) {
64
- if (lith.prop == null || isNaN(lith.prop) || lith.prop <= 0) {
65
- continue;
66
- }
67
- lith.prop = lith.prop / unitCount;
68
- }
69
- newLiths.push(...l1);
70
- }
71
- if (newLiths[0]?.lith_id != null) {
72
- newLiths = mergeLikeData(newLiths, "lith_id");
73
- } else if (newLiths[0]?.environ_id != null) {
74
- newLiths = mergeLikeData(newLiths, "environ_id");
75
- }
76
- // Sort by proportion descending
77
- newLiths.sort((a, b) => b.prop - a.prop);
78
- return newLiths;
79
- }
80
-
81
- export function getMixedColorForData<
82
- T extends UnitLithology | Lithology | Environment,
83
- >(
84
- liths: T[] | null,
85
- getColor: (val: T) => string | null,
86
- options: ColorBuilderOptions = {},
87
- ): string | null {
88
- const { inDarkMode = false, asBackground = true } = options;
89
- if (liths == null || liths.length === 0) {
90
- return null;
91
- }
92
- const lithData = liths
93
- .map((d) => {
94
- let prop = d.prop;
95
- if (prop == null || isNaN(prop) || prop <= 0) {
96
- prop = null;
97
- }
98
- return {
99
- ...d,
100
- prop,
101
- color: getColor?.(d) ?? d.color,
102
- };
103
- })
104
- .filter((d) => d.color != null);
105
-
106
- if (lithData.length == 0) {
107
- return null;
108
- }
109
-
110
- const lithsWithProp = addProportionsToAllData(lithData);
111
-
112
- // Mix colors proportionally
113
- const baseColor = chroma.average(
114
- lithsWithProp.map((d) => d.color),
115
- "lrgb",
116
- lithsWithProp.map((d) => d.prop),
117
- );
118
-
119
- if (!asBackground) {
120
- return baseColor.hex();
121
- }
122
-
123
- if (inDarkMode) {
124
- return baseColor.set("hsl.l", 0.2).hex();
125
- } else {
126
- return baseColor.set("hsl.l", 0.9).hex();
127
- }
128
- }
129
-
130
- function addProportionsToAllData<T extends { prop?: number }>(liths: T[]): T[] {
131
- /** Make sure that all lithologies/environments have a defined proportion,
132
- * and that proportions sum to 1. If some liths lack a defined proportion,
133
- * the remaining proportion is distributed equally among them.
134
- *
135
- * NOTE: This function does not normalize proportions if they already sum to more than 1.
136
- */
137
- const lithsWithProp = liths.filter((d) => d.prop != null);
138
- const lithsWithoutProp = liths.filter((d) => d.prop == null);
139
-
140
- const totalProp = lithsWithProp.reduce((sum, d) => sum + d.prop, 0);
141
- let overallTotal = 1;
142
-
143
- if (totalProp < overallTotal && lithsWithoutProp.length > 0) {
144
- const remainingProp = overallTotal - totalProp;
145
- // Distribute remaining proportion equally among liths without prop
146
- const equalProp = remainingProp / lithsWithoutProp.length;
147
- lithsWithoutProp.forEach((d) => {
148
- lithsWithProp.push({
149
- ...d,
150
- prop: equalProp,
151
- } as T);
152
- });
153
- }
154
- return lithsWithProp as T[];
155
- }
156
-
157
- function mergeLikeData<
158
- T extends { prop: number; lith_id?: number; environ_id?: number },
159
- >(liths: T[], key: "lith_id" | "environ_id"): T[] {
160
- /** Merge lithology/environment data with the same identifying property (lith_id or environ_id),
161
- * summing their proportions.
162
- *
163
- * TODO: handle attribute merging
164
- */
165
- const mergedMap: Map<number, T> = new Map();
166
-
167
- for (const lith of liths) {
168
- const id = lith[key];
169
- if (id == null) continue;
170
-
171
- if (mergedMap.has(id)) {
172
- const existing = mergedMap.get(id);
173
- mergedMap.set(id, {
174
- ...existing,
175
- prop: existing.prop + lith.prop,
176
- });
177
- } else {
178
- mergedMap.set(id, { ...lith });
179
- }
180
- }
181
-
182
- return Array.from(mergedMap.values());
183
- }
@@ -1,141 +0,0 @@
1
- import { Lithology, UnitLithology } from "@macrostrat/api-types";
2
- import { LithologyCore } from "@macrostrat/api-types/src/lithologies";
3
-
4
- const symbolIndex = {
5
- "dolomite-limestone": 641,
6
- lime_mudstone: 627,
7
- sandstone: 607,
8
- "quartz arenite": 607,
9
- litharenite: 608,
10
- sand: 608,
11
- siltstone: 616,
12
- silt: 616,
13
- siliciclastic: 615,
14
- mud: 620,
15
- "dolomitic siltstone": 616,
16
- shale: 620,
17
- limestone: 627,
18
- dolomite: 642,
19
- conglomerate: 602,
20
- carbonate: 627,
21
- "dolomite-mudstone": 642,
22
- dolostone: 642,
23
- mudstone: 620,
24
- slate: 703,
25
- "sandy-dolomite": 645,
26
- quartzite: 702,
27
- halite: 668,
28
- gypsum: 667,
29
- evaporite: 667,
30
- claystone: 620,
31
- anhydrite: 667,
32
- gabbro: 720,
33
- basalt: 717,
34
- diabase: 717,
35
- rhyolite: 722,
36
- andesite: 723,
37
- till: 681,
38
- loess: 684,
39
- "calcareous ooze": 653,
40
- "siliceous ooze": 653,
41
- chalk: 626,
42
- gravel: 601,
43
- plutonic: 721,
44
- granite: 719,
45
- clay: 660,
46
- syenite: 722,
47
- tuff: 711,
48
- volcanic: 725,
49
- metamorphic: 707,
50
- volcaniclastic: 714,
51
- migmatite: 709,
52
- gneiss: 708,
53
- tonalite: 727,
54
- granodiorite: 725,
55
- monzonite: 723,
56
- argillite: 624,
57
- diamictite: 681,
58
- };
59
-
60
- export function getBestFGDCPatternForLithologyList<
61
- T extends UnitLithology | Lithology,
62
- >(liths: T[]): { lith: T; patternID: string } | null {
63
- let lithsSorted = [...liths];
64
- lithsSorted.sort((a, b) => b.prop - a.prop);
65
- let firstLith = lithsSorted[0];
66
- let sym = symbolIndex[firstLith.name];
67
- if (sym != null) {
68
- return { lith: firstLith, patternID: `${sym}` };
69
- }
70
- return null;
71
- }
72
-
73
- const resolveID = (d: any) => {
74
- if (d.lith == null || d.lith.length == 0) {
75
- return null;
76
- }
77
- let liths = [...d.lith];
78
- let environs = d.environ.map((d) => d.name).join(" ");
79
- liths.sort((a, b) => b.prop - a.prop);
80
-
81
- //console.log(d, d.unit_name, liths.map(d => d.name), environs)
82
-
83
- let sym = null;
84
-
85
- // overrides for IODP columns
86
- if (d.unit_name == "clay") {
87
- return "650";
88
- }
89
- if (d.unit_name == "calcareous clay") {
90
- return "651";
91
- }
92
-
93
- for (const k of liths) {
94
- if (k.name == "sandstone") {
95
- // Special cases for sandstone
96
- if (environs.includes("dune")) {
97
- return "609";
98
- }
99
- if (environs.includes("marine")) {
100
- return "608";
101
- }
102
- if (environs.includes("shore")) {
103
- return "611";
104
- }
105
- if (environs.includes("loess")) {
106
- return "686";
107
- }
108
- }
109
-
110
- if (k.name == "conglomerate") {
111
- // Special cases for sandstone
112
- if (environs.includes("fluvial")) {
113
- return "603";
114
- }
115
- }
116
-
117
- if (k.name.includes("tuff")) {
118
- return "711";
119
- }
120
- sym = symbolIndex[k.name];
121
- if (sym != null) {
122
- return sym;
123
- }
124
-
125
- if (k.type == "volcanic") {
126
- return "725";
127
- }
128
- }
129
- return sym;
130
- };
131
-
132
- const patternScale = {
133
- "609": 1.5,
134
- "603": 1.5,
135
- };
136
-
137
- const scalePattern = (id) => {
138
- return patternScale[`${id}`] ?? 1;
139
- };
140
-
141
- export { resolveID, scalePattern };