@emerson-eps/color-tables 0.1.21 → 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.
Files changed (69) hide show
  1. package/dist/component/ColorSelector/ColorSelectorComponent.d.ts +7 -0
  2. package/dist/component/ColorSelector/ColorSelectorComponent.js +62 -0
  3. package/dist/component/ColorSelector/ColorSelectorComponent.js.map +1 -0
  4. package/dist/component/ColorSelector/ColorTableSelectorWrapper.d.ts +2 -0
  5. package/dist/component/ColorSelector/ColorTableSelectorWrapper.js +25 -0
  6. package/dist/component/ColorSelector/ColorTableSelectorWrapper.js.map +1 -0
  7. package/dist/component/ColorSelector/legendComponent.d.ts +14 -0
  8. package/dist/component/ColorSelector/legendComponent.js +228 -0
  9. package/dist/component/ColorSelector/legendComponent.js.map +1 -0
  10. package/dist/component/Legend/ContinuousLegend.d.ts +2 -2
  11. package/dist/component/Legend/ContinuousLegend.js +2 -2
  12. package/dist/component/Legend/ContinuousLegend.js.map +1 -1
  13. package/dist/component/Legend/DiscreteLegend.d.ts +2 -2
  14. package/dist/component/Legend/DiscreteLegend.js +4 -4
  15. package/dist/component/Legend/DiscreteLegend.js.map +1 -1
  16. package/dist/component/Utils/d3ColorScale.d.ts +10 -0
  17. package/dist/component/Utils/d3ColorScale.js +84 -0
  18. package/dist/component/Utils/d3ColorScale.js.map +1 -0
  19. package/dist/component/Utils/discreteLegend.d.ts +2 -2
  20. package/dist/component/Utils/discreteLegend.js +26 -15
  21. package/dist/component/Utils/discreteLegend.js.map +1 -1
  22. package/dist/stories/ColorLegends/ColorSelector/Selector.stories.d.ts +7 -0
  23. package/dist/stories/ColorLegends/ColorSelector/Selector.stories.js +11 -0
  24. package/dist/stories/ColorLegends/ColorSelector/Selector.stories.js.map +1 -0
  25. package/dist/stories/ColorLegends/{ContinousLgends → ContinousLegends}/MD.stories.d.ts +0 -0
  26. package/dist/stories/ColorLegends/{ContinousLgends → ContinousLegends}/MD.stories.js +0 -2
  27. package/dist/stories/ColorLegends/ContinousLegends/MD.stories.js.map +1 -0
  28. package/dist/stories/ColorLegends/{ContinousLgends → ContinousLegends}/NTG.stories.d.ts +0 -0
  29. package/dist/stories/ColorLegends/{ContinousLgends → ContinousLegends}/NTG.stories.js +0 -2
  30. package/dist/stories/ColorLegends/ContinousLegends/NTG.stories.js.map +1 -0
  31. package/dist/stories/ColorLegends/{ContinousLgends → ContinousLegends}/PermTot.stories.d.ts +0 -0
  32. package/dist/stories/ColorLegends/{ContinousLgends → ContinousLegends}/PermTot.stories.js +0 -2
  33. package/dist/stories/ColorLegends/ContinousLegends/PermTot.stories.js.map +1 -0
  34. package/dist/stories/ColorLegends/{ContinousLgends → ContinousLegends}/Permeability.stories.d.ts +0 -0
  35. package/dist/stories/ColorLegends/{ContinousLgends → ContinousLegends}/Permeability.stories.js +0 -2
  36. package/dist/stories/ColorLegends/ContinousLegends/Permeability.stories.js.map +1 -0
  37. package/dist/stories/ColorLegends/{ContinousLgends → ContinousLegends}/PoroTot.stories.d.ts +0 -0
  38. package/dist/stories/ColorLegends/{ContinousLgends → ContinousLegends}/PoroTot.stories.js +0 -2
  39. package/dist/stories/ColorLegends/ContinousLegends/PoroTot.stories.js.map +1 -0
  40. package/dist/stories/ColorLegends/{ContinousLgends → ContinousLegends}/Porosity.stories.d.ts +0 -0
  41. package/dist/stories/ColorLegends/{ContinousLgends → ContinousLegends}/Porosity.stories.js +0 -2
  42. package/dist/stories/ColorLegends/ContinousLegends/Porosity.stories.js.map +1 -0
  43. package/dist/stories/ColorLegends/{ContinousLgends → ContinousLegends}/SW.stories.d.ts +0 -0
  44. package/dist/stories/ColorLegends/{ContinousLgends → ContinousLegends}/SW.stories.js +2 -4
  45. package/dist/stories/ColorLegends/ContinousLegends/SW.stories.js.map +1 -0
  46. package/package.json +3 -1
  47. package/src/component/ColorSelector/ColorSelectorComponent.tsx +109 -0
  48. package/src/component/ColorSelector/ColorTableSelectorWrapper.tsx +49 -0
  49. package/src/component/ColorSelector/legendComponent.tsx +289 -0
  50. package/src/component/Legend/ContinuousLegend.tsx +4 -4
  51. package/src/component/Legend/DiscreteLegend.tsx +6 -6
  52. package/src/component/Utils/d3ColorScale.ts +84 -0
  53. package/src/component/Utils/discreteLegend.ts +34 -23
  54. package/src/stories/ColorLegends/ColorSelector/Selector.stories.jsx +12 -0
  55. package/src/stories/ColorLegends/{ContinousLgends → ContinousLegends}/MD.stories.jsx +0 -2
  56. package/src/stories/ColorLegends/{ContinousLgends → ContinousLegends}/NTG.stories.jsx +0 -2
  57. package/src/stories/ColorLegends/{ContinousLgends → ContinousLegends}/PermTot.stories.jsx +0 -2
  58. package/src/stories/ColorLegends/{ContinousLgends → ContinousLegends}/Permeability.stories.jsx +0 -2
  59. package/src/stories/ColorLegends/{ContinousLgends → ContinousLegends}/PoroTot.stories.jsx +0 -2
  60. package/src/stories/ColorLegends/{ContinousLgends → ContinousLegends}/Porosity.stories.jsx +0 -2
  61. package/src/stories/ColorLegends/{ContinousLgends → ContinousLegends}/SW.stories.jsx +2 -4
  62. package/tsconfig.json +1 -1
  63. package/dist/stories/ColorLegends/ContinousLgends/MD.stories.js.map +0 -1
  64. package/dist/stories/ColorLegends/ContinousLgends/NTG.stories.js.map +0 -1
  65. package/dist/stories/ColorLegends/ContinousLgends/PermTot.stories.js.map +0 -1
  66. package/dist/stories/ColorLegends/ContinousLgends/Permeability.stories.js.map +0 -1
  67. package/dist/stories/ColorLegends/ContinousLgends/PoroTot.stories.js.map +0 -1
  68. package/dist/stories/ColorLegends/ContinousLgends/Porosity.stories.js.map +0 -1
  69. package/dist/stories/ColorLegends/ContinousLgends/SW.stories.js.map +0 -1
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ interface legendProps {
3
+ useColorTableColors: boolean;
4
+ useD3Colors: boolean;
5
+ }
6
+ export declare const ColorSelector: React.FC<legendProps>;
7
+ export {};
@@ -0,0 +1,62 @@
1
+ import * as React from "react";
2
+ import * as colorTables from "../color-tables.json";
3
+ import { d3ColorScales } from "../Utils/d3ColorScale";
4
+ import { LegendComponent } from "./legendComponent";
5
+ const position = [16, 206];
6
+ const continuosColorData = [];
7
+ const continuosD3ColorData = [];
8
+ const discreteColorData = [];
9
+ const discreteD3ColorData = [];
10
+ // code is for color table continuous data
11
+ var colorTableContinuousData = colorTables.filter((element) => {
12
+ return element.discrete == false;
13
+ });
14
+ colorTableContinuousData.forEach((element) => {
15
+ continuosColorData.push({ color: element.colors, name: element.name });
16
+ });
17
+ // code is for d3 continuous data
18
+ var d3continuousData = d3ColorScales.filter((element) => {
19
+ return element.discrete == false;
20
+ });
21
+ d3continuousData.forEach((element) => {
22
+ continuosD3ColorData.push({ color: element.colors, name: element.name });
23
+ });
24
+ // code is for color table discrete data
25
+ var discreteData = colorTables.filter((element) => {
26
+ return element.discrete == true;
27
+ });
28
+ discreteData.forEach((element) => {
29
+ discreteColorData.push({ color: element.colors, name: element.name });
30
+ });
31
+ // code is for color table d3 discrete data
32
+ var d3discreteData = d3ColorScales.filter((element) => {
33
+ return element.discrete == true;
34
+ });
35
+ d3discreteData.forEach((element) => {
36
+ discreteD3ColorData.push({ color: element.colors, name: element.name });
37
+ });
38
+ export const ColorSelector = ({ useColorTableColors, useD3Colors, }) => {
39
+ let continuousLegend;
40
+ let discreteLegend;
41
+ if (useColorTableColors) {
42
+ continuousLegend = continuosColorData.map((value, key) => {
43
+ return React.createElement("div", null,
44
+ React.createElement(LegendComponent, { position: position + key, colorsObject: value, legendColor: '', legendColorName: '', useContColorTable: true, valueIndex: key }));
45
+ });
46
+ discreteLegend = discreteColorData.map((val, key) => {
47
+ return React.createElement(LegendComponent, { legendColorName: val.name, position: position, colorsObject: discreteColorData[key], useDiscColorTable: true });
48
+ });
49
+ }
50
+ if (useD3Colors) {
51
+ continuousLegend = continuosD3ColorData.map((val, key) => {
52
+ return React.createElement(LegendComponent, { position: position + key, colorsObject: {}, legendColor: val.color, legendColorName: val.name, useContColorTable: false, valueIndex: key + "0" });
53
+ });
54
+ discreteLegend = d3discreteData.map((val) => {
55
+ return React.createElement(LegendComponent, { legendColorName: val.name, position: position, colorsObject: val.colors, useDiscColorTable: false });
56
+ });
57
+ }
58
+ return (React.createElement("div", null,
59
+ continuousLegend,
60
+ discreteLegend));
61
+ };
62
+ //# sourceMappingURL=ColorSelectorComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorSelectorComponent.js","sourceRoot":"","sources":["../../../src/component/ColorSelector/ColorSelectorComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,WAAW,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAElD,MAAM,QAAQ,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAC3B,MAAM,kBAAkB,GAAQ,EAAE,CAAA;AAClC,MAAM,oBAAoB,GAAQ,EAAE,CAAA;AACpC,MAAM,iBAAiB,GAAQ,EAAE,CAAA;AACjC,MAAM,mBAAmB,GAAQ,EAAE,CAAA;AAOnC,0CAA0C;AAC1C,IAAI,wBAAwB,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,OAAY,EAAE,EAAE;IAC/D,OAAO,OAAO,CAAC,QAAQ,IAAI,KAAK,CAAC;AACrC,CAAC,CAAC,CAAC;AAEH,wBAAwB,CAAC,OAAO,CAAC,CAAC,OAAY,EAAE,EAAE;IAC9C,kBAAkB,CAAC,IAAI,CAAC,EAAC,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAC,CAAC,CAAA;AACxE,CAAC,CAAC,CAAC;AAEH,iCAAiC;AACjC,IAAI,gBAAgB,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,OAAY,EAAE,EAAE;IACzD,OAAO,OAAO,CAAC,QAAQ,IAAI,KAAK,CAA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are const ColorSelectorWrapper: () => JSX.Element;
@@ -0,0 +1,25 @@
1
+ import * as React from "react";
2
+ import { Accordion } from "@equinor/eds-core-react";
3
+ import { ColorSelector } from "./ColorSelectorComponent";
4
+ export const ColorSelectorWrapper = () => {
5
+ return (React.createElement("div", { style: { width: "650px" } },
6
+ React.createElement(Accordion, null,
7
+ React.createElement(Accordion.Item, null,
8
+ React.createElement(Accordion.Header, null, "Color Scales"),
9
+ React.createElement(Accordion.Panel, null,
10
+ React.createElement(Accordion, null,
11
+ React.createElement(Accordion.Item, null,
12
+ React.createElement(Accordion.Header, null, "Geologic Color Scale"),
13
+ React.createElement(Accordion.Panel, null,
14
+ React.createElement(ColorSelector, { useColorTableColors: true, useD3Colors: false })))),
15
+ React.createElement(Accordion, null,
16
+ React.createElement(Accordion.Item, null,
17
+ React.createElement(Accordion.Header, null, "D3 Color Scale"),
18
+ React.createElement(Accordion.Panel, null,
19
+ React.createElement(ColorSelector, { useColorTableColors: false, useD3Colors: true })))),
20
+ React.createElement(Accordion, null,
21
+ React.createElement(Accordion.Item, null,
22
+ React.createElement(Accordion.Header, null, "Custom Color Scale"),
23
+ React.createElement(Accordion.Panel, null, "Custom Content"))))))));
24
+ };
25
+ //# sourceMappingURL=ColorTableSelectorWrapper.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,14 @@
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 {};
@@ -0,0 +1,228 @@
1
+ import * as React from "react";
2
+ import { useRef } from "react";
3
+ import { RGBToHex } from "../Utils/continousLegend";
4
+ import { d3ColorScales } from "../Utils/d3ColorScale";
5
+ import * as d3 from "d3";
6
+ import { scaleOrdinal, select } from "d3";
7
+ import discreteLegendUtil from "../Utils/discreteLegend";
8
+ export const LegendComponent = ({ position, colorsObject, legendColor, legendColorName, useContColorTable, useDiscColorTable, valueIndex, }) => {
9
+ const divRef = useRef(null);
10
+ React.useEffect(() => {
11
+ // continuous legend using color table colors
12
+ if (useContColorTable == true && divRef.current) {
13
+ contColortableLegend();
14
+ return function cleanup() {
15
+ d3.select(divRef.current).select("svg").remove();
16
+ };
17
+ }
18
+ // discrete legend using color table colors
19
+ if (useDiscColorTable == true && divRef.current) {
20
+ discColorTableLegend();
21
+ return function cleanup() {
22
+ select(divRef.current).select("div").remove();
23
+ select(divRef.current).select("svg").remove();
24
+ };
25
+ }
26
+ // discrete legend using d3 colors
27
+ if (useDiscColorTable == false && divRef.current) {
28
+ discD3legend();
29
+ return function cleanup() {
30
+ select(divRef.current).select("div").remove();
31
+ select(divRef.current).select("svg").remove();
32
+ };
33
+ }
34
+ // continuous legend using d3 colors
35
+ else if (useContColorTable == false && divRef.current) {
36
+ contD3Legend();
37
+ return function cleanup() {
38
+ d3.select(divRef.current).select("svg").remove();
39
+ };
40
+ }
41
+ }, [useContColorTable]);
42
+ // continuous legend using color table colors (linear gradiend code)
43
+ function contColortableLegend() {
44
+ const itemColor = [];
45
+ colorsObject.color.forEach((value) => {
46
+ // return the color and offset needed to draw the legend
47
+ itemColor.push({
48
+ offset: RGBToHex(value).offset,
49
+ color: RGBToHex(value).color,
50
+ });
51
+ });
52
+ // append a defs (for definition) element to your SVG
53
+ const svgLegend = d3.select(divRef.current)
54
+ .append("svg")
55
+ .style("height", "50px")
56
+ .style("display", "flex");
57
+ const defs = svgLegend.append("defs");
58
+ let currentIndex = "linear-gradient-" + valueIndex;
59
+ // append a linearGradient element to the defs and give it a unique id
60
+ const linearGradient = defs
61
+ .append("linearGradient")
62
+ .attr("id", currentIndex)
63
+ .attr("x1", "0%")
64
+ .attr("x2", "100%") //since it's a horizontal linear gradient
65
+ .attr("y1", "0%")
66
+ .attr("y2", "0%");
67
+ // append multiple color stops by using D3's data/enter step
68
+ linearGradient
69
+ .selectAll("stop")
70
+ .data(itemColor)
71
+ .enter()
72
+ .append("stop")
73
+ .attr("offset", function (data) {
74
+ return data.offset + "%";
75
+ })
76
+ .attr("stop-color", function (data) {
77
+ return data.color;
78
+ });
79
+ // append title
80
+ svgLegend
81
+ .append("text")
82
+ .attr("class", "legendTitle")
83
+ .attr("x", 0)
84
+ .attr("y", 43)
85
+ .style("text-anchor", "left")
86
+ .text(colorsObject.name);
87
+ // draw the rectangle and fill with gradient
88
+ svgLegend
89
+ .append("rect")
90
+ .attr("x", 180)
91
+ .attr("y", 30)
92
+ .attr("width", 150)
93
+ .attr("height", 25)
94
+ .style("fill", "url(#" + currentIndex + ")");
95
+ }
96
+ // continuous legend using d3 colors (linear gradiend code)
97
+ function contD3Legend() {
98
+ const itemColor = [];
99
+ d3ColorScales.forEach((value) => {
100
+ // return the color and offset needed to draw the legend
101
+ itemColor.push(value.colors);
102
+ });
103
+ // create an array of steps based on the color scale
104
+ // returns an array of evenly-spaced numbers. Returns the integers from zero to the specified end minus one.
105
+ // d3.range(start, stop, step)
106
+ var data = d3.range(10).map(d => ({ color: legendColor(d / 10), value: d }));
107
+ // get the array's min and max value
108
+ var extent = d3.extent(data, d => d.value);
109
+ // append a defs (for definition) element to your SVG
110
+ const svgLegend = d3.select(divRef.current)
111
+ .append("svg")
112
+ .style("height", "50px")
113
+ .style("display", "flex");
114
+ const defs = svgLegend.append("defs");
115
+ let currentIndex = "linear-gradient-" + valueIndex;
116
+ // append a linearGradient element to the defs and give it a unique id
117
+ const linearGradient = defs
118
+ .append("linearGradient")
119
+ .attr("id", currentIndex)
120
+ .attr("x1", "0%")
121
+ .attr("x2", "100%") //since it's a horizontal linear gradient
122
+ .attr("y1", "0%")
123
+ .attr("y2", "0%");
124
+ // append multiple color stops by using D3's data/enter step
125
+ linearGradient.selectAll("stop")
126
+ .data(data)
127
+ .enter().append("stop")
128
+ .attr("offset", d => ((d.value - extent[0]) / (extent[1] - extent[0]) * 100) + "%")
129
+ .attr("stop-color", d => d.color);
130
+ // append title
131
+ svgLegend
132
+ .append("text")
133
+ .attr("class", "legendTitle")
134
+ .attr("x", 0)
135
+ .attr("y", 43)
136
+ .style("text-anchor", "left")
137
+ .text(legendColorName);
138
+ // draw the rectangle and fill with gradient
139
+ svgLegend
140
+ .append("rect")
141
+ .attr("x", 180)
142
+ .attr("y", 30)
143
+ .attr("width", 150)
144
+ .attr("height", 25)
145
+ .style("fill", "url(#" + currentIndex + ")");
146
+ }
147
+ // discrete legend using color table colors
148
+ function discColorTableLegend() {
149
+ const itemColor = [];
150
+ const itemName = [];
151
+ colorsObject.color.forEach((element, key) => {
152
+ itemColor.push({ color: RGBToHex(element) });
153
+ itemName.push(key);
154
+ });
155
+ function RGBToHex(rgb) {
156
+ let r = rgb[1].toString(16), g = rgb[2].toString(16), b = rgb[3].toString(16);
157
+ if (r.length == 1)
158
+ r = "0" + r;
159
+ if (g.length == 1)
160
+ g = "0" + g;
161
+ if (b.length == 1)
162
+ b = "0" + b;
163
+ return "#" + r + g + b;
164
+ }
165
+ const ordinalValues = scaleOrdinal().domain(itemName);
166
+ const colorLegend = discreteLegendUtil(itemColor, "ColorSelector").inputScale(ordinalValues);
167
+ select("svg").append("g").attr("transform", "translate(50,70)").attr("class", "legend").call(colorLegend);
168
+ //const calcLegendHeight = 22 * itemColor.length + 4 * itemColor.length;
169
+ const selectedLegend = select(divRef.current);
170
+ selectedLegend
171
+ .append("text")
172
+ .text(legendColorName)
173
+ .attr("y", 7)
174
+ .style("float", "left")
175
+ .style("width", "30%")
176
+ .style("margin", "10px 0px");
177
+ selectedLegend
178
+ .append("svg")
179
+ .style("margin-top", "13px")
180
+ .style("margin-right", "103px")
181
+ .style("float", "right")
182
+ // .style("width", "60%")
183
+ .style("height", "25px")
184
+ .call(colorLegend);
185
+ }
186
+ // discrete legend using d3 colors
187
+ function discD3legend() {
188
+ const itemName = [];
189
+ const itemColor = [];
190
+ colorsObject.forEach((element, key) => {
191
+ itemColor.push({ color: element });
192
+ itemName.push(key);
193
+ });
194
+ const ordinalValues = scaleOrdinal(colorsObject).domain(itemName);
195
+ const discreteLegend = discreteLegendUtil(itemColor, "ColorSelector").inputScale(ordinalValues);
196
+ select("svg").append("g").attr("transform", "translate(50,70)").attr("class", "legend").call(discreteLegend);
197
+ const selectedLegend = select(divRef.current);
198
+ selectedLegend
199
+ .append("text")
200
+ .text(legendColorName)
201
+ .attr("y", 7)
202
+ .style("float", "left")
203
+ .style("width", "30%")
204
+ .style("margin", "10px 0px");
205
+ selectedLegend
206
+ .append("svg")
207
+ .style("margin-top", "13px")
208
+ .style("margin-right", "103px")
209
+ .style("float", "right")
210
+ // .style("width", "60%")
211
+ .style("height", "25px")
212
+ .call(discreteLegend);
213
+ }
214
+ return (React.createElement("div", { style: {
215
+ right: position[0],
216
+ top: position[1],
217
+ borderRadius: "5px",
218
+ height: "35px",
219
+ marginTop: "15px"
220
+ } },
221
+ React.createElement("div", { id: "legend", ref: divRef })));
222
+ };
223
+ // Based on name return the colors array from color.tables.json file
224
+ export function colorTableData(colorName, colorTables) {
225
+ const colorTableData = colorTables.filter((value) => value.name.toLowerCase() == colorName.toLowerCase());
226
+ return colorTableData.length > 0 ? colorTableData[0].colors : [];
227
+ }
228
+ //# sourceMappingURL=legendComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legendComponent.js","sourceRoot":"","sources":["../../../src/component/ColorSelector/legendComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAE1C,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AAiBzD,MAAM,CAAC,MAAM,eAAe,GAA0B,CAAC,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AAC;aAC3B,KAAK,CAAC,cAAc,EAAE,OAAO,CAAC;aAC9B,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC;YACxB,yBAAyB;aACxB,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC;aACvB,IAAI,CAAC,cAAc,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,CACH,6BACI,KAAK,EAAE;YACH,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;YAClB,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;YAChB,YAAY,EAAE,KAAK;YACnB,MAAM,EAAE,MAAM;YACd,SAAS,EAAE,MAAM;SACpB;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"}
@@ -4,10 +4,10 @@ declare type legendProps = {
4
4
  min: number;
5
5
  max: number;
6
6
  dataObjectName: string;
7
- position: number[];
7
+ position?: number[] | null;
8
8
  colorName: string;
9
9
  colorTables: colorTablesArray;
10
- horizontal: boolean;
10
+ horizontal?: boolean | null;
11
11
  };
