@emerson-eps/color-tables 0.0.3 → 0.1.4
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/.storybook/main.js +11 -0
- package/.storybook/preview.js +9 -0
- package/package.json +40 -8
- package/src/component/ColorTableTypes.ts +6 -0
- package/src/component/Legend/ContinuousLegend.tsx +131 -0
- package/src/component/Legend/DiscreteLegend.tsx +126 -0
- package/src/component/Utils/continousLegend.ts +81 -0
- package/src/component/Utils/discreteLegend.ts +69 -0
- package/src/component/WelllayerTemplateTypes.ts +15 -0
- package/{color-tables.json → src/component/color-tables.json} +12 -12
- package/src/component/welllayer_template.json +89 -0
- package/src/index.js +2 -0
- package/src/setupTests.js +5 -0
- package/src/stories/ColorLegends/ContinousLgends/MD.stories.jsx +31 -0
- package/src/stories/ColorLegends/ContinousLgends/NTG.stories.jsx +31 -0
- package/src/stories/ColorLegends/ContinousLgends/PermTot.stories.jsx +31 -0
- package/src/stories/ColorLegends/ContinousLgends/Permeability.stories.jsx +31 -0
- package/src/stories/ColorLegends/ContinousLgends/PoroTot.stories.jsx +31 -0
- package/src/stories/ColorLegends/ContinousLgends/Porosity.stories.jsx +31 -0
- package/src/stories/ColorLegends/ContinousLgends/SW.stories.jsx +31 -0
- package/src/stories/ColorLegends/DiscreteLegends/Facies.stories.jsx +41 -0
- package/src/stories/ColorLegends/DiscreteLegends/FaciesNoCalcite.stories.jsx +41 -0
- package/src/stories/ColorLegends/DiscreteLegends/FaultDistanceHum.stories.jsx +33 -0
- package/src/stories/ColorLegends/DiscreteLegends/FaultProximityFlag.stories.jsx +33 -0
- package/src/stories/ColorLegends/DiscreteLegends/RDE.stories.jsx +36 -0
- package/src/stories/ColorLegends/DiscreteLegends/RDE_Orig.stories.jsx +47 -0
- package/src/stories/ColorLegends/DiscreteLegends/ZoneMain.stories.jsx +36 -0
- package/src/stories/ColorLegends/DiscreteLegends/Zonelog.stories.jsx +48 -0
- package/.github/workflows/node.js.yml +0 -34
- package/LICENSE +0 -373
- package/README.md +0 -8
package/package.json
CHANGED
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emerson-eps/color-tables",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Standard library of color tables for geological domain",
|
|
5
|
-
"main": "color-tables.json",
|
|
6
5
|
"release": {
|
|
7
6
|
"branches": [
|
|
8
7
|
"main"
|
|
9
8
|
]
|
|
10
9
|
},
|
|
10
|
+
"private": false,
|
|
11
|
+
"main": "src/index.js",
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@testing-library/jest-dom": "^5.16.1",
|
|
14
|
+
"@testing-library/react": "^11.2.7",
|
|
15
|
+
"@testing-library/user-event": "^12.8.3",
|
|
16
|
+
"d3": "^7.2.0",
|
|
17
|
+
"d3-color": "^3.0.1",
|
|
18
|
+
"d3-interpolate": "^3.0.1",
|
|
19
|
+
"react": "^17.0.2",
|
|
20
|
+
"react-dom": "^17.0.2",
|
|
21
|
+
"react-scripts": "4.0.3",
|
|
22
|
+
"typescript": "^4.5.4",
|
|
23
|
+
"web-vitals": "^1.1.2"
|
|
24
|
+
},
|
|
11
25
|
"scripts": {
|
|
12
|
-
"
|
|
26
|
+
"storybook": "start-storybook -p 6006",
|
|
27
|
+
"build-storybook": "build-storybook",
|
|
13
28
|
"semantic-release": "semantic-release"
|
|
14
29
|
},
|
|
15
30
|
"repository": {
|
|
@@ -17,14 +32,31 @@
|
|
|
17
32
|
"url": "git+https://github.com/emerson-eps/color-tables.git"
|
|
18
33
|
},
|
|
19
34
|
"license": "MPL",
|
|
20
|
-
"
|
|
21
|
-
"
|
|
35
|
+
"eslintConfig": {
|
|
36
|
+
"extends": [
|
|
37
|
+
"react-app",
|
|
38
|
+
"react-app/jest"
|
|
39
|
+
]
|
|
22
40
|
},
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
41
|
+
"browserslist": {
|
|
42
|
+
"production": [
|
|
43
|
+
">0.2%",
|
|
44
|
+
"not dead",
|
|
45
|
+
"not op_mini all"
|
|
46
|
+
],
|
|
47
|
+
"development": [
|
|
48
|
+
"last 1 chrome version",
|
|
49
|
+
"last 1 firefox version",
|
|
50
|
+
"last 1 safari version"
|
|
51
|
+
]
|
|
26
52
|
},
|
|
27
53
|
"devDependencies": {
|
|
54
|
+
"@babel/core": "^7.16.0",
|
|
55
|
+
"@storybook/addon-actions": "^6.4.9",
|
|
56
|
+
"@storybook/addon-essentials": "^6.4.9",
|
|
57
|
+
"@storybook/addon-links": "^6.4.9",
|
|
58
|
+
"@storybook/react": "^6.4.9",
|
|
59
|
+
"babel-loader": "^8.1.0",
|
|
28
60
|
"semantic-release": "^18.0.1"
|
|
29
61
|
}
|
|
30
62
|
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { RGBToHex, colorsArray } from "../Utils/continousLegend";
|
|
3
|
+
import { select, scaleLinear, scaleSequential, axisBottom } from "d3";
|
|
4
|
+
import { templateArray } from "../WelllayerTemplateTypes";
|
|
5
|
+
import { colorTablesArray } from "../ColorTableTypes";
|
|
6
|
+
|
|
7
|
+
interface legendProps {
|
|
8
|
+
min: number;
|
|
9
|
+
max: number;
|
|
10
|
+
dataObjectName: string;
|
|
11
|
+
position: number[];
|
|
12
|
+
name: string;
|
|
13
|
+
template: templateArray;
|
|
14
|
+
colorTables: colorTablesArray;
|
|
15
|
+
horizontal: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface ItemColor {
|
|
19
|
+
color: string;
|
|
20
|
+
offset: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const ContinuousLegend: React.FC<legendProps> = ({
|
|
24
|
+
min,
|
|
25
|
+
max,
|
|
26
|
+
dataObjectName,
|
|
27
|
+
position,
|
|
28
|
+
name,
|
|
29
|
+
template,
|
|
30
|
+
colorTables,
|
|
31
|
+
horizontal,
|
|
32
|
+
}: legendProps) => {
|
|
33
|
+
React.useEffect(() => {
|
|
34
|
+
continuousLegend("#legend");
|
|
35
|
+
}, [min, max, template, colorTables, horizontal]);
|
|
36
|
+
|
|
37
|
+
function continuousLegend(selected_id: string) {
|
|
38
|
+
const itemColor: ItemColor[] = [];
|
|
39
|
+
// Return the matched colors array from color.tables.json file
|
|
40
|
+
const colorTableColors = colorsArray(name, template, colorTables);
|
|
41
|
+
colorTableColors.forEach((value: [number, number, number, number]) => {
|
|
42
|
+
// return the color and offset needed to draw the legend
|
|
43
|
+
itemColor.push({
|
|
44
|
+
offset: RGBToHex(value).offset,
|
|
45
|
+
color: RGBToHex(value).color,
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
select(selected_id).select("svg").remove();
|
|
49
|
+
const colorScale = scaleSequential().domain([min, max]);
|
|
50
|
+
// append a defs (for definition) element to your SVG
|
|
51
|
+
const svgLegend = select(selected_id)
|
|
52
|
+
.append("svg")
|
|
53
|
+
.style("background-color", "#ffffffcc")
|
|
54
|
+
.style("border-radius", "5px");
|
|
55
|
+
if (!horizontal) {
|
|
56
|
+
svgLegend
|
|
57
|
+
.style("transform", "rotate(270deg)")
|
|
58
|
+
.style("margin-top", "80px");
|
|
59
|
+
}
|
|
60
|
+
const defs = svgLegend.append("defs");
|
|
61
|
+
// append a linearGradient element to the defs and give it a unique id
|
|
62
|
+
const linearGradient = defs
|
|
63
|
+
.append("linearGradient")
|
|
64
|
+
.attr("id", "linear-gradient")
|
|
65
|
+
.attr("x1", "0%")
|
|
66
|
+
.attr("x2", "100%") //since it's a horizontal linear gradient
|
|
67
|
+
.attr("y1", "0%")
|
|
68
|
+
.attr("y2", "0%");
|
|
69
|
+
// append multiple color stops by using D3's data/enter step
|
|
70
|
+
linearGradient
|
|
71
|
+
.selectAll("stop")
|
|
72
|
+
.data(itemColor)
|
|
73
|
+
.enter()
|
|
74
|
+
.append("stop")
|
|
75
|
+
.attr("offset", function (data) {
|
|
76
|
+
return data.offset + "%";
|
|
77
|
+
})
|
|
78
|
+
.attr("stop-color", function (data) {
|
|
79
|
+
return data.color;
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// append title
|
|
83
|
+
svgLegend
|
|
84
|
+
.append("text")
|
|
85
|
+
.attr("class", "legendTitle")
|
|
86
|
+
.attr("x", 25)
|
|
87
|
+
.attr("y", 20)
|
|
88
|
+
.style("text-anchor", "left")
|
|
89
|
+
.text(dataObjectName);
|
|
90
|
+
|
|
91
|
+
// draw the rectangle and fill with gradient
|
|
92
|
+
svgLegend
|
|
93
|
+
.append("rect")
|
|
94
|
+
.attr("x", 25)
|
|
95
|
+
.attr("y", 30)
|
|
96
|
+
.attr("width", 250)
|
|
97
|
+
.attr("height", 25)
|
|
98
|
+
.style("fill", "url(#linear-gradient)");
|
|
99
|
+
|
|
100
|
+
//create tick marks
|
|
101
|
+
const xLeg = scaleLinear().domain([min, max]).range([10, 258]);
|
|
102
|
+
|
|
103
|
+
const axisLeg = axisBottom(xLeg).tickValues(colorScale.domain());
|
|
104
|
+
|
|
105
|
+
svgLegend
|
|
106
|
+
.attr("class", "axis")
|
|
107
|
+
.append("g")
|
|
108
|
+
.attr("transform", "translate(15, 55)")
|
|
109
|
+
.style("font-size", "10px")
|
|
110
|
+
.style("font-weight", "700")
|
|
111
|
+
.call(axisLeg);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<div
|
|
116
|
+
style={{
|
|
117
|
+
position: "absolute",
|
|
118
|
+
right: position[0],
|
|
119
|
+
top: position[1],
|
|
120
|
+
}}
|
|
121
|
+
>
|
|
122
|
+
<div id="legend"></div>
|
|
123
|
+
</div>
|
|
124
|
+
);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
ContinuousLegend.defaultProps = {
|
|
128
|
+
position: [5, 10],
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export default ContinuousLegend;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import legendUtil from "../Utils/discreteLegend";
|
|
3
|
+
import { scaleOrdinal, select } from "d3";
|
|
4
|
+
import { templateArray, propertiesObj } from "../WelllayerTemplateTypes";
|
|
5
|
+
import { colorTablesArray, colorTablesObj } from "../ColorTableTypes";
|
|
6
|
+
|
|
7
|
+
interface ItemColor {
|
|
8
|
+
color: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface colorLegendProps {
|
|
12
|
+
discreteData: { objects: Record<string, [number[], number]> };
|
|
13
|
+
dataObjectName: string;
|
|
14
|
+
name: string;
|
|
15
|
+
position: number[];
|
|
16
|
+
template: templateArray;
|
|
17
|
+
colorTables: colorTablesArray;
|
|
18
|
+
horizontal: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const DiscreteColorLegend: React.FC<colorLegendProps> = ({
|
|
22
|
+
discreteData,
|
|
23
|
+
name,
|
|
24
|
+
dataObjectName,
|
|
25
|
+
position,
|
|
26
|
+
template,
|
|
27
|
+
colorTables,
|
|
28
|
+
horizontal,
|
|
29
|
+
}: colorLegendProps) => {
|
|
30
|
+
React.useEffect(() => {
|
|
31
|
+
discreteLegend("#legend");
|
|
32
|
+
}, [discreteData, template, colorTables, horizontal]);
|
|
33
|
+
function discreteLegend(legend: string) {
|
|
34
|
+
const itemName: string[] = [];
|
|
35
|
+
const itemColor: ItemColor[] = [];
|
|
36
|
+
const colorsArray: [number, number, number, number][] = colorTableData(
|
|
37
|
+
name,
|
|
38
|
+
template,
|
|
39
|
+
colorTables
|
|
40
|
+
);
|
|
41
|
+
Object.keys(discreteData).forEach((key) => {
|
|
42
|
+
// eslint-disable-next-line
|
|
43
|
+
let code = (discreteData as { [key: string]: any })[key][1]
|
|
44
|
+
// compare the first value in colorarray(colortable) and code from discreteData
|
|
45
|
+
const matchedColorsArrays = colorsArray.find((value: number[]) => {
|
|
46
|
+
return value[0] == code;
|
|
47
|
+
});
|
|
48
|
+
if (matchedColorsArrays)
|
|
49
|
+
itemColor.push({
|
|
50
|
+
color: RGBToHex(matchedColorsArrays),
|
|
51
|
+
});
|
|
52
|
+
itemName.push(key);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
function RGBToHex(rgb: number[]) {
|
|
56
|
+
let r = rgb[1].toString(16),
|
|
57
|
+
g = rgb[2].toString(16),
|
|
58
|
+
b = rgb[3].toString(16);
|
|
59
|
+
if (r.length == 1) r = "0" + r;
|
|
60
|
+
if (g.length == 1) g = "0" + g;
|
|
61
|
+
if (b.length == 1) b = "0" + b;
|
|
62
|
+
return "#" + r + g + b;
|
|
63
|
+
}
|
|
64
|
+
const ordinalValues = scaleOrdinal().domain(itemName);
|
|
65
|
+
const colorLegend = legendUtil(itemColor).inputScale(ordinalValues);
|
|
66
|
+
select(legend).select("svg").remove();
|
|
67
|
+
const legendLength = itemColor.length;
|
|
68
|
+
const calcLegendHeight = 22 * legendLength + 4 * legendLength;
|
|
69
|
+
const selectedLegend = select(legend);
|
|
70
|
+
if (!horizontal) selectedLegend.style("height", 150 + "px");
|
|
71
|
+
const svgLegend = selectedLegend
|
|
72
|
+
.append("svg")
|
|
73
|
+
.style("margin", "10px 10px")
|
|
74
|
+
.call(colorLegend);
|
|
75
|
+
if (colorLegend && horizontal) {
|
|
76
|
+
svgLegend
|
|
77
|
+
.attr("height", calcLegendHeight + "px")
|
|
78
|
+
.attr("width", 220 + "px");
|
|
79
|
+
} else {
|
|
80
|
+
svgLegend
|
|
81
|
+
.style("transform", "rotate(90deg)")
|
|
82
|
+
.attr("width", calcLegendHeight + "px")
|
|
83
|
+
.attr("height", calcLegendHeight + "px");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return (
|
|
87
|
+
<div
|
|
88
|
+
style={{
|
|
89
|
+
position: "absolute",
|
|
90
|
+
right: position[0],
|
|
91
|
+
top: position[1],
|
|
92
|
+
backgroundColor: "#ffffffcc",
|
|
93
|
+
borderRadius: "5px",
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
96
|
+
<label style={{ color: "#6F6F6F", margin: "10px 10px" }}>
|
|
97
|
+
{dataObjectName}
|
|
98
|
+
</label>
|
|
99
|
+
<div id="legend"></div>
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// Based on name return the colors array from color.tables.json file
|
|
105
|
+
export function colorTableData(
|
|
106
|
+
name: string,
|
|
107
|
+
template: templateArray,
|
|
108
|
+
colorTables: colorTablesArray
|
|
109
|
+
): [number, number, number, number][] {
|
|
110
|
+
const properties = template[0]["properties"];
|
|
111
|
+
const propertiesData = properties.filter(
|
|
112
|
+
(value: propertiesObj) => value.objectName == name
|
|
113
|
+
);
|
|
114
|
+
const colorTableData = colorTables.filter(
|
|
115
|
+
(value: colorTablesObj) =>
|
|
116
|
+
value.name.toLowerCase() ==
|
|
117
|
+
propertiesData[0].colorTable.toLowerCase()
|
|
118
|
+
);
|
|
119
|
+
return colorTableData[0].colors;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
DiscreteColorLegend.defaultProps = {
|
|
123
|
+
position: [5, 10],
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export default DiscreteColorLegend;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { color } from "d3-color";
|
|
2
|
+
import { interpolateRgb } from "d3-interpolate";
|
|
3
|
+
import {
|
|
4
|
+
colorTablesArray,
|
|
5
|
+
colorTablesObj,
|
|
6
|
+
} from "../ColorTableTypes";
|
|
7
|
+
import {
|
|
8
|
+
templateArray,
|
|
9
|
+
propertiesObj,
|
|
10
|
+
} from "../WelllayerTemplateTypes";
|
|
11
|
+
|
|
12
|
+
// Based on objectName return the colors array from color.tables.json file
|
|
13
|
+
export function colorsArray(
|
|
14
|
+
objectName: string,
|
|
15
|
+
template: templateArray,
|
|
16
|
+
colorTables: colorTablesArray
|
|
17
|
+
): [number, number, number, number][] {
|
|
18
|
+
const properties = template[0]["properties"];
|
|
19
|
+
const propertiesData = properties.filter(
|
|
20
|
+
(value: propertiesObj) => value.objectName == objectName
|
|
21
|
+
);
|
|
22
|
+
const colorTableData = colorTables.filter(
|
|
23
|
+
(value: colorTablesObj) =>
|
|
24
|
+
value.name.toLowerCase() ==
|
|
25
|
+
propertiesData[0].colorTable.toLowerCase()
|
|
26
|
+
);
|
|
27
|
+
return colorTableData[0].colors;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// return the colors based on the point
|
|
31
|
+
export function rgbValues(
|
|
32
|
+
objectName: string,
|
|
33
|
+
point: number,
|
|
34
|
+
template: templateArray,
|
|
35
|
+
colorTables: colorTablesArray
|
|
36
|
+
): number[] | { r: number; g: number; b: number; opacity: number } | undefined {
|
|
37
|
+
const colorTableColors = colorsArray(objectName, template, colorTables);
|
|
38
|
+
// compare the point and first value from colorTableColors
|
|
39
|
+
const colorArrays = colorTableColors.find(
|
|
40
|
+
(value: [number, number, number, number]) => {
|
|
41
|
+
return point == value[0];
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
// if point and value in color table matches then return particular colors
|
|
46
|
+
if (colorArrays) {
|
|
47
|
+
return colorArrays.slice(1);
|
|
48
|
+
}
|
|
49
|
+
// if no match then need to do interpolation
|
|
50
|
+
else {
|
|
51
|
+
// Get index of first match of colortable point greater than point
|
|
52
|
+
const index = colorTableColors.findIndex((value: number[]) => {
|
|
53
|
+
return value[0] > point;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const firstColorArray = colorTableColors[index - 1];
|
|
57
|
+
const secondColorArray = colorTableColors[index];
|
|
58
|
+
|
|
59
|
+
if ((firstColorArray || secondColorArray) != undefined) {
|
|
60
|
+
const interpolatedValues = interpolateRgb(
|
|
61
|
+
RGBToHex(firstColorArray).color,
|
|
62
|
+
RGBToHex(secondColorArray).color
|
|
63
|
+
)(point);
|
|
64
|
+
return color(interpolatedValues)?.rgb();
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// return the hex color code and offset
|
|
71
|
+
export function RGBToHex(rgb: number[]): { color: string; offset: number } {
|
|
72
|
+
let r = Math.round(rgb[1]).toString(16),
|
|
73
|
+
g = Math.round(rgb[2]).toString(16),
|
|
74
|
+
b = Math.round(rgb[3]).toString(16);
|
|
75
|
+
if (r.length == 1) r = "0" + r;
|
|
76
|
+
if (g.length == 1) g = "0" + g;
|
|
77
|
+
if (b.length == 1) b = "0" + b;
|
|
78
|
+
const offset = rgb[0] * 100.0;
|
|
79
|
+
|
|
80
|
+
return { color: "#" + r + g + b, offset: offset };
|
|
81
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
interface ItemColor {
|
|
2
|
+
color: string;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line
|
|
6
|
+
export default function legendUtil(itemColor: ItemColor[]): any {
|
|
7
|
+
let legendValues: ItemColor[] = [];
|
|
8
|
+
const cellWidth = 22;
|
|
9
|
+
const cellHeight = 22;
|
|
10
|
+
const cellPadding = 4;
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line
|
|
13
|
+
function legend(g: any) {
|
|
14
|
+
function drawLegend() {
|
|
15
|
+
itemColor.forEach((item, index) => {
|
|
16
|
+
legendValues[index].color = item.color;
|
|
17
|
+
});
|
|
18
|
+
// Code to fill the color
|
|
19
|
+
g.selectAll("g.legendCells")
|
|
20
|
+
.append("rect")
|
|
21
|
+
.attr("height", cellHeight)
|
|
22
|
+
.attr("width", cellWidth)
|
|
23
|
+
.style("stroke", "black")
|
|
24
|
+
.style("stroke-width", "1px")
|
|
25
|
+
.style("fill", function (d: Record<string, unknown>) {
|
|
26
|
+
return d["color"];
|
|
27
|
+
});
|
|
28
|
+
// Display the label
|
|
29
|
+
g.selectAll("g.legendCells")
|
|
30
|
+
.append("text")
|
|
31
|
+
.attr("class", "breakLabels")
|
|
32
|
+
.style("fill", "#6F6F6F")
|
|
33
|
+
.attr("x", cellWidth + cellPadding)
|
|
34
|
+
.attr("y", 5 + cellHeight / 2)
|
|
35
|
+
.text(function (d: Record<string, unknown>) {
|
|
36
|
+
return d["label"];
|
|
37
|
+
});
|
|
38
|
+
// Alighment of cell in straight line
|
|
39
|
+
g.selectAll("g.legendCells").attr(
|
|
40
|
+
"transform",
|
|
41
|
+
function (_d: Record<string, unknown>, i: number) {
|
|
42
|
+
return (
|
|
43
|
+
"translate(0," + i * (cellHeight + cellPadding) + ")"
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
// display the discrete legend
|
|
49
|
+
g.selectAll("g.legendCells")
|
|
50
|
+
.data(legendValues)
|
|
51
|
+
.enter()
|
|
52
|
+
.append("g")
|
|
53
|
+
.attr("class", "legendCells");
|
|
54
|
+
drawLegend();
|
|
55
|
+
}
|
|
56
|
+
// eslint-disable-next-line
|
|
57
|
+
legend.inputScale = function (newScale: any) {
|
|
58
|
+
// eslint-disable-next-line
|
|
59
|
+
let scale: any = {};
|
|
60
|
+
scale = newScale;
|
|
61
|
+
legendValues = [];
|
|
62
|
+
scale.domain().forEach(function (el: string) {
|
|
63
|
+
const cellObject = { color: scale(el), label: el };
|
|
64
|
+
legendValues.push(cellObject);
|
|
65
|
+
});
|
|
66
|
+
return this;
|
|
67
|
+
};
|
|
68
|
+
return legend;
|
|
69
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface propertiesObj {
|
|
2
|
+
objectName: string;
|
|
3
|
+
colorTable: string;
|
|
4
|
+
context: string;
|
|
5
|
+
colorInterpolation: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type propertiesArr = Array<propertiesObj>;
|
|
9
|
+
|
|
10
|
+
interface template {
|
|
11
|
+
name: string;
|
|
12
|
+
properties: propertiesArr;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type templateArray = Array<template>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
3
|
"name": "Physics",
|
|
4
|
-
"discrete":
|
|
4
|
+
"discrete": false,
|
|
5
5
|
"colors": [
|
|
6
6
|
[ 0.00, 255, 0, 0 ],
|
|
7
7
|
[ 0.25, 255, 255, 0 ],
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
"name": "Rainbow",
|
|
15
|
-
"discrete":
|
|
15
|
+
"discrete": false,
|
|
16
16
|
"colors": [
|
|
17
17
|
[ 0.00, 255, 0, 0 ],
|
|
18
18
|
[ 0.20, 255, 255, 0 ],
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
26
|
"name": "Porosity",
|
|
27
|
-
"discrete":
|
|
27
|
+
"discrete": false,
|
|
28
28
|
"colors": [
|
|
29
29
|
[ 0.00, 255, 246, 117 ],
|
|
30
30
|
[ 0.11, 255, 243, 53 ],
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
46
|
"name": "Permeability",
|
|
47
|
-
"discrete":
|
|
47
|
+
"discrete": false,
|
|
48
48
|
"colors": [
|
|
49
49
|
[ 0.00, 119, 63, 49 ],
|
|
50
50
|
[ 0.148, 135, 49, 45 ],
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
"name": "Seismic BlueWhiteRed",
|
|
63
|
-
"discrete":
|
|
63
|
+
"discrete": false,
|
|
64
64
|
"colors": [
|
|
65
65
|
[ 0.00, 0, 0, 255 ],
|
|
66
66
|
[ 0.50, 255, 255, 255 ],
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
71
|
"name": "Time/Depth",
|
|
72
|
-
"discrete":
|
|
72
|
+
"discrete": false,
|
|
73
73
|
"colors": [
|
|
74
74
|
[ 0.00, 252, 174, 169 ],
|
|
75
75
|
[ 0.10, 226, 44, 118 ],
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
},
|
|
91
91
|
{
|
|
92
92
|
"name": "Stratigraphy",
|
|
93
|
-
"discrete":
|
|
93
|
+
"discrete": true,
|
|
94
94
|
"colors": [
|
|
95
95
|
[ 0, 255, 120, 61 ],
|
|
96
96
|
[ 1, 255, 193, 0 ],
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
},
|
|
137
137
|
{
|
|
138
138
|
"name": "Facies",
|
|
139
|
-
"discrete":
|
|
139
|
+
"discrete": true,
|
|
140
140
|
"colors": [
|
|
141
141
|
[ 0, 255, 193, 0 ],
|
|
142
142
|
[ 1, 255, 246, 117 ],
|
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
},
|
|
160
160
|
{
|
|
161
161
|
"name": "Gas-Oil-Water",
|
|
162
|
-
"discrete":
|
|
162
|
+
"discrete": true,
|
|
163
163
|
"colors": [
|
|
164
164
|
[ 0, 255, 46, 0],
|
|
165
165
|
[ 1, 0, 184, 0 ],
|
|
@@ -169,7 +169,7 @@
|
|
|
169
169
|
},
|
|
170
170
|
{
|
|
171
171
|
"name": "Gas-Water",
|
|
172
|
-
"discrete":
|
|
172
|
+
"discrete": true,
|
|
173
173
|
"colors": [
|
|
174
174
|
[ 0, 255, 46, 0 ],
|
|
175
175
|
[ 1, 0, 25, 255 ],
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
},
|
|
179
179
|
{
|
|
180
180
|
"name": "Oil-Water",
|
|
181
|
-
"discrete":
|
|
181
|
+
"discrete": true,
|
|
182
182
|
"colors": [
|
|
183
183
|
[ 0, 0, 184, 0 ],
|
|
184
184
|
[ 1, 0, 25, 255 ],
|
|
@@ -186,4 +186,4 @@
|
|
|
186
186
|
]
|
|
187
187
|
}
|
|
188
188
|
]
|
|
189
|
-
|
|
189
|
+
|