<?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 row color when the field &amp;quot;time value&amp;quot; increases in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Change-row-color-when-the-field-quot-time-value-quot-increases/m-p/301296#M19178</link>
    <description>&lt;P&gt;Thanks Dal &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Oct 2017 09:14:42 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-10-10T09:14:42Z</dc:date>
    <item>
      <title>Change row color when the field "time value" increases</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Change-row-color-when-the-field-quot-time-value-quot-increases/m-p/301291#M19173</link>
      <description>&lt;P&gt;Hi ,&lt;BR /&gt;
In my dashboard I am watching the ticketing system , am calculating the time frame , if the ticket age was grater 02:00 hours  then the row would be turn to red , if it less than  02:00 then it should be  yellow,  and if it less than 01:30 it would be turn green &lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/3647iBCE8CCF6B03299C0/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 16:53:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Change-row-color-when-the-field-quot-time-value-quot-increases/m-p/301291#M19173</guid>
      <dc:creator>svemurilv</dc:creator>
      <dc:date>2017-10-09T16:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: Change row color when the field "time value" increases</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Change-row-color-when-the-field-quot-time-value-quot-increases/m-p/301292#M19174</link>
      <description>&lt;P&gt;Install the "dashboard examples app"&lt;BR /&gt;
 &lt;A href="https://splunkbase.splunk.com/app/1603/"&gt;https://splunkbase.splunk.com/app/1603/&lt;/A&gt;&lt;BR /&gt;
and look for the coloring options for table elements&lt;/P&gt;

&lt;P&gt;As a hour is not a integer, you may have to create an extra field for the coloring code (by example in minutes, not in hour:min:second)&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 17:19:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Change-row-color-when-the-field-quot-time-value-quot-increases/m-p/301292#M19174</guid>
      <dc:creator>yannK</dc:creator>
      <dc:date>2017-10-09T17:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: Change row color when the field "time value" increases</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Change-row-color-when-the-field-quot-time-value-quot-increases/m-p/301293#M19175</link>
      <description>&lt;P&gt;This is based on Splunk Dashboard Examples App to color Rows based on values. This compare string time duration in HH:MM:SS format assuming each single digit time unit is prefixed with zeros hence allowing comparison of sorted string time duration i.e. &lt;CODE&gt;02:00:00 &amp;gt; 01:59:59&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/3646i14F37CFCE6C459DF/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;BR /&gt;
Following is a run anywhere dashboard based on your sample data. The field containing duration in HH:MM:SS formation is called &lt;CODE&gt;duration&lt;/CODE&gt; and the table for formatting has &lt;CODE&gt;id="highlight"&lt;/CODE&gt; for applying CSS style.&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;Table Row Color based on String Time Duration in HH:MM:SS&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table id="highlight"&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults
| eval data="00005914652,03:13:59,10/09/17 09:31:57;00005914653,01:30:59,10/09/17 09:33:42;00005914654,00:13:59,10/09/17 09:40:13;"
| makemv data delim=";"
| mvexpand data
| eval data=split(data,",")
| eval id=mvindex(data,0)Q
| eval duration=mvindex(data,1)
| eval time=mvindex(data,2)
| table id duration time&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;20&amp;lt;/option&amp;gt;
        &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is the required JavaScript &lt;CODE&gt;table_row_highlighting.js&lt;/CODE&gt; to be placed under your Splunk App's static folder i.e. &lt;BR /&gt;
&lt;CODE&gt;$SPLUNK_HOME$/etc/apps/&amp;lt;YourAppName&amp;gt;/appserver/static&lt;/CODE&gt; folder.&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 by String Comparision of Numeric Time Value in HH:MM:SS

    var CustomRangeRenderer = TableView.BaseCellRenderer.extend({
        canRender: function(cell) {
            // Enable this custom cell renderer for duration field
            return _(['duration']).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 duration field
            if (cell.field === 'duration') {
                if (value &amp;gt;= "02:00:00") {
                    $td.addClass('range-cell').addClass('range-severe');
                }
                if (value &amp;lt; "02:00:00" &amp;amp;&amp;amp; value &amp;gt; "01:30:00") {
                    $td.addClass('range-cell').addClass('range-elevated');
                }
            }

            // Update the cell content with string duration value HH:MM:SS
            $td.text(value).addClass('string');
        }
    });

    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;Following is the &lt;CODE&gt;table_decorations.css&lt;/CODE&gt;file to be placed under your Splunk App's static folder same as JavaScript file above:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/* Row Coloring */

#highlight tr td {
    background-color: #65A637 !important;
}

#highlight tr.range-elevated td {
    background-color: #F7BC38 !important;
}

#highlight tr.range-severe td {
    background-color: #D93F3C !important;
}

#highlight .table td {
    border-top: 1px solid #fff;
}

#highlight td.range-severe, td.range-elevated {
    font-weight: bold;
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: Changes/Application of static JavaScript and CSS files requires reboot/refresh or bump of Splunk instance based on whichever is comfortable. It might also require clearing up of internet browser history to prevent cached static file to be loaded.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 17:53:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Change-row-color-when-the-field-quot-time-value-quot-increases/m-p/301293#M19175</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-10-09T17:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: Change row color when the field "time value" increases</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Change-row-color-when-the-field-quot-time-value-quot-increases/m-p/301294#M19176</link>
      <description>&lt;P&gt;Hey @svemurilv, if they solved your problem, remember to "√Accept" an answer to award karma points &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 00:21:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Change-row-color-when-the-field-quot-time-value-quot-increases/m-p/301294#M19176</guid>
      <dc:creator>lfedak_splunk</dc:creator>
      <dc:date>2017-10-10T00:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: Change row color when the field "time value" increases</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Change-row-color-when-the-field-quot-time-value-quot-increases/m-p/301295#M19177</link>
      <description>&lt;P&gt;@niketnilay - beautiful.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 04:49:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Change-row-color-when-the-field-quot-time-value-quot-increases/m-p/301295#M19177</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-10-10T04:49:36Z</dc:date>
    </item>
    <item>
      <title>Re: Change row color when the field "time value" increases</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Change-row-color-when-the-field-quot-time-value-quot-increases/m-p/301296#M19178</link>
      <description>&lt;P&gt;Thanks Dal &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 09:14:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Change-row-color-when-the-field-quot-time-value-quot-increases/m-p/301296#M19178</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-10-10T09:14:42Z</dc:date>
    </item>
  </channel>
</rss>