12
12
  export declare const ContinuousLegend: React.FC<legendProps>;
13
13
  export {};
@@ -85,8 +85,8 @@ export const ContinuousLegend = ({ min, max, dataObjectName, position, colorName
85
85
  }
86
86
  return (React.createElement("div", { style: {
87
87
  position: "absolute",
88
- right: position[0],
89
- top: position[1],
88
+ right: position ? position[0] : ' ',
89
+ top: position ? position[1] : ' ',
90
90
  } },
91
91
  React.createElement("div", { id: "legend", ref: divRef })));
92
92
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ContinuousLegend.js","sourceRoot":"","sources":["../../../src/component/Legend/ContinuousLegend.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAkBtE,MAAM,CAAC,MAAM,gBAAgB,GAA0B,CAAC,EACpD,GAAG,EACH,GAAG,EACH,cAAc,EACd,QAAQ,EACR,SAAS,EACT,WAAW,EACX,UAAU,GACA,EAAE,EAAE;IACd,MAAM,MAAM,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC5C,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,IAAI,MAAM,CAAC,OAAO,EAAE;YAChB,gBAAgB,EAAE,CAAC;SACtB;QAAA,CAAC;QACF,OAAO,SAAS,OAAO;YACnB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;QAClD,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;IAEnD,SAAS,gBAAgB;QACrB,MAAM,SAAS,GAAgB,EAAE,CAAC;QAClC,8DAA8D;QAC9D,MAAM,gBAAgB,GAAG,WAAW,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QAC7D,gBAAgB,CAAC,OAAO,CAAC,CAAC,KAAuC,EAAE,EAAE;YACjE,wDAAwD;YACxD,SAAS,CAAC,IAAI,CAAC;gBACX,M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AK,CAAC;aAC3B,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,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;SACpC;QAED,6BAAK,EAAE,EAAC,QAAQ,EAAC,GAAG,EAAE,MAAM,GAAQ,CAClC,CACT,CAAC;AACN,CAAC,CAAC;AAEF,gBAAgB,CAAC,YAAY,GAAG;IAC5B,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;CACpB,CAAC"}
@@ -5,10 +5,10 @@ declare type colorLegendProps = {
5
5
  objects: Record<string, [number[], number]>;
6
6
  };
7
7
  dataObjectName: string;
8
- position: number[];
8
+ position?: number[] | null;
9
9
  colorName: string;
10
10
  colorTables: colorTablesArray;
11
- horizontal: boolean;
11
+ horizontal?: boolean | null;
12
12
  };
