Dashboards & Visualizations

Colouring Table cells based on the table ID and Cell Value

ahallak2016
Explorer

Hi all,

I would like to color table cells based on the table ID and the cell values. The only examples that I have found on splunk answers involve checking what the cell.field is first before checking the values, but in my case this wont be possible because the field names returned may be different with each search. Furthermore, different tables will have the exact same field names but will always have different coloring rules (thresholds).

Is there a way to color the table cells by first checking what the table ID is and then checking the values?

This is what I would like to do (notice how i would like to check what the table id is in the if statement, instead of checking what the cell.field is?):

var val = cell.value;
var split_val = val.split("%")[0];
var value = parseFloat(split_val); 

if ({table id} == 'some value') 
{
      if (value >= 50.0) 
     {
       $td.addClass('Green');
     }
     else
     {
        $td.addClass('Red');
     }
}
if ({table id} == 'another value') 
{
      if (value >= 70.0) 
     {
       $td.addClass('Green');
     }
     else
     {
        $td.addClass('Red');
     }
}
Tags (1)
0 Karma
1 Solution

rjthibod
Champion

I am pretty sure the answer is no, you cannot do what you ask.

My understanding is the coding pattern dictates that you must add a cell rendering callback (via addCellRenderer()) for the table instance, but the callback function does not get the table ID when it is called. So you can create multiple callback functions (i.e., a unique callback for each table), and then apply your thresholds accordingly.

View solution in original post

niketn
Legend

If you upgrade to 6.5 or higher you will have cell coloring option built in to the table. Without JS/CSS extension.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

rjthibod
Champion

I am pretty sure the answer is no, you cannot do what you ask.

My understanding is the coding pattern dictates that you must add a cell rendering callback (via addCellRenderer()) for the table instance, but the callback function does not get the table ID when it is called. So you can create multiple callback functions (i.e., a unique callback for each table), and then apply your thresholds accordingly.

ahallak2016
Explorer

Ahh thanks for the reply.

I eventually found a work around by creating a separate JS file for each table. Its not a very elegant solutions but it will suffice for the time being.

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...