@emerson-eps/color-tables 0.2.1 → 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 +2 -1
  14. package/dist/component/Legend/ContinuousLegend.js +162 -71
  15. package/dist/component/Legend/ContinuousLegend.js.map +1 -1
  16. package/dist/component/Legend/DiscreteLegend.d.ts +3 -1
  17. package/dist/component/Legend/DiscreteLegend.js +132 -57
  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 +3 -3
  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 +164 -74
  45. package/src/component/Legend/DiscreteLegend.tsx +132 -58
  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,8 +1,17 @@
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 { RGBToHex, colorsArray } from "../Utils/continousLegend";
4
- import { select, scaleLinear, scaleSequential, axisBottom } from "d3";
5
- export const ContinuousLegend = ({ min, max, dataObjectName, position, colorName, colorTables, horizontal, }) => {
13
+ import { select, scaleLinear, scaleSequential, axisBottom, axisRight } from "d3";
14
+ export const ContinuousLegend = ({ min, max, dataObjectName, position, colorName, colorTables, horizontal, updateLegend, }) => {
6
15
  const divRef = useRef(null);
7
16
  React.useEffect(() => {
8
17
  if (divRef.current) {
@@ -10,85 +19,167 @@ export const ContinuousLegend = ({ min, max, dataObjectName, position, colorName
10
19
  }
11
20
  ;
12
21
  return function cleanup() {
22
+ select(divRef.current).select("div").remove();
13
23
  select(divRef.current).select("svg").remove();
14
24
  };
15
- }, [min, max, colorName, colorTables, horizontal]);
25
+ }, [min, max, colorName, colorTables, horizontal, updateLegend]);
16
26
  function continuousLegend() {
17
- const itemColor = [];
18
- // Return the matched colors array from color.tables.json file
19
- const colorTableColors = colorsArray(colorName, colorTables);
20
- colorTableColors.forEach((value) => {
21
- // return the color and offset needed to draw the legend
22
- itemColor.push({
23
- offset: RGBToHex(value).offset,
24
- color: RGBToHex(value).color,
25
- });
26
- });
27
- const colorScale = scaleSequential().domain([min, max]);
28
- // append a defs (for definition) element to your SVG
29
- const svgLegend = select(divRef.current)
30
- .append("svg")
31
- .style("background-color", "#ffffffcc")
32
- .style("border-radius", "5px");
33
- if (!horizontal) {
34
- svgLegend
35
- .style("transform", "rotate(270deg)")
36
- .style("margin-top", "80px");
37
- }
38
- const defs = svgLegend.append("defs");
39
- // append a linearGradient element to the defs and give it a unique id
40
- const linearGradient = defs
41
- .append("linearGradient")
42
- .attr("id", "linear-gradient")
43
- .attr("x1", "0%")
44
- .attr("x2", "100%") //since it's a horizontal linear gradient
45
- .attr("y1", "0%")
46
- .attr("y2", "0%");
47
- // append multiple color stops by using D3's data/enter step
48
- linearGradient
49
- .selectAll("stop")
50
- .data(itemColor)
51
- .enter()
52
- .append("stop")
53
- .attr("offset", function (data) {
54
- return data.offset + "%";
55
- })
56
- .attr("stop-color", function (data) {
57
- return data.color;
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ const itemColor = [];
29
+ let dataSet;
30
+ try {
31
+ // fix for dash wrapper
32
+ if (typeof colorTables === "string") {
33
+ let res = yield fetch(colorTables);
34
+ dataSet = yield res.json();
35
+ }
36
+ // Return the matched colors array from color.tables.json file
37
+ let legendColors = typeof colorTables === "string" ?
38
+ colorsArray(colorName, dataSet)
39
+ :
40
+ colorsArray(colorName, colorTables);
41
+ // Update color of legend based on color selector scales
42
+ // data is passed on click upon color scales
43
+ if (updateLegend) {
44
+ // legend using color table data
45
+ if (updateLegend.color) {
46
+ legendColors = updateLegend.color;
47
+ }
48
+ // legend using d3 data
49
+ else if (updateLegend.length > 0) {
50
+ legendColors = updateLegend;
51
+ }
52
+ }
53
+ // main continuous legend
54
+ else {
55
+ legendColors;
56
+ }
57
+ legendColors.forEach((value) => {
58
+ // return the color and offset needed to draw the legend
59
+ itemColor.push({
60
+ offset: RGBToHex(value).offset,
61
+ color: RGBToHex(value).color,
62
+ });
63
+ });
64
+ const colorScale = scaleSequential().domain([min, max]);
65
+ // append a defs (for definition) element to your SVG
66
+ const svgLegend = select(divRef.current)
67
+ .append("svg")
68
+ .style("background-color", "#ffffffcc")
69
+ .style("border-radius", "5px");
70
+ const defs = svgLegend.append("defs");
71
+ let linearGradient;
72
+ // vertical legend
73
+ if (!horizontal) {
74
+ svgLegend
75
+ // .style("transform", "rotate(270deg)")
76
+ // .style("margin-top", "80px");
77
+ .attr("width", "100")
78
+ .attr("height", "150");
79
+ linearGradient = defs
80
+ .append("linearGradient")
81
+ .attr("id", "linear-gradient")
82
+ .attr("x1", "0%")
83
+ .attr("x2", "0%")
84
+ .attr("y1", "0%")
85
+ .attr("y2", "100%"); //since it's a vertical linear gradient
86
+ }
87
+ // horizontal legend
88
+ else {
89
+ svgLegend
90
+ .attr("width", "220")
91
+ .attr("height", "165");
92
+ // append a linearGradient element to the defs and give it a unique id
93
+ linearGradient = defs
94
+ .append("linearGradient")
95
+ .attr("id", "linear-gradient")
96
+ .attr("x1", "0%")
97
+ .attr("x2", "100%") //since it's a horizontal linear gradient
98
+ .attr("y1", "0%")
99
+ .attr("y2", "0%");
100
+ }
101
+ // append multiple color stops by using D3's data/enter step
102
+ linearGradient
103
+ .selectAll("stop")
104
+ .data(itemColor)
105
+ .enter()
106
+ .append("stop")
107
+ .attr("offset", function (data) {
108
+ return data.offset + "%";
109
+ })
110
+ .attr("stop-color", function (data) {
111
+ return data.color;
112
+ });
113
+ // append title
114
+ svgLegend
115
+ .append("text")
116
+ .attr("class", "legendTitle")
117
+ .attr("x", 25)
118
+ .attr("y", 20)
119
+ .style("text-anchor", "left")
120
+ .text(dataObjectName);
121
+ // vertical legend
122
+ if (!horizontal) {
123
+ // draw the rectangle and fill with gradient
124
+ svgLegend
125
+ .append("rect")
126
+ .attr("x", 25)
127
+ .attr("y", 30)
128
+ .attr("width", 25)
129
+ .attr("height", "150")
130
+ .style("fill", "url(#linear-gradient)");
131
+ }
132
+ // horizontal legend
133
+ else {
134
+ // draw the rectangle and fill with gradient
135
+ svgLegend
136
+ .append("rect")
137
+ .attr("x", 25)
138
+ .attr("y", 30)
139
+ .attr("width", "150")
140
+ .attr("height", 25)
141
+ .style("fill", "url(#linear-gradient)");
142
+ }
143
+ //create tick marks
144
+ // range varies the size of the axis
145
+ const xLeg = scaleLinear().domain([min, max]).range([10, 158]);
146
+ const yLeg = scaleLinear().domain([min, max]).range([10, 127]);
147
+ const horizontalAxisLeg = axisBottom(xLeg).tickValues(colorScale.domain());
148
+ var VerticalAxisLeg = axisRight(yLeg).tickSize(24).tickValues(colorScale.domain());
149
+ if (horizontal) {
150
+ svgLegend
151
+ .attr("class", "axis")
152
+ .append("g")
153
+ .attr("transform", "translate(15, 55)")
154
+ .style("font-size", "10px")
155
+ .style("font-weight", "700")
156
+ .call(horizontalAxisLeg)
157
+ .style("height", 25);
158
+ }
159
+ else {
160
+ svgLegend
161
+ .attr("class", "axis")
162
+ .append("g")
163
+ .attr("transform", "translate(25, 20)")
164
+ .style("font-size", "10px")
165
+ .style("font-weight", "700")
166
+ .call(VerticalAxisLeg);
167
+ }
168
+ }
169
+ catch (error) {
170
+ console.error(error);
171
+ }
58
172
  });
59
- // append title
60
- svgLegend
61
- .append("text")
62
- .attr("class", "legendTitle")
63
- .attr("x", 25)
64
- .attr("y", 20)
65
- .style("text-anchor", "left")
66
- .text(dataObjectName);
67
- // draw the rectangle and fill with gradient
68
- svgLegend
69
- .append("rect")
70
- .attr("x", 25)
71
- .attr("y", 30)
72
- .attr("width", 250)
73
- .attr("height", 25)
74
- .style("fill", "url(#linear-gradient)");
75
- //create tick marks
76
- const xLeg = scaleLinear().domain([min, max]).range([10, 258]);
77
- const axisLeg = axisBottom(xLeg).tickValues(colorScale.domain());
78
- svgLegend
79
- .attr("class", "axis")
80
- .append("g")
81
- .attr("transform", "translate(15, 55)")
82
- .style("font-size", "10px")
83
- .style("font-weight", "700")
84
- .call(axisLeg);
85
173
  }
86
174
  return (React.createElement("div", { style: {
87
175
  position: "absolute",
88
176
  right: position ? position[0] : ' ',
89
177
  top: position ? position[1] : ' ',
90
178
  } },
91
- React.createElement("div", { id: "legend", ref: divRef })));
179
+ React.createElement("div", { id: "legend", ref: divRef, style: {
180
+ width: horizontal ? "220px" : "100px",
181
+ height: horizontal ? "165px" : "150px",
182
+ } })));
92
183
  };
