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!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...