<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: change field value font color in a table in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183174#M11314</link>
    <description>&lt;P&gt;What you tried is the right way:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if (cell.field === 'severity') { 
  if (value =='High') { 
   $td.addClass('range-cell').addClass('range-elevated'); } }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But right before these lines, you define what is in the value variable. In the original piece of code it looks like this:&lt;BR /&gt;
    var value = parseFloat(cell.value);&lt;/P&gt;

&lt;P&gt;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.&lt;/P&gt;

&lt;P&gt;so try to replace this with:&lt;BR /&gt;
    var value = cell.value;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Oct 2014 12:27:30 GMT</pubDate>
    <dc:creator>tom_frotscher</dc:creator>
    <dc:date>2014-10-27T12:27:30Z</dc:date>
    <item>
      <title>change field value font color in a table</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183170#M11310</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;
below is my table in a dashboard:&lt;/P&gt;

&lt;H2&gt;severity   count &lt;/H2&gt;

&lt;P&gt;High        1004&lt;BR /&gt;
Low          12000&lt;BR /&gt;
Medium   10000&lt;/P&gt;

&lt;P&gt;my question is how to show entire line in red color which is having High severity.&lt;BR /&gt;
please help me anyone i tried application.js and application.css&lt;BR /&gt;
here is my application.js and application.css&lt;/P&gt;

&lt;H2&gt;application.js&lt;/H2&gt;

&lt;P&gt;if( Splunk.Module.SimpleResultsTable ){&lt;BR /&gt;
     Splunk.Module.SimpleResultsTable = $.klass(Splunk.Module.SimpleResultsTable, {&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; 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() );
     });
 }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;});&lt;/P&gt;

&lt;H2&gt;application.css&lt;/H2&gt;

&lt;P&gt;.SimpleResultsTable tr td.d[field="severity"][data-value="High"]{&lt;BR /&gt;
     font-weight: bold;&lt;BR /&gt;
     background-color: #C42323;&lt;BR /&gt;
     color: white;&lt;BR /&gt;
 }&lt;/P&gt;

&lt;P&gt;please help me on this..&lt;/P&gt;</description>
      <pubDate>Mon, 27 Oct 2014 06:45:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183170#M11310</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2014-10-27T06:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: change field value font color in a table</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183171#M11311</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
there is a example implementation of this feature in the &lt;A href="https://apps.splunk.com/app/1603/"&gt;"Splunk 6.x Dashboard Example App"&lt;/A&gt;. 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.&lt;/P&gt;

&lt;P&gt;Greetings&lt;/P&gt;

&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Mon, 27 Oct 2014 11:01:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183171#M11311</guid>
      <dc:creator>tom_frotscher</dc:creator>
      <dc:date>2014-10-27T11:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: change field value font color in a table</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183172#M11312</link>
      <description>&lt;P&gt;how to use code the which showing bottom of the each dashboard.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Oct 2014 11:47:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183172#M11312</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2014-10-27T11:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: change field value font color in a table</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183173#M11313</link>
      <description>&lt;P&gt;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&lt;BR /&gt;
 // Apply interpretation for number of historical searches&lt;BR /&gt;
            if (cell.field === 'severity') {&lt;BR /&gt;
                if (value =='High') {&lt;BR /&gt;
                    $td.addClass('range-cell').addClass('range-elevated');&lt;BR /&gt;
                }&lt;BR /&gt;
            }&lt;BR /&gt;
            // Apply interpretation for number of realtime searches&lt;BR /&gt;
            if (cell.field === 'severity') {&lt;BR /&gt;
                if (value == 'Low') {&lt;BR /&gt;
                    $td.addClass('range-cell').addClass('range-severe');&lt;BR /&gt;
                }&lt;BR /&gt;
            }&lt;BR /&gt;
            // Update the cell content&lt;BR /&gt;
            $td.text(value.addClass('string');&lt;BR /&gt;
        }&lt;/P&gt;</description>
      <pubDate>Mon, 27 Oct 2014 12:17:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183173#M11313</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2014-10-27T12:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: change field value font color in a table</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183174#M11314</link>
      <description>&lt;P&gt;What you tried is the right way:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if (cell.field === 'severity') { 
  if (value =='High') { 
   $td.addClass('range-cell').addClass('range-elevated'); } }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But right before these lines, you define what is in the value variable. In the original piece of code it looks like this:&lt;BR /&gt;
    var value = parseFloat(cell.value);&lt;/P&gt;

&lt;P&gt;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.&lt;/P&gt;

&lt;P&gt;so try to replace this with:&lt;BR /&gt;
    var value = cell.value;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Oct 2014 12:27:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183174#M11314</guid>
      <dc:creator>tom_frotscher</dc:creator>
      <dc:date>2014-10-27T12:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: change field value font color in a table</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183175#M11315</link>
      <description>&lt;PRE&gt;&lt;CODE&gt; 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');
    }
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;i am getting every row in a green color even though i tried above snippet&lt;/P&gt;</description>
      <pubDate>Mon, 27 Oct 2014 12:34:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183175#M11315</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2014-10-27T12:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: change field value font color in a table</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183176#M11316</link>
      <description>&lt;P&gt;and one more thing what ever is appearing on the dashboard it is not showing the color when i generated pdf.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Oct 2014 12:43:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183176#M11316</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2014-10-27T12:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: change field value font color in a table</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183177#M11317</link>
      <description>&lt;P&gt;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:&lt;BR /&gt;
    console.log(cell.field)&lt;BR /&gt;
or&lt;BR /&gt;
    console.log(value)&lt;/P&gt;

&lt;P&gt;and then look at your browsers web console.&lt;/P&gt;