93
184
  ContinuousLegend.defaultProps = {
94
185
  position: [5, 10],
@@ -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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  position?: number[] | null;
9
9
  colorName: string;
10
- colorTables: colorTablesArray;
10
+ colorTables: colorTablesArray | string;
11
11
  horizontal?: boolean | null;
12
+ updateLegend?: any;
12
13
  };
13
14
  export declare const DiscreteColorLegend: React.FC<colorLegendProps>;
14
15
  export declare function colorTableData(colorName: string, colorTables: colorTablesArray): [number, number, number, number][];
16
+ export declare function RGBToHex(rgb: number[]): string;
15
17
  export {};
@@ -1,9 +1,22 @@
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
- import legendUtil from "../Utils/discreteLegend";
4
- import { scaleOrdinal, select } from "d3";
5
- export const DiscreteColorLegend = ({ discreteData, dataObjectName, position, colorName, colorTables, horizontal, }) => {
12
+ import discreteLegendUtil from "../Utils/discreteLegend";
13
+ import { select } from "d3";
14
+ export const DiscreteColorLegend = ({ discreteData, dataObjectName, position, colorName, colorTables, horizontal, updateLegend, }) => {
6
15
  const divRef = useRef(null);
16
+ let itemName = [];
17
+ let itemColor = [];
18
+ let testColor = [];
19
+ let testName = [];
7
20
  React.useEffect(() => {
8
21
  if (divRef.current) {
9
22
  discreteLegend();
@@ -12,62 +25,114 @@ export const DiscreteColorLegend = ({ discreteData, dataObjectName, position, co
12
25
  select(divRef.current).select("div").remove();
13
26
  select(divRef.current).select("svg").remove();
14
27
  };
15
- }, [discreteData, colorName, colorTables, horizontal]);
28
+ }, [discreteData, colorName, colorTables, horizontal, updateLegend]);
16
29
  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),
30
- });
31
- itemName.push(key);
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ let dataSet;
32
+ let discreteFlag = false;
33
+ try {
34
+ // fix for dash wrapper
35
+ if (typeof colorTables === "string") {
36
+ let res = yield fetch(colorTables);
37
+ dataSet = yield res.json();
38
+ }
39
+ let colorsArray = typeof colorTables === "string" ?
40
+ colorTableData(colorName, dataSet)
41
+ :
42
+ colorTableData(colorName, colorTables);
43
+ // Main discrete legend
44
+ if (!updateLegend) {
45
+ Object.keys(discreteData).forEach((key) => {
46
+ //eslint-disable-next-line
47
+ let code = discreteData[key][1];
48
+ //compare the first value in colorarray(colortable) and code from discreteData
49
+ const matchedColorsArrays = colorsArray.find((value) => {
50
+ return value[0] == code;
51
+ });
52
+ if (matchedColorsArrays)
53
+ itemColor.push({ color: RGBToHex(matchedColorsArrays) });
54
+ itemName.push(key);
55
+ });
56
+ discreteFlag = false;
57
+ }
58
+ // Discrete legend using Colortable colors
59
+ else if (updateLegend && updateLegend.color) {
60
+ // Object.keys(discreteData).forEach((key) => {
61
+ // //eslint-disable-next-line
62
+ // let code = (discreteData as { [key: string]: any })[key][1]
63
+ // //compare the first value in colorarray(colortable) and code from discreteData
64
+ // const matchedColorsArrays = updateLegend.color.find((value: number[]) => {
65
+ // return value[0] == code;
66
+ // });
67
+ // if (matchedColorsArrays) {
68
+ // testColor.push({color: RGBToHex(matchedColorsArrays)});
69
+ // testName.push(key);
70
+ // }
71
+ // });
72
+ //let color = updateLegend;
73
+ updateLegend.color.forEach((key) => {
74
+ testColor.push({ color: RGBToHex(key) });
75
+ });
76
+ itemColor = testColor;
77
+ itemName = testName;
78
+ discreteFlag = true;
79
+ }
80
+ // Discrete legend using d3 colors
81
+ else {
82
+ updateLegend.colorsObject.forEach((key) => {
83
+ itemColor.push({ color: key });
84
+ });
85
+ itemColor = itemColor;
86
+ itemName = updateLegend.legendColorName;
87
+ discreteFlag = true;
88
+ }
89
+ //const ordinalValues = scaleOrdinal().domain(itemName);
90
+ const colorLegend = discreteLegendUtil(itemColor, discreteFlag);
91
+ const legendLength = itemColor.length;
92
+ const calcLegendHeight = 22 * legendLength + 4 * legendLength;
93
+ const selectedLegend = select(divRef.current);
94
+ selectedLegend
95
+ .append("div")
96
+ .text(dataObjectName)
97
+ .attr("y", 10)
98
+ .style("margin-bottom", "5px");
99
+ if (horizontal && !discreteFlag)
100
+ selectedLegend.style("height", 150 + "px");
101
+ const svgLegend = selectedLegend
102
+ .style("margin-right", "41px")
103
+ .style("margin-top", "5px")
104
+ .append("svg")
105
+ .call(colorLegend);
106
+ if (colorLegend && !horizontal) {
107
+ svgLegend
108
+ .attr("height", calcLegendHeight + "px")
109
+ .attr("width", 220 + "px");
110
+ }
111
+ else if (!discreteFlag && horizontal) {
112
+ svgLegend
113
+ .style("transform", "rotate(90deg)")
114
+ .attr("height", calcLegendHeight + "px")
115
+ .attr("width", calcLegendHeight + "px");
116
+ }
117
+ else {
118
+ var totalRect;
119
+ if (updateLegend.color) {
120
+ totalRect = updateLegend.color.length;
121
+ }
122
+ else {
123
+ totalRect = updateLegend.colorsObject.length;
124
+ }
125
+ svgLegend.attr("viewBox", `0 0 ${totalRect} 2`)
126
+ .attr("preserveAspectRatio", "none")
127
+ .style("font-size", ".5")
128
+ .attr("height", "50px")
129
+ .attr("width", "150px");
130
+ }
131
+ }
132
+ catch (error) {
133
+ console.error(error);
134
+ }
32
135
  });
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
136
  }
