# Changing Radial Gauge Label Colors Conditionally

## Environment

<table>
	<tr>
		<td>Product</td>
		<td>Progress® Kendo UI® for Angular RadialGauge</td>
	</tr>
</table>

## Description

You may want to customize the colors of the labels in the [Kendo UI for Angular RadialGauge](https://www.telerik.com/kendo-angular-ui/components/gauges/radialgauge) component based on their content. For example, you might want different colors for labels containing specific text or numeric values, or to highlight certain ranges or categories.

This knowledge base article also answers the following questions:

* How to change the color of RadialGauge labels based on their content?
* How to apply dynamic colors to RadialGauge labels?
* Can RadialGauge labels have different colors for text and numbers?

## Solution

To achieve conditional label coloring, the [`color`](https://www.telerik.com/kendo-angular-ui/components/gauges/api/radiallabels#color) property of the Kendo UI for Angular RadialGauge does not directly support dynamic functions. However, this can be implemented using custom JavaScript to target the [`text`](https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Element/text) elements and set their colors based on conditions. Follow these steps:

1. Use the [`querySelectorAll()`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll) method to select all `text` elements within the RadialGauge.
2. Iterate over the `text` elements to access their content.
3. Match the label content with predefined conditions and apply the desired color using the `fill` attribute.

   ```ts
   public setLabelColor(): void {
     const textElements = document.querySelectorAll('text');
     textElements.forEach((textElement) => {
       const label = textElement.textContent?.trim();
       if (label) {
         const range = this.ranges.find((item) => item.label === label);
         if (range) {
           this.renderer.setAttribute(textElement, 'fill', range.color);
         }
       }
     });
   }
   ```

The following example demonstrates the complete implementation of this approach:

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/knowledge-base/radial-gauge-label-color/source.txt)

## See Also

* [Gauges Appearance and Styling](https://www.telerik.com/kendo-angular-ui/components/gauges/styling)
* [RadialGauge Scale Options](https://www.telerik.com/kendo-angular-ui/components/gauges/radialgauge/scale-options)
* [Adding Tooltips to RadialGauge](https://www.telerik.com/kendo-angular-ui/components/knowledge-base/gauge-adding-tooltip-for-radial-gauges-pointer)
* [Gauges API Reference](https://www.telerik.com/kendo-angular-ui/components/gauges/api)