13
13
  export declare const DiscreteColorLegend: React.FC<colorLegendProps>;
14
14
  export declare function colorTableData(colorName: string, colorTables: colorTablesArray): [number, number, number, number][];
@@ -51,13 +51,13 @@ export const DiscreteColorLegend = ({ discreteData, dataObjectName, position, co
51
51
  .attr("y", 7)
52
52
  .style("color", "#6F6F6F")
53
53
  .style("margin", "10px 10px");
54
- if (!horizontal)
54
+ if (horizontal)
55
55
  selectedLegend.style("height", 150 + "px");
56
56
  const svgLegend = selectedLegend
57
57
  .append("svg")
58
58
  .style("margin", "10px 10px")
59
59
  .call(colorLegend);
60
- if (colorLegend && horizontal) {
60
+ if (colorLegend && !horizontal) {
61
61
  svgLegend
62
62
  .attr("height", calcLegendHeight + "px")
63
63
  .attr("width", 220 + "px");
@@ -71,8 +71,8 @@ export const DiscreteColorLegend = ({ discreteData, dataObjectName, position, co
71
71
  }
72
72
  return (React.createElement("div", { style: {
73
73
  position: "absolute",
74
- right: position[0],
75
- top: position[1],
74
+ right: position ? position[0] : ' ',
75
+ top: position ? position[1] : ' ',
76
76
  backgroundColor: "#ffffffcc",
77
77
  borderRadius: "5px",
78
78
  } },
@@ -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,IAAI,MAAM,CAAC,OAAO,EAAE;YAChB,cAAc,EAAE,CAAC;SACpB;QACD,OAAO,SAAS,OAAO;YACnB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;YAC9C,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;QAClD,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;IACvD,SAAS,cAAc;QACnB,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,MAAM,SAAS,GAAgB,EAAE,CAAC;QAClC,MAAM,WAAW,GAAuC,cAAc,CAClE,SAAS,EACT,WAAW,CACd,CAAC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 name: string;
8
+ discrete: boolean;
9
+ colors: readonly string[];
10
+ })[];
@@ -0,0 +1,84 @@
1
+ import * as d3 from "d3";
2
+ export const d3ColorScales = [
3
+ {
4
+ "name": "Spectral",
5
+ "discrete": false,
6
+ "colors": d3.interpolateSpectral
7
+ },
8
+ {
9
+ "name": "RdYlBu",
10
+ "discrete": false,
11
+ "colors": d3.interpolateRdYlBu
12
+ },
13
+ {
14
+ "name": "Warm",
15
+ "discrete": false,
16
+ "colors": d3.interpolateWarm
17
+ },
18
+ {
19
+ "name": "Cool",
20
+ "discrete": false,
21
+ "colors": d3.interpolateCool
22
+ },
23
+ {
24
+ "name": "Viridis",
25
+ "discrete": false,
26
+ "colors": d3.interpolateViridis
27
+ },
28
+ {
29
+ "name": "Inferno",
30
+ "discrete": false,
31
+ "colors": d3.interpolateInferno
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
+ },
83
+ ];
84
+ //# sourceMappingURL=d3ColorScale.js.map
@@ -0,0 +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,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 {};