Skip to content

Commit 11a3592

Browse files
authored
fix: Made Well Log Viewer set correct bounds even if no tracks are present (#2520)
This PR adds a small fix to make it so a well log viewer without any tracks still renders the full axis curves and any potential well-picks. Would be helpful for some user flows in our webviz project Before | After :-------------------------:|:-------------------------: ![image](https://github.com/user-attachments/assets/fd9a69e1-14cd-433a-aadd-454496846a52) | ![image](https://github.com/user-attachments/assets/d60f04e2-eeeb-475b-8c37-fe1cd9400724)
1 parent 6fe3a65 commit 11a3592

File tree

1 file changed

+22
-0
lines changed
  • typescript/packages/well-log-viewer/src/utils

1 file changed

+22
-0
lines changed

typescript/packages/well-log-viewer/src/utils/tracks.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,28 @@ export function createWellLogTracks(
198198
}
199199
}
200200

201+
// If no bounds have been defined (for example, if no tracks were added),
202+
// we default to using the axis curve's min/max as bounds
203+
if (!isFinite(info.minmaxPrimaryAxis[0])) {
204+
const curves = wellLog[0].curves;
205+
const data = wellLog[0].data;
206+
const { primary } = getAxisIndices(curves, axes);
207+
208+
const firstAxisValue = data[0]?.[primary];
209+
if (typeof firstAxisValue === "number")
210+
info.minmaxPrimaryAxis[0] = firstAxisValue;
211+
}
212+
213+
if (!isFinite(info.minmaxPrimaryAxis[1])) {
214+
const curves = wellLog[0].curves;
215+
const data = wellLog[0].data;
216+
const { primary } = getAxisIndices(curves, axes);
217+
218+
const lastAxisValue = data[data.length - 1]?.[primary];
219+
if (typeof lastAxisValue === "number")
220+
info.minmaxPrimaryAxis[1] = lastAxisValue;
221+
}
222+
201223
return info;
202224
}
203225

0 commit comments

Comments
 (0)