Dashboards & Visualizations

How to add color to table rows in Dashboard Studio?

bamartinez
Explorer

Hello!

I am looking to add color to a table I have in Dashboard Studio. I notice in the UI there are no coloring options when you select Column Formatting for a string type - the color formats only show for number types. So I tried to replicate the color formatting onto a string type via the source code but am not getting anywhere.

Is there something I am missing? Is this possible to color strings in tables with the current release of dashboard studio?

TIA!

Labels (1)
Tags (2)

jasonlashua
Engager

oooh can doo!

Format a column first, and make a range map or value match then take note of that in the code, for instance the "Users in group" column:

 "Users in Group": { "data": "> table | seriesByName(\"Users in Group\") | formatByType(Users_in_GroupColumnFormatEditorConfig)",
"rowColors": "> table | seriesByName('Users in Group') | pick(Users_in_GroupRowColorsEditorConfig)",
"rowBackgroundColors": "> table | seriesByName(\"Users in Group\") | rangeValue(Users_in_GroupRowBackgroundColorsEditorConfig)" } 

 
Then find tableFormat and change rowBackgroundColors to the same as you used to color the column

"headerVisibility": "fixed",
"backgroundColor": "transparent",
"tableFormat": {
    "rowBackgroundColors": "> table | seriesByName('Users in Group') | rangeValue(Users_in_GroupRowBackgroundColorsEditorConfig)",
    "headerBackgroundColor": "> backgroundColor | setColorChannel(tableHeaderBackgroundColorConfig)",
    "rowColors": "> rowBackgroundColors | maxContrast(tableRowColorMaxContrast)",
    "headerColor": "> headerBackgroundColor | maxContrast(tableRowColorMaxContrast)" } 

And the whole row is now that color. 

 

 

RedPooch
Engager

As you see adding to colors to number columns in Dashboard Studio is straightforward via GUI editor for numbered fields.   To add colors to a column based on a value you need to do it in the source .json of the dashboard.

In my example, I created a table with a column name of "Status", which has the values of Success, Warning, Failed or Running.  I wanted to change the color of the cell based on the value.

Here is what I did in the Dashboard source under "Visualizations" (skip down the section "Column Format:) 

    "visualizations": {
        "viz_table_1": {
            "type""splunk.table",
            "options": {
.......(many option fields).....
 
                "columnFormat": {
                    "Status": {
                        "rowBackgroundColors""> table | seriesByName('Status') | matchValue(matchConfig)"
                    },
 
            "dataSources": {
                "primary""ds_search_1"
            },
            "context": {
                "tableRowBackgroundColors": [
                    "#2C3033",
                    "#32373D"
                ],
                "tableRowColor": [
                    "#A870EF"
                ],
                "matchConfig": [
                    {
                        "match""Success",
                        "value""#53A051"
                    },
                    {
                        "match""Warning",
                        "value""#B6C75A"
                    },
                    {
                        "match""Failed",
                        "value""#DC4E41"
                    },
                    {
                        "match""Running",
                        "value""#006D9C"
                    }
                ]
 
 
I'd recommend looking at the Example Hub  under Search>Dashboards>Examples for Dashboard Studio" in the Splunk UI.  Hope it points you down the right path.

nayagan
Engager

It is more helpful but we need to highlight entire row based on the column values success, warning, failed and running. 

In your code only highlight particular cell not entire row. More appreciated if you are providing the json code for the same. 

Tags (1)
0 Karma

Augus123
New Member

Hi,

I am looking to edit my dashboard (Studio) - to color code a column based on certain values (non-numeric)

Same here...I am just looking for the JS code to add it to visualization part of the source code

Field name is "Game Status". The values in this columns and their respective color codes:
"Completed" to be in Blue, "on-line" to be in "Green" and "Not available" to be in "Red"

0 Karma

SteveM-905
Loves-to-Learn

Me too

0 Karma

Racer73b
Explorer

Can you also do conditional formatting for a line or column chart, or just a table?  I have a column chart where I would like to highlight one of the columns (series) based on value.  I don't think dashboard studio allows this... iirc the classic dashboard does allow it.  Unfortunately this is a major drawback for using dashboard studio :(.  I hope they fix it.

0 Karma
Get Updates on the Splunk Community!

Get Inspired! We’ve Got Validation that Your Hard Work is Paying Off

We love our Splunk Community and want you to feel inspired by all your hard work! Eric Fusilero, our VP of ...

What's New in Splunk Enterprise 9.4: Features to Power Your Digital Resilience

Hey Splunky People! We are excited to share the latest updates in Splunk Enterprise 9.4. In this release we ...

Take Your Breath Away with Splunk Risk-Based Alerting (RBA)

WATCH NOW!The Splunk Guide to Risk-Based Alerting is here to empower your SOC like never before. Join Haylee ...