&lt;P&gt;For example use this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  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'));
 }
});
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Oct 2014 13:03:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183177#M11317</guid>
      <dc:creator>tom_frotscher</dc:creator>
      <dc:date>2014-10-27T13:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: change field value font color in a table</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183178#M11318</link>
      <description>&lt;P&gt;and one more thing what ever is appearing on the dashboard it is not showing the color when i generated pdf.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Oct 2014 03:10:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183178#M11318</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2014-10-28T03:10:32Z</dc:date>
    </item>
    <item>
      <title>Re: change field value font color in a table</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183179#M11319</link>
      <description>&lt;H2&gt;console log&lt;/H2&gt;

&lt;P&gt;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) &lt;BR /&gt;
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) &lt;BR /&gt;
Resource interpreted as Script but transferred with MIME type text/plain: "&lt;A href="http://10.215.3.195:8000/en-GB/static/@207789:10003/app/Symantec_DLP/table_row_highlighting.js" target="_blank"&gt;http://10.215.3.195:8000/en-GB/static/@207789:10003/app/Symantec_DLP/table_row_highlighting.js&lt;/A&gt;". mtd_dlp_incidents?earliest=0&amp;amp;latest=:676&lt;BR /&gt;
Uncaught SyntaxError: Unexpected token ; table_row_highlighting.js:38&lt;BR /&gt;
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&lt;BR /&gt;
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&lt;BR /&gt;
Resource interpreted as Image but transferred with MIME type image/x-png: "&lt;A href="http://10.215.3.195:8000/en-GB/static/@207789/img/skins/default/loading_medium_green_2x.png" target="_blank"&gt;http://10.215.3.195:8000/en-GB/static/@207789/img/skins/default/loading_medium_green_2x.png&lt;/A&gt;".&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:57:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183179#M11319</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2020-09-28T17:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: change field value font color in a table</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183180#M11320</link>
      <description>&lt;P&gt;I hope this could help you. just test it.&lt;BR /&gt;
you'll have to put js and css files in the folowing directory: your_app_name / appserver / static , and do not forget to restart splunk. &lt;BR /&gt;
Here is the search i will use: (index=_internal sourcetype=* | stats count as total_count by sourcetype ) and i will change the font of the row where "&lt;STRONG&gt;splunkd_access&lt;/STRONG&gt;" is a sourcetype. lets go!&lt;/P&gt;

&lt;P&gt;table_row_highlighting.xml&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;dashboard script="table_row_highlighting.js" stylesheet="table_decorations.css"&amp;gt;
     &amp;lt;label&amp;gt;font_of_single_table_string&amp;lt;/label&amp;gt;
     &amp;lt;row&amp;gt;
         &amp;lt;table id="highlight"&amp;gt;
             &amp;lt;title&amp;gt;Row Coloring&amp;lt;/title&amp;gt;
             &amp;lt;searchString&amp;gt;index=_internal sourcetype=*  | stats count as total_count by sourcetype&amp;lt;/searchString&amp;gt;
             &amp;lt;earliestTime&amp;gt;-24h&amp;lt;/earliestTime&amp;gt;
             &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
         &amp;lt;/table&amp;gt;
     &amp;lt;/row&amp;gt;
 &amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;table_row_highlighting.js&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; require([
     'underscore',
     'jquery',
     'splunkjs/mvc',
     'splunkjs/mvc/tableview',
     'splunkjs/mvc/simplexml/ready!'
 ], function(_, $, mvc, TableView) {
      // Row Coloring Example with custom, client-side range interpretation
     var CustomRangeRenderer = TableView.BaseCellRenderer.extend({
         canRender: function(cell) {
             // Enable this custom cell renderer for the sourcetype field
             return _([ 'sourcetype']).contains(cell.field);
         },
         render: function($td, cell) {
             // Add a class to the cell based on the returned value
             var value = String(cell.value);
            // Apply interpretation for number of historical searches
             if (cell.field === 'sourcetype') {
                  if (value==="splunkd_access" ){
                     $td.addClass('range-cell').addClass('range-elevated');
                 }
             }
             $td.text(value.toString()).addClass('string');
         }
     });
     mvc.Components.get('highlight').getVisualization(function(tableView) {
         // Add custom cell renderer
         tableView.table.addCellRenderer(new CustomRangeRenderer());
         tableView.on('rendered', function() {
             // Apply class of the cells to the parent row in order to color the whole row
             tableView.$el.find('td.range-cell').each(function() {
                 $(this).parents('tr').addClass(this.className);
             });
         });
         // Force the table to re-render
         tableView.table.render();
     });
 });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;table_decorations.css&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/* Row Coloring */

 #highlight tr.range-elevated td {
     background-color: #ffc57a !important;
     font-weight: bold;
     color:blue;
 }
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:04:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183180#M11320</guid>
      <dc:creator>stephanefotso</dc:creator>
      <dc:date>2020-09-28T19:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: change field value font color in a table</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183181#M11321</link>
      <description>&lt;P&gt;Thank you so much - i used this to highlight status words instead of numbers - awesome!&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2015 21:15:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183181#M11321</guid>
      <dc:creator>0YAoNnmRmKDg</dc:creator>
      <dc:date>2015-05-26T21:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: change field value font color in a table</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183182#M11322</link>
      <description>&lt;P&gt;Upvote! All Splunk Examples are only with numbers, your example shows how to handel also text values in cells.&lt;/P&gt;

&lt;P&gt;@Splunk, please update your examples!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2016 06:17:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/change-field-value-font-color-in-a-table/m-p/183182#M11322</guid>
      <dc:creator>splk</dc:creator>
      <dc:date>2016-08-24T06:17:16Z</dc:date>
    </item>
  </channel>
</rss>

