@emerson-eps/color-tables 1.0.0 → 1.0.2

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 (114) hide show
  1. package/dist/component/BreakPoint/Canvas.d.ts +3 -3
  2. package/dist/component/BreakPoint/Canvas.js +10 -21
  3. package/dist/component/BreakPoint/Canvas.js.map +1 -1
  4. package/dist/component/BreakPoint/ColorScale.d.ts +2 -3
  5. package/dist/component/BreakPoint/ColorScale.js +19 -20
  6. package/dist/component/BreakPoint/ColorScale.js.map +1 -1
  7. package/dist/component/BreakPoint/Legend.d.ts +2 -3
  8. package/dist/component/BreakPoint/Legend.js +31 -37
  9. package/dist/component/BreakPoint/Legend.js.map +1 -1
  10. package/dist/component/BreakPoint/Modal.d.ts +6 -3
  11. package/dist/component/BreakPoint/Modal.js +17 -21
  12. package/dist/component/BreakPoint/Modal.js.map +1 -1
  13. package/dist/component/BreakPoint/index.d.ts +4 -0
  14. package/dist/component/BreakPoint/index.js +6 -0
  15. package/dist/component/BreakPoint/index.js.map +1 -0
  16. package/dist/component/ColorSelector/BreakPointModule.d.ts +3 -4
  17. package/dist/component/ColorSelector/BreakPointModule.js +99 -140
  18. package/dist/component/ColorSelector/BreakPointModule.js.map +1 -1
  19. package/dist/component/ColorSelector/ColorSelectorAccordion.js +55 -60
  20. package/dist/component/ColorSelector/ColorSelectorAccordion.js.map +1 -1
  21. package/dist/component/ColorSelector/ColorSelectorComponent.d.ts +2 -3
  22. package/dist/component/ColorSelector/ColorSelectorComponent.js +83 -86
  23. package/dist/component/ColorSelector/ColorSelectorComponent.js.map +1 -1
  24. package/dist/component/ColorSelector/ColorSelectorWrapper.d.ts +12 -5
  25. package/dist/component/ColorSelector/ColorSelectorWrapper.js +41 -51
  26. package/dist/component/ColorSelector/ColorSelectorWrapper.js.map +1 -1
  27. package/dist/component/ColorSelector/index.d.ts +4 -0
  28. package/dist/component/ColorSelector/index.js +6 -0
  29. package/dist/component/ColorSelector/index.js.map +1 -0
  30. package/dist/component/Legend/ColorLegend.d.ts +2 -2
  31. package/dist/component/Legend/ColorLegend.js +38 -39
  32. package/dist/component/Legend/ColorLegend.js.map +1 -1
  33. package/dist/component/Legend/ColorLegend.stories.js +20 -31
  34. package/dist/component/Legend/ColorLegend.stories.js.map +1 -1
  35. package/dist/component/Legend/ContinuousLegend.d.ts +2 -2
  36. package/dist/component/Legend/ContinuousLegend.js +230 -276
  37. package/dist/component/Legend/ContinuousLegend.js.map +1 -1
  38. package/dist/component/Legend/ContinuousLegend.stories.js +13 -24
  39. package/dist/component/Legend/ContinuousLegend.stories.js.map +1 -1
  40. package/dist/component/Legend/DiscreteLegend.d.ts +2 -2
  41. package/dist/component/Legend/DiscreteLegend.js +130 -180
  42. package/dist/component/Legend/DiscreteLegend.js.map +1 -1
  43. package/dist/component/Legend/DiscreteLegend.stories.js +15 -26
  44. package/dist/component/Legend/DiscreteLegend.stories.js.map +1 -1
  45. package/dist/component/Legend/constants.js +1 -1
  46. package/dist/component/Legend/constants.js.map +1 -1
  47. package/dist/component/Legend/index.d.ts +3 -0
  48. package/dist/component/Legend/index.js +4 -0
  49. package/dist/component/Legend/index.js.map +1 -0
  50. package/dist/component/Utils/d3ColorScale.js +1 -1
  51. package/dist/component/Utils/d3ColorScale.js.map +1 -1
  52. package/dist/component/Utils/discreteLegend.d.ts +2 -3
  53. package/dist/component/Utils/discreteLegend.js.map +1 -1
  54. package/dist/component/Utils/index.d.ts +2 -0
  55. package/dist/component/Utils/index.js +4 -0
  56. package/dist/component/Utils/index.js.map +1 -0
  57. package/dist/component/Utils/legendCommonFunction.d.ts +7 -7
  58. package/dist/component/Utils/legendCommonFunction.js +128 -139
  59. package/dist/component/Utils/legendCommonFunction.js.map +1 -1
  60. package/dist/component/Utils/legendCommonFunction.stories.js +14 -25
  61. package/dist/component/Utils/legendCommonFunction.stories.js.map +1 -1
  62. package/dist/component/colorTableTypes.d.ts +10 -2
  63. package/dist/component/index.d.ts +8 -0
  64. package/dist/component/index.js +9 -0
  65. package/dist/component/index.js.map +1 -0
  66. package/dist/index.d.ts +1 -9
  67. package/dist/index.js +1 -8
  68. package/dist/index.js.map +1 -1
  69. package/dist/stories/ColorLegends/ContinousLegends/MD.stories.d.ts +7 -0
  70. package/dist/stories/ColorLegends/ContinousLegends/MD.stories.js +34 -0
  71. package/dist/stories/ColorLegends/ContinousLegends/MD.stories.js.map +1 -0
  72. package/dist/stories/ColorLegends/ContinousLegends/NTG.stories.d.ts +7 -0
  73. package/dist/stories/ColorLegends/ContinousLegends/NTG.stories.js +34 -0
  74. package/dist/stories/ColorLegends/ContinousLegends/NTG.stories.js.map +1 -0
  75. package/dist/stories/ColorLegends/ContinousLegends/PermTot.stories.d.ts +7 -0
  76. package/dist/stories/ColorLegends/ContinousLegends/PermTot.stories.js +34 -0
  77. package/dist/stories/ColorLegends/ContinousLegends/PermTot.stories.js.map +1 -0
  78. package/dist/stories/ColorLegends/ContinousLegends/Permeability.stories.d.ts +7 -0
  79. package/dist/stories/ColorLegends/ContinousLegends/Permeability.stories.js +36 -0
  80. package/dist/stories/ColorLegends/ContinousLegends/Permeability.stories.js.map +1 -0
  81. package/dist/stories/ColorLegends/ContinousLegends/PoroTot.stories.d.ts +7 -0
  82. package/dist/stories/ColorLegends/ContinousLegends/PoroTot.stories.js +34 -0
  83. package/dist/stories/ColorLegends/ContinousLegends/PoroTot.stories.js.map +1 -0
  84. package/dist/stories/ColorLegends/ContinousLegends/Porosity.stories.d.ts +7 -0
  85. package/dist/stories/ColorLegends/ContinousLegends/Porosity.stories.js +34 -0
  86. package/dist/stories/ColorLegends/ContinousLegends/Porosity.stories.js.map +1 -0
  87. package/dist/stories/ColorLegends/ContinousLegends/SW.stories.d.ts +7 -0
  88. package/dist/stories/ColorLegends/ContinousLegends/SW.stories.js +34 -0
  89. package/dist/stories/ColorLegends/ContinousLegends/SW.stories.js.map +1 -0
  90. package/dist/stories/ColorLegends/DiscreteLegends/FaciesNoCalcite.stories.d.ts +7 -0
  91. package/dist/stories/ColorLegends/DiscreteLegends/FaciesNoCalcite.stories.js +39 -0
  92. package/dist/stories/ColorLegends/DiscreteLegends/FaciesNoCalcite.stories.js.map +1 -0
  93. package/dist/stories/ColorLegends/DiscreteLegends/FaultDistanceHum.stories.d.ts +7 -0
  94. package/dist/stories/ColorLegends/DiscreteLegends/FaultDistanceHum.stories.js +31 -0
  95. package/dist/stories/ColorLegends/DiscreteLegends/FaultDistanceHum.stories.js.map +1 -0
  96. package/dist/stories/ColorLegends/DiscreteLegends/FaultProximityFlag.stories.d.ts +7 -0
  97. package/dist/stories/ColorLegends/DiscreteLegends/FaultProximityFlag.stories.js +31 -0
  98. package/dist/stories/ColorLegends/DiscreteLegends/FaultProximityFlag.stories.js.map +1 -0
  99. package/dist/stories/ColorLegends/DiscreteLegends/RDE.stories.d.ts +7 -0
  100. package/dist/stories/ColorLegends/DiscreteLegends/RDE.stories.js +34 -0
  101. package/dist/stories/ColorLegends/DiscreteLegends/RDE.stories.js.map +1 -0
  102. package/dist/stories/ColorLegends/DiscreteLegends/RDE_Orig.stories.d.ts +7 -0
  103. package/dist/stories/ColorLegends/DiscreteLegends/RDE_Orig.stories.js +45 -0
  104. package/dist/stories/ColorLegends/DiscreteLegends/RDE_Orig.stories.js.map +1 -0
  105. package/dist/stories/ColorLegends/DiscreteLegends/ZoneMain.stories.d.ts +7 -0
  106. package/dist/stories/ColorLegends/DiscreteLegends/ZoneMain.stories.js +34 -0
  107. package/dist/stories/ColorLegends/DiscreteLegends/ZoneMain.stories.js.map +1 -0
  108. package/dist/stories/ColorLegends/DiscreteLegends/Zonelog.stories.d.ts +7 -0
  109. package/dist/stories/ColorLegends/DiscreteLegends/Zonelog.stories.js +44 -0
  110. package/dist/stories/ColorLegends/DiscreteLegends/Zonelog.stories.js.map +1 -0
  111. package/dist/stories/ColorLegends/LegendWithSelector/LegendSelector.stories.d.ts +7 -0
  112. package/dist/stories/ColorLegends/LegendWithSelector/LegendSelector.stories.js +33 -0
  113. package/dist/stories/ColorLegends/LegendWithSelector/LegendSelector.stories.js.map +1 -0
  114. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ export * from "./d3ColorScale";
