@emerson-eps/color-tables
Advanced tools
Comparing version 0.2.35 to 0.2.36
@@ -18,3 +18,3 @@ import * as React from "react"; | ||
}, [isOpen]); | ||
var _c = React.useState([]), updateLegend = _c[0], setUpdateLegendColor = _c[1]; | ||
var _c = React.useState([]), getColorScaleData = _c[0], setGetColorScaleData = _c[1]; | ||
var isColortableColors = colorTables.find(function (value) { | ||
@@ -38,3 +38,3 @@ return (value === null || value === void 0 ? void 0 : value.name) == colorName; | ||
} | ||
setUpdateLegendColor(data); | ||
setGetColorScaleData(data); | ||
setIsCont(value); | ||
@@ -44,6 +44,6 @@ }, []); | ||
React.createElement("div", { ref: divRef, onClick: toggleColorSelector }, | ||
isCont == true && (React.createElement(ContinuousLegend, { min: min, max: max, dataObjectName: dataObjectName, position: position, colorName: colorName, horizontal: horizontal, updateLegend: updateLegend, id: generateUniqueId, colorTables: colorTables })), | ||
isCont == false && (React.createElement(DiscreteColorLegend, { discreteData: discreteData, dataObjectName: dataObjectName, position: position, colorName: colorName, horizontal: horizontal, updateLegend: updateLegend, id: generateUniqueId, colorTables: colorTables }))), | ||
isCont == true && (React.createElement(ContinuousLegend, { min: min, max: max, dataObjectName: dataObjectName, position: position, colorName: colorName, horizontal: horizontal, getColorScaleData: getColorScaleData, id: generateUniqueId, colorTables: colorTables })), | ||
isCont == false && (React.createElement(DiscreteColorLegend, { discreteData: discreteData, dataObjectName: dataObjectName, position: position, colorName: colorName, horizontal: horizontal, getColorScaleData: getColorScaleData, id: generateUniqueId, colorTables: colorTables }))), | ||
React.createElement("div", null, isOpen && (React.createElement(ColorSelectorAccordion, { newColorScaleData: getSelectedColorScale, isHorizontal: horizontal, colorTables: colorTables }))))); | ||
}; | ||
//# sourceMappingURL=ColorLegend.js.map |
@@ -10,3 +10,3 @@ import * as React from "react"; | ||
horizontal?: boolean | null; | ||
updateLegend?: any; | ||
getColorScaleData?: any; | ||
id?: string; | ||
@@ -13,0 +13,0 @@ colorTables: colorTablesArray; |
@@ -45,3 +45,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
export var ContinuousLegend = function (_a) { | ||
var min = _a.min, max = _a.max, dataObjectName = _a.dataObjectName, position = _a.position, colorName = _a.colorName, horizontal = _a.horizontal, updateLegend = _a.updateLegend, id = _a.id, colorTables = _a.colorTables; | ||
var min = _a.min, max = _a.max, dataObjectName = _a.dataObjectName, position = _a.position, colorName = _a.colorName, horizontal = _a.horizontal, getColorScaleData = _a.getColorScaleData, id = _a.id, colorTables = _a.colorTables; | ||
var generateUniqueId = Math.ceil((Math.random() * 9999)).toString(); | ||
@@ -58,3 +58,3 @@ var divRef = useRef(null); | ||
}; | ||
}, [min, max, colorName, colorTables, horizontal, updateLegend]); | ||
}, [min, max, colorName, colorTables, horizontal, getColorScaleData]); | ||
function continuousLegend() { | ||
@@ -85,10 +85,10 @@ return __awaiter(this, void 0, void 0, function () { | ||
// data is passed on click upon color scales | ||
if (updateLegend && Object.keys(updateLegend).length > 0) { | ||
if (getColorScaleData && Object.keys(getColorScaleData).length > 0) { | ||
// legend using color table data | ||
if (updateLegend.color) { | ||
legendColors = updateLegend.color; | ||
if (getColorScaleData.color) { | ||
legendColors = getColorScaleData.color; | ||
} | ||
// legend using d3 data | ||
else if (updateLegend.arrayData) { | ||
legendColors = updateLegend.arrayData; | ||
else if (getColorScaleData.arrayData) { | ||
legendColors = getColorScaleData.arrayData; | ||
} | ||
@@ -112,3 +112,8 @@ } | ||
getColorTableScale_1 = colorTables.find(function (value) { | ||
return value.name == colorName; | ||
if (getColorScaleData) { | ||
return value.name == (getColorScaleData === null || getColorScaleData === void 0 ? void 0 : getColorScaleData.name); | ||
} | ||
else { | ||
return value.name == colorName; | ||
} | ||
}); | ||
@@ -115,0 +120,0 @@ maxValue_1 = legendColors.length - 1; |
@@ -11,3 +11,3 @@ import * as React from "react"; | ||
horizontal?: boolean | null; | ||
updateLegend?: any; | ||
getColorScaleData?: any; | ||
id?: string; | ||
@@ -14,0 +14,0 @@ colorTables: colorTablesArray | string; |
@@ -44,3 +44,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
export var DiscreteColorLegend = function (_a) { | ||
var discreteData = _a.discreteData, dataObjectName = _a.dataObjectName, position = _a.position, colorName = _a.colorName, horizontal = _a.horizontal, updateLegend = _a.updateLegend, id = _a.id, colorTables = _a.colorTables; | ||
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; | ||
var generateUniqueId = Math.ceil((Math.random() * 9999)).toString(); | ||
@@ -60,3 +60,3 @@ var divRef = useRef(null); | ||
}; | ||
}, [discreteData, colorName, colorTables, horizontal, updateLegend]); | ||
}, [discreteData, colorName, colorTables, horizontal, getColorScaleData]); | ||
function discreteLegend() { | ||
@@ -86,3 +86,3 @@ return __awaiter(this, void 0, void 0, function () { | ||
// Main discrete legend | ||
if (!updateLegend || updateLegend.length == 0) { | ||
if (!getColorScaleData || getColorScaleData.length == 0) { | ||
Object.keys(discreteData).forEach(function (key) { | ||
@@ -116,4 +116,4 @@ //eslint-disable-next-line | ||
// Discrete legend using Colortable colors | ||
else if (updateLegend === null || updateLegend === void 0 ? void 0 : updateLegend.color) { | ||
updateLegend.color.forEach(function (key) { | ||
else if (getColorScaleData === null || getColorScaleData === void 0 ? void 0 : getColorScaleData.color) { | ||
getColorScaleData.color.forEach(function (key) { | ||
itemColor.push({ color: RGBToHex(key) }); | ||
@@ -124,7 +124,7 @@ }); | ||
// Discrete legend using d3 colors | ||
else if (updateLegend === null || updateLegend === void 0 ? void 0 : updateLegend.colorsObject) { | ||
updateLegend.colorsObject.forEach(function (key) { | ||
else if (getColorScaleData === null || getColorScaleData === void 0 ? void 0 : getColorScaleData.colorsObject) { | ||
getColorScaleData.colorsObject.forEach(function (key) { | ||
itemColor.push({ color: key }); | ||
}); | ||
itemName = updateLegend.legendColorName; | ||
itemName = getColorScaleData.legendColorName; | ||
useSelectorLegend = true; | ||
@@ -162,8 +162,8 @@ } | ||
// calculate width for legend using colortable colors | ||
if (updateLegend === null || updateLegend === void 0 ? void 0 : updateLegend.color) { | ||
totalRect = updateLegend.color.length; | ||
if (getColorScaleData === null || getColorScaleData === void 0 ? void 0 : getColorScaleData.color) { | ||
totalRect = getColorScaleData.color.length; | ||
} | ||
// calculate width for legend using d3 colors | ||
else { | ||
totalRect = updateLegend.colorsObject.length; | ||
totalRect = getColorScaleData.colorsObject.length; | ||
} | ||
@@ -170,0 +170,0 @@ } |
{ | ||
"name": "@emerson-eps/color-tables", | ||
"version": "0.2.35", | ||
"version": "0.2.36", | ||
"description": "Standard library of color tables for geological domain", | ||
@@ -5,0 +5,0 @@ "release": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
116487
1559