Color Coding Grid Columns Based on Hex Color Data
In data visualization, it is often useful to represent different statuses with distinct colors for better clarity and user experience. This article outlines a method to dynamically set the background color of a grid column based on hex color data from another column.
Sample Data:
Check Status | Package Name | Case Created | Updated Date | status_colour |
---|---|---|---|---|
In Progress | Testing WLP 3.0 | 10/30/2024 7:36 | 10/30/2024 7:36 | #D9D9B9 |
Completed | Vanilla Package CLONE | 10/30/2024 5:38 | 10/30/2024 5:38 | #32CD32 |
Pending | Testing WLP 3.0 | 10/30/2024 5:29 | 10/30/2024 5:29 | #FFD700 |
Failed | Vanilla Package CLONE | 10/30/2024 6:10 | 10/30/2024 6:10 | #FF4500 |
In Progress | Testing WLP 3.0 | 10/30/2024 8:12 | 10/30/2024 8:12 | #D9D9B9 |
Completed | Vanilla Package CLONE | 10/30/2024 9:02 | 10/30/2024 9:02 | #32CD32 |
Pending | Testing WLP 3.0 | 10/30/2024 10:45 | 10/30/2024 10:45 | #FFD700 |
Failed | Vanilla Package CLONE | 10/30/2024 11:30 | 10/30/2024 11:30 | #FF4500 |
Completed | Testing WLP 3.0 | 10/30/2024 13:15 | 10/30/2024 13:15 | #32CD32 |
Pending | Vanilla Package CLONE | 10/30/2024 14:50 | 10/30/2024 14:50 | #FFD700 |
Solution Overview
For example, to achieve the desired color coding for the “Check Status” column based on the “status_colour” field (hex color code), you can use a specific expression that combines HTML and data values. This method allows for a visually dynamic representation of status entries in your grid.
Steps to Implement
-
Create an Expression:
Use the following expression to set the background color for the “Check Status” column:
CONCAT('<div class="uniqueClassBGColor" style="padding:-11px;background-color:', [status_colour], ';">', [Check Status], '</div>')
Explanation:
- The
CONCAT
function is used to combine HTML tags with the color and text values. - The
style
attribute sets the padding and assigns the background color from thestatus_colour
column. - The
Check Status
displays the text of the column inside the div.
- The
-
Bind the Expression to the Grid:
After creating the expression, bind it to the grid. This will apply the background color specified in the
status_colour
column to the “Check Status” text.
Output in Bold BI:
By following these steps, the background color of the “Check Status” column will dynamically reflect the color specified in the status_colour
column, enhancing the visual representation of the data.