2
+ export * from "./legendCommonFunction";
@@ -0,0 +1,4 @@
1
+ export * from "./d3ColorScale";
2
+ export * from "./legendCommonFunction";
3
+ // discreteLegend is internal utility.
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/component/Utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AAEvC,sCAAsC"}
@@ -1,6 +1,6 @@
1
- import { colorTablesArray } from "../colorTableTypes";
1
+ import { ColorTableArray } from "../colorTableTypes";
2
2
  type Color = [number, number, number];
3
- export declare function colorsArray(colorName: string, iscolorTablesDefined: colorTablesArray | any): any;
3
+ export declare function colorsArray(colorName: string, iscolorTablesDefined: ColorTableArray | any): any;
4
4
  export declare function RGBToHex(rgb: number[], max?: number): {
5
5
  color: string;
6
6
  offset: number;
@@ -10,17 +10,17 @@ export declare function HextoRGB(hex: string): {
10
10
  g: number;
11
11
  b: number;
12
12
  };
13
- export declare function getRgbData(point: number, colorName: string, iscolorTablesDefined: colorTablesArray | any, isLog?: boolean, isNearest?: boolean, userBreakPoint?: any): number[] | {
13
+ export declare function getRgbData(point: number, colorName: string, iscolorTablesDefined: ColorTableArray | any, isLog?: boolean, isNearest?: boolean, userBreakPoint?: any): number[] | {
14
14
  r: number;
15
15
  g: number;
16
16
  b: number;
17
17
  opacity: number;
18
18
  } | undefined;
19
19
  export declare function getColors(colorName: string, iscolorTablesDefined: any, point: number): any;
20
- export declare function rgbValues(point: number, colorName: string, iscolorTablesDefined: colorTablesArray | any, isLog?: boolean, isNearest?: boolean, breakPoints?: any): Color;
21
- export declare function sampledColor(colorScaleName: string, point: number, categorial?: boolean, min?: number, max?: number, iscolorTablesDefined?: colorTablesArray | any, isLog?: boolean, isNearest?: boolean, breakPoints?: number[]): [number, number, number, number] | Color;
22
- export declare function createColorMapFunction(colorScaleName: string, isLog: boolean, isNearest: boolean, breakPoints: number[]): (x: number, categorial?: boolean, min?: number, max?: number, iscolorTablesDefined?: colorTablesArray | any) => [number, number, number, number] | Color;
23
- export declare function createContinuousLibraryColorScale(name: string, library?: colorTablesArray): (value: number) => Color;
20
+ export declare function rgbValues(point: number, colorName: string, iscolorTablesDefined: ColorTableArray | any, isLog?: boolean, isNearest?: boolean, breakPoints?: any): Color;
21
+ export declare function sampledColor(colorScaleName: string, point: number, categorial?: boolean, min?: number, max?: number, iscolorTablesDefined?: ColorTableArray | any, isLog?: boolean, isNearest?: boolean, breakPoints?: number[]): [number, number, number, number] | Color;
22
+ export declare function createColorMapFunction(colorScaleName: string, isLog: boolean, isNearest: boolean, breakPoints: number[]): (x: number, categorial?: boolean, min?: number, max?: number, iscolorTablesDefined?: ColorTableArray | any) => [number, number, number, number] | Color;
23
+ export declare function createContinuousLibraryColorScale(name: string, library?: ColorTableArray): (value: number) => Color;
24
24
  export declare function createDefaultContinuousColorScale(): (value: number) => Color;
25
25
  export declare const getColorArrayFromBreakPoints: (breakpoints: number[], arraySize?: number) => string[];
26
26
  export declare function getColorSelectorPosition(styles: any, isHorizontal: boolean, legendScaleSize: number): {
@@ -12,24 +12,22 @@ function getColor(rgb) {
12
12
  }
13
13
  // Based on objectName return the colors array from color.tables.json file
14
14
  export function colorsArray(colorName, iscolorTablesDefined) {
15
- var getColorTables = iscolorTablesDefined
15
+ const getColorTables = iscolorTablesDefined
16
16
  ? iscolorTablesDefined
17
17
  : colorTables;
18
- var colorTableData = getColorTables.filter(function (value) {
19
- return value.name.toLowerCase() === colorName.toLowerCase();
20
- });
18
+ const colorTableData = getColorTables.filter((value) => value.name.toLowerCase() === colorName.toLowerCase());
21
19
  return colorTableData.length > 0 ? colorTableData[0].colors : [];
22
20
  }
23
21
  // return the hex color code and offset
24
22
  export function RGBToHex(rgb, max) {
25
- var r = Math.round(rgb[1]).toString(16), g = Math.round(rgb[2]).toString(16), b = Math.round(rgb[3]).toString(16);
23
+ let r = Math.round(rgb[1]).toString(16), g = Math.round(rgb[2]).toString(16), b = Math.round(rgb[3]).toString(16);
26
24
  if (r.length === 1)
27
25
  r = "0" + r;
28
26
  if (g.length === 1)
29
27
  g = "0" + g;
30
28
  if (b.length === 1)
31
29
  b = "0" + b;
32
- var offset = max ? ((rgb[0] - 0) / (max - 0)) * 100.0 : rgb[0] * 100.0;
30
+ const offset = max ? ((rgb[0] - 0) / (max - 0)) * 100.0 : rgb[0] * 100.0;
33
31
  return { color: "#" + r + g + b, offset: offset };
34
32
  }
35
33
  export function HextoRGB(hex) {
@@ -44,38 +42,38 @@ export function HextoRGB(hex) {
44
42
  // return the colors based on the point
45
43
  export function getRgbData(point, colorName, iscolorTablesDefined, isLog, isNearest, userBreakPoint) {
46
44
  var _a, _b;
47
- var getColorTables = iscolorTablesDefined
45
+ const getColorTables = iscolorTablesDefined
48
46
  ? iscolorTablesDefined
49
47
  : colorTables;
50
48
  // get colortable colorscale data
51
- var getColorTableScale = getColorTables.find(function (value) {
49
+ const getColorTableScale = getColorTables.find((value) => {
52
50
  return value.name === colorName;
53
51
  });
54
52
  // get d3 colorscale data
55
- var getD3Scale = d3ColorScales.find(function (value) {
53
+ const getD3Scale = d3ColorScales.find(function (value) {
56
54
  return value.name === colorName;
57
55
  });
58
- var rgb;
56
+ let rgb;
59
57
  // condition for logarithmic values
60
58
  if (isLog) {
61
- var log = scaleSymlog().domain([0, 1]);
59
+ const log = scaleSymlog().domain([0, 1]);
62
60
  point = log(point);
63
61
  }
64
62
  // colortable discrete scale
65
63
  if ((getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.discrete) === true) {
66
- var getSelectedScaleLength = getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.colors.length;
67
- var minValue_1 = 0;
68
- var maxValue_1 = getSelectedScaleLength - 1;
69
- getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.colors.forEach(function (item, index) {
64
+ const getSelectedScaleLength = getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.colors.length;
65
+ const minValue = 0;
66
+ const maxValue = getSelectedScaleLength - 1;
67
+ getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.colors.forEach((item, index) => {
70
68
  var _a, _b, _c;
71
- var currentIndex = index;
72
- var normalizedCurrentIndex = (currentIndex - minValue_1) / (maxValue_1 - minValue_1);
73
- var nextIndex = index + 1;
74
- var normalizedNextIndex = (nextIndex - minValue_1) / (maxValue_1 - 0);
69
+ const currentIndex = index;
70
+ const normalizedCurrentIndex = (currentIndex - minValue) / (maxValue - minValue);
71
+ const nextIndex = index + 1;
72
+ const normalizedNextIndex = (nextIndex - minValue) / (maxValue - 0);
75
73
  //const t = (point - t0) / (t1 - t0); // t = 0.0 gives first color, t = 1.0 gives second color.
76
74
  if (point >= normalizedCurrentIndex && point <= normalizedNextIndex) {
77
75
  if ((item && (getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.colors[nextIndex])) !== undefined) {
78
- 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);
76
+ const 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);
79
77
  rgb = (_c = color(interpolate)) === null || _c === void 0 ? void 0 : _c.rgb();
80
78
  }
81
79
  }
@@ -83,43 +81,43 @@ export function getRgbData(point, colorName, iscolorTablesDefined, isLog, isNear
83
81
  return rgb;
84
82
  }
85
83
  else if (typeof (getD3Scale === null || getD3Scale === void 0 ? void 0 : getD3Scale.colors) == "function") {
86
- var colorMappingRange = getD3Scale === null || getD3Scale === void 0 ? void 0 : getD3Scale.colors(point);
84
+ const colorMappingRange = getD3Scale === null || getD3Scale === void 0 ? void 0 : getD3Scale.colors(point);
87
85
  return (rgb = getColor((_a = color(colorMappingRange)) === null || _a === void 0 ? void 0 : _a.rgb()));
88
86
  }
89
87
  else if (typeof (getD3Scale === null || getD3Scale === void 0 ? void 0 : getD3Scale.colors) == "object") {
90
- var max_1 = (getD3Scale === null || getD3Scale === void 0 ? void 0 : getD3Scale.colors.length) - 1;
91
- getD3Scale === null || getD3Scale === void 0 ? void 0 : getD3Scale.colors.forEach(function (item, index) {
88
+ const max = (getD3Scale === null || getD3Scale === void 0 ? void 0 : getD3Scale.colors.length) - 1;
89
+ getD3Scale === null || getD3Scale === void 0 ? void 0 : getD3Scale.colors.forEach((item, index) => {
92
90
  var _a;
93
- var currentIndex = index;
94
- var normalizedCurrentIndex = (currentIndex - 0) / (max_1 - 0);
95
- var nextIndex = index + 1;
96
- var normalizedNextIndex = (nextIndex - 0) / (max_1 - 0);
97
- var indexableD3Scale = getD3Scale;
91
+ const currentIndex = index;
92
+ const normalizedCurrentIndex = (currentIndex - 0) / (max - 0);
93
+ const nextIndex = index + 1;
94
+ const normalizedNextIndex = (nextIndex - 0) / (max - 0);
95
+ const indexableD3Scale = getD3Scale;
98
96
  //const t = (point - t0) / (t1 - t0); // t = 0.0 gives first color, t = 1.0 gives second color.
99
97
  if (point >= normalizedCurrentIndex && point <= normalizedNextIndex) {
100
- var interpolate = interpolateRgb(item, indexableD3Scale[nextIndex])(point);
98
+ const interpolate = interpolateRgb(item, indexableD3Scale[nextIndex])(point);
101
99
  rgb = getColor((_a = color(interpolate)) === null || _a === void 0 ? void 0 : _a.rgb());
102
100
  }
103
101
  });
104
102
  return rgb;
105
103
  }
106
104
  else {
107
- var colorTableColors_1 = colorsArray(colorName, getColorTables);
108
- var itemColor_1 = [];
105
+ let colorTableColors = colorsArray(colorName, getColorTables);
106
+ const itemColor = [];
109
107
  if ((userBreakPoint === null || userBreakPoint === void 0 ? void 0 : userBreakPoint.length) > 0) {
110
- userBreakPoint.forEach(function (value) {
111
- var rgbColor = HextoRGB(value.color);
112
- itemColor_1.push([value.position, rgbColor.r, rgbColor.g, rgbColor.b]);
108
+ userBreakPoint.forEach((value) => {
109
+ const rgbColor = HextoRGB(value.color);
110
+ itemColor.push([value.position, rgbColor.r, rgbColor.g, rgbColor.b]);
113
111
  });
114
- itemColor_1 === null || itemColor_1 === void 0 ? void 0 : itemColor_1.sort(function (a, b) {
112
+ itemColor === null || itemColor === void 0 ? void 0 : itemColor.sort((a, b) => {
115
113
  if (a[0] === b[0])
116
114
  return 0;
117
115
  return a[0] < b[0] ? -1 : 1;
118
116
  });
119
- colorTableColors_1 = itemColor_1;
117
+ colorTableColors = itemColor;
120
118
  }
121
119
  // compare the point and first value from colorTableColors
122
- var colorArrays = colorTableColors_1.find(function (value) {
120
+ const colorArrays = colorTableColors.find((value) => {
123
121
  return point === value[0];
124
122
  });
125
123
  // if point and value in color table matches then return particular colors
@@ -128,35 +126,35 @@ export function getRgbData(point, colorName, iscolorTablesDefined, isLog, isNear
128
126
  }
129
127
  // if no match then need to do interpolation
130
128
  else {
131
- var nearestColor_1 = [];
129
+ const nearestColor = [];
132
130
  if (isNearest) {
133
- colorTableColors_1.forEach(function (val, index) {
134
- if (colorTableColors_1[index + 1] &&
131
+ colorTableColors.forEach(function (val, index) {
132
+ if (colorTableColors[index + 1] &&
135
133
  point > val[0] &&
136
- point < colorTableColors_1[index + 1][0]) {
137
- var middle = (val[0] + colorTableColors_1[index + 1][0]) / 2;
134
+ point < colorTableColors[index + 1][0]) {
135
+ const middle = (val[0] + colorTableColors[index + 1][0]) / 2;
138
136
  if (point < middle) {
139
- nearestColor_1.push(val[1], val[2], val[3]);
137
+ nearestColor.push(val[1], val[2], val[3]);
140
138
  }
141
139
  else {
142
- nearestColor_1.push(colorTableColors_1[index + 1][1], colorTableColors_1[index + 1][2], colorTableColors_1[index + 1][3]);
140
+ nearestColor.push(colorTableColors[index + 1][1], colorTableColors[index + 1][2], colorTableColors[index + 1][3]);
143
141
  }
144
142
  }
145
143
  });
146
- return nearestColor_1;
144
+ return nearestColor;
147
145
  }
148
146
  else {
149
147
  // Get index of first match of colortable point greater than point
150
- var index = colorTableColors_1.findIndex(function (value) {
148
+ const index = colorTableColors.findIndex((value) => {
151
149
  return value[0] > point;
152
150
  });
153
- var firstColorArray = colorTableColors_1[index - 1];
154
- var secondColorArray = colorTableColors_1[index];
151
+ const firstColorArray = colorTableColors[index - 1];
152
+ const secondColorArray = colorTableColors[index];
155
153
  if (firstColorArray && secondColorArray) {
156
- var t0 = firstColorArray[0];
157
- var t1 = secondColorArray[0];
158
- var t = (point - t0) / (t1 - t0); // t = 0.0 gives first color, t = 1.0 gives second color.
159
- var interpolatedValues = interpolateRgb(RGBToHex(firstColorArray).color, RGBToHex(secondColorArray).color)(t);
154
+ const t0 = firstColorArray[0];
155
+ const t1 = secondColorArray[0];
156
+ const t = (point - t0) / (t1 - t0); // t = 0.0 gives first color, t = 1.0 gives second color.
157
+ const interpolatedValues = interpolateRgb(RGBToHex(firstColorArray).color, RGBToHex(secondColorArray).color)(t);
160
158
  return (_b = color(interpolatedValues)) === null || _b === void 0 ? void 0 : _b.rgb();
161
159
  }
162
160
  }
@@ -166,13 +164,11 @@ export function getRgbData(point, colorName, iscolorTablesDefined, isLog, isNear
166
164
  }
167
165
  export function getColors(colorName, iscolorTablesDefined, point) {
168
166
  var _a;
169
- var getColorTables = iscolorTablesDefined
167
+ const getColorTables = iscolorTablesDefined
170
168
  ? iscolorTablesDefined
171
169
  : colorTables;
172
- var colorTableData = getColorTables.filter(function (value) {
173
- return value.name.toLowerCase() === colorName.toLowerCase();
174
- });
175
- var colorArrays = (_a = colorTableData[0]) === null || _a === void 0 ? void 0 : _a.colors.find(function (value) {
170
+ const colorTableData = getColorTables.filter((value) => value.name.toLowerCase() === colorName.toLowerCase());
171
+ const colorArrays = (_a = colorTableData[0]) === null || _a === void 0 ? void 0 : _a.colors.find((value) => {
176
172
  return value[0] === point;
177
173
  });
178
174
  return colorTableData.length > 0 ? colorArrays : [];
@@ -182,22 +178,22 @@ export function rgbValues(point, colorName, iscolorTablesDefined, isLog, isNeare
182
178
  var _a;
183
179
  // condition for logarithmic values
184
180
  if (isLog) {
185
- var log = scaleSymlog().domain([0, 1]);
181
+ const log = scaleSymlog().domain([0, 1]);
186
182
  point = log(point);
187
183
  }
188
184
  // check if the user has his own colortables else use default one
189
- var getColorTables = iscolorTablesDefined
185
+ const getColorTables = iscolorTablesDefined
190
186
  ? iscolorTablesDefined
191
187
  : colorTables;
192
188
  // get the colors from the colortable for matching colorname
193
- var colorTableColors = colorsArray(colorName, getColorTables);
194
- var itemColor = [];
189
+ let colorTableColors = colorsArray(colorName, getColorTables);
190
+ const itemColor = [];
195
191
  if ((breakPoints === null || breakPoints === void 0 ? void 0 : breakPoints.length) > 0) {
196
- breakPoints.forEach(function (value) {
197
- var rgbColor = HextoRGB(value.color);
192
+ breakPoints.forEach((value) => {
193
+ const rgbColor = HextoRGB(value.color);
198
194
  itemColor.push([value.position, rgbColor.r, rgbColor.g, rgbColor.b]);
199
195
  });
200
- itemColor === null || itemColor === void 0 ? void 0 : itemColor.sort(function (a, b) {
196
+ itemColor === null || itemColor === void 0 ? void 0 : itemColor.sort((a, b) => {
201
197
  if (a[0] === b[0])
202
198
  return 0;
203
199
  return a[0] < b[0] ? -1 : 1;
@@ -205,7 +201,7 @@ export function rgbValues(point, colorName, iscolorTablesDefined, isLog, isNeare
205
201
  colorTableColors = itemColor;
206
202
  }
207
203
  // compare the point and first value from colorTableColors
208
- var colorArrays = colorTableColors.find(function (value) {
204
+ const colorArrays = colorTableColors.find((value) => {
209
205
  return point === value[0];
210
206
  });
211
207
  // if point and value in color table matches then return particular colors
@@ -233,17 +229,17 @@ export function rgbValues(point, colorName, iscolorTablesDefined, isLog, isNeare
233
229
  }
234
230
  else {
235
231
  // Get index of first match of colortable point greater than point
236
- var index = colorTableColors.findIndex(function (value) {
232
+ const index = colorTableColors.findIndex((value) => {
237
233
  return value[0] > point;
238
234
  });
239
- var firstColorArray = colorTableColors[index - 1];
240
- var secondColorArray = colorTableColors[index];
235
+ const firstColorArray = colorTableColors[index - 1];
236
+ const secondColorArray = colorTableColors[index];
241
237
  if (firstColorArray && secondColorArray) {
242
- var t0 = firstColorArray[0];
243
- var t1 = secondColorArray[0];
244
- var t = (point - t0) / (t1 - t0); // t = 0.0 gives first color, t = 1.0 gives second color.
245
- var interpolatedValues = interpolateRgb(RGBToHex(firstColorArray).color, RGBToHex(secondColorArray).color)(t);
246
- var c = (_a = color(interpolatedValues)) === null || _a === void 0 ? void 0 : _a.rgb();
238
+ const t0 = firstColorArray[0];
239
+ const t1 = secondColorArray[0];
240
+ const t = (point - t0) / (t1 - t0); // t = 0.0 gives first color, t = 1.0 gives second color.
241
+ const interpolatedValues = interpolateRgb(RGBToHex(firstColorArray).color, RGBToHex(secondColorArray).color)(t);
242
+ const c = (_a = color(interpolatedValues)) === null || _a === void 0 ? void 0 : _a.rgb();
247
243
  return getColor(c);
248
244
  }
249
245
  return undefined;
@@ -252,32 +248,32 @@ export function rgbValues(point, colorName, iscolorTablesDefined, isLog, isNeare
252
248
  }
253
249
  export function sampledColor(colorScaleName, point, categorial, min, max, iscolorTablesDefined, isLog, isNearest, breakPoints) {
254
250
  var _a, _b;
255
- var getColorTables = iscolorTablesDefined
251
+ const getColorTables = iscolorTablesDefined
256
252
  ? iscolorTablesDefined
257
253
  : colorTables;
258
254
  // get colortable colorscale data
259
- var getColorTableScale = getColorTables.find(function (value) {
255
+ const getColorTableScale = getColorTables.find((value) => {
260
256
  return value.name === colorScaleName;
261
257
  });
262
258
  // get d3 colorscale data
263
- var getD3Scale = d3ColorScales.find(function (value) {
259
+ const getD3Scale = d3ColorScales.find((value) => {
264
260
  return value.name === colorScaleName;
265
261
  });
266
262
  // condition for logarithmic values
267
263
  if (isLog) {
268
- var log = scaleSymlog().domain([0, 1]);
264
+ const log = scaleSymlog().domain([0, 1]);
269
265
  point = log(point);
270
266
  }
271
267
  // return the color for matched point
272
268
  // does interpolation for non-matching point
273
- var rgb = rgbValues(point, colorScaleName, getColorTables, isLog, isNearest, breakPoints);
269
+ let rgb = rgbValues(point, colorScaleName, getColorTables, isLog, isNearest, breakPoints);
274
270
  // colortable continuous scale
275
271
  if ((getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.discrete) === false) {
276
272
  // if log is discrete, then need to normalize
277
273
  if (categorial) {
278
274
  // condition added to resolve typescript error
279
275
  //if (min && max) {
280
- var normalizedPoint = (point - min) / (max - min);
276
+ const normalizedPoint = (point - min) / (max - min);
281
277
  rgb = rgbValues(normalizedPoint, colorScaleName, getColorTables, isLog, isNearest);
282
278
  //}
283
279
  }
@@ -287,10 +283,10 @@ export function sampledColor(colorScaleName, point, categorial, min, max, iscolo
287
283
  }
288
284
  // d3 continuous scale
289
285
  if (typeof (getD3Scale === null || getD3Scale === void 0 ? void 0 : getD3Scale.colors) == "function") {
290
- var colorMappingRange = getD3Scale === null || getD3Scale === void 0 ? void 0 : getD3Scale.colors(point);
286
+ let colorMappingRange = getD3Scale === null || getD3Scale === void 0 ? void 0 : getD3Scale.colors(point);
291
287
  // if log is discrete, then need to normalize
292
288
  if (categorial) {
293
- var normalizedPoint = (point - min) / (max - min);
289
+ const normalizedPoint = (point - min) / (max - min);
294
290
  colorMappingRange = getD3Scale === null || getD3Scale === void 0 ? void 0 : getD3Scale.colors(normalizedPoint);
295
291
  }
296
292
  rgb = getColor((_a = color(colorMappingRange)) === null || _a === void 0 ? void 0 : _a.rgb());
@@ -299,26 +295,26 @@ export function sampledColor(colorScaleName, point, categorial, min, max, iscolo
299
295
  if ((getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.discrete) === true) {
300
296
  if (categorial) {
301
297
  // compare the code and first value from colorsArray(colortable)
302
- var arrayOfColors = colorsArray(colorScaleName, getColorTables);
303
- var colorArrays = arrayOfColors.find(function (value) {
298
+ const arrayOfColors = colorsArray(colorScaleName, getColorTables);
299
+ const colorArrays = arrayOfColors.find((value) => {
304
300
  return value[0] === point;
305
301
  });
306
302
  return colorArrays;
307
303
  }
308
304
  else {
309
- var getSelectedScaleLength = getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.colors.length;
310
- var minValue_2 = 0;
311
- var maxValue_2 = getSelectedScaleLength - 1;
312
- getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.colors.forEach(function (item, index) {
305
+ const getSelectedScaleLength = getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.colors.length;
306
+ const minValue = 0;
307
+ const maxValue = getSelectedScaleLength - 1;
308
+ getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.colors.forEach((item, index) => {
313
309
  var _a, _b, _c;
314
- var currentIndex = index;
315
- var normalizedCurrentIndex = (currentIndex - minValue_2) / (maxValue_2 - minValue_2);
316
- var nextIndex = index + 1;
317
- var normalizedNextIndex = (nextIndex - minValue_2) / (maxValue_2 - 0);
310
+ const currentIndex = index;
311
+ const normalizedCurrentIndex = (currentIndex - minValue) / (maxValue - minValue);
312
+ const nextIndex = index + 1;
313
+ const normalizedNextIndex = (nextIndex - minValue) / (maxValue - 0);
318
314
  //const t = (point - t0) / (t1 - t0); // t = 0.0 gives first color, t = 1.0 gives second color.
319
315
  if (point >= normalizedCurrentIndex && point <= normalizedNextIndex) {
320
316
  if ((item && (getColorTableScale === null || getColorTableScale === void 0 ? void 0 : getColorTableScale.colors[nextIndex])) !== undefined) {
321
- 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);
317
+ const 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);
322
318
  rgb = getColor((_c = color(interpolate)) === null || _c === void 0 ? void 0 : _c.rgb());
323
319
  }
324
320
  }
@@ -330,25 +326,25 @@ export function sampledColor(colorScaleName, point, categorial, min, max, iscolo
330
326
  // discrete log
331
327
  if (categorial) {
332
328
  // const normalizedPoint = (point - min) / (max - min);
333
- var code_1 = point;
334
- var d3ColorArrays = getD3Scale === null || getD3Scale === void 0 ? void 0 : getD3Scale.colors.find(function (_value, index) {
335
- return index === code_1;
329
+ const code = point;
330
+ const d3ColorArrays = getD3Scale === null || getD3Scale === void 0 ? void 0 : getD3Scale.colors.find((_value, index) => {
331
+ return index === code;
336
332
  });
337
333
  rgb = getColor((_b = color(d3ColorArrays)) === null || _b === void 0 ? void 0 : _b.rgb());
338
334
  }
339
335
  // continous log
340
336
  else {
341
- var max_2 = (getD3Scale === null || getD3Scale === void 0 ? void 0 : getD3Scale.colors.length) - 1;
342
- getD3Scale === null || getD3Scale === void 0 ? void 0 : getD3Scale.colors.forEach(function (item, index) {
337
+ const max = (getD3Scale === null || getD3Scale === void 0 ? void 0 : getD3Scale.colors.length) - 1;
338
+ getD3Scale === null || getD3Scale === void 0 ? void 0 : getD3Scale.colors.forEach((item, index) => {
343
339
  var _a;
344
- var currentIndex = index;
345
- var normalizedCurrentIndex = (currentIndex - 0) / (max_2 - 0);
346
- var nextIndex = index + 1;
347
- var normalizedNextIndex = (nextIndex - 0) / (max_2 - 0);
348
- var indexableD3Scale = getD3Scale;
340
+ const currentIndex = index;
341
+ const normalizedCurrentIndex = (currentIndex - 0) / (max - 0);
342
+ const nextIndex = index + 1;
343
+ const normalizedNextIndex = (nextIndex - 0) / (max - 0);
344
+ const indexableD3Scale = getD3Scale;
349
345
  //const t = (point - t0) / (t1 - t0); // t = 0.0 gives first color, t = 1.0 gives second color.
350
346
  if (point >= normalizedCurrentIndex && point <= normalizedNextIndex) {
351
- var interpolate = interpolateRgb(item, indexableD3Scale[nextIndex])(point);
347
+ const interpolate = interpolateRgb(item, indexableD3Scale[nextIndex])(point);
352
348
  rgb = getColor((_a = color(interpolate)) === null || _a === void 0 ? void 0 : _a.rgb());
353
349
  }
354
350
  });
@@ -357,32 +353,26 @@ export function sampledColor(colorScaleName, point, categorial, min, max, iscolo
357
353
  return rgb;
358
354
  }
359
355
  export function createColorMapFunction(colorScaleName, isLog, isNearest, breakPoints) {
360
- return function (x, categorial, min, max, iscolorTablesDefined) {
361
- if (categorial === void 0) { categorial = false; }
362
- if (min === void 0) { min = 0; }
363
- if (max === void 0) { max = 1; }
364
- if (iscolorTablesDefined === void 0) { iscolorTablesDefined = colorTables; }
356
+ return (x, categorial = false, min = 0, max = 1, iscolorTablesDefined = colorTables) => {
365
357
  return sampledColor(colorScaleName, x, categorial, min, max, iscolorTablesDefined, isLog, isNearest, breakPoints);
366
358
  };
367
359
  }
368
- export function createContinuousLibraryColorScale(name, library) {
369
- if (library === void 0) { library = colorTables; }
370
- return function (value) {
360
+ export function createContinuousLibraryColorScale(name, library = colorTables) {
361
+ return (value) => {
371
362
  return rgbValues(value, name, library);
372
363
  };
373
364
  }
374
365
  export function createDefaultContinuousColorScale() {
375
366
  return createContinuousLibraryColorScale("Rainbow");
376
367
  }
377
- export var getColorArrayFromBreakPoints = function (breakpoints, arraySize) {
378
- if (arraySize === void 0) { arraySize = 512; }
368
+ export const getColorArrayFromBreakPoints = (breakpoints, arraySize = 512) => {
379
369
  if (breakpoints.length === 0) {
380
370
  throw new Error("Couldn't provide color supplier from empty color array");
381
371
  }
382
- var colors = breakpoints.map(function (item) { return item.color; });
383
- var ratios = breakpoints.map(function (item) { return item.position; });
384
- var position = 0;
385
- return range(0, arraySize).map(function (i) {
372
+ const colors = breakpoints.map((item) => item.color);
373
+ const ratios = breakpoints.map((item) => item.position);
374
+ let position = 0;
375
+ return range(0, arraySize).map((i) => {
386
376
  var _a;
387
377
  if (ratios[position] < i / (arraySize - 1)) {
388
378
  position++;
@@ -393,19 +383,18 @@ export var getColorArrayFromBreakPoints = function (breakpoints, arraySize) {
393
383
  if (position === ratios.length) {
394
384
  return colors[colors.length - 1];
395
385
  }
396
- var color = d3.interpolateRgb(colors[position - 1], colors[position]);
386
+ const color = d3.interpolateRgb(colors[position - 1], colors[position]);
397
387
  return (_a = d3
398
388
  .color(color((i / arraySize - ratios[position - 1]) /
399
389
  (ratios[position] - ratios[position - 1])))) === null || _a === void 0 ? void 0 : _a.formatHex();
400
390
  });
401
391
  };
402
- export function getColorSelectorPosition(styles, isHorizontal, legendScaleSize) {
403
- if (styles === void 0) { styles = { top: "0vh", left: "0vw" }; }
392
+ export function getColorSelectorPosition(styles = { top: "0vh", left: "0vw" }, isHorizontal, legendScaleSize) {
404
393
  // when horizontal, the legend dimentions are: width = legendWidth & height = 80px
405
394
  // when vertical, the legend dimentions are: height = legendWidth & width = 80px
406
- var legendWidth = isHorizontal ? legendScaleSize + "px" : "100px";
407
- var legendHeight = isHorizontal ? "100px" : legendScaleSize + "px";
408
- var accordionPosition = { left: "", top: "", right: "", bottom: "" };
395
+ const legendWidth = isHorizontal ? legendScaleSize + "px" : "100px";
396
+ const legendHeight = isHorizontal ? "100px" : legendScaleSize + "px";
397
+ const accordionPosition = { left: "", top: "", right: "", bottom: "" };
409
398
  // when any of the styles positions is zero, convert to string so that it can pass the conditions afteron
410
399
  styles.left = styles.left == 0 ? "0px" : styles.left;
411
400
  styles.right = styles.right == 0 ? "0px" : styles.right;
@@ -415,37 +404,37 @@ export function getColorSelectorPosition(styles, isHorizontal, legendScaleSize)
415
404
  if (styles.left && styles.top) {
416
405
  accordionPosition.left = isHorizontal
417
406
  ? styles.left
418
- : "calc(".concat(styles.left, " + ").concat(legendWidth, ")");
407
+ : `calc(${styles.left} + ${legendWidth})`;
419
408
  accordionPosition.top = isHorizontal
420
- ? "calc(".concat(styles.top, " + ").concat(legendHeight, ")")
409
+ ? `calc(${styles.top} + ${legendHeight})`
421
410
  : styles.top;
422
411
  }
423
412
  else if (styles.left && styles.bottom) {
424
413
  /* When legend is close to bottom-left corner */
425
414
  accordionPosition.left = isHorizontal
426
415
  ? styles.left
427
- : "calc(".concat(styles.left, " + ").concat(legendWidth, ")");
416
+ : `calc(${styles.left} + ${legendWidth})`;
428
417
  accordionPosition.bottom = isHorizontal
429
- ? "calc(".concat(styles.bottom, " + ").concat(legendHeight, ")")
418
+ ? `calc(${styles.bottom} + ${legendHeight})`
430
419
  : styles.bottom;
431
420
  }
432
421
  else if (styles.top && styles.right) {
433
422
  /* When the legend is close to the top-right corner */
434
423
  accordionPosition.right = isHorizontal
435
424
  ? styles.right
436
- : "calc(".concat(styles.right, " + ").concat(legendWidth, ")");
425
+ : `calc(${styles.right} + ${legendWidth})`;
437
426
  accordionPosition.top = isHorizontal
438
- ? "calc(".concat(styles.top, " + ").concat(legendHeight, ")")
427
+ ? `calc(${styles.top} + ${legendHeight})`
439
428
  : styles.top;
440
429
  }
441
430
  else if (styles.bottom && styles.right) {
442
431
  /* When the legend is close to the bottom-right corner */
443
432
  accordionPosition.bottom = isHorizontal
444
- ? "calc(".concat(styles.bottom, " + ").concat(legendHeight, ")")
433
+ ? `calc(${styles.bottom} + ${legendHeight})`
445
434
  : styles.bottom;
446
435
  accordionPosition.right = isHorizontal
447
436
  ? styles.right
448
- : "calc(".concat(styles.right, " + ").concat(legendWidth, ")");
437
+ : `calc(${styles.right} + ${legendWidth})`;
449
438
  }
450
439
  else if (
451
440
  /* Set a default */
@@ -457,9 +446,9 @@ export function getColorSelectorPosition(styles, isHorizontal, legendScaleSize)
457
446
  styles.top = "0px";
458
447
  accordionPosition.left = isHorizontal
459
448
  ? styles.left
460
- : "calc(".concat(styles.left, " + ").concat(legendWidth, ")");
449
+ : `calc(${styles.left} + ${legendWidth})`;
461
450
  accordionPosition.top = isHorizontal
462
- ? "calc(".concat(styles.top, " + ").concat(legendHeight, ")")
451
+ ? `calc(${styles.top} + ${legendHeight})`
463
452
  : styles.top;
464
453
  }
465
454
  return accordionPosition;
@@ -472,13 +461,13 @@ export function getTickValues(range, numberOfTicks) {
472
461
  if (numberOfTicks < 1 || !numberOfTicks) {
473
462
  return [];
474
463
  }
475
- var min = range[0];
476
- var max = range[1];
464
+ const min = range[0];
465
+ const max = range[1];
477
466
  numberOfTicks = Math.floor(numberOfTicks);
478
- var step = (max - min) / (numberOfTicks + 1);
479
- var ticksArray = [];
480
- for (var i = 1; i <= numberOfTicks; i++) {
481
- var currentTickValue = step * i + min;
467
+ const step = (max - min) / (numberOfTicks + 1);
468
+ const ticksArray = [];
469
+ for (let i = 1; i <= numberOfTicks; i++) {
470
+ let currentTickValue = step * i + min;
482
471
  currentTickValue = Math.round(currentTickValue * 100) / 100;
483
472
  ticksArray.push(currentTickValue);
484
473
  }