Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ColorMapFunction type in WellLogView #2249

Merged
merged 42 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
44a1de6
New ColorFunction type
iWowik Sep 17, 2024
0887900
Merge branch 'master' into ColorFunctions
iWowik Sep 20, 2024
4fd7478
Fix tests
iWowik Sep 20, 2024
a3330b7
Update Settings.tsx
iWowik Sep 20, 2024
23c91cc
Merge branch 'master' into ColorFunctions
iWowik Sep 20, 2024
1f56363
Merge branch 'master' into ColorFunctions
iWowik Sep 20, 2024
9737e84
Merge branch 'master' into ColorFunctions
iWowik Sep 24, 2024
6226e51
Merge branch 'master' into ColorFunctions
iWowik Sep 24, 2024
4d4db71
remove ColorTable in favor of ColorFunction
iWowik Sep 24, 2024
76b57ef
fix JSON templates
iWowik Sep 24, 2024
3ad797e
remove defColorFunction
iWowik Sep 24, 2024
c660ac4
revert
iWowik Sep 24, 2024
e6348ac
add PropTypes
iWowik Sep 24, 2024
9df8e32
fix PropTypes
iWowik Sep 24, 2024
9b0cb86
more PropTypes
iWowik Sep 25, 2024
fd1ab31
add PropTypes
iWowik Sep 25, 2024
a30a8c3
Merge branch 'master' into ColorFunctions
iWowik Sep 25, 2024
94a2542
Add test snapshot
iWowik Sep 25, 2024
60a2087
Merge branch 'master' into ColorFunctions
iWowik Sep 25, 2024
7737cc1
update test snapshots
iWowik Sep 26, 2024
ec0de38
Fix dialog colorFunction labels
iWowik Sep 26, 2024
288e268
ColorFunction => ColorMapFunction
iWowik Sep 26, 2024
1ba493a
Merge branch 'master' into ColorFunctions
iWowik Sep 26, 2024
6d991f5
colorFunctions => colorMapFunctions
iWowik Sep 26, 2024
9115f99
Merge branch 'master' into ColorFunctions
iWowik Sep 26, 2024
1f61f2c
exampleMapFunctions => exampleColorMapFunctions
iWowik Sep 26, 2024
b17ab7b
Merge branch 'ColorFunctions' of https://github.com/iWowik/webviz-sub…
iWowik Sep 26, 2024
6f48967
fix prettier
iWowik Sep 27, 2024
0b4c798
fix python WLV
iWowik Sep 27, 2024
09d11d7
rename ColorTableTypes.ts to ColorMapFunction.ts
iWowik Sep 27, 2024
a3cba4a
ColorTableTypes.ts => ColorMapFunction.ts
iWowik Sep 27, 2024
37430de
colorMapFunction => colorMapFunctionName
iWowik Oct 1, 2024
b8f632a
Update welllogviewer-demo-welllogviewer--discrete.png
iWowik Oct 1, 2024
c260daa
Merge remote-tracking branch 'upstream/master' into ColorFunctions
iWowik Oct 2, 2024
4585349
Update facies3wells.json
iWowik Oct 2, 2024
078d33f
Merge branch 'master' into ColorFunctions
iWowik Oct 2, 2024
e1e15b7
Update some snapshots
iWowik Oct 2, 2024
5f73a37
Update welllogviewer-components-welllogview--discrete.png
iWowik Oct 2, 2024
bb452d0
Update welllogviewer-demo-welllogviewer--discrete.png
iWowik Oct 2, 2024
b96ea4e
Update welllogviewer-components-welllogview--discrete.png
iWowik Oct 3, 2024
e7d87c1
Merge branch 'master' into ColorFunctions
iWowik Oct 3, 2024
2ee0432
Merge branch 'master' into ColorFunctions
w1nklr Oct 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,6 @@ bh_unicode_properties.cache
# Sublime-github package stores a github token in this file
# https://packagecontrol.io/packages/sublime-github
GitHub.sublime-settings

