@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
@@ -10,8 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import * as React from "react";
11
11
  import { useRef } from "react";
12
12
  import { RGBToHex, colorsArray } from "../Utils/continousLegend";
13
- import { select, scaleLinear, scaleSequential, axisBottom } from "d3";
14
- 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, }) => {
15
15
  const divRef = useRef(null);
16
16
  React.useEffect(() => {
17
17
  if (divRef.current) {
@@ -19,87 +19,156 @@ export const ContinuousLegend = ({ min, max, dataObjectName, position, colorName
19
19
  }
20
20
  ;
21
21
  return function cleanup() {
22
+ select(divRef.current).select("div").remove();
22
23
  select(divRef.current).select("svg").remove();
23
24
  };
24
- }, [min, max, colorName, colorTables, horizontal]);
25
+ }, [min, max, colorName, colorTables, horizontal, updateLegend]);
25
26
  function continuousLegend() {
26
27
  return __awaiter(this, void 0, void 0, function* () {
27
28
  const itemColor = [];
28
29
  let dataSet;
29
- if (typeof colorTables === "string") {
30
- let res = yield fetch(colorTables);
31
- dataSet = yield res.json();
32
- }
33
- // Return the matched colors array from color.tables.json file
34
- let colorTableColors = typeof colorTables === "string" ?
35
- colorsArray(colorName, dataSet)
36
- :
37
- colorsArray(colorName, colorTables);
38
- colorTableColors.forEach((value) => {
39
- // return the color and offset needed to draw the legend
40
- itemColor.push({
41
- offset: RGBToHex(value).offset,
42
- color: RGBToHex(value).color,
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;
43
112
  });
44
- });
45
- const colorScale = scaleSequential().domain([min, max]);
46
- // append a defs (for definition) element to your SVG
47
- const svgLegend = select(divRef.current)
48
- .append("svg")
49
- .style("background-color", "#ffffffcc")
50
- .style("border-radius", "5px");
51
- if (!horizontal) {
113
+ // append title
52
114
  svgLegend
53
- .style("transform", "rotate(270deg)")
54
- .style("margin-top", "80px");
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);
55
171
  }
56
- const defs = svgLegend.append("defs");
57
- // append a linearGradient element to the defs and give it a unique id
58
- const linearGradient = defs
59
- .append("linearGradient")
60
- .attr("id", "linear-gradient")
61
- .attr("x1", "0%")
62
- .attr("x2", "100%") //since it's a horizontal linear gradient
63
- .attr("y1", "0%")
64
- .attr("y2", "0%");
65
- // append multiple color stops by using D3's data/enter step
66
- linearGradient
67
- .selectAll("stop")
68
- .data(itemColor)
69
- .enter()
70
- .append("stop")
71
- .attr("offset", function (data) {
72
- return data.offset + "%";
73
- })
74
- .attr("stop-color", function (data) {
75
- return data.color;
76
- });
77
- // append title
78
- svgLegend
79
- .append("text")
80
- .attr("class", "legendTitle")
81
- .attr("x", 25)
82
- .attr("y", 20)
83
- .style("text-anchor", "left")
84
- .text(dataObjectName);
85
- // draw the rectangle and fill with gradient
86
- svgLegend
87
- .append("rect")
88
- .attr("x", 25)
89
- .attr("y", 30)
90
- .attr("width", 250)
91
- .attr("height", 25)
92
- .style("fill", "url(#linear-gradient)");
93
- //create tick marks
94
- const xLeg = scaleLinear().domain([min, max]).range([10, 258]);
95
- const axisLeg = axisBottom(xLeg).tickValues(colorScale.domain());
96
- svgLegend
97
- .attr("class", "axis")
98
- .append("g")
99
- .attr("transform", "translate(15, 55)")
100
- .style("font-size", "10px")
101
- .style("font-weight", "700")
102
- .call(axisLeg);
103
172
  });
104
173
  }
105
174
  return (React.createElement("div", { style: {
@@ -107,7 +176,10 @@ export const ContinuousLegend = ({ min, max, dataObjectName, position, colorName
107
176
  right: position ? position[0] : ' ',
108
177
  top: position ? position[1] : ' ',
109
178
  } },
110
- 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
+ } })));
111
183
  };
112
184
  ContinuousLegend.defaultProps = {
113
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,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;IAEn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Q,CACP,CACT,CAAC;AACN,CAAC,CAAC;AAEF,gBAAgB,CAAC,YAAY,GAAG;IAC5B,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;CACpB,CAAC"}
@@ -9,7 +9,9 @@ declare type colorLegendProps = {
9
9
  colorName: string;
10
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 {};
@@ -9,10 +9,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import * as React from "react";
11
11
  import { useRef } from "react";
12
- import legendUtil from "../Utils/discreteLegend";
13
- import { scaleOrdinal, select } from "d3";
14
- 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, }) => {
15
15
  const divRef = useRef(null);
16
+ let itemName = [];
17
+ let itemColor = [];
18
+ let testColor = [];
19
+ let testName = [];
16
20
  React.useEffect(() => {
17
21
  if (divRef.current) {
18
22
  discreteLegend();
@@ -21,70 +25,112 @@ export const DiscreteColorLegend = ({ discreteData, dataObjectName, position, co
21
25
  select(divRef.current).select("div").remove();
22
26
  select(divRef.current).select("svg").remove();
23
27
  };
24
- }, [discreteData, colorName, colorTables, horizontal]);
28
+ }, [discreteData, colorName, colorTables, horizontal, updateLegend]);
25
29
  function discreteLegend() {
26
30
  return __awaiter(this, void 0, void 0, function* () {
27
- const itemName = [];
28
- const itemColor = [];
29
31
  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;
44
- });
45
- if (matchedColorsArrays)
46
- itemColor.push({
47
- color: RGBToHex(matchedColorsArrays),
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);
48
55
  });
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");
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
+ }
82
131
  }
83
- else {
84
- svgLegend
85
- .style("transform", "rotate(90deg)")
86
- .attr("width", calcLegendHeight + "px")
87
- .attr("height", calcLegendHeight + "px");
132
+ catch (error) {
133
+ console.error(error);
88
134
  }
89
135
  });
90
136
  }
@@ -102,6 +148,16 @@ export function colorTableData(colorName, colorTables) {
102
148
  const colorTableData = colorTables.filter((value) => value.name.toLowerCase() == colorName.toLowerCase());
103
149
  return colorTableData.length > 0 ? colorTableData[0].colors : [];
104
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
+ }
105
161
  DiscreteColorLegend.defaultProps = {
106
162
  position: [5, 10],
107
163
  };
@@ -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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,GAAa;IAClC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EACvB,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EACvB,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC5B,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,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 {};