@emerson-eps/color-tables 0.2.41 → 0.4.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.
@@ -44,140 +44,143 @@ export var DiscreteColorLegend = function (_a) {
44
44
  var discreteData = _a.discreteData, dataObjectName = _a.dataObjectName, position = _a.position, colorName = _a.colorName, horizontal = _a.horizontal, getColorScaleData = _a.getColorScaleData, id = _a.id, colorTables = _a.colorTables;
45
45
  var generateUniqueId = Math.ceil(Math.random() * 9999).toString();
46
46
  var divRef = useRef(null);
47
- var itemName = [];
48
- var itemColor = [];
49
47
  React.useEffect(function () {
50
48
  if (divRef.current) {
51
49
  select(divRef.current).select("div").remove();
52
50
  select(divRef.current).select("svg").remove();
53
51
  discreteLegend();
54
52
  }
55
- return function cleanup() {
56
- select(divRef.current).select("div").remove();
57
- select(divRef.current).select("svg").remove();
58
- };
59
- }, [discreteData, colorName, colorTables, horizontal, getColorScaleData]);
60
- function discreteLegend() {
61
- return __awaiter(this, void 0, void 0, function () {
62
- var dataSet, useSelectorLegend, res, arrayOfColors_1, d3ColorArrays_1, ordinalValues, colorLegend, currentDiv, totalRect, svgLegend, error_1;
63
- return __generator(this, function (_a) {
64
- switch (_a.label) {
65
- case 0:
66
- useSelectorLegend = false;
67
- _a.label = 1;
68
- case 1:
69
- _a.trys.push([1, 5, , 6]);
70
- if (!(typeof colorTables === "string")) return [3 /*break*/, 4];
71
- return [4 /*yield*/, fetch(colorTables)];
72
- case 2:
73
- res = _a.sent();
74
- return [4 /*yield*/, res.json()];
75
- case 3:
76
- dataSet = _a.sent();
77
- _a.label = 4;
78
- case 4:
79
- arrayOfColors_1 = typeof colorTables === "string"
80
- ? colorsArray(colorName, dataSet)
81
- : colorsArray(colorName, colorTables);
82
- d3ColorArrays_1 = colorsArray(colorName, d3ColorScales);
83
- // Main discrete legend
84
- if (!getColorScaleData || getColorScaleData.length == 0) {
85
- Object.keys(discreteData).forEach(function (key) {
86
- //eslint-disable-next-line
87
- var code = discreteData[key][1];
88
- // for colortable colors
89
- if (arrayOfColors_1.length > 0) {
90
- //compare the first value in colorarray(colortable) and code from discreteData
91
- var matchedColorsArrays_1 = arrayOfColors_1.find(function (value) {
92
- return value[0] == code;
93
- });
94
- if (matchedColorsArrays_1)
95
- itemColor.push({
96
- color: RGBToHex(matchedColorsArrays_1),
97
- name: key,
53
+ function discreteLegend() {
54
+ return __awaiter(this, void 0, void 0, function () {
55
+ var dataSet, useSelectorLegend, itemName, itemColor, res, arrayOfColors_1, d3ColorArrays_1, ordinalValues, colorLegend, currentDiv, totalRect, svgLegend, error_1;
56
+ return __generator(this, function (_a) {
57
+ switch (_a.label) {
58
+ case 0:
59
+ useSelectorLegend = false;
60
+ itemName = [];
61
+ itemColor = [];
62
+ _a.label = 1;
63
+ case 1:
64
+ _a.trys.push([1, 5, , 6]);
65
+ if (!(typeof colorTables === "string")) return [3 /*break*/, 4];
66
+ return [4 /*yield*/, fetch(colorTables)];
67
+ case 2:
68
+ res = _a.sent();
69
+ return [4 /*yield*/, res.json()];
70
+ case 3:
71
+ dataSet = _a.sent();
72
+ _a.label = 4;
73
+ case 4:
74
+ arrayOfColors_1 = typeof colorTables === "string"
75
+ ? colorsArray(colorName, dataSet)
76
+ : colorsArray(colorName, colorTables);
77
+ d3ColorArrays_1 = colorsArray(colorName, d3ColorScales);
78
+ // Main discrete legend
79
+ if (!getColorScaleData || getColorScaleData.length === 0) {
80
+ Object.keys(discreteData).forEach(function (key) {
81
+ //eslint-disable-next-line
82
+ var code = discreteData[key][1];
83
+ // for colortable colors
84
+ if (arrayOfColors_1.length > 0) {
85
+ //compare the first value in colorarray(colortable) and code from discreteData
86
+ var matchedColorsArrays_1 = arrayOfColors_1.find(function (value) {
87
+ return value[0] === code;
88
+ });
89
+ if (matchedColorsArrays_1)
90
+ itemColor.push({
91
+ color: RGBToHex(matchedColorsArrays_1),
92
+ name: key,
93
+ });
94
+ itemName.push(key);
95
+ }
96
+ // for d3 colors
97
+ else {
98
+ var matchedColorsArrays = d3ColorArrays_1.find(function (_value, index) {
99
+ return index === code;
98
100
  });
99
- itemName.push(key);
101
+ if (matchedColorsArrays)
102
+ itemColor.push({ color: matchedColorsArrays });
103
+ }
104
+ });
105
+ useSelectorLegend = false;
106
+ }
107
+ // Discrete legend using Colortable colors
108
+ else if (getColorScaleData === null || getColorScaleData === void 0 ? void 0 : getColorScaleData.color) {
109
+ getColorScaleData.color.forEach(function (key) {
110
+ itemColor.push({ color: RGBToHex(key) });
111
+ });
112
+ useSelectorLegend = true;
113
+ }
114
+ // Discrete legend using d3 colors
115
+ else if (getColorScaleData === null || getColorScaleData === void 0 ? void 0 : getColorScaleData.colorsObject) {
116
+ getColorScaleData.colorsObject.forEach(function (key) {
117
+ itemColor.push({ color: key });
118
+ });
119
+ itemName = getColorScaleData.legendColorName;
120
+ useSelectorLegend = true;
121
+ }
122
+ ordinalValues = scaleOrdinal().domain(itemName);
123
+ colorLegend = discreteLegendUtil(itemColor, useSelectorLegend, horizontal).inputScale(ordinalValues);
124
+ currentDiv = select(divRef.current);
125
+ totalRect = void 0;
126
+ // append the title
127
+ currentDiv
128
+ .append("div")
129
+ .text(dataObjectName)
130
+ .style("color", "grey")
131
+ .style("white-space", "nowrap")
132
+ .style("overflow", "hidden")
133
+ .style("width", "150px")
134
+ .style("text-overflow", "ellipsis")
135
+ .style("margin-bottom", horizontal ? "5px" : "0px")
136
+ .style("transform", "none")
137
+ .style("font-size", "small")
138
+ .style("transform", horizontal ? "none" : "translate(-69px, 80px) rotate(270deg)");
139
+ svgLegend = currentDiv
140
+ .style("margin", horizontal ? "5px 0px 0px 15px" : "0px 5px 0px 5px")
141
+ .style("width", horizontal ? "145px" : "50px")
142
+ .append("svg")
143
+ .call(colorLegend);
144
+ // Style for main horizontal legend
145
+ if (!useSelectorLegend) {
146
+ totalRect = itemColor.length;
147
+ }
148
+ // Style for color selector legend
149
+ else {
150
+ // calculate width for legend using colortable colors
151
+ if (getColorScaleData === null || getColorScaleData === void 0 ? void 0 : getColorScaleData.color) {
152
+ totalRect = getColorScaleData.color.length;
100
153
  }
101
- // for d3 colors
154
+ // calculate width for legend using d3 colors
102
155
  else {
103
- var matchedColorsArrays = d3ColorArrays_1.find(function (_value, index) {
104
- return index == code;
105
- });
106
- if (matchedColorsArrays)
107
- itemColor.push({ color: matchedColorsArrays });
156
+ totalRect = getColorScaleData.colorsObject.length;
108
157
  }
109
- });
110
- useSelectorLegend = false;
111
- }
112
- // Discrete legend using Colortable colors
113
- else if (getColorScaleData === null || getColorScaleData === void 0 ? void 0 : getColorScaleData.color) {
114
- getColorScaleData.color.forEach(function (key) {
115
- itemColor.push({ color: RGBToHex(key) });
116
- });
117
- useSelectorLegend = true;
118
- }
119
- // Discrete legend using d3 colors
120
- else if (getColorScaleData === null || getColorScaleData === void 0 ? void 0 : getColorScaleData.colorsObject) {
121
- getColorScaleData.colorsObject.forEach(function (key) {
122
- itemColor.push({ color: key });
123
- });
124
- itemName = getColorScaleData.legendColorName;
125
- useSelectorLegend = true;
126
- }
127
- ordinalValues = scaleOrdinal().domain(itemName);
128
- colorLegend = discreteLegendUtil(itemColor, useSelectorLegend, horizontal).inputScale(ordinalValues);
129
- currentDiv = select(divRef.current);
130
- totalRect = void 0;
131
- // append the title
132
- currentDiv
133
- .append("div")
134
- .text(dataObjectName)
135
- .style("color", "grey")
136
- .style("white-space", "nowrap")
137
- .style("overflow", "hidden")
138
- .style("width", "150px")
139
- .style("text-overflow", "ellipsis")
140
- .style("margin-bottom", horizontal ? "5px" : "0px")
141
- .style("transform", "none")
142
- .style("font-size", "small")
143
- .style("transform", horizontal ? "none" : "translate(-69px, 80px) rotate(270deg)");
144
- svgLegend = currentDiv
145
- .style("margin", horizontal ? "5px 0px 0px 15px" : "0px 5px 0px 5px")
146
- .style("width", horizontal ? "145px" : "50px")
147
- .append("svg")
148
- .call(colorLegend);
149
- // Style for main horizontal legend
150
- if (!useSelectorLegend) {
151
- totalRect = itemColor.length;
152
- }
153
- // Style for color selector legend
154
- else {
155
- // calculate width for legend using colortable colors
156
- if (getColorScaleData === null || getColorScaleData === void 0 ? void 0 : getColorScaleData.color) {
157
- totalRect = getColorScaleData.color.length;
158
158
  }
159
- // calculate width for legend using d3 colors
160
- else {
161
- totalRect = getColorScaleData.colorsObject.length;
162
- }
163
- }
164
- svgLegend
165
- .attr("viewBox", horizontal ? "0 0 ".concat(totalRect, " 1.5") : "0 0 2 ".concat(totalRect))
166
- .attr("preserveAspectRatio", "none")
167
- .style("font-size", ".4")
168
- .style("margin-left", horizontal ? "0" : "20px")
169
- .attr("height", horizontal ? "30px" : "153px")
170
- .attr("width", horizontal ? "150px" : "40px");
171
- return [3 /*break*/, 6];
172
- case 5:
173
- error_1 = _a.sent();
174
- console.error(error_1);
175
- return [3 /*break*/, 6];
176
- case 6: return [2 /*return*/];
177
- }
159
+ svgLegend
160
+ .attr("viewBox", horizontal ? "0 0 ".concat(totalRect, " 1.5") : "0 0 2 ".concat(totalRect))
161
+ .attr("preserveAspectRatio", "none")
162
+ .style("font-size", ".4")
163
+ .style("margin-left", horizontal ? "0" : "20px")
164
+ .attr("height", horizontal ? "30px" : "153px")
165
+ .attr("width", horizontal ? "150px" : "40px");
166
+ return [3 /*break*/, 6];
167
+ case 5:
168
+ error_1 = _a.sent();
169
+ console.error(error_1);
170
+ return [3 /*break*/, 6];
171
+ case 6: return [2 /*return*/];
172
+ }
173
+ });
178
174
  });
179
- });
180
- }
175
+ }
176
+ }, [
177
+ discreteData,
178
+ colorName,
179
+ colorTables,
180
+ horizontal,
181
+ getColorScaleData,
182
+ dataObjectName,
183
+ ]);
181
184
  return (React.createElement("div", { style: {
182
185
  right: position ? position[0] : " ",
183
186
  top: position ? position[1] : " ",
@@ -189,11 +192,11 @@ export var DiscreteColorLegend = function (_a) {
189
192
  };
190
193
  export function RGBToHex(rgb) {
191
194
  var r = rgb[1].toString(16), g = rgb[2].toString(16), b = rgb[3].toString(16);
192
- if (r.length == 1)
195
+ if (r.length === 1)
193
196
  r = "0" + r;
194
- if (g.length == 1)
197
+ if (g.length === 1)
195
198
  g = "0" + g;
196
- if (b.length == 1)
199
+ if (b.length === 1)
197
200
  b = "0" + b;
198
201
  return "#" + r + g + b;
199
202
  }
@@ -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,kBAAkB,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAmBtD,MAAM,CAAC,IAAM,mBAAmB,GAAkC,UAAC,EAS7C;QARpB,YAAY,kBAAA,EACZ,cAAc,oBAAA,EACd,QAAQ,cAAA,EACR,SAAS,eAAA,EACT,UAAU,gBAAA,EACV,iBAAiB,uBAAA,EACjB,EAAE,QAAA,EACF,WAAW,iBAAA;IAEX,IAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;IACpE,IAAM,MAAM,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC5C,IAAI,QAAQ,GAAa,EAAE,CAAC;IAC5B,IAAI,SAAS,GAAgB,EAAE,CAAC;IAEhC,KAAK,CAAC,SAAS,CAAC;QACd,IAAI,MAAM,CAAC,OAAO,EAAE;YAClB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;YAC9C,MAAM,CAAC,MAAM,C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;AACzB,CAAC;AAED,mBAAmB,CAAC,YAAY,GAAG;IACjC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;CAClB,CAAC"}
@@ -38,14 +38,14 @@ export default function discreteLegendUtil(itemColor, isSelectorLegend, horizont
38
38
  })
39
39
  .attr("x", 0);
40
40
  }
41
- else if (horizontal == true && isSelectorLegend) {
41
+ else if (horizontal === true && isSelectorLegend) {
42
42
  g.selectAll("rect")
43
43
  .attr("x", function (_d, i) {
44
44
  return i;
45
45
  })
46
46
  .attr("y", 0);
47
47
  }
48
- else if (horizontal == false && isSelectorLegend) {
48
+ else if (horizontal === false && isSelectorLegend) {
49
49
  g.selectAll("rect")
50
50
  .attr("y", function (_d, i) {
51
51
  return i;
@@ -1 +1 @@
1
- {"version":3,"file":"discreteLegend.js","sourceRoot":"","sources":["../../../src/component/Utils/discreteLegend.ts"],"names":[],"mappings":"AAIA,2BAA2B;AAC3B,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,SAAsB,EACtB,gBAA0B,EAC1B,UAAgB;IAEhB,IAAM,YAAY,GAAgB,EAAE,CAAC;IAErC,2BAA2B;IAC3B,SAAS,MAAM,CAAC,CAAM;QACpB,SAAS,UAAU;YACjB,yBAAyB;YACzB,oCAAoC;YACpC,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC;iBACzB,IAAI,CAAC,SAAS,CAAC;iBACf,KAAK,EAAE;iBACP,MAAM,CAAC,GAAG,CAAC;iBACX,MAAM,CAAC,MAAM,CAAC;iBACd,MAAM,CAAC,OAAO,CAAC;iBACf,IAAI,CAAC,UAAU,CAA0B;gBACxC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;YACnB,CAAC,CAAC;iBACD,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC;iBAC1B,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC;iBAC1B,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;YAClC,CAAC,CAAC,SAAS,CAAC,MA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AAM,CAAC;qBAChB,IAAI,CAAC,GAAG,EAAE,UAAU,EAAU,EAAE,CAAS;oBACxC,OAAO,CAAC,CAAC;gBACX,CAAC,CAAC;qBACD,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;aACjB;QACH,CAAC;QAED,UAAU,EAAE,CAAC;IACf,CAAC;IACD,2BAA2B;IAC3B,MAAM,CAAC,UAAU,GAAG,UAAU,QAAa;QACzC,2BAA2B;QAC3B,IAAI,KAAK,GAAQ,EAAE,CAAC;QACpB,KAAK,GAAG,QAAQ,CAAC;QAEjB,KAAK,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,UAAU,EAAO;YACtC,IAAM,UAAU,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;YACnD,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"discreteLegend.js","sourceRoot":"","sources":["../../../src/component/Utils/discreteLegend.ts"],"names":[],"mappings":"AAIA,2BAA2B;AAC3B,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,SAAsB,EACtB,gBAA0B,EAC1B,UAAgB;IAEhB,IAAM,YAAY,GAAgB,EAAE,CAAC;IAErC,2BAA2B;IAC3B,SAAS,MAAM,CAAC,CAAM;QACpB,SAAS,UAAU;YACjB,yBAAyB;YACzB,oCAAoC;YACpC,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC;iBACzB,IAAI,CAAC,SAAS,CAAC;iBACf,KAAK,EAAE;iBACP,MAAM,CAAC,GAAG,CAAC;iBACX,MAAM,CAAC,MAAM,CAAC;iBACd,MAAM,CAAC,OAAO,CAAC;iBACf,IAAI,CAAC,UAAU,CAA0B;gBACxC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;YAC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AChB,IAAI,CAAC,GAAG,EAAE,UAAU,EAAU,EAAE,CAAS;oBACxC,OAAO,CAAC,CAAC;gBACX,CAAC,CAAC;qBACD,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;aACjB;iBAAM;gBACL,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC;qBAChB,IAAI,CAAC,GAAG,EAAE,UAAU,EAAU,EAAE,CAAS;oBACxC,OAAO,CAAC,CAAC;gBACX,CAAC,CAAC;qBACD,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;aACjB;QACH,CAAC;QAED,UAAU,EAAE,CAAC;IACf,CAAC;IACD,2BAA2B;IAC3B,MAAM,CAAC,UAAU,GAAG,UAAU,QAAa;QACzC,2BAA2B;QAC3B,IAAI,KAAK,GAAQ,EAAE,CAAC;QACpB,KAAK,GAAG,QAAQ,CAAC;QAEjB,KAAK,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,UAAU,EAAO;YACtC,IAAM,UAAU,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;YACnD,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,11 +1,7 @@
1
1
  import { colorTablesArray } from "../colorTableTypes";
2
+ declare type Color = [number, number, number];
2
3
  export declare function colorsArray(colorName: string, iscolorTablesDefined: colorTablesArray | any): any;
3
- export declare function rgbValues(point: number, colorName: string, iscolorTablesDefined: colorTablesArray | any): number[] | {
4
- r: number;
5
- g: number;
6
- b: number;
7
- opacity: number;
8
- } | undefined;
4
+ export declare function rgbValues(point: number, colorName: string, iscolorTablesDefined: colorTablesArray | any): Color;
9
5
  export declare function RGBToHex(rgb: number[]): {
10
6
  color: string;
11
7
  offset: number;
@@ -21,15 +17,8 @@ export declare function getRgbData(point: number, colorName: string, iscolorTabl
21
17
  opacity: number;
22
18
  } | undefined;
23
19
  export declare function getColors(colorName: string, iscolorTablesDefined: any, point: number): any;
24
- export declare function sampledColor(colorScaleName: string, point: number, categorial?: boolean, min?: number, max?: number, iscolorTablesDefined?: colorTablesArray | any): number[] | {
25
- r: number;
26
- g: number;
27
- b: number;
28
- opacity: number;
29
- };
30
- export declare function createColorMapFunction(colorScaleName: string): (x: number, categorial: boolean, min: number, max: number, iscolorTablesDefined: colorTablesArray | any) => number[] | {
31
- r: number;
32
- g: number;
33
- b: number;
34
- opacity: number;
35
- };
20
+ export declare function sampledColor(colorScaleName: string, point: number, categorial?: boolean, min?: number, max?: number, iscolorTablesDefined?: colorTablesArray | any): [number, number, number, number] | Color;
21
+ export declare function createColorMapFunction(colorScaleName: string): (x: number, categorial?: boolean, min?: number, max?: number, iscolorTablesDefined?: colorTablesArray | any) => [number, number, number, number] | Color;
22
+ export declare function createContinuousLibraryColorScale(name: string, library?: colorTablesArray): (value: number) => Color;
23
+ export declare function createDefaultContinuousColorScale(): (value: number) => Color;
24
+ export {};
@@ -2,13 +2,16 @@ import { color } from "d3-color";
2
2
  import { interpolateRgb } from "d3-interpolate";
3
3
  import { d3ColorScales } from "./d3ColorScale";
4
4
  import colorTables from "../../component/color-tables.json";
5
+ function getColor(rgb) {
6
+ return [rgb["r"], rgb["g"], rgb["b"]];
7
+ }
5
8
  // Based on objectName return the colors array from color.tables.json file
6
9
  export function colorsArray(colorName, iscolorTablesDefined) {
7
10
  var getColorTables = iscolorTablesDefined
8
11
  ? iscolorTablesDefined
9
12
  : colorTables;
10
13
  var colorTableData = getColorTables.filter(function (value) {
11
- return value.name.toLowerCase() == colorName.toLowerCase();
14
+ return value.name.toLowerCase() === colorName.toLowerCase();
12
15
  });
13
16
  return colorTableData.length > 0 ? colorTableData[0].colors : [];
14
17
  }
@@ -21,7 +24,7 @@ export function rgbValues(point, colorName, iscolorTablesDefined) {
21
24
  var colorTableColors = colorsArray(colorName, getColorTables);
22
25
  // compare the point and first value from colorTableColors
23
26
  var colorArrays = colorTableColors.find(function (value) {
24
- return point == value[0];
27
+ return point === value[0];
25
28
  });
26
29
  // if point and value in color table matches then return particular colors
27
30
  if (colorArrays) {
@@ -35,12 +38,13 @@ export function rgbValues(point, colorName, iscolorTablesDefined) {
35
38
  });
36
39
  var firstColorArray = colorTableColors[index - 1];
37
40
  var secondColorArray = colorTableColors[index];
38
- if ((firstColorArray || secondColorArray) != undefined) {
41
+ if ((firstColorArray || secondColorArray) !== undefined) {
39
42
  var t0 = firstColorArray[0];
40
43
  var t1 = secondColorArray[0];
41
44
  var t = (point - t0) / (t1 - t0); // t = 0.0 gives first color, t = 1.0 gives second color.
42
45
  var interpolatedValues = interpolateRgb(RGBToHex(firstColorArray).color, RGBToHex(secondColorArray).color)(t);
43
- return (_a = color(interpolatedValues)) === null || _a === void 0 ? void 0 : _a.rgb();
46
+ var c = (_a = color(interpolatedValues)) === null || _a === void 0 ? void 0 : _a.rgb();
47
+ return getColor(c);
44
48
  }
45
49
  return undefined;
46
50
  }
@@ -48,11 +52,11 @@ export function rgbValues(point, colorName, iscolorTablesDefined) {
48
52
  // return the hex color code and offset
49
53
  export function RGBToHex(rgb) {
50
54
  var r = Math.round(rgb[1]).toString(16), g = Math.round(rgb[2]).toString(16), b = Math.round(rgb[3]).toString(16);
51
- if (r.length == 1)
55
+ if (r.length === 1)
52
56
  r = "0" + r;
53
- if (g.length == 1)
57
+ if (g.length === 1)
54
58
  g = "0" + g;
55
- if (b.length == 1)
59
+ if (b.length === 1)
56
60
  b = "0" + b;
57
61
  var offset = rgb[0] * 100.0;
58
62
  return { color: "#" + r + g + b, offset: offset };
@@ -61,11 +65,11 @@ export function RGBToHex(rgb) {
61
65
  // return the hex color code and offset
62
66
  export function RGBToHexValue(rgb, max) {
63
67
  var r = Math.round(rgb[1]).toString(16), g = Math.round(rgb[2]).toString(16), b = Math.round(rgb[3]).toString(16);
64
- if (r.length == 1)
68
+ if (r.length === 1)
65
69
  r = "0" + r;
66
- if (g.length == 1)
70
+ if (g.length === 1)
67
71
  g = "0" + g;
68
- if (b.length == 1)
72
+ if (b.length === 1)
69
73
  b = "0" + b;
70
74
  var normalizePoint = (rgb[0] - 0) / (max - 0);
71
75
  return { color: "#" + r + g + b, offset: normalizePoint * 100.0 };
@@ -79,10 +83,10 @@ export function getRgbData(point, colorName, iscolorTablesDefined) {
79
83
  : colorTables;
80
84
  // get colortable colorscale data
81
85
  var getColorTableScale = getColorTables.find(function (value) {
82
- return value.name == colorName;
86
+ return value.name === colorName;
83
87
  });
84
88
  // colortable discrete scale
85
- if ((getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.discrete) == true) {
89
+ if ((getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.discrete) === true) {
86
90
  var rgb_1;
87
91
  var getSelectedScaleLength = getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.colors.length;
88
92
  var minValue_1 = 0;
@@ -95,7 +99,7 @@ export function getRgbData(point, colorName, iscolorTablesDefined) {
95
99
  var normalizedNextIndex = (nextIndex - minValue_1) / (maxValue_1 - 0);
96
100
  //const t = (point - t0) / (t1 - t0); // t = 0.0 gives first color, t = 1.0 gives second color.
97
101
  if (point >= normalizedCurrentIndex && point <= normalizedNextIndex) {
98
- if ((item && (getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.colors[nextIndex])) != undefined) {
102
+ if ((item && (getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.colors[nextIndex])) !== undefined) {
99
103
  var interpolate = interpolateRgb((_a = RGBToHex(item)) === null || _a === void 0 ? void 0 : _a.color, (_b = RGBToHex(getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.colors[nextIndex])) === null || _b === void 0 ? void 0 : _b.color)(point);
100
104
  rgb_1 = (_c = color(interpolate)) === null || _c === void 0 ? void 0 : _c.rgb();
101
105
  }
@@ -107,7 +111,7 @@ export function getRgbData(point, colorName, iscolorTablesDefined) {
107
111
  var colorTableColors = colorsArray(colorName, getColorTables);
108
112
  // compare the point and first value from colorTableColors
109
113
  var colorArrays = colorTableColors.find(function (value) {
110
- return point == value[0];
114
+ return point === value[0];
111
115
  });
112
116
  // if point and value in color table matches then return particular colors
113
117
  if (colorArrays) {
@@ -121,7 +125,7 @@ export function getRgbData(point, colorName, iscolorTablesDefined) {
121
125
  });
122
126
  var firstColorArray = colorTableColors[index - 1];
123
127
  var secondColorArray = colorTableColors[index];
124
- if ((firstColorArray || secondColorArray) != undefined) {
128
+ if ((firstColorArray || secondColorArray) !== undefined) {
125
129
  var t0 = firstColorArray[0];
126
130
  var t1 = secondColorArray[0];
127
131
  var t = (point - t0) / (t1 - t0); // t = 0.0 gives first color, t = 1.0 gives second color.
@@ -138,10 +142,10 @@ export function getColors(colorName, iscolorTablesDefined, point) {
138
142
  ? iscolorTablesDefined
139
143
  : colorTables;
140
144
  var colorTableData = getColorTables.filter(function (value) {
141
- return value.name.toLowerCase() == colorName.toLowerCase();
145
+ return value.name.toLowerCase() === colorName.toLowerCase();
142
146
  });
143
147
  var colorArrays = (_a = colorTableData[0]) === null || _a === void 0 ? void 0 : _a.colors.find(function (value) {
144
- return value[0] == point;
148
+ return value[0] === point;
145
149
  });
146
150
  return colorTableData.length > 0 ? colorArrays : [];
147
151
  }
@@ -152,17 +156,17 @@ export function sampledColor(colorScaleName, point, categorial, min, max, iscolo
152
156
  : colorTables;
153
157
  // get colortable colorscale data
154
158
  var getColorTableScale = getColorTables.find(function (value) {
155
- return value.name == colorScaleName;
159
+ return value.name === colorScaleName;
156
160
  });
157
161
  // get d3 colorscale data
158
162
  var getD3Scale = d3ColorScales.find(function (value) {
159
- return value.name == colorScaleName;
163
+ return value.name === colorScaleName;
160
164
  });
161
165
  // return the color for matched point
162
166
  // does interpolation for non-matching point
163
167
  var rgb = rgbValues(point, colorScaleName, getColorTables);
164
168
  // colortable continuous scale
165
- if ((getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.discrete) == false) {
169
+ if ((getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.discrete) === false) {
166
170
  // if log is discrete, then need to normalize
167
171
  if (categorial) {
168
172
  // condition added to resolve typescript error
@@ -183,17 +187,17 @@ export function sampledColor(colorScaleName, point, categorial, min, max, iscolo
183
187
  var normalizedPoint = (point - min) / (max - min);
184
188
  colorMappingRange = getD3Scale === null || getD3Scale === void 0 ? void 0 : getD3Scale.colors(normalizedPoint);
185
189
  }
186
- rgb = (_a = color(colorMappingRange)) === null || _a === void 0 ? void 0 : _a.rgb();
190
+ rgb = getColor((_a = color(colorMappingRange)) === null || _a === void 0 ? void 0 : _a.rgb());
187
191
  }
188
192
  // colortable discrete scale
189
- if ((getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.discrete) == true) {
193
+ if ((getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.discrete) === true) {
190
194
  if (categorial) {
191
195
  // compare the code and first value from colorsArray(colortable)
192
196
  var arrayOfColors = colorsArray(colorScaleName, getColorTables);
193
197
  var colorArrays = arrayOfColors.find(function (value) {
194
- return value[0] == point;
198
+ return value[0] === point;
195
199
  });
196
- rgb = colorArrays;
200
+ return colorArrays;
197
201
  }
198
202
  else {
199
203
  var getSelectedScaleLength = getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.colors.length;
@@ -207,9 +211,9 @@ export function sampledColor(colorScaleName, point, categorial, min, max, iscolo
207
211
  var normalizedNextIndex = (nextIndex - minValue_2) / (maxValue_2 - 0);
208
212
  //const t = (point - t0) / (t1 - t0); // t = 0.0 gives first color, t = 1.0 gives second color.
209
213
  if (point >= normalizedCurrentIndex && point <= normalizedNextIndex) {
210
- if ((item && (getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.colors[nextIndex])) != undefined) {
214
+ if ((item && (getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.colors[nextIndex])) !== undefined) {
211
215
  var interpolate = interpolateRgb((_a = RGBToHex(item)) === null || _a === void 0 ? void 0 : _a.color, (_b = RGBToHex(getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.colors[nextIndex])) === null || _b === void 0 ? void 0 : _b.color)(point);
212
- rgb = (_c = color(interpolate)) === null || _c === void 0 ? void 0 : _c.rgb();
216
+ rgb = getColor((_c = color(interpolate)) === null || _c === void 0 ? void 0 : _c.rgb());
213
217
  }
214
218
  }
215
219
  });
@@ -222,9 +226,9 @@ export function sampledColor(colorScaleName, point, categorial, min, max, iscolo
222
226
  // const normalizedPoint = (point - min) / (max - min);
223
227
  var code_1 = point;
224
228
  var d3ColorArrays = getD3Scale === null || getD3Scale === void 0 ? void 0 : getD3Scale.colors.find(function (_value, index) {
225
- return index == code_1;
229
+ return index === code_1;
226
230
  });
227
- rgb = (_b = color(d3ColorArrays)) === null || _b === void 0 ? void 0 : _b.rgb();
231
+ rgb = getColor((_b = color(d3ColorArrays)) === null || _b === void 0 ? void 0 : _b.rgb());
228
232
  }
229
233
  // continous log
230
234
  else {
@@ -238,7 +242,7 @@ export function sampledColor(colorScaleName, point, categorial, min, max, iscolo
238
242
  //const t = (point - t0) / (t1 - t0); // t = 0.0 gives first color, t = 1.0 gives second color.
239
243
  if (point >= normalizedCurrentIndex && point <= normalizedNextIndex) {
240
244
  var interpolate = interpolateRgb(item, getD3Scale[nextIndex])(point);
241
- rgb = (_a = color(interpolate)) === null || _a === void 0 ? void 0 : _a.rgb();
245
+ rgb = getColor((_a = color(interpolate)) === null || _a === void 0 ? void 0 : _a.rgb());
242
246
  }
243
247
  });
244
248
  }
@@ -247,7 +251,20 @@ export function sampledColor(colorScaleName, point, categorial, min, max, iscolo
247
251
  }
248
252
  export function createColorMapFunction(colorScaleName) {
249
253
  return function (x, categorial, min, max, iscolorTablesDefined) {
254
+ if (categorial === void 0) { categorial = false; }
255
+ if (min === void 0) { min = 0; }
256
+ if (max === void 0) { max = 1; }
257
+ if (iscolorTablesDefined === void 0) { iscolorTablesDefined = colorTables; }
250
258
  return sampledColor(colorScaleName, x, categorial, min, max, iscolorTablesDefined);
251
259
  };
252
260
  }
261
+ export function createContinuousLibraryColorScale(name, library) {
262
+ if (library === void 0) { library = colorTables; }
263
+ return function (value) {
264
+ return rgbValues(value, name, library);
265
+ };
266
+ }
267
+ export function createDefaultContinuousColorScale() {
268
+ return createContinuousLibraryColorScale("Rainbow");
269
+ }
253
270
  //# sourceMappingURL=legendCommonFunction.js.map