72
137
  return (React.createElement("div", { style: {
73
138
  position: "absolute",
@@ -83,6 +148,16 @@ export function colorTableData(colorName, colorTables) {
83
148
  const colorTableData = colorTables.filter((value) => value.name.toLowerCase() == colorName.toLowerCase());
84
149
  return colorTableData.length > 0 ? colorTableData[0].colors : [];
85
150
  }
151
+ export function RGBToHex(rgb) {
152
+ let r = rgb[1].toString(16), g = rgb[2].toString(16), b = rgb[3].toString(16);
153
+ if (r.length == 1)
154
+ r = "0" + r;
155
+ if (g.length == 1)
156
+ g = "0" + g;
157
+ if (b.length == 1)
158
+ b = "0" + b;
159
+ return "#" + r + g + b;
160
+ }
86
161
  DiscreteColorLegend.defaultProps = {
87
162
  position: [5, 10],
88
163
  };
@@ -1 +1 @@
1
- {"version":3,"file":"DiscreteLegend.js","sourceRoot":"","sources":["../../../src/component/Legend/DiscreteLegend.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,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CAAC,MAAM,IAAI,CAAC;QAAE,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;IAC/B,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC;QAAE,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;IAC/B,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC;QAAE,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;IAC/B,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;AAED,mBAAmB,CAAC,YAAY,GAAG;IAC/B,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;CACpB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  declare type ItemColor = {
2
2
  color: any;
3
3
  };
4
- export default function discreteLegendUtil(itemColor: ItemColor[], ColorSelector?: string): any;
4
+ export default function discreteLegendUtil(itemColor: ItemColor[], isSelectorLegend?: boolean): any;
5
5
  export {};