@emerson-eps/color-tables 0.2.0 → 0.2.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.
Files changed (60) hide show
  1. package/dist/component/ColorSelector/ColorSelectorComponent.js +32 -6
  2. package/dist/component/ColorSelector/ColorSelectorComponent.js.map +1 -1
  3. package/dist/component/ColorSelector/ColorTableSelectorWrapper.js +3 -5
  4. package/dist/component/ColorSelector/ColorTableSelectorWrapper.js.map +1 -1
  5. package/dist/component/ColorSelector/legendComponent.d.ts +14 -0
  6. package/dist/component/ColorSelector/legendComponent.js +228 -0
  7. package/dist/component/ColorSelector/legendComponent.js.map +1 -0
  8. package/dist/component/Legend/ContinuousLegend.d.ts +1 -1
  9. package/dist/component/Legend/ContinuousLegend.js +84 -65
  10. package/dist/component/Legend/ContinuousLegend.js.map +1 -1
  11. package/dist/component/Legend/DiscreteLegend.d.ts +1 -1
  12. package/dist/component/Legend/DiscreteLegend.js +71 -52
  13. package/dist/component/Legend/DiscreteLegend.js.map +1 -1
  14. package/dist/component/Utils/d3ColorScale.d.ts +6 -3
  15. package/dist/component/Utils/d3ColorScale.js +51 -5
  16. package/dist/component/Utils/d3ColorScale.js.map +1 -1
  17. package/dist/component/Utils/discreteLegend.d.ts +2 -2
  18. package/dist/component/Utils/discreteLegend.js +26 -15
  19. package/dist/component/Utils/discreteLegend.js.map +1 -1
  20. package/package.json +3 -3
  21. package/src/component/ColorSelector/ColorSelectorComponent.tsx +55 -14
  22. package/src/component/ColorSelector/ColorTableSelectorWrapper.tsx +4 -6
  23. package/src/component/ColorSelector/legendComponent.tsx +289 -0
  24. package/src/component/Legend/ContinuousLegend.tsx +12 -3
  25. package/src/component/Legend/DiscreteLegend.tsx +14 -6
  26. package/src/component/Utils/d3ColorScale.ts +52 -7
  27. package/src/component/Utils/discreteLegend.ts +34 -23
  28. package/tsconfig.json +1 -1
  29. package/dist/component/Legend/legendContinous.d.ts +0 -11
  30. package/dist/component/Legend/legendContinous.js +0 -132
  31. package/dist/component/Legend/legendContinous.js.map +0 -1
  32. package/dist/stories/ColorLegends/ContinousLgends/MD.stories.d.ts +0 -7
  33. package/dist/stories/ColorLegends/ContinousLgends/MD.stories.js +0 -29
  34. package/dist/stories/ColorLegends/ContinousLgends/MD.stories.js.map +0 -1
  35. package/dist/stories/ColorLegends/ContinousLgends/NTG.stories.d.ts +0 -7
  36. package/dist/stories/ColorLegends/ContinousLgends/NTG.stories.js +0 -29
  37. package/dist/stories/ColorLegends/ContinousLgends/NTG.stories.js.map +0 -1
  38. package/dist/stories/ColorLegends/ContinousLgends/PermTot.stories.d.ts +0 -7
  39. package/dist/stories/ColorLegends/ContinousLgends/PermTot.stories.js +0 -29
  40. package/dist/stories/ColorLegends/ContinousLgends/PermTot.stories.js.map +0 -1
  41. package/dist/stories/ColorLegends/ContinousLgends/Permeability.stories.d.ts +0 -7
  42. package/dist/stories/ColorLegends/ContinousLgends/Permeability.stories.js +0 -29
  43. package/dist/stories/ColorLegends/ContinousLgends/Permeability.stories.js.map +0 -1
  44. package/dist/stories/ColorLegends/ContinousLgends/PoroTot.stories.d.ts +0 -7
  45. package/dist/stories/ColorLegends/ContinousLgends/PoroTot.stories.js +0 -29
  46. package/dist/stories/ColorLegends/ContinousLgends/PoroTot.stories.js.map +0 -1
  47. package/dist/stories/ColorLegends/ContinousLgends/Porosity.stories.d.ts +0 -7
  48. package/dist/stories/ColorLegends/ContinousLgends/Porosity.stories.js +0 -29
  49. package/dist/stories/ColorLegends/ContinousLgends/Porosity.stories.js.map +0 -1
  50. package/dist/stories/ColorLegends/ContinousLgends/SW.stories.d.ts +0 -7
  51. package/dist/stories/ColorLegends/ContinousLgends/SW.stories.js +0 -29
  52. package/dist/stories/ColorLegends/ContinousLgends/SW.stories.js.map +0 -1
  53. package/src/component/Legend/legendContinous.tsx +0 -175
  54. package/src/stories/ColorLegends/ContinousLgends/MD.stories.jsx +0 -31
  55. package/src/stories/ColorLegends/ContinousLgends/NTG.stories.jsx +0 -31
  56. package/src/stories/ColorLegends/ContinousLgends/PermTot.stories.jsx +0 -31
  57. package/src/stories/ColorLegends/ContinousLgends/Permeability.stories.jsx +0 -31
  58. package/src/stories/ColorLegends/ContinousLgends/PoroTot.stories.jsx +0 -31
  59. package/src/stories/ColorLegends/ContinousLgends/Porosity.stories.jsx +0 -31
  60. package/src/stories/ColorLegends/ContinousLgends/SW.stories.jsx +0 -31
