@webviz/well-log-viewer 0.0.1-alpha.1 → 0.0.1-alpha.3
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/dist/SyncLogViewer.js +3 -4
- package/dist/SyncLogViewer.js.map +1 -1
- package/dist/components/WellLogView.js +5 -5
- package/dist/components/WellLogView.js.map +1 -1
- package/dist/demo/example-data/welllog_template_2.json +167 -167
- package/dist/demo/example-data/wellpick_colors.json +1 -1
- package/dist/demo/example-data/wellpicks.json +179 -179
- package/package.json +32 -5
- package/dist/Intro.stories.mdx +0 -59
- package/dist/package.json +0 -21
- package/src/Intro.stories.mdx +0 -59
- package/src/MapAndWellLogViewer.stories.jsx +0 -147
- package/src/MapAndWellLogViewer.test.tsx +0 -26
- package/src/MapAndWellLogViewer.tsx +0 -473
- package/src/SyncLogViewer.stories.jsx +0 -361
- package/src/SyncLogViewer.test.tsx +0 -41
- package/src/SyncLogViewer.tsx +0 -1188
- package/src/WellLogViewer.png +0 -0
- package/src/WellLogViewer.stories.jsx +0 -169
- package/src/WellLogViewer.test.tsx +0 -53
- package/src/WellLogViewer.tsx +0 -439
- package/src/WellLogViewer_performance.test.tsx +0 -78
- package/src/__snapshots__/MapAndWellLogViewer.test.tsx.snap +0 -365
- package/src/__snapshots__/SyncLogViewer.test.tsx.snap +0 -510
- package/src/__snapshots__/WellLogViewer.test.tsx.snap +0 -552
- package/src/components/AxisSelector.test.tsx +0 -50
- package/src/components/AxisSelector.tsx +0 -49
- package/src/components/ColorTableTypes.ts +0 -9
- package/src/components/InfoPanel.test.tsx +0 -58
- package/src/components/InfoPanel.tsx +0 -144
- package/src/components/InfoTypes.ts +0 -17
- package/src/components/LocalMenus.tsx +0 -336
- package/src/components/PlotDialog.tsx +0 -419
- package/src/components/Scroller.stories.jsx +0 -80
- package/src/components/Scroller.test.tsx +0 -22
- package/src/components/Scroller.tsx +0 -173
- package/src/components/TrackDialog.tsx +0 -217
- package/src/components/WellLogSpacer.tsx +0 -483
- package/src/components/WellLogTemplateTypes.ts +0 -65
- package/src/components/WellLogTypes.ts +0 -53
- package/src/components/WellLogView.stories.jsx +0 -84
- package/src/components/WellLogView.test.tsx +0 -52
- package/src/components/WellLogView.tsx +0 -2063
- package/src/components/WellLogViewWithScroller.stories.jsx +0 -69
- package/src/components/WellLogViewWithScroller.test.tsx +0 -47
- package/src/components/WellLogViewWithScroller.tsx +0 -179
- package/src/components/ZoomSlider.stories.jsx +0 -52
- package/src/components/ZoomSlider.test.tsx +0 -28
- package/src/components/ZoomSlider.tsx +0 -86
- package/src/components/__snapshots__/AxisSelector.test.tsx.snap +0 -28
- package/src/components/__snapshots__/InfoPanel.test.tsx.snap +0 -103
- package/src/components/__snapshots__/Scroller.test.tsx.snap +0 -13
- package/src/components/__snapshots__/WellLogView.test.tsx.snap +0 -54
- package/src/components/__snapshots__/WellLogViewWithScroller.test.tsx.snap +0 -270
- package/src/components/__snapshots__/ZoomSlider.test.tsx.snap +0 -50
- package/src/components/styles.scss +0 -106
- package/src/custom.d.ts +0 -13
- package/src/demo/example-data/volve_logs.json +0 -689617
- package/src/demo/example-data/welllog_template_2.json +0 -196
- package/src/demo/example-data/wellpick_colors.json +0 -156
- package/src/demo/example-data/wellpicks.json +0 -186
- package/src/index.ts +0 -8
- package/src/utils/axes.ts +0 -26
- package/src/utils/color-table.ts +0 -153
- package/src/utils/deepcopy.ts +0 -3
- package/src/utils/edit-track.tsx +0 -40
- package/src/utils/fill-info.ts +0 -224
- package/src/utils/gradientfill-plot-legend.ts +0 -177
- package/src/utils/gradientfill-plot.ts +0 -203
- package/src/utils/graph/factory.ts +0 -15
- package/src/utils/legend/common.ts +0 -153
- package/src/utils/log-viewer.ts +0 -209
- package/src/utils/minmax.ts +0 -126
- package/src/utils/pattern.tsx +0 -50
- package/src/utils/stack/stack-legend.ts +0 -100
- package/src/utils/tracks.ts +0 -1559
- package/tsconfig.json +0 -8
package/src/utils/color-table.ts
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { ColorTable } from "../components/ColorTableTypes";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
Binary serach in array of elements [number, ...]
|
|
5
|
-
*/
|
|
6
|
-
function binarySearch(array: number[][], v: number) {
|
|
7
|
-
let lo = -1,
|
|
8
|
-
hi = array.length;
|
|
9
|
-
while (1 + lo < hi) {
|
|
10
|
-
const mi = lo + ((hi - lo) >> 1);
|
|
11
|
-
if (array[mi][0] > v) {
|
|
12
|
-
hi = mi;
|
|
13
|
-
} else {
|
|
14
|
-
lo = mi;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
// v should be in the semiopen interval [array[lo][0], array[hi][0])
|
|
18
|
-
// i.e. array[lo][0] <= v < array[hi][0]
|
|
19
|
-
return hi;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/*
|
|
23
|
-
get HTML string in #xxxxxx format with color value given in the first 3 elements of array
|
|
24
|
-
*/
|
|
25
|
-
export function colorToString(
|
|
26
|
-
color: [number, number, number] | undefined, // [r,g,b]
|
|
27
|
-
cDefault: string
|
|
28
|
-
): string {
|
|
29
|
-
if (!color) return cDefault;
|
|
30
|
-
const p =
|
|
31
|
-
0x1000000 | // force value to have 7 hex digits : 1rrggbb
|
|
32
|
-
(color[0] << 16) |
|
|
33
|
-
(color[1] << 8) |
|
|
34
|
-
color[2];
|
|
35
|
-
return "#" + p.toString(16).substr(1); // cut the first (additional) character and add leading '#' character
|
|
36
|
-
}
|
|
37
|
-
/*
|
|
38
|
-
get HTML string in #xxxxxx format with color value given in the [1],[2],[3] elements of array (skip the first element [0] containing stop value)
|
|
39
|
-
*/
|
|
40
|
-
export function color4ToString(
|
|
41
|
-
color: [number, number, number, number] // [stop, r,g,b]
|
|
42
|
-
): string {
|
|
43
|
-
// see colorToString()
|
|
44
|
-
const p = 0x1000000 | (color[1] << 16) | (color[2] << 8) | color[3];
|
|
45
|
-
return "#" + p.toString(16).substr(1);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/*
|
|
49
|
-
export function getExactColor(
|
|
50
|
-
colorTable: ColorTable,
|
|
51
|
-
v: number
|
|
52
|
-
): [number, number, number] {
|
|
53
|
-
const cNaN: [number, number, number] = colorTable.colorNaN
|
|
54
|
-
? colorTable.colorNaN
|
|
55
|
-
: [255, 255, 255]; // "white"
|
|
56
|
-
|
|
57
|
-
const colors = colorTable.colors;
|
|
58
|
-
const j = binarySearch(colors, v);
|
|
59
|
-
|
|
60
|
-
const cBelow = colorTable.colorBelow ? colorTable.colorBelow : cNaN;
|
|
61
|
-
if (j <= 0) {
|
|
62
|
-
return cBelow;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const cAbove = colorTable.colorAbove ? colorTable.colorAbove : cBelow;
|
|
66
|
-
if (j >= colors.length) {
|
|
67
|
-
return cAbove;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
/*
|
|
73
|
-
get HTML string with interpolated color value in #xxxxxx format
|
|
74
|
-
*/
|
|
75
|
-
export function getInterpolatedColor(
|
|
76
|
-
colorTable: ColorTable,
|
|
77
|
-
v: number
|
|
78
|
-
): [number, number, number] {
|
|
79
|
-
// TODO: Do not compute these 3 constants (cNaN, cBelow, cAbove) every time!
|
|
80
|
-
|
|
81
|
-
const cNaN: [number, number, number] = colorTable.colorNaN
|
|
82
|
-
? colorTable.colorNaN
|
|
83
|
-
: [255, 255, 255]; // "white"
|
|
84
|
-
if (Number.isNaN(v)) {
|
|
85
|
-
return cNaN;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const colors = colorTable.colors;
|
|
89
|
-
const j = binarySearch(colors, v);
|
|
90
|
-
|
|
91
|
-
const cBelow = colorTable.colorBelow ? colorTable.colorBelow : cNaN;
|
|
92
|
-
if (j <= 0) {
|
|
93
|
-
return cBelow;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const cAbove = colorTable.colorAbove ? colorTable.colorAbove : cBelow;
|
|
97
|
-
if (j >= colors.length) {
|
|
98
|
-
return cAbove;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// linear interpolation on interval [colors[j-1][0], colors[j][0]]
|
|
102
|
-
const color0 = colors[j - 1];
|
|
103
|
-
const color = colors[j];
|
|
104
|
-
|
|
105
|
-
const f = (v - color0[0]) / (color[0] - color0[0]);
|
|
106
|
-
|
|
107
|
-
return [
|
|
108
|
-
color0[1] + f * (color[1] - color0[1]),
|
|
109
|
-
color0[2] + f * (color[2] - color0[2]),
|
|
110
|
-
color0[3] + f * (color[3] - color0[3]),
|
|
111
|
-
];
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/*
|
|
115
|
-
get HTML string with interpolated color value in #xxxxxx format
|
|
116
|
-
*/
|
|
117
|
-
export function getInterpolatedColorString(
|
|
118
|
-
colorTable: ColorTable,
|
|
119
|
-
v: number
|
|
120
|
-
): string {
|
|
121
|
-
// TODO: Do not compute these 3 constants (cNaN, cBelow, cAbove) every time!
|
|
122
|
-
const cNaN = colorToString(colorTable.colorNaN, "#ffffff"); // "white"
|
|
123
|
-
|
|
124
|
-
if (Number.isNaN(v)) return cNaN;
|
|
125
|
-
const cBelow = colorToString(colorTable.colorBelow, cNaN);
|
|
126
|
-
const cAbove = colorToString(colorTable.colorAbove, cBelow);
|
|
127
|
-
|
|
128
|
-
const colors = colorTable.colors;
|
|
129
|
-
const j = binarySearch(colors, v);
|
|
130
|
-
let c: string;
|
|
131
|
-
if (j <= 0) c = cBelow;
|
|
132
|
-
else if (j >= colors.length) c = cAbove;
|
|
133
|
-
else {
|
|
134
|
-
// linear interpolation on interval [colors[j-1][0], colors[j][0]]
|
|
135
|
-
const color0 = colors[j - 1];
|
|
136
|
-
const color = colors[j];
|
|
137
|
-
|
|
138
|
-
const f = (v - color0[0]) / (color[0] - color0[0]);
|
|
139
|
-
|
|
140
|
-
const p = // see also color4ToString()
|
|
141
|
-
0x1000000 |
|
|
142
|
-
((color0[1] + f * (color[1] - color0[1])) << 16) |
|
|
143
|
-
((color0[2] + f * (color[2] - color0[2])) << 8) |
|
|
144
|
-
(color0[3] + f * (color[3] - color0[3]));
|
|
145
|
-
c = "#" + p.toString(16).substr(1);
|
|
146
|
-
if (c.length !== 7) {
|
|
147
|
-
console.error("wrong color table ");
|
|
148
|
-
console.log(c, p, p.toString(16), f, color, color0);
|
|
149
|
-
return cNaN;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
return c;
|
|
153
|
-
}
|
package/src/utils/deepcopy.ts
DELETED
package/src/utils/edit-track.tsx
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import ReactDOM from "react-dom";
|
|
3
|
-
import { Plot } from "@equinor/videx-wellog";
|
|
4
|
-
import WellLogView from "../components/WellLogView";
|
|
5
|
-
import { TrackMouseEvent } from "../components/WellLogView";
|
|
6
|
-
import { SimpleMenu, editPlots } from "../components/LocalMenus";
|
|
7
|
-
|
|
8
|
-
export function onTrackMouseEvent(
|
|
9
|
-
wellLogView: WellLogView,
|
|
10
|
-
ev: TrackMouseEvent
|
|
11
|
-
): void {
|
|
12
|
-
const track = ev.track;
|
|
13
|
-
if (ev.type === "click") {
|
|
14
|
-
wellLogView.selectTrack(track, !wellLogView.isTrackSelected(track)); // toggle selection
|
|
15
|
-
} else if (ev.type === "dblclick") {
|
|
16
|
-
wellLogView.selectTrack(track, true);
|
|
17
|
-
if (ev.area === "title") {
|
|
18
|
-
wellLogView.editTrack(ev.element, ev.track);
|
|
19
|
-
} else {
|
|
20
|
-
const plot: Plot | null = ev.plot;
|
|
21
|
-
if (!plot) editPlots(ev.element, wellLogView, ev.track);
|
|
22
|
-
else wellLogView.editPlot(ev.element, ev.track, plot);
|
|
23
|
-
}
|
|
24
|
-
} else if (ev.type === "contextmenu") {
|
|
25
|
-
wellLogView.selectTrack(track, true);
|
|
26
|
-
const el: HTMLElement = document.createElement("div");
|
|
27
|
-
el.style.width = "10px";
|
|
28
|
-
el.style.height = "3px";
|
|
29
|
-
ev.element.appendChild(el);
|
|
30
|
-
ReactDOM.render(
|
|
31
|
-
<SimpleMenu
|
|
32
|
-
type={ev.area}
|
|
33
|
-
anchorEl={el}
|
|
34
|
-
wellLogView={wellLogView}
|
|
35
|
-
track={track}
|
|
36
|
-
/>,
|
|
37
|
-
el
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
}
|
package/src/utils/fill-info.ts
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import { Info, InfoOptions } from "../components/InfoTypes";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Track,
|
|
5
|
-
DualScaleTrack,
|
|
6
|
-
GraphTrack,
|
|
7
|
-
StackedTrack,
|
|
8
|
-
} from "@equinor/videx-wellog";
|
|
9
|
-
|
|
10
|
-
import { InterpolatedScaleHandler } from "@equinor/videx-wellog";
|
|
11
|
-
import { DifferentialPlotLegendInfo } from "@equinor/videx-wellog/dist/plots/legend/interfaces";
|
|
12
|
-
import { DifferentialPlotOptions } from "@equinor/videx-wellog/dist/plots/interfaces";
|
|
13
|
-
import { LogViewer } from "@equinor/videx-wellog";
|
|
14
|
-
|
|
15
|
-
import { ExtPlotOptions } from "./tracks";
|
|
16
|
-
import { isScaleTrack } from "./tracks";
|
|
17
|
-
import { getPlotType } from "./tracks";
|
|
18
|
-
|
|
19
|
-
function getValueOnInterval(
|
|
20
|
-
x: number,
|
|
21
|
-
rowPrev: number[],
|
|
22
|
-
row: number[],
|
|
23
|
-
type: string
|
|
24
|
-
): number {
|
|
25
|
-
if (rowPrev[0] == null) return Number.NaN;
|
|
26
|
-
if (type === "linestep") {
|
|
27
|
-
if (row[1] == null) return Number.NaN;
|
|
28
|
-
return row[1]; //!! not rowPrev[1] !!
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const d = row[0] - rowPrev[0];
|
|
32
|
-
const f = x - rowPrev[0];
|
|
33
|
-
if (type === "dot") {
|
|
34
|
-
if (f < d * 0.5) {
|
|
35
|
-
if (rowPrev[1] == null) return Number.NaN;
|
|
36
|
-
return rowPrev[1];
|
|
37
|
-
}
|
|
38
|
-
if (row[1] == null) return Number.NaN;
|
|
39
|
-
return row[1];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// "line", "area", "gradientfill"
|
|
43
|
-
if (rowPrev[1] == null) return Number.NaN;
|
|
44
|
-
if (row[1] == null) return Number.NaN;
|
|
45
|
-
const mul = d ? (row[1] - rowPrev[1]) / d : 1.0;
|
|
46
|
-
return f * mul + rowPrev[1];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function getValue(x: number, data: [], type: string): number {
|
|
50
|
-
const v = Number.NaN;
|
|
51
|
-
if (Number.isFinite(x)) {
|
|
52
|
-
const n = data.length;
|
|
53
|
-
for (let i = 0; i < n; i++) {
|
|
54
|
-
const row = data[i];
|
|
55
|
-
//if (row[0] == null) continue;
|
|
56
|
-
//!! if (row[1] == null) continue;
|
|
57
|
-
if (x < row[0]) {
|
|
58
|
-
if (!i) break;
|
|
59
|
-
const rowPrev = data[i - 1];
|
|
60
|
-
return getValueOnInterval(x, rowPrev, row, type);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return v;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function addScaleTrackInfos(
|
|
68
|
-
infos: Info[],
|
|
69
|
-
x: number,
|
|
70
|
-
logController: LogViewer,
|
|
71
|
-
tracks: Track[]
|
|
72
|
-
) {
|
|
73
|
-
const interpolator = (
|
|
74
|
-
logController.scaleHandler as InterpolatedScaleHandler
|
|
75
|
-
).interpolator;
|
|
76
|
-
const x2 = interpolator && !isNaN(x) ? interpolator.reverse(x) : Number.NaN;
|
|
77
|
-
let iPlot = 0;
|
|
78
|
-
for (const _track of tracks) {
|
|
79
|
-
if (!isScaleTrack(_track)) continue;
|
|
80
|
-
const track = _track as DualScaleTrack;
|
|
81
|
-
const _x = track.options.mode /* DualScaleTrack and mode is slave */
|
|
82
|
-
? x2
|
|
83
|
-
: x;
|
|
84
|
-
infos.push({
|
|
85
|
-
name: track.options.abbr,
|
|
86
|
-
units: track.options.units,
|
|
87
|
-
color: iPlot == 0 ? "black" : "grey", //??
|
|
88
|
-
value: _x,
|
|
89
|
-
type: "", // "scale"
|
|
90
|
-
trackId: track.id,
|
|
91
|
-
});
|
|
92
|
-
iPlot++;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Add separator line
|
|
96
|
-
infos.push({
|
|
97
|
-
color: "", // dummy value
|
|
98
|
-
value: Number.NaN, // dummy value
|
|
99
|
-
type: "separator",
|
|
100
|
-
trackId: "separator",
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export function fillInfos(
|
|
105
|
-
x: number,
|
|
106
|
-
logController: LogViewer,
|
|
107
|
-
iFrom: number,
|
|
108
|
-
iTo: number,
|
|
109
|
-
collapsedTrackIds: (string | number)[],
|
|
110
|
-
options?: InfoOptions
|
|
111
|
-
): Info[] {
|
|
112
|
-
const infos: Info[] = [];
|
|
113
|
-
const tracks = logController.tracks;
|
|
114
|
-
|
|
115
|
-
// Scale tracks first
|
|
116
|
-
addScaleTrackInfos(infos, x, logController, tracks);
|
|
117
|
-
|
|
118
|
-
// another tracks
|
|
119
|
-
const allTracks = options?.allTracks;
|
|
120
|
-
const grouping = options?.grouping;
|
|
121
|
-
|
|
122
|
-
let iTrack = 0;
|
|
123
|
-
for (const _track of tracks) {
|
|
124
|
-
if (isScaleTrack(_track)) continue;
|
|
125
|
-
const visible = allTracks || (iFrom <= iTrack && iTrack < iTo);
|
|
126
|
-
iTrack++;
|
|
127
|
-
if (!visible) continue;
|
|
128
|
-
const collapsed =
|
|
129
|
-
collapsedTrackIds && collapsedTrackIds.indexOf(_track.id) >= 0;
|
|
130
|
-
|
|
131
|
-
const track = _track as GraphTrack;
|
|
132
|
-
if (grouping === "by_track" && track.plots && track.plots.length) {
|
|
133
|
-
infos.push({
|
|
134
|
-
name: track.options.label,
|
|
135
|
-
color: "", // dummy value
|
|
136
|
-
value: Number.NaN, // dummy value,
|
|
137
|
-
type: "track",
|
|
138
|
-
collapsed: collapsed,
|
|
139
|
-
trackId: track.id,
|
|
140
|
-
groupStart: "!",
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
if (!collapsed) {
|
|
144
|
-
if (_track instanceof StackedTrack) {
|
|
145
|
-
const trackStacked = _track as StackedTrack;
|
|
146
|
-
const d = trackStacked.data;
|
|
147
|
-
let discrete = "";
|
|
148
|
-
let value = Number.NaN; // dummy value
|
|
149
|
-
let color = "";
|
|
150
|
-
if (d) {
|
|
151
|
-
// data is ready
|
|
152
|
-
for (let i = 0; i < d.length; i++) {
|
|
153
|
-
const p = d[i];
|
|
154
|
-
if (p.from <= x && x <= p.to) {
|
|
155
|
-
value = p.code; // additional attribute to AreaData
|
|
156
|
-
discrete = p.name;
|
|
157
|
-
color =
|
|
158
|
-
"rgb(" +
|
|
159
|
-
p.color.r +
|
|
160
|
-
"," +
|
|
161
|
-
p.color.g +
|
|
162
|
-
"," +
|
|
163
|
-
p.color.b +
|
|
164
|
-
")";
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
infos.push({
|
|
170
|
-
name: trackStacked.options.abbr,
|
|
171
|
-
units: "",
|
|
172
|
-
color: color,
|
|
173
|
-
value: value,
|
|
174
|
-
discrete: discrete,
|
|
175
|
-
type: "stacked", //??
|
|
176
|
-
trackId: trackStacked.id,
|
|
177
|
-
});
|
|
178
|
-
} else {
|
|
179
|
-
for (const plot of track.plots) {
|
|
180
|
-
const type = getPlotType(plot);
|
|
181
|
-
let data = plot.data;
|
|
182
|
-
if (type === "differential") data = plot.data[0]; // DifferentialPlot has 2 arrays of data pairs
|
|
183
|
-
|
|
184
|
-
const options = plot.options as ExtPlotOptions;
|
|
185
|
-
const optionsDifferential =
|
|
186
|
-
plot.options as DifferentialPlotOptions; // DifferentialPlot - 2 series!
|
|
187
|
-
const options1 = optionsDifferential.serie1;
|
|
188
|
-
const options2 = optionsDifferential.serie2;
|
|
189
|
-
|
|
190
|
-
const legend = options.legendInfo();
|
|
191
|
-
const legendDifferential =
|
|
192
|
-
legend as DifferentialPlotLegendInfo; // DifferentialPlot - 2 series!
|
|
193
|
-
const legend1 = legendDifferential.serie1;
|
|
194
|
-
const legend2 = legendDifferential.serie2;
|
|
195
|
-
|
|
196
|
-
infos.push({
|
|
197
|
-
name: legend1 ? legend1.label : legend.label,
|
|
198
|
-
units: legend1 ? legend1.unit : legend.unit,
|
|
199
|
-
color:
|
|
200
|
-
(options1 ? options1.color : options.color) || "",
|
|
201
|
-
value: getValue(x, data, type),
|
|
202
|
-
type: type,
|
|
203
|
-
trackId: track.id,
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
if (type === "differential") {
|
|
207
|
-
data = plot.data[1];
|
|
208
|
-
infos.push({
|
|
209
|
-
name: legend2.label,
|
|
210
|
-
units: legend2.unit,
|
|
211
|
-
color:
|
|
212
|
-
(options2 ? options2.color : options.color) ||
|
|
213
|
-
"",
|
|
214
|
-
value: getValue(x, data, type),
|
|
215
|
-
type: type,
|
|
216
|
-
trackId: "_" + track.id,
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
return infos;
|
|
224
|
-
}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { LegendBounds } from "@equinor/videx-wellog/dist/utils/legend-helper";
|
|
2
|
-
import { LegendInfo } from "@equinor/videx-wellog/dist/plots/legend/interfaces";
|
|
3
|
-
import { GradientFillPlotOptions } from "./gradientfill-plot";
|
|
4
|
-
import GradientFillPlot from "./gradientfill-plot";
|
|
5
|
-
import { setAttrs } from "@equinor/videx-wellog";
|
|
6
|
-
|
|
7
|
-
/* Missed exports from "@equinor/videx-wellog !!! */
|
|
8
|
-
// eslint-disable-next-line
|
|
9
|
-
declare type D3Selection = any; //import { D3Selection } from "@equinor/videx-wellog/dist/common/interfaces';
|
|
10
|
-
import { renderBasicPlotLegend } from "./legend/common"; //import { renderBasicPlotLegend } from "@equinor/videx-wellog/dist/plots/legend/common';
|
|
11
|
-
/* End of missed from "@equinor/videx-wellog */
|
|
12
|
-
|
|
13
|
-
import { ColorTable } from "../components/ColorTableTypes";
|
|
14
|
-
import { getInterpolatedColorString } from "./color-table";
|
|
15
|
-
|
|
16
|
-
import { color4ToString } from "./color-table";
|
|
17
|
-
let __idGradient = 0;
|
|
18
|
-
function createGradient(
|
|
19
|
-
g: D3Selection,
|
|
20
|
-
colorTable: ColorTable,
|
|
21
|
-
rLogarithmic?: number
|
|
22
|
-
): string {
|
|
23
|
-
const id = "grad" + ++__idGradient; // generate unique id
|
|
24
|
-
const lg = g
|
|
25
|
-
.append("defs")
|
|
26
|
-
.append("linearGradient")
|
|
27
|
-
.attr("id", id) //id of the gradient
|
|
28
|
-
.attr("x1", "0%")
|
|
29
|
-
.attr("x2", "100%") //since it's a horizontal linear gradient
|
|
30
|
-
.attr("y1", "0%")
|
|
31
|
-
.attr("y2", "0%");
|
|
32
|
-
const colors = colorTable.colors;
|
|
33
|
-
if (rLogarithmic !== undefined) {
|
|
34
|
-
const yDelta = Math.log(rLogarithmic); // log(max/min)
|
|
35
|
-
const d = rLogarithmic - 1;
|
|
36
|
-
const nIntervals = 25;
|
|
37
|
-
for (let i = 0; i <= nIntervals; i++) {
|
|
38
|
-
const fraction = i / nIntervals;
|
|
39
|
-
const y = 1 + fraction * d;
|
|
40
|
-
const v = Math.log(y) / yDelta;
|
|
41
|
-
const c = getInterpolatedColorString(colorTable, v);
|
|
42
|
-
lg.append("stop")
|
|
43
|
-
.attr("offset", fraction * 100.0 + "%")
|
|
44
|
-
.style("stop-color", c);
|
|
45
|
-
}
|
|
46
|
-
} else {
|
|
47
|
-
for (let i = 0; i < colors.length; i++) {
|
|
48
|
-
const color = colors[i];
|
|
49
|
-
const c = color4ToString(color);
|
|
50
|
-
lg.append("stop")
|
|
51
|
-
.attr("offset", color[0] * 100.0 + "%")
|
|
52
|
-
.style("stop-color", c);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return id;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Renders area legend to a SVG group element according to bounds.
|
|
60
|
-
*/
|
|
61
|
-
export default function renderGradientFillPlotLegend(
|
|
62
|
-
g: D3Selection,
|
|
63
|
-
bounds: LegendBounds,
|
|
64
|
-
legendInfo: LegendInfo,
|
|
65
|
-
plot: GradientFillPlot
|
|
66
|
-
): void {
|
|
67
|
-
const options = plot.options as GradientFillPlotOptions;
|
|
68
|
-
const { top, left, width, height } = bounds;
|
|
69
|
-
const shadeH = height / 2;
|
|
70
|
-
const shadeY = top;
|
|
71
|
-
const fillOpacity = Math.min((options.fillOpacity || 0.0) + 0.25, 1);
|
|
72
|
-
|
|
73
|
-
if (options.inverseColor || options.inverseColorTable) {
|
|
74
|
-
const [min, max] = plot.scale.domain();
|
|
75
|
-
const minIsLeft = min <= max;
|
|
76
|
-
const centerX = left + width / 2;
|
|
77
|
-
const useMinAsBase =
|
|
78
|
-
options.useMinAsBase === undefined ? true : options.useMinAsBase;
|
|
79
|
-
|
|
80
|
-
const shadeW = Math.max(0, width - 2);
|
|
81
|
-
|
|
82
|
-
let fillNrm =
|
|
83
|
-
useMinAsBase && minIsLeft
|
|
84
|
-
? plot.options.color
|
|
85
|
-
: options.inverseColor;
|
|
86
|
-
|
|
87
|
-
let fillInv =
|
|
88
|
-
useMinAsBase && minIsLeft
|
|
89
|
-
? options.inverseColor
|
|
90
|
-
: plot.options.color;
|
|
91
|
-
|
|
92
|
-
/* Start GradientFill code */
|
|
93
|
-
let colorTable =
|
|
94
|
-
useMinAsBase && minIsLeft
|
|
95
|
-
? options.colorTable
|
|
96
|
-
: options.inverseColorTable;
|
|
97
|
-
if (colorTable) {
|
|
98
|
-
const id = createGradient(
|
|
99
|
-
g,
|
|
100
|
-
colorTable,
|
|
101
|
-
options.scale === "linear" && options.colorScale === "log"
|
|
102
|
-
? max / min
|
|
103
|
-
: undefined
|
|
104
|
-
);
|
|
105
|
-
fillNrm = "url(#" + id + ")";
|
|
106
|
-
}
|
|
107
|
-
colorTable =
|
|
108
|
-
useMinAsBase && minIsLeft
|
|
109
|
-
? options.inverseColorTable
|
|
110
|
-
: options.colorTable;
|
|
111
|
-
if (colorTable) {
|
|
112
|
-
const id = createGradient(
|
|
113
|
-
g,
|
|
114
|
-
colorTable,
|
|
115
|
-
options.scale === "linear" &&
|
|
116
|
-
(options.inverseColorScale || options.colorScale) === "log"
|
|
117
|
-
? max / min
|
|
118
|
-
: undefined
|
|
119
|
-
);
|
|
120
|
-
fillInv = "url(#" + id + ")";
|
|
121
|
-
}
|
|
122
|
-
/* End GradientFill code */
|
|
123
|
-
|
|
124
|
-
setAttrs(g.append("rect"), {
|
|
125
|
-
x: left + 2,
|
|
126
|
-
y: shadeY,
|
|
127
|
-
width: shadeW / 2,
|
|
128
|
-
height: shadeH,
|
|
129
|
-
fill: fillNrm,
|
|
130
|
-
"fill-opacity": fillOpacity,
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
setAttrs(g.append("rect"), {
|
|
134
|
-
x: centerX,
|
|
135
|
-
y: shadeY,
|
|
136
|
-
width: shadeW / 2,
|
|
137
|
-
height: shadeH,
|
|
138
|
-
fill: fillInv,
|
|
139
|
-
"fill-opacity": fillOpacity,
|
|
140
|
-
});
|
|
141
|
-
} else {
|
|
142
|
-
let fillNrm = plot.options.color; // see area-plot-legend.ts! should be? plot.options.fill || plot.options.color;
|
|
143
|
-
/* Start GradientFill code */
|
|
144
|
-
const colorTable = options.colorTable;
|
|
145
|
-
if (colorTable) {
|
|
146
|
-
const [min, max] = plot.scale.domain();
|
|
147
|
-
const id = createGradient(
|
|
148
|
-
g,
|
|
149
|
-
colorTable,
|
|
150
|
-
options.scale === "linear" && options.colorScale === "log"
|
|
151
|
-
? max / min
|
|
152
|
-
: undefined
|
|
153
|
-
);
|
|
154
|
-
fillNrm = "url(#" + id + ")";
|
|
155
|
-
}
|
|
156
|
-
/* End GradientFill code */
|
|
157
|
-
|
|
158
|
-
setAttrs(g.append("rect"), {
|
|
159
|
-
x: left + 2,
|
|
160
|
-
y: shadeY,
|
|
161
|
-
width: Math.max(0, width - 4),
|
|
162
|
-
height: shadeH,
|
|
163
|
-
fill: fillNrm,
|
|
164
|
-
"fill-opacity": fillOpacity,
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
renderBasicPlotLegend(
|
|
169
|
-
g,
|
|
170
|
-
bounds,
|
|
171
|
-
legendInfo.label ? legendInfo.label : "",
|
|
172
|
-
legendInfo.unit ? legendInfo.unit : "",
|
|
173
|
-
plot.scale.domain(),
|
|
174
|
-
plot.options.color ? plot.options.color : "",
|
|
175
|
-
true
|
|
176
|
-
);
|
|
177
|
-
}
|