# MS Visual Studio
.vs
8 changes: 4 additions & 4 deletions example-data/facies3wells.json
Original file line number Diff line number Diff line change
Expand Up @@ -1857,7 +1857,7 @@
"name": "discrete",
"type": "stacked",
"color": "red",
"colorTable": "Stratigraphy"
"colorFunction": "Stratigraphy"
},
{ "name": "categorical", "type": "stacked", "color": "green" }
]
Expand Down Expand Up @@ -1909,7 +1909,7 @@
"name": "discrete",
"type": "stacked",
"color": "red",
"colorTable": "Stratigraphy"
"colorFunction": "Stratigraphy"
w1nklr marked this conversation as resolved.
Show resolved Hide resolved
},
{ "name": "categorical", "type": "stacked", "color": "green" }
]
Expand Down Expand Up @@ -1961,13 +1961,13 @@
"name": "discrete",
"type": "stacked",
"color": "red",
"colorTable": "Stratigraphy"
"colorFunction": "Stratigraphy"
w1nklr marked this conversation as resolved.
Show resolved Hide resolved
},
{ "name": "categorical", "type": "stacked", "color": "green" }
]
}
],
"colorTables": [
"colorFunctions": [
{
"name": "Physics",
"discrete": false,
Expand Down
2 changes: 1 addition & 1 deletion example-data/synclog_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
{
"name": "HKL",
"type": "gradientfill",
"colorTable": "Physics",
"colorFunction": "Physics",
w1nklr marked this conversation as resolved.
Show resolved Hide resolved
"color": "green"
},
{
Expand Down
6 changes: 3 additions & 3 deletions example-data/welllog_template_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
"name": "HKLA",
"type": "gradientfill",
"color": "blue",
"colorTable": "Physics",
"inverseColorTable": "Physics"
"colorFunction": "Physics",
"inverseColorFunction": "Physics"
}
]
},
Expand Down Expand Up @@ -196,7 +196,7 @@
{
"name": "HKL",
"type": "gradientfill",
"colorTable": "Physics",
"colorFunction": "Physics",
"color": "green"
},
{
Expand Down
2 changes: 1 addition & 1 deletion example-data/welllog_template_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
{
"name": "discrete",
"type": "stacked",
"colorTable": "Stratigraphy"
"colorFunction": "Stratigraphy"
w1nklr marked this conversation as resolved.
Show resolved Hide resolved
}
]
}
14 changes: 8 additions & 6 deletions python/src/components/WellLogViewer/WellLogViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
}))
);

import type { ColorFunction } from "../components/ColorTableTypes";
import type { WellPickProps } from "../components/WellLogView";

// react-docgen / dash-generate-components/extract-meta.js does not properly parse
// the imported WellLogViewerProps. Hence, we have to recreate them here.
/**
Expand Down Expand Up @@ -52,9 +55,8 @@
/** Prop containing track template data */
template: object;

/** Prop containing color table data */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
colorTables: any[]; // specify the exact type if known
/** Prop containing color function/table array */
colorFunctions: ColorFunction[];

Check failure on line 59 in python/src/components/WellLogViewer/WellLogViewer.tsx

View workflow job for this annotation

GitHub Actions / python (3.8)

Delete `·`

/** Orientation of the track plots on the screen. Default is false */
horizontal?: boolean;
Expand All @@ -66,16 +68,16 @@
selection?: number[];

/** Well picks data */
wellpick?: object;
wellpick?: WellPickProps;

/** Primary axis id: " md", "tvd", "time"... */
primaryAxis?: string;

/** Log mnemonics for axes */
axisTitles?: object;
axisTitles?: Record<string, string>;

/** Names for axes */
axisMnemos?: object;
axisMnemos?: Record<string, string[]>;

/** Set to true for default titles or to array of individual well log titles */
viewTitle?: boolean | string | object; // 'object' might be replaced by a specific type like ReactNode
Expand Down
74 changes: 39 additions & 35 deletions typescript/packages/well-log-viewer/src/SyncLogViewer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@ import type { Meta, StoryObj } from "@storybook/react";
import React from "react";

import { colorTables } from "@emerson-eps/color-tables";
const exampleColorTable = colorTables; /*as unknown as ColorTable[]*/ // equivalent types, should be merged
import type { ColorFunction } from "./components/ColorTableTypes";
const exampleColorFunctions = colorTables as ColorFunction[];
const wellpickColorTable = require("../../../../example-data/wellpick_colors.json"); // eslint-disable-line
const wellpickColorFunctions = wellpickColorTable as ColorFunction[];
const wellpick = require("../../../../example-data/wellpicks.json");// eslint-disable-line

import { ToggleButton } from "@mui/material";

import SyncLogViewer, { argTypesSyncLogViewerProp } from "./SyncLogViewer";
import type { SyncLogViewerProps } from "./SyncLogViewer";
import type {
// @ts-expect-error TS2614
WellLogView,
WellLogController,
TrackMouseEvent,
WellPickProps,
} from "./components/WellLogView";

const ComponentCode =
Expand All @@ -32,7 +36,7 @@ const ComponentCode =
' require("../../../../example-data/synclog_template.json"), \r\n' +
' require("../../../../example-data/synclog_template.json"), \r\n' +
" } \r\n" +
" colorTables={colorTables} \r\n" +
" colorFunctions={colorFunctions} \r\n" +
"/>";

