diff --git a/app/assets/javascripts/lib/utils/color_utils.js b/app/assets/javascripts/lib/utils/color_utils.js index 3d8df4fde0589591349c20427c161efe9943585f..a9f4257e28bf8cab315155a2d4769172d17487d3 100644 --- a/app/assets/javascripts/lib/utils/color_utils.js +++ b/app/assets/javascripts/lib/utils/color_utils.js @@ -8,7 +8,7 @@ const colorValidatorEl = document.createElement('div'); * element’s color property. If the color expression is valid, * the DOM API will accept the value. * - * @param {String} color color expression rgba, hex, hsla, etc. + * @param {String} colorExpression color expression rgba, hex, hsla, etc. */ export const isValidColorExpression = (colorExpression) => { colorValidatorEl.style.color = ''; @@ -17,32 +17,6 @@ export const isValidColorExpression = (colorExpression) => { return colorValidatorEl.style.color.length > 0; }; -/** - * Convert hex color to rgb array - * - * @param hex string - * @returns array|null - */ -export const hexToRgb = (hex) => { - // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") - const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i; - const fullHex = hex.replace(shorthandRegex, (_m, r, g, b) => r + r + g + g + b + b); - - const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(fullHex); - return result - ? [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)] - : null; -}; - -export const textColorForBackground = (backgroundColor) => { - const [r, g, b] = hexToRgb(backgroundColor); - - if (r + g + b > 500) { - return '#333333'; - } - return '#FFFFFF'; -}; - /** * Check whether a color matches the expected hex format * diff --git a/app/assets/javascripts/monitoring/components/charts/anomaly.vue b/app/assets/javascripts/monitoring/components/charts/anomaly.vue index a995497ab9c7e393e0fab3abcac667540308e6e4..b6eb1a23f87bccdc79c06e21e12e5922b83a3296 100644 --- a/app/assets/javascripts/monitoring/components/charts/anomaly.vue +++ b/app/assets/javascripts/monitoring/components/charts/anomaly.vue @@ -1,8 +1,9 @@