Dashboards & Visualizations
Highlighted

change field value font color in a table

Motivator

Hi
below is my table in a dashboard:

severity count

High 1004
Low 12000
Medium 10000

my question is how to show entire line in red color which is having High severity.
please help me anyone i tried application.js and application.css
here is my application.js and application.css

application.js

if( Splunk.Module.SimpleResultsTable ){
Splunk.Module.SimpleResultsTable = $.klass(Splunk.Module.SimpleResultsTable, {

 renderResults: function($super, htmlFragment) {
     $super(htmlFragment);

     if (this.getInferredEntityName()=="events") {
         this.renderedCount = $("tr", this.container).length - 1;
     }

     $.each( $('.simpleResultsTable td'), function(index, value) {
         $(this).attr('data-value', $(this).text() );
     });
 }

});

application.css

.SimpleResultsTable tr td.d[field="severity"][data-value="High"]{
font-weight: bold;
background-color: #C42323;
color: white;
}

please help me on this..

Tags (2)
Highlighted

Re: change field value font color in a table

Hi,
there is a example implementation of this feature in the "Splunk 6.x Dashboard Example App". The example is called "Table Row Highlighting" and provides a simple xml example, together with the corresponding js and css files. This should be a good startingpoint for you.

Greetings

Tom

0 Karma
Highlighted

Re: change field value font color in a table

Motivator

in table row highlighting they are highlighting by using numeric values now i want to highlight by using text inside the field.please help me
// Apply interpretation for number of historical searches
if (cell.field === 'severity') {
if (value =='High') {
$td.addClass('range-cell').addClass('range-elevated');
}
}
// Apply interpretation for number of realtime searches
if (cell.field === 'severity') {
if (value == 'Low') {
$td.addClass('range-cell').addClass('range-severe');
}
}
// Update the cell content
$td.text(value.addClass('string');
}

0 Karma
Highlighted

Re: change field value font color in a table

What you tried is the right way:

if (cell.field === 'severity') { 
  if (value =='High') { 
   $td.addClass('range-cell').addClass('range-elevated'); } }

But right before these lines, you define what is in the value variable. In the original piece of code it looks like this:
var value = parseFloat(cell.value);

This parses the string value of the cell to a number. But in your case, you don't want to get a number from the cell, instead you just want to the string.

so try to replace this with:
var value = cell.value;

0 Karma
Highlighted

Re: change field value font color in a table

Motivator
 return _(['severity']).contains(cell.field);
    },
    render: function($td, cell) {
        // Add a class to the cell based on the returned value
        var value = cell.value;
        // Apply interpretation for number of historical searches
        if (cell.field === 'severity') {
            if (value=='High') {
                $td.addClass('range-cell').addClass('range-elevated');
            }
        }
        // Apply interpretation for number of realtime searches
        if (cell.field === 'severity') {
            if (value=='Low') {
                $td.addClass('range-cell').addClass('range-severe');
            }
        }
        // Update the cell content
    $td.text(value.addClass('string');
    }
});

i am getting every row in a green color even though i tried above snippet

0 Karma
Highlighted

Re: change field value font color in a table

Motivator

and one more thing what ever is appearing on the dashboard it is not showing the color when i generated pdf.

0 Karma
Highlighted

Re: change field value font color in a table

If everything is green, there should be a problem with your if clauses or the check for cell.field==='severity'. Because in the css it looks like green is the default color. You can use a debuger or manually look what values your variables have with something like this:
console.log(cell.field)
or
console.log(value)

and then look at your browsers web console.

For example use this:

  return _(['severity']).contains(cell.field);
 },
 render: function($td, cell) {
     // Add a class to the cell based on the returned value
     var value = cell.value;
     // Apply interpretation for number of historical searches
     if (cell.field === 'severity') {
         console.log(value + "High case");
         if (value=='High') {
             $td.addClass('range-cell').addClass('range-elevated');
         }
     }
     // Apply interpretation for number of realtime searches
     if (cell.field === 'severity') {
         console.log(value + "Low case");
         if (value=='Low') {
             $td.addClass('range-cell').addClass('range-severe');
         }
     }
     // Update the cell content
 $td.text(value.addClass('string'));
 }
});
0 Karma
Highlighted

Re: change field value font color in a table

Motivator

and one more thing what ever is appearing on the dashboard it is not showing the color when i generated pdf.

0 Karma
Highlighted

Re: change field value font color in a table

Motivator

console log

Consider using 'dppx' units, as in CSS 'dpi' means dots-per-CSS-inch, not dots-per-physical-inch, so does not correspond to the actual 'dpi' of a screen. In media query expression: (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi)
Consider using 'dppx' units, as in CSS 'dpi' means dots-per-CSS-inch, not dots-per-physical-inch, so does not correspond to the actual 'dpi' of a screen. In media query expression: only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi)
Resource interpreted as Script but transferred with MIME type text/plain: "http://10.215.3.195:8000/en-GB/static/@207789:10003/app/Symantec_DLP/table_row_highlighting.js". mtddlpincidents?earliest=0&latest=:676
Uncaught SyntaxError: Unexpected token ; tablerowhighlighting.js:38
Consider using 'dppx' units, as in CSS 'dpi' means dots-per-CSS-inch, not dots-per-physical-inch, so does not correspond to the actual 'dpi' of a screen. In media query expression: (min-resolution: 144dpi) mvc.js:6
Consider using 'dppx' units, as in CSS 'dpi' means dots-per-CSS-inch, not dots-per-physical-inch, so does not correspond to the actual 'dpi' of a screen. In media query expression: only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) mvc.js:6
Resource interpreted as Image but transferred with MIME type image/x-png: "http://10.215.3.195:8000/en-GB/static/@207789/img/skins/default/loading_medium_green_2x.png".

0 Karma
Highlighted

Re: change field value font color in a table

Motivator

how to use code the which showing bottom of the each dashboard.

0 Karma