import type { WellLog } from "./components/WellLogTypes";
Expand Down Expand Up @@ -65,8 +69,8 @@ const stories: Meta = {
templates: {
description: "Array of track template data.",
},
colorTables: {
description: "Prop containing color table data.",
colorFunctions: {
description: "Prop containing color function/table data.",
},
wellpickFlatting: {
description: "Horizon names for wellpick flatting",
Expand Down Expand Up @@ -158,11 +162,9 @@ function fillInfo(controller: WellLogController | undefined) {
);
}

// @ts-expect-error TS7006
const Template = (args) => {
const infoRef = React.useRef();
const Template = (args: SyncLogViewerProps) => {
const infoRef = React.useRef<HTMLDivElement | null>(null);
const setInfo = function (info: string) {
// @ts-expect-error TS2339
if (infoRef.current) infoRef.current.innerHTML = info;
};

Expand Down Expand Up @@ -228,13 +230,13 @@ const Template = (args) => {
onDeleteController={onDeleteController}
onContentRescale={onContentRescale}
onContentSelection={onContentSelection}
onTrackMouseEvent={checked ? onTrackMouseEventCustom : null}
onTrackMouseEvent={
checked ? onTrackMouseEventCustom : undefined
}
/>
</div>
{/* Print info for the first WellLog */}
<div style={{ display: "flex", flexDirection: "row" }}>
{/*
// @ts-expect-error TS2322 */}
<div ref={infoRef}></div>
<label style={{ marginLeft: 10 }}>disable context menu</label>
<input
Expand Down Expand Up @@ -363,9 +365,30 @@ const patternNamesEnglish = [
"Vulcanic",
];

const exampleWellPicks: WellPickProps[] = [
{
wellpick: wellpick[0],
name: "HORIZON",
colorFunctions: wellpickColorFunctions,
colorFunction: "Stratigraphy",
},
{
wellpick: wellpick[1],
name: "HORIZON",
colorFunctions: wellpickColorFunctions,
colorFunction: "Stratigraphy",
},
{
wellpick: wellpick[0],
name: "HORIZON",
colorFunctions: wellpickColorFunctions,
colorFunction: "Stratigraphy",
},
];

export const Default: StoryObj<typeof Template> = {
args: {
id: "Sync-Log-Viewer",
//id: "Sync-Log-Viewer",
syncTrackPos: true,
syncContentDomain: true,
syncContentSelection: true,
Expand All @@ -381,31 +404,12 @@ export const Default: StoryObj<typeof Template> = {
require("../../../../example-data/synclog_template.json"), // eslint-disable-line
require("../../../../example-data/synclog_template.json"), // eslint-disable-line
],
colorTables: exampleColorTable,
wellpicks: [
{
wellpick: wellpick[0],
name: "HORIZON",
colorTables: wellpickColorTable,
color: "Stratigraphy",
},
{
wellpick: wellpick[1],
name: "HORIZON",
colorTables: wellpickColorTable, // eslint-disable-line
color: "Stratigraphy",
},
{
wellpick: wellpick[0],
name: "HORIZON",
colorTables: wellpickColorTable, // eslint-disable-line
color: "Stratigraphy",
},
],
colorFunctions: exampleColorFunctions,
wellpicks: exampleWellPicks,
patternsTable: {
patternSize: 24,
patternImages: patternImages,
names: patternNamesEnglish,
patternNames: patternNamesEnglish,
},
patterns: require("../../../../example-data/horizon_patterns.json"), // eslint-disable-line

Expand Down Expand Up @@ -614,7 +618,7 @@ const TemplateWithSelection = (args: { welllogs: WellLog[] }) => {
{/*
// @ts-expect-error TS2739 */}
<SyncLogViewer
id="SyncLogViewer"
id="SyncLogViewer2"
{...argsWithSelection}
onCreateController={onCreateController}
onDeleteController={onDeleteController}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import React from "react";
import SyncLogViewer from "./SyncLogViewer";
import { axisMnemos, axisTitles } from "./utils/axes";

import type { ColorTable } from "./components/ColorTableTypes";
const exampleColorTable = colorTables as unknown as ColorTable[]; // equivalent types, should be merged
import type { ColorFunction } from "./components/ColorTableTypes";
const exampleColorFunction = colorTables as unknown as ColorFunction[];
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-require-imports
const exampleWellLog = require("../../../../example-data/L898MUD.json")[0];
Expand Down Expand Up @@ -37,7 +37,7 @@ describe("Sync Log Viewer", () => {
axisMnemos={axisMnemos}
welllogs={[exampleWellLog]} // the same log for all wellog viewers
templates={[exampleTemplate]} // the same template for all wellog viewers
colorTables={exampleColorTable} // the same colortables for all wellog viewers
colorFunctions={exampleColorFunction} // the same colortables for all wellog viewers
/>
);
expect(container.firstChild).toMatchSnapshot();
Expand Down
Loading
Loading