@emerson-eps/color-tables 0.2.0 → 0.2.1
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/component/ColorSelector/ColorSelectorComponent.js +32 -6
- package/dist/component/ColorSelector/ColorSelectorComponent.js.map +1 -1
- package/dist/component/ColorSelector/ColorTableSelectorWrapper.js +3 -5
- package/dist/component/ColorSelector/ColorTableSelectorWrapper.js.map +1 -1
- package/dist/component/ColorSelector/legendComponent.d.ts +14 -0
- package/dist/component/ColorSelector/legendComponent.js +228 -0
- package/dist/component/ColorSelector/legendComponent.js.map +1 -0
- package/dist/component/Utils/d3ColorScale.d.ts +6 -3
- package/dist/component/Utils/d3ColorScale.js +51 -5
- package/dist/component/Utils/d3ColorScale.js.map +1 -1
- package/dist/component/Utils/discreteLegend.d.ts +2 -2
- package/dist/component/Utils/discreteLegend.js +26 -15
- package/dist/component/Utils/discreteLegend.js.map +1 -1
- package/package.json +1 -1
- package/src/component/ColorSelector/ColorSelectorComponent.tsx +55 -14
- package/src/component/ColorSelector/ColorTableSelectorWrapper.tsx +4 -6
- package/src/component/ColorSelector/legendComponent.tsx +289 -0
- package/src/component/Utils/d3ColorScale.ts +52 -7
- package/src/component/Utils/discreteLegend.ts +34 -23
- package/tsconfig.json +1 -1
- package/dist/component/Legend/legendContinous.d.ts +0 -11
- package/dist/component/Legend/legendContinous.js +0 -132
- package/dist/component/Legend/legendContinous.js.map +0 -1
- package/dist/stories/ColorLegends/ContinousLgends/MD.stories.d.ts +0 -7
- package/dist/stories/ColorLegends/ContinousLgends/MD.stories.js +0 -29
- package/dist/stories/ColorLegends/ContinousLgends/MD.stories.js.map +0 -1
- package/dist/stories/ColorLegends/ContinousLgends/NTG.stories.d.ts +0 -7
- package/dist/stories/ColorLegends/ContinousLgends/NTG.stories.js +0 -29
- package/dist/stories/ColorLegends/ContinousLgends/NTG.stories.js.map +0 -1
- package/dist/stories/ColorLegends/ContinousLgends/PermTot.stories.d.ts +0 -7
- package/dist/stories/ColorLegends/ContinousLgends/PermTot.stories.js +0 -29
- package/dist/stories/ColorLegends/ContinousLgends/PermTot.stories.js.map +0 -1
- package/dist/stories/ColorLegends/ContinousLgends/Permeability.stories.d.ts +0 -7
- package/dist/stories/ColorLegends/ContinousLgends/Permeability.stories.js +0 -29
- package/dist/stories/ColorLegends/ContinousLgends/Permeability.stories.js.map +0 -1
- package/dist/stories/ColorLegends/ContinousLgends/PoroTot.stories.d.ts +0 -7
- package/dist/stories/ColorLegends/ContinousLgends/PoroTot.stories.js +0 -29
- package/dist/stories/ColorLegends/ContinousLgends/PoroTot.stories.js.map +0 -1
- package/dist/stories/ColorLegends/ContinousLgends/Porosity.stories.d.ts +0 -7
- package/dist/stories/ColorLegends/ContinousLgends/Porosity.stories.js +0 -29
- package/dist/stories/ColorLegends/ContinousLgends/Porosity.stories.js.map +0 -1
- package/dist/stories/ColorLegends/ContinousLgends/SW.stories.d.ts +0 -7
- package/dist/stories/ColorLegends/ContinousLgends/SW.stories.js +0 -29
- package/dist/stories/ColorLegends/ContinousLgends/SW.stories.js.map +0 -1
- package/src/component/Legend/legendContinous.tsx +0 -175
- package/src/stories/ColorLegends/ContinousLgends/MD.stories.jsx +0 -31
- package/src/stories/ColorLegends/ContinousLgends/NTG.stories.jsx +0 -31
- package/src/stories/ColorLegends/ContinousLgends/PermTot.stories.jsx +0 -31
- package/src/stories/ColorLegends/ContinousLgends/Permeability.stories.jsx +0 -31
- package/src/stories/ColorLegends/ContinousLgends/PoroTot.stories.jsx +0 -31
- package/src/stories/ColorLegends/ContinousLgends/Porosity.stories.jsx +0 -31
- package/src/stories/ColorLegends/ContinousLgends/SW.stories.jsx +0 -31
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { useRef } from "react";
|
|
3
|
-
import { RGBToHex } from "../Utils/continousLegend";
|
|
4
|
-
import { colorScalesCont } from "../Utils/d3ColorScale";
|
|
5
|
-
import * as d3 from "d3";
|
|
6
|
-
export const LegendContinous = ({ position, colorArray, legendColor, legendColorName, useContColorTable, valueIndex, }) => {
|
|
7
|
-
const divRef = useRef(null);
|
|
8
|
-
React.useEffect(() => {
|
|
9
|
-
// colortable colors
|
|
10
|
-
if (useContColorTable == true && divRef.current) {
|
|
11
|
-
colortableLegend();
|
|
12
|
-
}
|
|
13
|
-
// d3 colors
|
|
14
|
-
else if (useContColorTable == false && divRef.current) {
|
|
15
|
-
d3colorLegend(colorScalesCont);
|
|
16
|
-
}
|
|
17
|
-
return function cleanup() {
|
|
18
|
-
d3.select(divRef.current).select("svg").remove();
|
|
19
|
-
};
|
|
20
|
-
}, [useContColorTable]);
|
|
21
|
-
function colortableLegend() {
|
|
22
|
-
const itemColor = [];
|
|
23
|
-
colorArray.color.forEach((value) => {
|
|
24
|
-
// return the color and offset needed to draw the legend
|
|
25
|
-
itemColor.push({
|
|
26
|
-
offset: RGBToHex(value).offset,
|
|
27
|
-
color: RGBToHex(value).color,
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
// append a defs (for definition) element to your SVG
|
|
31
|
-
const svgLegend = d3.select(divRef.current)
|
|
32
|
-
.append("svg")
|
|
33
|
-
.style("height", "50px")
|
|
34
|
-
.style("display", "flex");
|
|
35
|
-
const defs = svgLegend.append("defs");
|
|
36
|
-
let currentIndex = "linear-gradient-" + valueIndex;
|
|
37
|
-
// append a linearGradient element to the defs and give it a unique id
|
|
38
|
-
const linearGradient = defs
|
|
39
|
-
.append("linearGradient")
|
|
40
|
-
.attr("id", currentIndex)
|
|
41
|
-
.attr("x1", "0%")
|
|
42
|
-
.attr("x2", "100%") //since it's a horizontal linear gradient
|
|
43
|
-
.attr("y1", "0%")
|
|
44
|
-
.attr("y2", "0%");
|
|
45
|
-
// append multiple color stops by using D3's data/enter step
|
|
46
|
-
linearGradient
|
|
47
|
-
.selectAll("stop")
|
|
48
|
-
.data(itemColor)
|
|
49
|
-
.enter()
|
|
50
|
-
.append("stop")
|
|
51
|
-
.attr("offset", function (data) {
|
|
52
|
-
return data.offset + "%";
|
|
53
|
-
})
|
|
54
|
-
.attr("stop-color", function (data) {
|
|
55
|
-
return data.color;
|
|
56
|
-
});
|
|
57
|
-
// append title
|
|
58
|
-
svgLegend
|
|
59
|
-
.append("text")
|
|
60
|
-
.attr("class", "legendTitle")
|
|
61
|
-
.attr("x", 0)
|
|
62
|
-
.attr("y", 43)
|
|
63
|
-
.style("text-anchor", "left")
|
|
64
|
-
.text(colorArray.name);
|
|
65
|
-
// draw the rectangle and fill with gradient
|
|
66
|
-
svgLegend
|
|
67
|
-
.append("rect")
|
|
68
|
-
.attr("x", 180)
|
|
69
|
-
.attr("y", 30)
|
|
70
|
-
.attr("width", 150)
|
|
71
|
-
.attr("height", 25)
|
|
72
|
-
.style("fill", "url(#" + currentIndex + ")");
|
|
73
|
-
}
|
|
74
|
-
// continuous legend using d3 color scale (linear gradiend code)
|
|
75
|
-
function d3colorLegend(colorscale) {
|
|
76
|
-
const itemColor = [];
|
|
77
|
-
colorscale.forEach((value) => {
|
|
78
|
-
// return the color and offset needed to draw the legend
|
|
79
|
-
itemColor.push(value.colors);
|
|
80
|
-
});
|
|
81
|
-
// create an array of steps based on the color scale
|
|
82
|
-
// returns an array of evenly-spaced numbers. Returns the integers from zero to the specified end minus one.
|
|
83
|
-
// d3.range(start, stop, step)
|
|
84
|
-
var data = d3.range(10).map(d => ({ color: legendColor(d / 10), value: d }));
|
|
85
|
-
// get the array's min and max value
|
|
86
|
-
var extent = d3.extent(data, d => d.value);
|
|
87
|
-
// append a defs (for definition) element to your SVG
|
|
88
|
-
const svgLegend = d3.select(divRef.current)
|
|
89
|
-
.append("svg")
|
|
90
|
-
.style("height", "50px")
|
|
91
|
-
.style("display", "flex");
|
|
92
|
-
const defs = svgLegend.append("defs");
|
|
93
|
-
let currentIndex = "linear-gradient-" + valueIndex;
|
|
94
|
-
// append a linearGradient element to the defs and give it a unique id
|
|
95
|
-
const linearGradient = defs
|
|
96
|
-
.append("linearGradient")
|
|
97
|
-
.attr("id", currentIndex)
|
|
98
|
-
.attr("x1", "0%")
|
|
99
|
-
.attr("x2", "100%") //since it's a horizontal linear gradient
|
|
100
|
-
.attr("y1", "0%")
|
|
101
|
-
.attr("y2", "0%");
|
|
102
|
-
// append multiple color stops by using D3's data/enter step
|
|
103
|
-
linearGradient.selectAll("stop")
|
|
104
|
-
.data(data)
|
|
105
|
-
.enter().append("stop")
|
|
106
|
-
.attr("offset", d => ((d.value - extent[0]) / (extent[1] - extent[0]) * 100) + "%")
|
|
107
|
-
.attr("stop-color", d => d.color);
|
|
108
|
-
// append title
|
|
109
|
-
svgLegend
|
|
110
|
-
.append("text")
|
|
111
|
-
.attr("class", "legendTitle")
|
|
112
|
-
.attr("x", 0)
|
|
113
|
-
.attr("y", 43)
|
|
114
|
-
.style("text-anchor", "left")
|
|
115
|
-
.text(legendColorName);
|
|
116
|
-
// draw the rectangle and fill with gradient
|
|
117
|
-
svgLegend
|
|
118
|
-
.append("rect")
|
|
119
|
-
.attr("x", 180)
|
|
120
|
-
.attr("y", 30)
|
|
121
|
-
.attr("width", 150)
|
|
122
|
-
.attr("height", 25)
|
|
123
|
-
.style("fill", "url(#" + currentIndex + ")");
|
|
124
|
-
}
|
|
125
|
-
return (React.createElement("div", { style: {
|
|
126
|
-
right: position ? position[0] : ' ',
|
|
127
|
-
top: position ? position[1] : ' ',
|
|
128
|
-
} }, useContColorTable ? React.createElement("div", { className: "colortableLegend", ref: divRef })
|
|
129
|
-
:
|
|
130
|
-
React.createElement("div", { className: "d3colorLegend", ref: divRef })));
|
|
131
|
-
};
|
|
132
|
-
//# sourceMappingURL=legendContinous.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legendContinous.js","sourceRoot":"","sources":["../../../src/component/Legend/legendContinous.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,C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GAAC,GAAG,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,CACH,6BACI,KAAK,EAAE;YACH,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;YACnC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;SACpC,IAEA,iBAAiB,CAAC,CAAC,CAAC,6BAAK,SAAS,EAAC,kBAAkB,EAAC,GAAG,EAAE,MAAM,GAAQ;QAC1E,CAAC;YACD,6BAAK,SAAS,EAAC,eAAe,EAAC,GAAG,EAAE,MAAM,GAAQ,CAChD,CACT,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ContinuousLegend } from "../../../component/Legend/ContinuousLegend";
|
|
3
|
-
export default {
|
|
4
|
-
component: ContinuousLegend,
|
|
5
|
-
title: "Legends/ContinousLegend",
|
|
6
|
-
};
|
|
7
|
-
import colorTables from "../../../component/color-tables.json";
|
|
8
|
-
const min = 2918;
|
|
9
|
-
const max = 4770;
|
|
10
|
-
const dataObjectName = "Wells / MD";
|
|
11
|
-
const position = [16, 10];
|
|
12
|
-
const name = "MD";
|
|
13
|
-
const horizontal = true;
|
|
14
|
-
const colorName = "Time/Depth";
|
|
15
|
-
const Template = (args) => {
|
|
16
|
-
return React.createElement(ContinuousLegend, Object.assign({}, args));
|
|
17
|
-
};
|
|
18
|
-
export const MDTemplate = Template.bind({});
|
|
19
|
-
MDTemplate.args = {
|
|
20
|
-
min,
|
|
21
|
-
max,
|
|
22
|
-
dataObjectName,
|
|
23
|
-
position,
|
|
24
|
-
name,
|
|
25
|
-
colorName,
|
|
26
|
-
colorTables,
|
|
27
|
-
horizontal,
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=MD.stories.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MD.stories.js","sourceRoot":"","sources":["../../../../src/stories/ColorLegends/ContinousLgends/MD.stories.jsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,gBAAgB,EAAC,MAAM,4CAA4C,CAAC;AAC5E,eAAe;IACX,SAAS,EAAE,gBAAgB;IAC3B,KAAK,EAAE,yBAAyB;CACnC,CAAC;AACF,OAAO,WAAW,MAAM,sCAAsC,CAAC;AAE/D,MAAM,GAAG,GAAG,IAAI,CAAC;AACjB,MAAM,GAAG,GAAG,IAAI,CAAC;AACjB,MAAM,cAAc,GAAG,YAAY,CAAC;AACpC,MAAM,QAAQ,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1B,MAAM,IAAI,GAAG,IAAI,CAAC;AAClB,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,SAAS,GAAG,YAAY,CAAC;AAE/B,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,EAAE;IACtB,OAAO,oBAAC,gBAAgB,oBAAK,IAAI,EAAI,CAAC;AAC1C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC5C,UAAU,CAAC,IAAI,GAAG;IACd,GAAG;IACH,GAAG;IACH,cAAc;IACd,QAAQ;IACR,IAAI;IACJ,SAAS;IACT,WAAW;IACX,UAAU;CACb,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ContinuousLegend } from "../../../component/Legend/ContinuousLegend";
|
|
3
|
-
export default {
|
|
4
|
-
component: ContinuousLegend,
|
|
5
|
-
title: "Legends/ContinousLegend",
|
|
6
|
-
};
|
|
7
|
-
import colorTables from "../../../component/color-tables.json";
|
|
8
|
-
const min = 0;
|
|
9
|
-
const max = 1;
|
|
10
|
-
const dataObjectName = "Wells / NTG";
|
|
11
|
-
const position = [16, 10];
|
|
12
|
-
const name = "NTG";
|
|
13
|
-
const horizontal = true;
|
|
14
|
-
const colorName = "Rainbow";
|
|
15
|
-
const Template = (args) => {
|
|
16
|
-
return React.createElement(ContinuousLegend, Object.assign({}, args));
|
|
17
|
-
};
|
|
18
|
-
export const NTGTemplate = Template.bind({});
|
|
19
|
-
NTGTemplate.args = {
|
|
20
|
-
min,
|
|
21
|
-
max,
|
|
22
|
-
dataObjectName,
|
|
23
|
-
position,
|
|
24
|
-
name,
|
|
25
|
-
colorName,
|
|
26
|
-
colorTables,
|
|
27
|
-
horizontal,
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=NTG.stories.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NTG.stories.js","sourceRoot":"","sources":["../../../../src/stories/ColorLegends/ContinousLgends/NTG.stories.jsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,gBAAgB,EAAC,MAAM,4CAA4C,CAAC;AAC5E,eAAe;IACX,SAAS,EAAE,gBAAgB;IAC3B,KAAK,EAAE,yBAAyB;CACnC,CAAC;AACF,OAAO,WAAW,MAAM,sCAAsC,CAAC;AAE/D,MAAM,GAAG,GAAG,CAAC,CAAC;AACd,MAAM,GAAG,GAAG,CAAC,CAAC;AACd,MAAM,cAAc,GAAG,aAAa,CAAC;AACrC,MAAM,QAAQ,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1B,MAAM,IAAI,GAAG,KAAK,CAAC;AACnB,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,SAAS,GAAG,SAAS,CAAC;AAE5B,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,EAAE;IACtB,OAAO,oBAAC,gBAAgB,oBAAK,IAAI,EAAI,CAAC;AAC1C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC7C,WAAW,CAAC,IAAI,GAAG;IACf,GAAG;IACH,GAAG;IACH,cAAc;IACd,QAAQ;IACR,IAAI;IACJ,SAAS;IACT,WAAW;IACX,UAAU;CACb,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ContinuousLegend } from "../../../component/Legend/ContinuousLegend";
|
|
3
|
-
export default {
|
|
4
|
-
component: ContinuousLegend,
|
|
5
|
-
title: "Legends/ContinousLegend",
|
|
6
|
-
};
|
|
7
|
-
import colorTables from "../../../component/color-tables.json";
|
|
8
|
-
const min = -999;
|
|
9
|
-
const max = 14023;
|
|
10
|
-
const dataObjectName = "Wells / PERMTOT";
|
|
11
|
-
const position = [16, 10];
|
|
12
|
-
const name = "PERM_TOT";
|
|
13
|
-
const horizontal = true;
|
|
14
|
-
const colorName = "Porosity";
|
|
15
|
-
const Template = (args) => {
|
|
16
|
-
return React.createElement(ContinuousLegend, Object.assign({}, args));
|
|
17
|
-
};
|
|
18
|
-
export const PermTotTemplate = Template.bind({});
|
|
19
|
-
PermTotTemplate.args = {
|
|
20
|
-
min,
|
|
21
|
-
max,
|
|
22
|
-
dataObjectName,
|
|
23
|
-
position,
|
|
24
|
-
name,
|
|
25
|
-
colorName,
|
|
26
|
-
colorTables,
|
|
27
|
-
horizontal,
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=PermTot.stories.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PermTot.stories.js","sourceRoot":"","sources":["../../../../src/stories/ColorLegends/ContinousLgends/PermTot.stories.jsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,gBAAgB,EAAC,MAAM,4CAA4C,CAAC;AAC5E,eAAe;IACX,SAAS,EAAE,gBAAgB;IAC3B,KAAK,EAAE,yBAAyB;CACnC,CAAC;AACF,OAAO,WAAW,MAAM,sCAAsC,CAAC;AAE/D,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC;AACjB,MAAM,GAAG,GAAG,KAAK,CAAC;AAClB,MAAM,cAAc,GAAG,iBAAiB,CAAC;AACzC,MAAM,QAAQ,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1B,MAAM,IAAI,GAAG,UAAU,CAAC;AACxB,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,SAAS,GAAG,UAAU,CAAC;AAE7B,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,EAAE;IACtB,OAAO,oBAAC,gBAAgB,oBAAK,IAAI,EAAI,CAAC;AAC1C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACjD,eAAe,CAAC,IAAI,GAAG;IACnB,GAAG;IACH,GAAG;IACH,cAAc;IACd,QAAQ;IACR,IAAI;IACJ,SAAS;IACT,WAAW;IACX,UAAU;CACb,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ContinuousLegend } from "../../../component/Legend/ContinuousLegend";
|
|
3
|
-
export default {
|
|
4
|
-
component: ContinuousLegend,
|
|
5
|
-
title: "Legends/ContinousLegend",
|
|
6
|
-
};
|
|
7
|
-
import colorTables from "../../../component/color-tables.json";
|
|
8
|
-
const min = -999;
|
|
9
|
-
const max = 14023;
|
|
10
|
-
const dataObjectName = "Wells / PERM";
|
|
11
|
-
const position = [16, 10];
|
|
12
|
-
const name = "PERM";
|
|
13
|
-
const horizontal = true;
|
|
14
|
-
const colorName = "Permeability";
|
|
15
|
-
const Template = (args) => {
|
|
16
|
-
return React.createElement(ContinuousLegend, Object.assign({}, args));
|
|
17
|
-
};
|
|
18
|
-
export const PermeabilityTemplate = Template.bind({});
|
|
19
|
-
PermeabilityTemplate.args = {
|
|
20
|
-
min,
|
|
21
|
-
max,
|
|
22
|
-
dataObjectName,
|
|
23
|
-
position,
|
|
24
|
-
name,
|
|
25
|
-
colorName,
|
|
26
|
-
colorTables,
|
|
27
|
-
horizontal,
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=Permeability.stories.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Permeability.stories.js","sourceRoot":"","sources":["../../../../src/stories/ColorLegends/ContinousLgends/Permeability.stories.jsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,gBAAgB,EAAC,MAAM,4CAA4C,CAAC;AAC5E,eAAe;IACX,SAAS,EAAE,gBAAgB;IAC3B,KAAK,EAAE,yBAAyB;CACnC,CAAC;AACF,OAAO,WAAW,MAAM,sCAAsC,CAAC;AAE/D,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC;AACjB,MAAM,GAAG,GAAG,KAAK,CAAC;AAClB,MAAM,cAAc,GAAG,cAAc,CAAC;AACtC,MAAM,QAAQ,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1B,MAAM,IAAI,GAAG,MAAM,CAAC;AACpB,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,SAAS,GAAG,cAAc,CAAC;AAEjC,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,EAAE;IACtB,OAAO,oBAAC,gBAAgB,oBAAK,IAAI,EAAI,CAAC;AAC1C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACtD,oBAAoB,CAAC,IAAI,GAAG;IACxB,GAAG;IACH,GAAG;IACH,cAAc;IACd,QAAQ;IACR,IAAI;IACJ,SAAS;IACT,WAAW;IACX,UAAU;CACb,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ContinuousLegend } from "../../../component/Legend/ContinuousLegend";
|
|
3
|
-
export default {
|
|
4
|
-
component: ContinuousLegend,
|
|
5
|
-
title: "Legends/ContinousLegend",
|
|
6
|
-
};
|
|
7
|
-
import colorTables from "../../../component/color-tables.json";
|
|
8
|
-
const min = 0;
|
|
9
|
-
const max = 0.35;
|
|
10
|
-
const dataObjectName = "Wells / POROTOT";
|
|
11
|
-
const position = [16, 10];
|
|
12
|
-
const name = "PORO";
|
|
13
|
-
const horizontal = true;
|
|
14
|
-
const colorName = "Porosity";
|
|
15
|
-
const Template = (args) => {
|
|
16
|
-
return React.createElement(ContinuousLegend, Object.assign({}, args));
|
|
17
|
-
};
|
|
18
|
-
export const PoroTotTemplate = Template.bind({});
|
|
19
|
-
PoroTotTemplate.args = {
|
|
20
|
-
min,
|
|
21
|
-
max,
|
|
22
|
-
dataObjectName,
|
|
23
|
-
position,
|
|
24
|
-
name,
|
|
25
|
-
colorName,
|
|
26
|
-
colorTables,
|
|
27
|
-
horizontal,
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=PoroTot.stories.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PoroTot.stories.js","sourceRoot":"","sources":["../../../../src/stories/ColorLegends/ContinousLgends/PoroTot.stories.jsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,gBAAgB,EAAC,MAAM,4CAA4C,CAAC;AAC5E,eAAe;IACX,SAAS,EAAE,gBAAgB;IAC3B,KAAK,EAAE,yBAAyB;CACnC,CAAC;AACF,OAAO,WAAW,MAAM,sCAAsC,CAAC;AAE/D,MAAM,GAAG,GAAG,CAAC,CAAC;AACd,MAAM,GAAG,GAAG,IAAI,CAAC;AACjB,MAAM,cAAc,GAAG,iBAAiB,CAAC;AACzC,MAAM,QAAQ,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1B,MAAM,IAAI,GAAG,MAAM,CAAC;AACpB,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,SAAS,GAAG,UAAU,CAAC;AAE7B,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,EAAE;IACtB,OAAO,oBAAC,gBAAgB,oBAAK,IAAI,EAAI,CAAC;AAC1C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACjD,eAAe,CAAC,IAAI,GAAG;IACnB,GAAG;IACH,GAAG;IACH,cAAc;IACd,QAAQ;IACR,IAAI;IACJ,SAAS;IACT,WAAW;IACX,UAAU;CACb,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ContinuousLegend } from "../../../component/Legend/ContinuousLegend";
|
|
3
|
-
export default {
|
|
4
|
-
component: ContinuousLegend,
|
|
5
|
-
title: "Legends/ContinousLegend",
|
|
6
|
-
};
|
|
7
|
-
import colorTables from "../../../component/color-tables.json";
|
|
8
|
-
const min = 0;
|
|
9
|
-
const max = 0.35;
|
|
10
|
-
const dataObjectName = "Wells / PORO";
|
|
11
|
-
const position = [16, 10];
|
|
12
|
-
const name = "PORO";
|
|
13
|
-
const horizontal = true;
|
|
14
|
-
const colorName = "Porosity";
|
|
15
|
-
const Template = (args) => {
|
|
16
|
-
return React.createElement(ContinuousLegend, Object.assign({}, args));
|
|
17
|
-
};
|
|
18
|
-
export const PorosityTemplate = Template.bind({});
|
|
19
|
-
PorosityTemplate.args = {
|
|
20
|
-
min,
|
|
21
|
-
max,
|
|
22
|
-
dataObjectName,
|
|
23
|
-
position,
|
|
24
|
-
name,
|
|
25
|
-
colorName,
|
|
26
|
-
colorTables,
|
|
27
|
-
horizontal,
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=Porosity.stories.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Porosity.stories.js","sourceRoot":"","sources":["../../../../src/stories/ColorLegends/ContinousLgends/Porosity.stories.jsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,gBAAgB,EAAC,MAAM,4CAA4C,CAAC;AAC5E,eAAe;IACX,SAAS,EAAE,gBAAgB;IAC3B,KAAK,EAAE,yBAAyB;CACnC,CAAC;AACF,OAAO,WAAW,MAAM,sCAAsC,CAAC;AAE/D,MAAM,GAAG,GAAG,CAAC,CAAC;AACd,MAAM,GAAG,GAAG,IAAI,CAAC;AACjB,MAAM,cAAc,GAAG,cAAc,CAAC;AACtC,MAAM,QAAQ,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1B,MAAM,IAAI,GAAG,MAAM,CAAC;AACpB,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,SAAS,GAAG,UAAU,CAAC;AAE7B,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,EAAE;IACtB,OAAO,oBAAC,gBAAgB,oBAAK,IAAI,EAAI,CAAC;AAC1C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAClD,gBAAgB,CAAC,IAAI,GAAG;IACpB,GAAG;IACH,GAAG;IACH,cAAc;IACd,QAAQ;IACR,IAAI;IACJ,SAAS;IACT,WAAW;IACX,UAAU;CACb,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ContinuousLegend } from "../../../component/Legend/ContinuousLegend";
|
|
3
|
-
export default {
|
|
4
|
-
component: ContinuousLegend,
|
|
5
|
-
title: "Legends/ContinousLegend",
|
|
6
|
-
};
|
|
7
|
-
import colorTables from "../../../component/color-tables.json";
|
|
8
|
-
const min = 0;
|
|
9
|
-
const max = 1;
|
|
10
|
-
const dataObjectName = "Wells / SW";
|
|
11
|
-
const position = [16, 10];
|
|
12
|
-
const name = "SW";
|
|
13
|
-
const horizontal = true;
|
|
14
|
-
const colorName = "Physics";
|
|
15
|
-
const Template = (args) => {
|
|
16
|
-
return React.createElement(ContinuousLegend, Object.assign({}, args));
|
|
17
|
-
};
|
|
18
|
-
export const SWTemplate = Template.bind({});
|
|
19
|
-
SWTemplate.args = {
|
|
20
|
-
min,
|
|
21
|
-
max,
|
|
22
|
-
dataObjectName,
|
|
23
|
-
position,
|
|
24
|
-
name,
|
|
25
|
-
Physics,
|
|
26
|
-
colorTables,
|
|
27
|
-
horizontal,
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=SW.stories.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SW.stories.js","sourceRoot":"","sources":["../../../../src/stories/ColorLegends/ContinousLgends/SW.stories.jsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,gBAAgB,EAAC,MAAM,4CAA4C,CAAC;AAC5E,eAAe;IACX,SAAS,EAAE,gBAAgB;IAC3B,KAAK,EAAE,yBAAyB;CACnC,CAAC;AACF,OAAO,WAAW,MAAM,sCAAsC,CAAC;AAE/D,MAAM,GAAG,GAAG,CAAC,CAAC;AACd,MAAM,GAAG,GAAG,CAAC,CAAC;AACd,MAAM,cAAc,GAAG,YAAY,CAAC;AACpC,MAAM,QAAQ,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1B,MAAM,IAAI,GAAG,IAAI,CAAC;AAClB,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,SAAS,GAAG,SAAS,CAAC;AAE5B,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,EAAE;IACtB,OAAO,oBAAC,gBAAgB,oBAAK,IAAI,EAAI,CAAC;AAC1C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC5C,UAAU,CAAC,IAAI,GAAG;IACd,GAAG;IACH,GAAG;IACH,cAAc;IACd,QAAQ;IACR,IAAI;IACJ,OAAO;IACP,WAAW;IACX,UAAU;CACb,CAAC"}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { useRef } from "react";
|
|
3
|
-
import { RGBToHex } from "../Utils/continousLegend";
|
|
4
|
-
import {colorScalesCont} from "../Utils/d3ColorScale"
|
|
5
|
-
import * as d3 from "d3";
|
|
6
|
-
|
|
7
|
-
interface legendProps {
|
|
8
|
-
position?: number[] | null;
|
|
9
|
-
colorArray: any;
|
|
10
|
-
legendColor: any;
|
|
11
|
-
legendColorName: string;
|
|
12
|
-
useContColorTable: boolean;
|
|
13
|
-
valueIndex: any;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface ItemColor {
|
|
17
|
-
color: string;
|
|
18
|
-
offset: number;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const LegendContinous: React.FC<legendProps> = ({
|
|
22
|
-
position,
|
|
23
|
-
colorArray,
|
|
24
|
-
legendColor,
|
|
25
|
-
legendColorName,
|
|
26
|
-
useContColorTable,
|
|
27
|
-
valueIndex,
|
|
28
|
-
}: legendProps) => {
|
|
29
|
-
const divRef = useRef<HTMLDivElement>(null);
|
|
30
|
-
React.useEffect(() => {
|
|
31
|
-
// colortable colors
|
|
32
|
-
if (useContColorTable == true && divRef.current) {
|
|
33
|
-
colortableLegend()
|
|
34
|
-
}
|
|
35
|
-
// d3 colors
|
|
36
|
-
else if (useContColorTable == false && divRef.current) {
|
|
37
|
-
d3colorLegend(colorScalesCont)
|
|
38
|
-
}
|
|
39
|
-
return function cleanup() {
|
|
40
|
-
d3.select(divRef.current).select("svg").remove();
|
|
41
|
-
};
|
|
42
|
-
}, [useContColorTable]);
|
|
43
|
-
|
|
44
|
-
function colortableLegend() {
|
|
45
|
-
const itemColor: ItemColor[] = [];
|
|
46
|
-
colorArray.color.forEach((value: [number, number, number, number]) => {
|
|
47
|
-
// return the color and offset needed to draw the legend
|
|
48
|
-
itemColor.push({
|
|
49
|
-
offset: RGBToHex(value).offset,
|
|
50
|
-
color: RGBToHex(value).color,
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// append a defs (for definition) element to your SVG
|
|
55
|
-
const svgLegend = d3.select(divRef.current)
|
|
56
|
-
.append("svg")
|
|
57
|
-
.style("height", "50px")
|
|
58
|
-
.style("display", "flex")
|
|
59
|
-
|
|
60
|
-
const defs = svgLegend.append("defs");
|
|
61
|
-
let currentIndex = "linear-gradient-" + valueIndex;
|
|
62
|
-
// append a linearGradient element to the defs and give it a unique id
|
|
63
|
-
const linearGradient = defs
|
|
64
|
-
.append("linearGradient")
|
|
65
|
-
.attr("id", currentIndex)
|
|
66
|
-
.attr("x1", "0%")
|
|
67
|
-
.attr("x2", "100%") //since it's a horizontal linear gradient
|
|
68
|
-
.attr("y1", "0%")
|
|
69
|
-
.attr("y2", "0%");
|
|
70
|
-
// append multiple color stops by using D3's data/enter step
|
|
71
|
-
|
|
72
|
-
linearGradient
|
|
73
|
-
.selectAll("stop")
|
|
74
|
-
.data(itemColor)
|
|
75
|
-
.enter()
|
|
76
|
-
.append("stop")
|
|
77
|
-
.attr("offset", function (data) {
|
|
78
|
-
return data.offset + "%";
|
|
79
|
-
})
|
|
80
|
-
.attr("stop-color", function (data) {
|
|
81
|
-
return data.color;
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// append title
|
|
85
|
-
svgLegend
|
|
86
|
-
.append("text")
|
|
87
|
-
.attr("class", "legendTitle")
|
|
88
|
-
.attr("x", 0)
|
|
89
|
-
.attr("y", 43)
|
|
90
|
-
.style("text-anchor", "left")
|
|
91
|
-
.text(colorArray.name);
|
|
92
|
-
|
|
93
|
-
// draw the rectangle and fill with gradient
|
|
94
|
-
svgLegend
|
|
95
|
-
.append("rect")
|
|
96
|
-
.attr("x", 180)
|
|
97
|
-
.attr("y", 30)
|
|
98
|
-
.attr("width", 150)
|
|
99
|
-
.attr("height", 25)
|
|
100
|
-
.style("fill", "url(#"+currentIndex+")");
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// continuous legend using d3 color scale (linear gradiend code)
|
|
104
|
-
function d3colorLegend(colorscale: any) {
|
|
105
|
-
|
|
106
|
-
const itemColor: any = [];
|
|
107
|
-
|
|
108
|
-
colorscale.forEach((value: any) => {
|
|
109
|
-
// return the color and offset needed to draw the legend
|
|
110
|
-
itemColor.push(value.colors);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
// create an array of steps based on the color scale
|
|
114
|
-
// returns an array of evenly-spaced numbers. Returns the integers from zero to the specified end minus one.
|
|
115
|
-
// d3.range(start, stop, step)
|
|
116
|
-
var data = d3.range(10).map(d=> ({color:legendColor(d/10), value:d}))
|
|
117
|
-
// get the array's min and max value
|
|
118
|
-
var extent: any = d3.extent(data, d => d.value);
|
|
119
|
-
|
|
120
|
-
// append a defs (for definition) element to your SVG
|
|
121
|
-
const svgLegend = d3.select(divRef.current)
|
|
122
|
-
.append("svg")
|
|
123
|
-
.style("height", "50px")
|
|
124
|
-
.style("display", "flex")
|
|
125
|
-
|
|
126
|
-
const defs = svgLegend.append("defs");
|
|
127
|
-
let currentIndex = "linear-gradient-" + valueIndex;
|
|
128
|
-
// append a linearGradient element to the defs and give it a unique id
|
|
129
|
-
const linearGradient = defs
|
|
130
|
-
.append("linearGradient")
|
|
131
|
-
.attr("id", currentIndex)
|
|
132
|
-
.attr("x1", "0%")
|
|
133
|
-
.attr("x2", "100%") //since it's a horizontal linear gradient
|
|
134
|
-
.attr("y1", "0%")
|
|
135
|
-
.attr("y2", "0%");
|
|
136
|
-
|
|
137
|
-
// append multiple color stops by using D3's data/enter step
|
|
138
|
-
linearGradient.selectAll("stop")
|
|
139
|
-
.data(data)
|
|
140
|
-
.enter().append("stop")
|
|
141
|
-
.attr("offset", d => ((d.value - extent[0]) / (extent[1] - extent[0]) * 100) + "%")
|
|
142
|
-
.attr("stop-color", d => d.color);
|
|
143
|
-
|
|
144
|
-
// append title
|
|
145
|
-
svgLegend
|
|
146
|
-
.append("text")
|
|
147
|
-
.attr("class", "legendTitle")
|
|
148
|
-
.attr("x", 0)
|
|
149
|
-
.attr("y", 43)
|
|
150
|
-
.style("text-anchor", "left")
|
|
151
|
-
.text(legendColorName);
|
|
152
|
-
|
|
153
|
-
// draw the rectangle and fill with gradient
|
|
154
|
-
svgLegend
|
|
155
|
-
.append("rect")
|
|
156
|
-
.attr("x", 180)
|
|
157
|
-
.attr("y", 30)
|
|
158
|
-
.attr("width", 150)
|
|
159
|
-
.attr("height", 25)
|
|
160
|
-
.style("fill", "url(#"+currentIndex+")");
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return (
|
|
164
|
-
<div
|
|
165
|
-
style={{
|
|
166
|
-
right: position ? position[0] : ' ',
|
|
167
|
-
top: position ? position[1] : ' ',
|
|
168
|
-
}}
|
|
169
|
-
>
|
|
170
|
-
{useContColorTable ? <div className="colortableLegend" ref={divRef}></div>
|
|
171
|
-
:
|
|
172
|
-
<div className="d3colorLegend" ref={divRef}></div>}
|
|
173
|
-
</div>
|
|
174
|
-
);
|
|
175
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import {ContinuousLegend} from "../../../component/Legend/ContinuousLegend";
|
|
3
|
-
export default {
|
|
4
|
-
component: ContinuousLegend,
|
|
5
|
-
title: "Legends/ContinousLegend",
|
|
6
|
-
};
|
|
7
|
-
import colorTables from "../../../component/color-tables.json";
|
|
8
|
-
|
|
9
|
-
const min = 2918;
|
|
10
|
-
const max = 4770;
|
|
11
|
-
const dataObjectName = "Wells / MD";
|
|
12
|
-
const position = [16, 10];
|
|
13
|
-
const name = "MD";
|
|
14
|
-
const horizontal = true;
|
|
15
|
-
const colorName = "Time/Depth";
|
|
16
|
-
|
|
17
|
-
const Template = (args) => {
|
|
18
|
-
return <ContinuousLegend {...args} />;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const MDTemplate = Template.bind({});
|
|
22
|
-
MDTemplate.args = {
|
|
23
|
-
min,
|
|
24
|
-
max,
|
|
25
|
-
dataObjectName,
|
|
26
|
-
position,
|
|
27
|
-
name,
|
|
28
|
-
colorName,
|
|
29
|
-
colorTables,
|
|
30
|
-
horizontal,
|
|
31
|
-
};
|