<?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 How to set different colors for each row of my results in dashboard panel? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-different-colors-for-each-row-of-my-results-in/m-p/207063#M187737</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Can someone please advise, how we can set different colors in a dashboard for each single row? &lt;/P&gt;

&lt;P&gt;Our data looks like below, and for each and every row, we need to set up different colors&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Data    average
EV    4477.12
PS    2223.47
PL    2098.59
PU    1012.99
PS    714.4
VP    193.99
HP    110.12
UP    93.26
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Wed, 17 Feb 2016 19:19:10 GMT</pubDate>
    <dc:creator>splunker9999</dc:creator>
    <dc:date>2016-02-17T19:19:10Z</dc:date>
    <item>
      <title>How to set different colors for each row of my results in dashboard panel?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-different-colors-for-each-row-of-my-results-in/m-p/207063#M187737</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Can someone please advise, how we can set different colors in a dashboard for each single row? &lt;/P&gt;

&lt;P&gt;Our data looks like below, and for each and every row, we need to set up different colors&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Data    average
EV    4477.12
PS    2223.47
PL    2098.59
PU    1012.99
PS    714.4
VP    193.99
HP    110.12
UP    93.26
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2016 19:19:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-different-colors-for-each-row-of-my-results-in/m-p/207063#M187737</guid>
      <dc:creator>splunker9999</dc:creator>
      <dc:date>2016-02-17T19:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to set different colors for each row of my results in dashboard panel?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-different-colors-for-each-row-of-my-results-in/m-p/207064#M187738</link>
      <description>&lt;P&gt;hi splunker9999,&lt;/P&gt;

&lt;P&gt;try with this example,&lt;/P&gt;

&lt;P&gt;create view table_row_highlighting.xml&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="table.js" stylesheet="table.css"&amp;gt;
     &amp;lt;label&amp;gt;Table Row Highlighting&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=test |table name test1 test2&amp;lt;/searchString&amp;gt;
             &amp;lt;earliestTime&amp;gt;0&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;next copy and paste &lt;CODE&gt;table.js&lt;/CODE&gt;and &lt;CODE&gt;table.css&lt;/CODE&gt; into &lt;CODE&gt;splunk_home/etc/apps/app_name/appserver/static&lt;/CODE&gt;&lt;BR /&gt;
after  your finish, restart SPLUNK&lt;BR /&gt;
table.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 both the active_hist_searches and the active_realtime_searches field
              return _(['test2']).contains(cell.field);
         },
         render: function($td, cell) {
             // Add a class to the cell based on the returned value
             var value = parseFloat(cell.value);

             // Apply interpretation for number of historical searches
             if (cell.field === 'test2') {
                 if (value &amp;lt; 60) {
                     $td.addClass('range-cell').addClass('range-elevated');
                 }
                 else if(value &amp;gt; 60 &amp;amp;&amp;amp; value &amp;lt; 80) {
                     $td.addClass('range-cell').addClass('range-severe');
                 }
                 else if(value &amp;gt; 80 &amp;amp;&amp;amp; value &amp;lt; 100) {
                     $td.addClass('range-cell').addClass('range-higher');
                 }

             }

             // Update the cell content
             $td.text(value.toFixed(2)).addClass('numeric');
         }
     });

     mvc.Components.get('highlight').getVisualization(function(tableView) {
         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);
             });
         });
         // Add custom cell renderer, the table will re-render automatically.
         tableView.addCellRenderer(new CustomRangeRenderer());
     });

 });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;table.css&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/* Row Coloring */
 #highlight tr.range-elevated td {
     background-color: #329606 !important;                  
 }

 #highlight tr.range-severe td {
     background-color: #F1FF70 !important;               
 }

 #highlight tr.range-higher td {
     background-color: #D6344D !important;               
 }

 #highlight td.range-severe, td.range-elevated, td.range-higher{
     font-weight: 800;
 }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;at finish, you have this result&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://community.splunk.com/storage/temp/106228-101173-capture.png" alt="![alt text][1]" /&gt;&lt;/P&gt;

&lt;P&gt;for more informations, follow this link:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/357989/how-to-color-a-table-row-based-on-a-cells-value.html#answer-363853" target="_blank"&gt;https://answers.splunk.com/answers/357989/how-to-color-a-table-row-based-on-a-cells-value.html#answer-363853&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 08:49:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-different-colors-for-each-row-of-my-results-in/m-p/207064#M187738</guid>
      <dc:creator>gyslainlatsa</dc:creator>
      <dc:date>2020-09-29T08:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to set different colors for each row of my results in dashboard panel?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-different-colors-for-each-row-of-my-results-in/m-p/207065#M187739</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Based on above example we understood that this can be used when we have range of values for every cell.&lt;/P&gt;

&lt;P&gt;BUt our scenario is , we dont need  any range for every cell, instead we are looking for different colors for each value in the cell.&lt;/P&gt;

&lt;P&gt;Is there a way to do this? &lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2016 16:07:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-different-colors-for-each-row-of-my-results-in/m-p/207065#M187739</guid>
      <dc:creator>splunker9999</dc:creator>
      <dc:date>2016-02-18T16:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to set different colors for each row of my results in dashboard panel?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-different-colors-for-each-row-of-my-results-in/m-p/207066#M187740</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
your table has how many values?&lt;/P&gt;

&lt;P&gt;because if your table has multiple values, then how will you proceed if these values do not relate to each other?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2016 17:03:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-different-colors-for-each-row-of-my-results-in/m-p/207066#M187740</guid>
      <dc:creator>gyslainlatsa</dc:creator>
      <dc:date>2016-02-18T17:03:16Z</dc:date>
    </item>
  </channel>
</rss>

