@emerson-eps/color-tables 0.2.3 → 0.2.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.
Files changed (60) hide show
  1. package/dist/component/ColorSelector/ColorSelectorAccordion.d.ts +2 -0
  2. package/dist/component/ColorSelector/{ColorTableSelectorWrapper.js → ColorSelectorAccordion.js} +12 -7
  3. package/dist/component/ColorSelector/ColorSelectorAccordion.js.map +1 -0
  4. package/dist/component/ColorSelector/ColorSelectorComponent.d.ts +12 -3
  5. package/dist/component/ColorSelector/ColorSelectorComponent.js +254 -51
  6. package/dist/component/ColorSelector/ColorSelectorComponent.js.map +1 -1
  7. package/dist/component/ColorSelector/ColorSelectorWrapper.d.ts +8 -0
  8. package/dist/component/ColorSelector/ColorSelectorWrapper.js +64 -0
  9. package/dist/component/ColorSelector/ColorSelectorWrapper.js.map +1 -0
  10. package/dist/component/Legend/ColorLegend.d.ts +13 -0
  11. package/dist/component/Legend/ColorLegend.js +26 -0
  12. package/dist/component/Legend/ColorLegend.js.map +1 -0
  13. package/dist/component/Legend/ContinuousLegend.d.ts +1 -0
  14. package/dist/component/Legend/ContinuousLegend.js +147 -75
  15. package/dist/component/Legend/ContinuousLegend.js.map +1 -1
  16. package/dist/component/Legend/DiscreteLegend.d.ts +2 -0
  17. package/dist/component/Legend/DiscreteLegend.js +118 -62
  18. package/dist/component/Legend/DiscreteLegend.js.map +1 -1
  19. package/dist/component/Utils/discreteLegend.d.ts +1 -1
  20. package/dist/component/Utils/discreteLegend.js +70 -50
  21. package/dist/component/Utils/discreteLegend.js.map +1 -1
  22. package/dist/component/color-tables.json +4 -4
  23. package/dist/stories/ColorLegends/ColorSelector/Selector.stories.d.ts +2 -2
  24. package/dist/stories/ColorLegends/ColorSelector/Selector.stories.js +3 -3
  25. package/dist/stories/ColorLegends/ColorSelector/Selector.stories.js.map +1 -1
  26. package/dist/stories/ColorLegends/DiscreteLegends/Facies.stories.js +11 -11
  27. package/dist/stories/ColorLegends/DiscreteLegends/Facies.stories.js.map +1 -1
  28. package/dist/stories/ColorLegends/DiscreteLegends/FaultDistanceHum.stories.js +1 -1
  29. package/dist/stories/ColorLegends/DiscreteLegends/FaultDistanceHum.stories.js.map +1 -1
  30. package/dist/stories/ColorLegends/LegendWithSelector/DiscreteLegendWithSelector.stories.d.ts +7 -0
  31. package/dist/stories/ColorLegends/LegendWithSelector/DiscreteLegendWithSelector.stories.js +41 -0
  32. package/dist/stories/ColorLegends/LegendWithSelector/DiscreteLegendWithSelector.stories.js.map +1 -0
  33. package/dist/stories/ColorLegends/LegendWithSelector/LegendWithSelector.stories.d.ts +7 -0
  34. package/dist/stories/ColorLegends/LegendWithSelector/LegendWithSelector.stories.js +27 -0
  35. package/dist/stories/ColorLegends/LegendWithSelector/LegendWithSelector.stories.js.map +1 -0
  36. package/dist/stories/ColorLegends/SingleComponent/Single.stories.d.ts +7 -0
  37. package/dist/stories/ColorLegends/SingleComponent/Single.stories.js +47 -0
  38. package/dist/stories/ColorLegends/SingleComponent/Single.stories.js.map +1 -0
  39. package/package.json +1 -1
  40. package/src/component/ColorSelector/{ColorTableSelectorWrapper.tsx → ColorSelectorAccordion.tsx} +11 -6
  41. package/src/component/ColorSelector/ColorSelectorComponent.tsx +308 -93
  42. package/src/component/ColorSelector/ColorSelectorWrapper.tsx +118 -0
  43. package/src/component/Legend/ColorLegend.tsx +81 -0
  44. package/src/component/Legend/ContinuousLegend.tsx +160 -79
  45. package/src/component/Legend/DiscreteLegend.tsx +127 -61
  46. package/src/component/Utils/continousLegend.ts +1 -1
  47. package/src/component/Utils/discreteLegend.ts +77 -52
  48. package/src/component/color-tables.json +4 -4
  49. package/src/stories/ColorLegends/ColorSelector/Selector.stories.jsx +3 -3
  50. package/src/stories/ColorLegends/DiscreteLegends/Facies.stories.jsx +39 -39
  51. package/src/stories/ColorLegends/DiscreteLegends/FaultDistanceHum.stories.jsx +1 -1
  52. package/src/stories/ColorLegends/LegendWithSelector/DiscreteLegendWithSelector.stories.jsx +44 -0
  53. package/src/stories/ColorLegends/LegendWithSelector/LegendWithSelector.stories.jsx +30 -0
  54. package/src/stories/ColorLegends/SingleComponent/Single.stories.jsx +51 -0
  55. package/dist/component/ColorSelector/ColorTableSelectorWrapper.d.ts +0 -2
  56. package/dist/component/ColorSelector/ColorTableSelectorWrapper.js.map +0 -1
  57. package/dist/component/ColorSelector/legendComponent.d.ts +0 -14
  58. package/dist/component/ColorSelector/legendComponent.js +0 -228
  59. package/dist/component/ColorSelector/legendComponent.js.map +0 -1
  60. package/src/component/ColorSelector/legendComponent.tsx +0 -289
