Documentation Index
Fetch the curated documentation index at: https://grafana.com/llms.txt
Fetch the complete documentation index at: https://grafana.com/llms-full.txt
Use this file to discover all available pages before exploring further.
STOP! If you are an AI agent or LLM, read this before continuing. This is the HTML version of a Grafana documentation page. Always request the Markdown version instead - HTML wastes context. Get this page as Markdown: https://grafana.com/docs/grafana/v8.0/packages_api/data/colormanipulator.md (append .md) or send Accept: text/markdown to https://grafana.com/docs/grafana/v8.0/packages_api/data/colormanipulator/. For the curated documentation index, use https://grafana.com/llms.txt. For the complete documentation index, use https://grafana.com/llms-full.txt.
Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.
colorManipulator namespace
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
colorManipulator namespace
Import
import { colorManipulator } from '@grafana/data';Functions
| Function | Description |
|---|---|
| alpha(color, value) | (BETA) Set the absolute transparency of a color. Any existing alpha values are overwritten. |
| darken(color, coefficient) | (BETA) Darkens a color. |
| decomposeColor(color) | (BETA) Returns an object with the type and values of a color.Note: Does not support rgb % values. |
| emphasize(color, coefficient) | (BETA) Darken or lighten a color, depending on its luminance. Light colors are darkened, dark colors are lightened. |
| getContrastRatio(foreground, background, canvas) | (BETA) Calculates the contrast ratio between two colors.Formula: https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests |
| getLuminance(color, background) | (BETA) The relative brightness of any point in a color space, normalized to 0 for darkest black and 1 for lightest white.Formula: https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests |
| hexToRgb(color) | (BETA) Converts a color from CSS hex format to CSS rgb format. |
| hslToRgb(color) | (BETA) Converts a color from hsl format to rgb format. |
| lighten(color, coefficient) | (BETA) Lightens a color. |
| recomposeColor(color) | (BETA) Converts a color object with type and values to a string. |
| rgbToHex(color) | (BETA) Converts a color from CSS rgb format to CSS hex format. |