@@ -1,3 +1,12 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import * as React from "react";
2
11
  import { useRef } from "react";
3
12
  import legendUtil from "../Utils/discreteLegend";
@@ -14,60 +23,70 @@ export const DiscreteColorLegend = ({ discreteData, dataObjectName, position, co
14
23
  };
15
24
  }, [discreteData, colorName, colorTables, horizontal]);
16
25
  function discreteLegend() {
17
- const itemName = [];
18
- const itemColor = [];
19
- const colorsArray = colorTableData(colorName, colorTables);
20
- Object.keys(discreteData).forEach((key) => {
21
- // eslint-disable-next-line
22
- let code = discreteData[key][1];
23
- // compare the first value in colorarray(colortable) and code from discreteData
24
- const matchedColorsArrays = colorsArray.find((value) => {
25
- return value[0] == code;
26
- });
27
- if (matchedColorsArrays)
28
- itemColor.push({
29
- color: RGBToHex(matchedColorsArrays),
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ const itemName = [];
28
+ const itemColor = [];
29
+ let dataSet;
30
+ if (typeof colorTables === "string") {
31
+ let res = yield fetch(colorTables);
32
+ dataSet = yield res.json();
33
+ }
34
+ let colorsArray = typeof colorTables === "string" ?
35
+ colorTableData(colorName, dataSet)
36
+ :
37
+ colorTableData(colorName, colorTables);
38
+ Object.keys(discreteData).forEach((key) => {
39
+ // eslint-disable-next-line
40
+ let code = discreteData[key][1];
41
+ // compare the first value in colorarray(colortable) and code from discreteData
42
+ const matchedColorsArrays = colorsArray.find((value) => {
43
+ return value[0] == code;
30
44
  });
31
- itemName.push(key);
45
+ if (matchedColorsArrays)
46
+ itemColor.push({
47
+ color: RGBToHex(matchedColorsArrays),
48
+ });
49
+ itemName.push(key);
50
+ });
51
+ function RGBToHex(rgb) {
52
+ let r = rgb[1].toString(16), g = rgb[2].toString(16), b = rgb[3].toString(16);
53
+ if (r.length == 1)
54
+ r = "0" + r;
55
+ if (g.length == 1)
56
+ g = "0" + g;
57
+ if (b.length == 1)
58
+ b = "0" + b;
59
+ return "#" + r + g + b;
60
+ }
61
+ const ordinalValues = scaleOrdinal().domain(itemName);
62
+ const colorLegend = legendUtil(itemColor).inputScale(ordinalValues);
63
+ const legendLength = itemColor.length;
64
+ const calcLegendHeight = 22 * legendLength + 4 * legendLength;
65
+ const selectedLegend = select(divRef.current);
66
+ selectedLegend
67
+ .append("div")
68
+ .text(dataObjectName)
69
+ .attr("y", 7)
70
+ .style("color", "#6F6F6F")
71
+ .style("margin", "10px 10px");
72
+ if (horizontal)
73
+ selectedLegend.style("height", 150 + "px");
74
+ const svgLegend = selectedLegend
75
+ .append("svg")
76
+ .style("margin", "10px 10px")
77
+ .call(colorLegend);
78
+ if (colorLegend && !horizontal) {
79
+ svgLegend
80
+ .attr("height", calcLegendHeight + "px")
81
+ .attr("width", 220 + "px");
82
+ }
83
+ else {
84
+ svgLegend
85
+ .style("transform", "rotate(90deg)")
86
+ .attr("width", calcLegendHeight + "px")
87
+ .attr("height", calcLegendHeight + "px");
88
+ }
32
89
  });
33
- function RGBToHex(rgb) {
34
- let r = rgb[1].toString(16), g = rgb[2].toString(16), b = rgb[3].toString(16);
35
- if (r.length == 1)
36
- r = "0" + r;
37
- if (g.length == 1)
38
- g = "0" + g;
39
- if (b.length == 1)
40
- b = "0" + b;
41
- return "#" + r + g + b;
42
- }
43
- const ordinalValues = scaleOrdinal().domain(itemName);
44
- const colorLegend = legendUtil(itemColor).inputScale(ordinalValues);
45
- const legendLength = itemColor.length;
46
- const calcLegendHeight = 22 * legendLength + 4 * legendLength;
47
- const selectedLegend = select(divRef.current);
48
- selectedLegend
49
- .append("div")
50
- .text(dataObjectName)
51
- .attr("y", 7)
52
- .style("color", "#6F6F6F")
53
- .style("margin", "10px 10px");
54
- if (horizontal)
55
- selectedLegend.style("height", 150 + "px");
56
- const svgLegend = selectedLegend
57
- .append("svg")
58
- .style("margin", "10px 10px")
59
- .call(colorLegend);
60
- if (colorLegend && !horizontal) {
61
- svgLegend
62
- .attr("height", calcLegendHeight + "px")
63
- .attr("width", 220 + "px");
64
- }
65
- else {
66
- svgLegend
67
- .style("transform", "rotate(90deg)")
68
- .attr("width", calcLegendHeight + "px")
69
- .attr("height", calcLegendHeight + "px");
70
- }
71
90
  }
72
91
  return (React.createElement("div", { style: {
73
92
  position: "absolute",
@@ -1 +1 @@
1
- {"version":3,"file":"DiscreteLegend.js","sourceRoot":"","sources":["../../../src/component/Legend/DiscreteLegend.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAgB1C,MAAM,CAAC,MAAM,mBAAmB,GAA+B,CAAC,EAC5D,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,SAAS,EACT,WAAW,EACX,UAAU,GACK,EAAE,EAAE;IACnB,MAAM,MAAM,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC5C,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,I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O,CACH,6BACI,KAAK,EAAE;YACH,QAAQ,EAAE,UAAU;YACpB,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;YACjC,eAAe,EAAE,WAAW;YAC5B,YAAY,EAAE,KAAK;SACtB;QAED,6BAAK,EAAE,EAAC,QAAQ,EAAC,GAAG,EAAE,MAAM,GAAQ,CAClC,CACT,CAAC;AACN,CAAC,CAAC;AAEF,oEAAoE;AACpE,MAAM,UAAU,cAAc,CAC1B,SAAiB,EACjB,WAA6B;IAE7B,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,CACrC,CAAC,KAAqB,EAAE,EAAE,CACtB,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,SAAS,CAAC,WAAW,EAAE,CAC1D,CAAC;IACF,OAAO,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;AACrE,CAAC;AAED,mBAAmB,CAAC,YAAY,GAAG;IAC/B,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;CACpB,CAAC"}
@@ -1,7 +1,10 @@
1
1
  import * as d3 from "d3";
2
- export declare const colorScalesCont: {
2
+ export declare const d3ColorScales: ({
3
3
  name: string;
4
4
  discrete: boolean;
5
5
  colors: typeof d3.interpolateSpectral;
6
- }[];
7
- export declare function interpolatorContinuous(): d3.ScaleSequential<string, never>;
6
+ } | {
7
+ name: string;
8
+ discrete: boolean;
9
+ colors: readonly string[];
10
+ })[];
@@ -1,5 +1,5 @@
1
1
  import * as d3 from "d3";
2
- export const colorScalesCont = [
2
+ export const d3ColorScales = [
3
3
  {
4
4
  "name": "Spectral",
5
5
  "discrete": false,
@@ -30,9 +30,55 @@ export const colorScalesCont = [
30
30
  "discrete": false,
31
31
  "colors": d3.interpolateInferno
32
32
  },
33
+ {
34
+ "name": "Accent",
35
+ "discrete": true,
36
+ "colors": d3.schemeAccent
37
+ },
38
+ {
39
+ "name": "Dark2",
40
+ "discrete": true,
41
+ "colors": d3.schemeDark2
42
+ },
43
+ {
44
+ "name": "Paired",
45
+ "discrete": true,
46
+ "colors": d3.schemePaired
47
+ },
48
+ {
49
+ "name": "Pastel1",
50
+ "discrete": true,
51
+ "colors": d3.schemePastel1
52
+ },
53
+ {
54
+ "name": "Pastel2",
55
+ "discrete": true,
56
+ "colors": d3.schemePastel2
57
+ },
58
+ {
59
+ "name": "Set1",
60
+ "discrete": true,
61
+ "colors": d3.schemeSet1
62
+ },
63
+ {
64
+ "name": "Set2",
65
+ "discrete": true,
66
+ "colors": d3.schemeSet3
67
+ },
68
+ {
69
+ "name": "Set3",
70
+ "discrete": true,
71
+ "colors": d3.schemeSet3
72
+ },
73
+ {
74
+ "name": "Tableau10",
75
+ "discrete": true,
76
+ "colors": d3.schemeTableau10
77
+ },
78
+ {
79
+ "name": "Category10",
80
+ "discrete": true,
81
+ "colors": d3.schemeCategory10
82
+ },
33
83
  ];
34
- export function interpolatorContinuous() {
35
- return d3.scaleSequential(d3.interpolateInferno);
36
- }
37
- ;
38
84
  //# sourceMappingURL=d3ColorScale.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"d3ColorScale.js","sourceRoot":"","sources":["../../../src/component/Utils/d3ColorScale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B;QACE,MAAM,EAAE,UAAU;QAClB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,EAAE,CAAC,mBAAmB;KACjC;IACD;QACE,MAAM,EAAE,QAAQ;QAChB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,EAAE,CAAC,iBAAiB;KAC/B;IACD;QACE,MAAM,EAAE,MAAM;QACd,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,EAAE,CAAC,eAAe;KAC7B;IACD;QACE,MAAM,EAAE,MAAM;QACd,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,EAAE,CAAC,eAAe;KAC7B;IACD;QACE,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,EAAE,CAAC,kBAAkB;KAChC;IACD;QACE,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,EAAE,CAAC,kBAAkB;KAChC;CACF,CAAA;AAGD,MAAM,UAAU,sBAAsB;IACpC,OAAO,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC;AACnD,CAAC;AAAA,CAAC"}
1
+ {"version":3,"file":"d3ColorScale.js","sourceRoot":"","sources":["../../../src/component/Utils/d3ColorScale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B;QACE,MAAM,EAAE,UAAU;QAClB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,EAAE,CAAC,mBAAmB;KACjC;IACD;QACE,MAAM,EAAE,QAAQ;QAChB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,EAAE,CAAC,iBAAiB;KAC/B;IACD;QACE,MAAM,EAAE,MAAM;QACd,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,EAAE,CAAC,eAAe;KAC7B;IACD;QACE,MAAM,EAAE,MAAM;QACd,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,EAAE,CAAC,eAAe;KAC7B;IACD;QACE,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,EAAE,CAAC,kBAAkB;KAChC;IACD;QACE,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,EAAE,CAAC,kBAAkB;KAChC;IACD;QACE,MAAM,EAAE,QAAQ;QAChB,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,EAAE,CAAC,YAAY;KAC1B;IACD;QACE,MAAM,EAAE,OAAO;QACf,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,EAAE,CAAC,WAAW;KACzB;IACD;QACE,MAAM,EAAE,QAAQ;QAChB,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,EAAE,CAAC,YAAY;KAC1B;IACD;QACE,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,EAAE,CAAC,aAAa;KAC3B;IACD;QACE,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,EAAE,CAAC,aAAa;KAC3B;IACD;QACE,MAAM,EAAE,MAAM;QACd,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,EAAE,CAAC,UAAU;KACxB;IACD;QACE,MAAM,EAAE,MAAM;QACd,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,EAAE,CAAC,UAAU;KACxB;IACD;QACE,MAAM,EAAE,MAAM;QACd,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,EAAE,CAAC,UAAU;KACxB;IACD;QACE,MAAM,EAAE,WAAW;QACnB,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,EAAE,CAAC,eAAe;KAC7B;IACD;QACE,MAAM,EAAE,YAAY;QACpB,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,EAAE,CAAC,gBAAgB;KAC9B;CACF,CAAA"}
@@ -1,5 +1,5 @@
1
1
  declare type ItemColor = {
2
- color: string;
2
+ color: any;
3
3
  };
4
- export default function legendUtil(itemColor: ItemColor[]): any;
4
+ export default function discreteLegendUtil(itemColor: ItemColor[], ColorSelector?: string): any;
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  // eslint-disable-next-line
2
- export default function legendUtil(itemColor) {
2
+ export default function discreteLegendUtil(itemColor, ColorSelector) {
3
3
  let legendValues = [];
4
4
  const cellWidth = 22;
5
5
  const cellHeight = 22;
@@ -15,25 +15,36 @@ export default function legendUtil(itemColor) {
15
15
  .append("rect")
16
16
  .attr("height", cellHeight)
17
17
  .attr("width", cellWidth)
18
- .style("stroke", "black")
19
- .style("stroke-width", "1px")
20
18
  .style("fill", function (d) {
21
19
  return d["color"];
22
20
  });
21
+ if (!ColorSelector) {
22
+ g.selectAll("g.legendCells.rect").style("stroke", "black").style("stroke-width", "1px");
23
+ }
23
24
  // Display the label
24
- g.selectAll("g.legendCells")
25
- .append("text")
26
- .attr("class", "breakLabels")
27
- .style("fill", "#6F6F6F")
28
- .attr("x", cellWidth + cellPadding)
29
- .attr("y", 5 + cellHeight / 2)
30
- .text(function (d) {
31
- return d["label"];
32
- });
25
+ if (!ColorSelector) {
26
+ g.selectAll("g.legendCells")
27
+ .append("text")
28
+ .attr("class", "breakLabels")
29
+ .style("fill", "#6F6F6F")
30
+ .attr("x", cellWidth + cellPadding)
31
+ .attr("y", 5 + cellHeight / 2)
32
+ .text(function (d) {
33
+ return d["label"];
34
+ });
35
+ }
33
36
  // Alighment of cell in straight line
34
- g.selectAll("g.legendCells").attr("transform", function (_d, i) {
35
- return ("translate(0," + i * (cellHeight + cellPadding) + ")");
36
- });
37
+ if (!ColorSelector) {
38
+ g.selectAll("g.legendCells").attr("transform", function (_d, i) {
39
+ return ("translate(0," + i * (cellHeight + cellPadding) + ")");
40
+ });
41
+ }
42
+ if (ColorSelector) {
43
+ g.selectAll("g.legendCells")
44
+ .attr("transform", function (d) {
45
+ return "translate(" + (d.label * cellWidth) + ",0)";
46
+ });
47
+ }
37
48
  }
38
49
  // display the discrete legend
39
50
  g.selectAll("g.legendCells")
@@ -1 +1 @@
1
- {"version":3,"file":"discreteLegend.js","sourceRoot":"","sources":["../../../src/component/Utils/discreteLegend.ts"],"names":[],"mappings":"AAIA,2BAA2B;AAC3B,MAAM,CAAC,OAAO,UA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C5C,OAAO,CACH,cAAc,GAAG,CAAC,GAAG,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,GAAG,CACxD,CAAC;gBACN,CAAC,CACJ,CAAC;aACL;YACD,IAAI,aAAa,EAAE;gBACf,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC;qBAC3B,IAAI,CAAC,WAAW,EAAE,UAAS,CAAM;oBAC9B,OAAO,YAAY,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,KAAK,CAAA;gBAAC,CAAC,CACxD,CAAC;aACL;QACL,CAAC;QACD,8BAA8B;QAC9B,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC;aACvB,IAAI,CAAC,YAAY,CAAC;aAClB,KAAK,EAAE;aACP,MAAM,CAAC,GAAG,CAAC;aACX,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAClC,UAAU,EAAE,CAAC;IACjB,CAAC;IACD,2BAA2B;IAC3B,MAAM,CAAC,UAAU,GAAG,UAAU,QAAa;QACvC,2BAA2B;QAC3B,IAAI,KAAK,GAAQ,EAAE,CAAC;QACpB,KAAK,GAAG,QAAQ,CAAC;QACjB,YAAY,GAAG,EAAE,CAAC;QAClB,KAAK,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,UAAU,EAAU;YACvC,MAAM,UAAU,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;YACnD,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;IACF,OAAO,MAAM,CAAC;AAClB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emerson-eps/color-tables",
3
- "version": "0.2.0",
3
+ "version": "0.2.3",
4
4
  "description": "Standard library of color tables for geological domain",
5
5
  "release": {
6
6
  "branches": [
@@ -16,14 +16,14 @@
16
16
  "semantic-release": "semantic-release"
17
17
  },
18
18
  "dependencies": {
19
- "@equinor/eds-core-react": "^0.17.0",
19
+ "@equinor/eds-core-react": "^0.18.0",
20
20
  "d3": "^7.2.0",
21
21
  "d3-color": "^3.0.1",
22
22
  "d3-interpolate": "^3.0.1",
23
23
  "react": "^17.0.2",
24
24
  "react-dom": "^17.0.2",
25
25
  "react-scripts": "^5.0.0",
26
- "web-vitals": "^1.1.2"
26
+ "web-vitals": "^2.1.4"
27
27
  },
28
28
  "repository": {
29
29
  "type": "git",
@@ -1,11 +1,13 @@
1
1
  import * as React from "react";
2
- import { LegendContinous } from "../Legend/legendContinous";
3
2
  import * as colorTables from "../color-tables.json";
4
- import {colorScalesCont} from "../Utils/d3ColorScale"
3
+ import {d3ColorScales} from "../Utils/d3ColorScale"
4
+ import {LegendComponent} from "./legendComponent";
5
5
 
6
6
  const position = [16, 206];
7
7
  const continuosColorData: any = []
8
8
  const continuosD3ColorData: any = []
9
+ const discreteColorData: any = []
10
+ const discreteD3ColorData: any = []
9
11
 
10
12
  interface legendProps {
11
13
  useColorTableColors: boolean
@@ -22,7 +24,7 @@ colorTableContinuousData.forEach((element: any) => {
22
24
  });
23
25
 
24
26
  // code is for d3 continuous data
25
- var d3continuousData = colorScalesCont.filter((element: any) => {
27
+ var d3continuousData = d3ColorScales.filter((element: any) => {
26
28
  return element.discrete == false;
27
29
  });
28
30
 
@@ -30,39 +32,78 @@ d3continuousData.forEach((element: any) => {
30
32
  continuosD3ColorData.push({color: element.colors, name: element.name})
31
33
  });
32
34
 
35
+ // code is for color table discrete data
36
+ var discreteData = colorTables.filter((element: any) => {
37
+ return element.discrete == true;
38
+ });
39
+
40
+ discreteData.forEach((element: any) => {
41
+ discreteColorData.push({color: element.colors, name: element.name})
42
+ });
43
+
44
+ // code is for color table d3 discrete data
45
+ var d3discreteData = d3ColorScales.filter((element: any) => {
46
+ return element.discrete == true;
47
+ });
48
+
49
+ d3discreteData.forEach((element: any) => {
50
+ discreteD3ColorData.push({color: element.colors, name: element.name})
51
+ });
52
+
33
53
  export const ColorSelector: React.FC<legendProps> = ({
34
54
  useColorTableColors,
35
55
  useD3Colors,
36
56
  }: legendProps) => {
37
57
  let continuousLegend;
58
+ let discreteLegend;
59
+
38
60
  if (useColorTableColors) {
39
61
  continuousLegend = continuosColorData.map((value: any, key: any) => {
40
- return <LegendContinous
41
- position={position + key}
42
- colorArray={value}
43
- legendColor={''}
44
- legendColorName={''}
45
- useContColorTable={true}
46
- valueIndex={key}
47
- />
62
+ return <div>
63
+ <LegendComponent
64
+ position={position + key}
65
+ colorsObject={value}
66
+ legendColor={''}
67
+ legendColorName={''}
68
+ useContColorTable={true}
69
+ valueIndex={key}
70
+ />
71
+ </div>
72
+ });
73
+
74
+ discreteLegend = discreteColorData.map((val: any, key: any) => {
75
+ return <LegendComponent
76
+ legendColorName={val.name}
77
+ position={position}
78
+ colorsObject={discreteColorData[key]}
79
+ useDiscColorTable={true} />
48
80
  });
49
81
  }
50
82
  if (useD3Colors) {
51
83
  continuousLegend = continuosD3ColorData.map((val: any, key: any) => {
52
- return <LegendContinous
84
+ return <LegendComponent
53
85
  position={position + key}
54
- colorArray={{}}
86
+ colorsObject={{}}
55
87
  legendColor={val.color}
56
88
  legendColorName={val.name}
57
89
  useContColorTable={false}
58
90
  valueIndex={key + "0"}
59
91
  />
60
92
  });
93
+
94
+ discreteLegend = d3discreteData.map((val: any) => {
95
+ return <LegendComponent
96
+ legendColorName={val.name}
97
+ position={position}
98
+ colorsObject={val.colors}
99
+ useDiscColorTable={false} />
100
+ });
61
101
  }
62
102
 
63
103
  return (
64
104
  <div>
65
- {continuousLegend}
105
+ {continuousLegend}
106
+ {discreteLegend}
66
107
  </div>
67
108
  );
68
109
  };
@@ -1,12 +1,10 @@
1
1
  import * as React from "react";
2
2
  import { Accordion } from "@equinor/eds-core-react";
3
- import {ColorSelector} from "./ColorSelectorComponent";
3
+ import { ColorSelector } from "./ColorSelectorComponent";
4
4
 
5
5
  export const ColorSelectorWrapper = () => {
6
- // export const ColorSelector: React.FC<legendProps> = ({
7
- // }: legendProps) => {
8
6
  return (
9
- <div style={{width: "450px"}}>
7
+ <div style={{width: "650px"}}>
10
8
  <Accordion >
11
9
  <Accordion.Item>
12
10
  <Accordion.Header>
@@ -19,7 +17,7 @@ export const ColorSelectorWrapper = () => {
19
17
  Geologic Color Scale
20
18
  </Accordion.Header>
21
19
  <Accordion.Panel>
22
- <ColorSelector useColorTableColors={true} useD3Colors={false} key={1}/>
20
+ <ColorSelector useColorTableColors={true} useD3Colors={false}/>
23
21
  </Accordion.Panel>
24
22
  </Accordion.Item>
25
23
  </Accordion>
@@ -29,7 +27,7 @@ export const ColorSelectorWrapper = () => {
29
27
  D3 Color Scale
30
28
  </Accordion.Header>
31
29
  <Accordion.Panel>
32
- <ColorSelector useColorTableColors={false} useD3Colors={true} key={1}/>
30
+ <ColorSelector useColorTableColors={false} useD3Colors={true}/>
33
31
  </Accordion.Panel>
34
32
  </Accordion.Item>
35
33
  </Accordion>