@@ -1,80 +1,105 @@
1
- declare type ItemColor = {
2
- color: any;
1
+ declare type ItemColor = {
2
+ color: any;
3
3
  }
4
4
 
5
5
  // eslint-disable-next-line
6
- export default function discreteLegendUtil(itemColor: ItemColor[], ColorSelector?: string): any {
7
- let legendValues: ItemColor[] = [];
8
- const cellWidth = 22;
9
- const cellHeight: any = 22;
10
- const cellPadding = 4;
6
+ export default function discreteLegendUtil(itemColor: ItemColor[], isSelectorLegend?: boolean): any {
7
+ var cellWidth = 22;
8
+ var cellHeight = 22;
9
+ const cellPadding = 2;
10
+
11
+ if (isSelectorLegend) {
12
+ cellWidth = 25;
13
+ cellHeight = 22;
14
+ }
15
+
16
+ //let legendValues: ItemColor[] = [];
11
17
 
12
18
  // eslint-disable-next-line
13
19
  function legend(g: any) {
14
20
  function drawLegend() {
15
- itemColor.forEach((item, index) => {
16
- legendValues[index].color = item.color;
17
- });
18
21
  // Code to fill the color
19
- g.selectAll("g.legendCells")
20
- .append("rect")
21
- .attr("height", cellHeight)
22
- .attr("width", cellWidth)
23
- .style("fill", function (d: Record<string, unknown>) {
24
- return d["color"];
25
- });
26
- if (!ColorSelector) {
27
- g.selectAll("g.legendCells.rect").style("stroke", "black").style("stroke-width", "1px")
28
- }
29
- // Display the label
30
- if (!ColorSelector) {
22
+ // Styling for color selector legend
23
+ if (isSelectorLegend) {
31
24
  g.selectAll("g.legendCells")
25
+ .data(itemColor)
26
+ .enter()
27
+ .append("g")
28
+ .append("rect");
29
+ g.selectAll("rect")
30
+ .attr("x", function (d: number, i: any) {
31
+ console.log(d)
32
+ return i;
33
+ })
34
+ .attr("y", 0)
35
+ .attr("height", 1)
36
+ .attr("width", 1)
37
+ .style("fill", function (d: Record<string, unknown>) {
38
+ return d["color"];
39
+ })
40
+ // Display the labels for legend
41
+ g.selectAll("g")
42
+ .style("background", "grey")
32
43
  .append("text")
33
44
  .attr("class", "breakLabels")
34
- .style("fill", "#6F6F6F")
35
- .attr("x", cellWidth + cellPadding)
36
- .attr("y", 5 + cellHeight / 2)
37
- .text(function (d: Record<string, unknown>) {
38
- return d["label"];
39
- });
45
+ .style("font-size", "0.4")
46
+ //.attr("x", cellWidth + cellPadding)
47
+ //.attr("y", 5 + cellHeight / 2)
48
+ .attr("x", function (d: any, i: any) {
49
+ console.log(d)
50
+ return i + "." + 25
51
+ })
52
+ .attr("y", 1.5)
53
+ .text(function (d: any, i: any) {
54
+ console.log(d)
55
+ return i;
56
+ })
40
57
  }
41
- // Alighment of cell in straight line
42
- if (!ColorSelector) {
58
+ // styling for main legend
59
+ else {
60
+ g.selectAll("g.legendCells")
61
+ .append("rect")
62
+ .attr("height", cellHeight)
63
+ .attr("width", cellWidth)
64
+ .style("fill", function (d: Record<string, unknown>) {
65
+ return d["color"];
66
+ });
67
+ // Alighment of cell in straight line
43
68
  g.selectAll("g.legendCells").attr(
44
69
  "transform",
45
70
  function (_d: Record<string, unknown>, i: number) {
46
71
  return (
47
- "translate(0," + i * (cellHeight + cellPadding) + ")"
72
+ "translate(0," + i * (cellHeight + cellPadding) + ")"
73
+ //"translate(0," + i + ")"
48
74
  );
49
75
  }
50
76
  );
51
77
  }
52
- if (ColorSelector) {
53
- g.selectAll("g.legendCells")
54
- .attr("transform", function(d: any) {
55
- return "translate(" + (d.label * cellWidth) + ",0)" }
56
- );
57
- }
58
78
  }
79
+
59
80
  // display the discrete legend
60
- g.selectAll("g.legendCells")
61
- .data(legendValues)
81
+ if (!isSelectorLegend) {
82
+ g.selectAll("g.legendCells")
83
+ .data(itemColor)
62
84
  .enter()
63
85
  .append("g")
64
- .attr("class", "legendCells");
86
+ .attr("class", "legendCells")
87
+ }
88
+
65
89
  drawLegend();
66
90
  }
67
91
  // eslint-disable-next-line
68
- legend.inputScale = function (newScale: any) {
69
- // eslint-disable-next-line
70
- let scale: any = {};
71
- scale = newScale;
72
- legendValues = [];
73
- scale.domain().forEach(function (el: string) {
74
- const cellObject = { color: scale(el), label: el };
75
- legendValues.push(cellObject);
76
- });
77
- return this;
78
- };
92
+ // legend.inputScale = function (newScale: any) {
93
+ // // eslint-disable-next-line
94
+ // let scale: any = {};
95
+ // scale = newScale;
96
+
97
+ // scale.domain().forEach(function (el: any) {
98
+ // const cellObject = { color: scale(el), label: el };
99
+ // legendValues.push(cellObject);
100
+ // });
101
+ // return this;
102
+ // };
103
+
79
104
  return legend;
80
- }
105
+ }
@@ -59,7 +59,7 @@
59
59
  ]
60
60
  },
61
61
  {
62
- "name": "Seismic BlueWhiteRed",
62
+ "name": "Seismic",
63
63
  "discrete": false,
64
64
  "colors": [
65
65
  [ 0.00, 0, 0, 255 ],
@@ -158,7 +158,7 @@
158
158
  ]
159
159
  },
160
160
  {
161
- "name": "Gas-Oil-Water",
161
+ "name": "GasOilWater",
162
162
  "discrete": true,
163
163
  "colors": [
164
164
  [ 0, 255, 46, 0],
@@ -168,7 +168,7 @@
168
168
  ]
169
169
  },
170
170
  {
171
- "name": "Gas-Water",
171
+ "name": "GasWater",
172
172
  "discrete": true,
173
173
  "colors": [
174
174
  [ 0, 255, 46, 0 ],
@@ -177,7 +177,7 @@
177
177
  ]
178
178
  },
179
179
  {
180
- "name": "Oil-Water",
180
+ "name": "OilWater",
181
181
  "discrete": true,
182
182
  "colors": [
183
183
  [ 0, 0, 184, 0 ],
@@ -1,12 +1,12 @@
1
1
  import * as React from "react";
2
- import { ColorSelectorWrapper } from "../../../component/ColorSelector/ColorTableSelectorWrapper";
2
+ import { ColorSelectorAccordion } from "../../../component/ColorSelector/ColorSelectorAccordion";
3
3
  export default {
4
- component: ColorSelectorWrapper,
4
+ component: ColorSelectorAccordion,
5
5
  title: "Legends/ColorSelector",
6
6
  };
7
7
 
8
8
  const Template = (args) => {
9
- return <ColorSelectorWrapper />;
9
+ return <ColorSelectorAccordion />;
10
10
  };
11
11
 
12
12
  export const selectorTemplate = Template.bind({});
@@ -1,39 +1,39 @@
1
- import React from "react";
2
- import {DiscreteColorLegend} from "../../../component/Legend/DiscreteLegend";
3
- import colorTables from "../../../component/color-tables.json";
4
-
5
- export default {
6
- component: DiscreteColorLegend,
7
- title: "Legends/DiscreteColorLegend",
8
- };
9
-
10
- const discreteData = {
11
- "OS": [[], 0],
12
- "LSF": [[], 1],
13
- "USF": [[], 2],
14
- "MB": [[], 3],
15
- "TB": [[], 4],
16
- "TC": [[], 5],
17
- "TFS": [[], 6],
18
- "TFM": [[], 7],
19
- "MSH": [[], 8],
20
- "CAL": [[], 9]
21
- };
22
- const dataObjectName = "Wells / FACIES";
23
- const position = [16, 10];
24
- const horizontal = true;
25
- const colorName = "Facies";
26
-
27
- const Template = (args) => {
28
- return <DiscreteColorLegend {...args} />;
29
- };
30
-
31
- export const FaciesTemplate = Template.bind({});
32
- FaciesTemplate.args = {
33
- discreteData,
34
- dataObjectName,
35
- position,
36
- colorName,
37
- colorTables,
38
- horizontal,
39
- };
1
+ import React from "react";
2
+ import { DiscreteColorLegend } from "../../../component/Legend/DiscreteLegend";
3
+ import colorTables from "../../../component/color-tables.json";
4
+
5
+ export default {
6
+ component: DiscreteColorLegend,
7
+ title: "Legends/DiscreteColorLegend",
8
+ };
9
+
10
+ const discreteData = {
11
+ OS: [[], 0],
12
+ LSF: [[], 1],
13
+ USF: [[], 2],
14
+ MB: [[], 3],
15
+ TB: [[], 4],
16
+ TC: [[], 5],
17
+ TFS: [[], 6],
18
+ TFM: [[], 7],
19
+ MSH: [[], 8],
20
+ CAL: [[], 9],
21
+ };
22
+ const dataObjectName = "Wells / FACIES";
23
+ const position = [16, 10];
24
+ const horizontal = true;
25
+ const colorName = "Facies";
26
+
27
+ const Template = args => {
28
+ return <DiscreteColorLegend {...args} />;
29
+ };
30
+
31
+ export const FaciesTemplate = Template.bind({});
32
+ FaciesTemplate.args = {
33
+ discreteData,
34
+ dataObjectName,
35
+ position,
36
+ colorName,
37
+ colorTables,
38
+ horizontal,
39
+ };
@@ -14,7 +14,7 @@ const discreteData = {
14
14
  const dataObjectName = "Wells / FaultDistance_HUM";
15
15
  const position = [16, 10];
16
16
  const horizontal = true;
17
- const colorName = "Gas-Oil-Water";
17
+ const colorName = "GasOilWater";
18
18
 
19
19
  const Template = (args) => {
20
20
  return <DiscreteColorLegend {...args} />;
@@ -0,0 +1,44 @@
1
+ import React from "react";
2
+ import { DiscreteColorLegend } from "../../../component/Legend/DiscreteLegend";
3
+ import colorTables from "../../../component/color-tables.json";
4
+
5
+ export default {
6
+ component: DiscreteColorLegend,
7
+ title: "Legends/DiscreteLegendWithSelector",
8
+ };
9
+
10
+ const discreteData = {
11
+ "Above_BCU": [[], 0],
12
+ "ABOVE": [[], 1],
13
+ "H12": [[], 2],
14
+ "H11": [[], 3],
15
+ "H10": [[], 4],
16
+ "H9": [[], 5],
17
+ "H8": [[], 6],
18
+ "H7": [[], 7],
19
+ "H6": [[], 8],
20
+ "H5": [[], 9],
21
+ "H4": [[], 10],
22
+ "H3": [[], 11],
23
+ "H2": [[], 12],
24
+ "H1": [[], 13],
25
+ "BELOW": [[], 14]
26
+ };
27
+ const dataObjectName = "Wells / ZONELOG";
28
+ const position = [16, 10];
29
+ const horizontal = true;
30
+ const colorName = "Stratigraphy";
31
+
32
+ const Template = (args) => {
33
+ return <DiscreteColorLegend {...args} />;
34
+ };
35
+
36
+ export const discreteLegendWithSelector = Template.bind({});
37
+ discreteLegendWithSelector.args = {
38
+ discreteData,
39
+ dataObjectName,
40
+ position,
41
+ horizontal,
42
+ colorName,
43
+ colorTables,
44
+ };
@@ -0,0 +1,30 @@
1
+ import React from "react";
2
+ import { ContinuousLegend } from "../../../component/Legend/ContinuousLegend";
3
+ import colorTables from "../../../component/color-tables.json";
4
+
5
+ export default {
6
+ component: ContinuousLegend,
7
+ title: "Legends/LegendWithSelector",
8
+ };
9
+
10
+ const min = 0;
11
+ const max = 0.35;
12
+ const dataObjectName = "Legend";
13
+ const position = [16, 10];
14
+ const horizontal = true;
15
+ const colorName = "Time/Depth";
16
+
17
+ const Template = (args) => {
18
+ return <ContinuousLegend {...args} />;
19
+ };
20
+
21
+ export const legendWithSelector = Template.bind({});
22
+ legendWithSelector.args = {
23
+ min,
24
+ max,
25
+ dataObjectName,
26
+ position,
27
+ horizontal,
28
+ colorName,
29
+ colorTables,
30
+ };
@@ -0,0 +1,51 @@
1
+ import React from "react";
2
+ import colorTables from "../../../component/color-tables.json";
3
+ import ColorLegend from "../../../component/Legend/ColorLegend";
4
+
5
+ export default {
6
+ component: ColorLegend,
7
+ title: "Legends/SingleComponent",
8
+ };
9
+
10
+ // prop for continous legend
11
+ const min = 0;
12
+ const max = 0.35;
13
+ const dataObjectName = "Legend";
14
+ const position = [16, 10];
15
+ const horizontal = true;
16
+ const colorName = "Physics";
17
+
18
+ // prop for discrete data
19
+ const discreteData = {
20
+ "Above_BCU": [[], 0],
21
+ "ABOVE": [[], 1],
22
+ "H12": [[], 2],
23
+ "H11": [[], 3],
24
+ "H10": [[], 4],
25
+ "H9": [[], 5],
26
+ "H8": [[], 6],
27
+ "H7": [[], 7],
28
+ "H6": [[], 8],
29
+ "H5": [[], 9],
30
+ "H4": [[], 10],
31
+ "H3": [[], 11],
32
+ "H2": [[], 12],
33
+ "H1": [[], 13],
34
+ "BELOW": [[], 14]
35
+ };
36
+
37
+ const Template = (args) => {
38
+ return <ColorLegend {...args} />;
39
+ };
40
+
41
+ export const legendWithSelector = Template.bind({});
42
+ legendWithSelector.args = {
43
+ min,
44
+ max,
45
+ dataObjectName,
46
+ position,
47
+ horizontal,
48
+ colorName,
49
+ colorTables,
50
+ discreteData,
51
+ };
@@ -1,2 +0,0 @@
1
- /// <reference types="react" />
2
- export declare const ColorSelectorWrapper: () => JSX.Element;
@@ -1 +0,0 @@
1
- {"version":3,"file":"ColorTableSelectorWrapper.js","sourceRoot":"","sources":["../../../src/component/ColorSelector/ColorTableSelectorWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAG,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE;IACrC,OAAO,CACH,6BAAK,KAAK,EAAE,EAAC,KAAK,EAAE,OAAO,EAAC;QACxB,oBAAC,SAAS;YACN,oBAAC,SAAS,CAAC,IAAI;gBACX,oBAAC,SAAS,CAAC,MAAM,uBAEE;gBACnB,oBAAC,SAAS,CAAC,KAAK;oBACZ,oBAAC,SAAS;wBACN,oBAAC,SAAS,CAAC,IAAI;4BACX,oBAAC,SAAS,CAAC,MAAM,+BAEE;4BACnB,oBAAC,SAAS,CAAC,KAAK;gCACZ,oBAAC,aAAa,IAAC,mBAAmB,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,GAAG,CACjD,CACL,CACT;oBACZ,oBAAC,SAAS;wBACN,oBAAC,SAAS,CAAC,IAAI;4BACX,oBAAC,SAAS,CAAC,MAAM,yBAEE;4BACnB,oBAAC,SAAS,CAAC,KAAK;gCACZ,oBAAC,aAAa,IAAC,mBAAmB,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,GAAG,CACjD,CACL,CACT;oBACZ,oBAAC,SAAS;wBACN,oBAAC,SAAS,CAAC,IAAI;4BACX,oBAAC,SAAS,CAAC,MAAM,6BAEE;4BACnB,oBAAC,SAAS,CAAC,KAAK,yBAEE,CACL,CACT,CACE,CACL,CACT,CACV,CACT,CAAC;AACN,CAAC,CAAC"}
@@ -1,14 +0,0 @@
1
- import * as React from "react";
2
- import { colorTablesArray } from "../ColorTableTypes";
3
- interface legendProps {
4
- position: number[];
5
- colorsObject?: any;
6
- legendColor?: any;
7
- legendColorName: string;
8
- useContColorTable?: boolean;
9
- useDiscColorTable?: boolean;
10
- valueIndex?: any;
11
- }
12
- export declare const LegendComponent: React.FC<legendProps>;
13
- export declare function colorTableData(colorName: string, colorTables: colorTablesArray): [number, number, number, number][];
14
- export {};