<?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: Cell Coloring of a Dynamic Column in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173992#M33175</link>
    <description>&lt;P&gt;Following are the change:&lt;BR /&gt;
 1. Change the splunk query. The columns which do not need highlighting, use the above eval statement.&lt;BR /&gt;
 2. In JS, you get the cell value using &lt;STRONG&gt;var value = cell.value;&lt;/STRONG&gt;, using this value, identify if the column needs highlighting or not. e.g. If the cell value is &lt;STRONG&gt;NO_HIGHLIGHT_BBC Sport&lt;/STRONG&gt;, then don't highlight. If not present, then highlight. Here, NO_HIGHLIGHT_ is the token we added (purposefully) in the search result (for column Channel).&lt;BR /&gt;
 3. Lastly, remove &lt;STRONG&gt;NO_HIGHLIGHT_&lt;/STRONG&gt; from the cell value (and show this value in dashboard).&lt;/P&gt;

&lt;P&gt;Thanks!!&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 20:21:01 GMT</pubDate>
    <dc:creator>vganjare</dc:creator>
    <dc:date>2020-09-28T20:21:01Z</dc:date>
    <item>
      <title>Cell Coloring of a Dynamic Column</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173987#M33170</link>
      <description>&lt;P&gt;How to highlight cells of fields which are dynamic? My table looks like below if you select last 3 days from timepicker&lt;/P&gt;
&lt;P&gt;Channel 24-Jun-15 23-Jun-15 22-Jun-15 21-Jun-15&lt;BR /&gt;BBC Sport 6 3 7 9&lt;BR /&gt;Discovery 2 6 4 3&lt;/P&gt;
&lt;P&gt;As you can see the fields names here are time dependent. I want to color all cells for fields other than 'Channel' here.&lt;BR /&gt;How can I do that? Please help.&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jun 2020 02:23:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173987#M33170</guid>
      <dc:creator>kabiraj</dc:creator>
      <dc:date>2020-06-07T02:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: Cell Coloring of a Dynamic Column</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173988#M33171</link>
      <description>&lt;P&gt;Do you want to highlight all the cells except Channel cell?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2015 09:14:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173988#M33171</guid>
      <dc:creator>vganjare</dc:creator>
      <dc:date>2015-06-24T09:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: Cell Coloring of a Dynamic Column</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173989#M33172</link>
      <description>&lt;P&gt;Yes. And other cells belong to fields which are time dependent. Based on the threshold ranges i will color the cells for all fields other than 'Channel'&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2015 09:16:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173989#M33172</guid>
      <dc:creator>kabiraj</dc:creator>
      <dc:date>2015-06-24T09:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: Cell Coloring of a Dynamic Column</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173990#M33173</link>
      <description>&lt;P&gt;In this case, you can mark the field which should &lt;STRONG&gt;not be highlighted&lt;/STRONG&gt;. e.g. | eval Channel="NO_HIGHLIGHT_".Channel ... In the cell renderer, see if the field value has string token : "NO_HIGHLIGHT_". If this token is present, then do not highlight the cell, and remove the NO_HIGHLIGHT token from the text. If the token is not present, then highlight the cell.&lt;/P&gt;

&lt;P&gt;Thanks!!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 20:20:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173990#M33173</guid>
      <dc:creator>vganjare</dc:creator>
      <dc:date>2020-09-28T20:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Cell Coloring of a Dynamic Column</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173991#M33174</link>
      <description>&lt;P&gt;Can you give an example to explain what you said? Below is my javascript&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 true;
        },
        render: function($td, cell) {
            // Add a class to the cell based on the returned value
            // Apply interpretation for number of historical searches
                var tdPosition = $td.parent().children().index($td[0]);
                var value = cell.value;
            if (tdPosition &amp;gt; 0) {
                    var value = parseInt(value);
                if ((value &amp;gt; 0) &amp;amp;&amp;amp; (value &amp;lt;= 50)) {
                    $td.addClass('range-cell').addClass('range-severe');
                }
                else if ((value &amp;gt; 50) &amp;amp;&amp;amp; (value &amp;lt;= 100)) {
                    $td.addClass('range-cell').addClass('range-elevated');
                }
                else if ((value &amp;gt; 100) &amp;amp;&amp;amp; (value &amp;lt;= 150)) {
                    $td.addClass('range-cell').addClass('range-low');
                }
                    else {
                        $td.addClass('range-cell').addClass('range-empty');
                    }

            }
            // Update the cell content
                $td.text(value).addClass('numeric');
        }
    });
    mvc.Components.get('samptable').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).addClass(this.className);
           // });
        //});
        // Force the table to re-render
        tableView.table.render();
    });
});
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Jun 2015 09:24:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173991#M33174</guid>
      <dc:creator>kabiraj</dc:creator>
      <dc:date>2015-06-24T09:24:45Z</dc:date>
    </item>
    <item>
      <title>Re: Cell Coloring of a Dynamic Column</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173992#M33175</link>
      <description>&lt;P&gt;Following are the change:&lt;BR /&gt;
 1. Change the splunk query. The columns which do not need highlighting, use the above eval statement.&lt;BR /&gt;
 2. In JS, you get the cell value using &lt;STRONG&gt;var value = cell.value;&lt;/STRONG&gt;, using this value, identify if the column needs highlighting or not. e.g. If the cell value is &lt;STRONG&gt;NO_HIGHLIGHT_BBC Sport&lt;/STRONG&gt;, then don't highlight. If not present, then highlight. Here, NO_HIGHLIGHT_ is the token we added (purposefully) in the search result (for column Channel).&lt;BR /&gt;
 3. Lastly, remove &lt;STRONG&gt;NO_HIGHLIGHT_&lt;/STRONG&gt; from the cell value (and show this value in dashboard).&lt;/P&gt;

&lt;P&gt;Thanks!!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 20:21:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173992#M33175</guid>
      <dc:creator>vganjare</dc:creator>
      <dc:date>2020-09-28T20:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: Cell Coloring of a Dynamic Column</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173993#M33176</link>
      <description>&lt;P&gt;I understood your point. Understood the eval condition. But i am confused about how to write that condition in js file. It would be great if you share a small example of the js file. &lt;/P&gt;

&lt;P&gt;Also i am using &lt;CODE&gt;return=true&lt;/CODE&gt;. previously it was &lt;CODE&gt;return _(['Fieldname']).contains(cell.field);&lt;/CODE&gt; Is it correct. As I am new to javascript, so if you could share a similar example it would be better for me to understand.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2015 09:41:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173993#M33176</guid>
      <dc:creator>kabiraj</dc:creator>
      <dc:date>2015-06-24T09:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: Cell Coloring of a Dynamic Column</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173994#M33177</link>
      <description>&lt;P&gt;See if this helps. Replace the update the render function to following. The varible &lt;STRONG&gt;isHighlight&lt;/STRONG&gt;  will be true if the highlight is required otherwise it will be false.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;render: function($td, cell) {
    // Add a class to the cell based on the returned value
    // Apply interpretation for number of historical searches
    var tdPosition = $td.parent().children().index($td[0]);
    var value = cell.value;
    var isHighlight = (value.search('NO_HIGHLIGHT_') == -1)
    if (isHighlight) {
        var value = parseInt(value);
        if ((value &amp;gt; 0) &amp;amp;&amp;amp; (value &amp;lt;= 50)) {
            $td.addClass('range-cell').addClass('range-severe');
        }else if ((value &amp;gt; 50) &amp;amp;&amp;amp; (value &amp;lt;= 100)) {
            $td.addClass('range-cell').addClass('range-elevated');
        }else if ((value &amp;gt; 100) &amp;amp;&amp;amp; (value &amp;lt;= 150)) {
            $td.addClass('range-cell').addClass('range-low');
        }else {
            $td.addClass('range-cell').addClass('range-empty');
        }
    }
    value = value.replace('NO_HIGHLIGHT_','');
    // Update the cell content
    $td.text(value).addClass('numeric');
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Jun 2015 09:51:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173994#M33177</guid>
      <dc:creator>vganjare</dc:creator>
      <dc:date>2015-06-24T09:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: Cell Coloring of a Dynamic Column</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173995#M33178</link>
      <description>&lt;P&gt;Hi vganjare. I tried your solution but the table shows empty if i apply the javascript and css to the dashboard.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Splunk Query&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=ret | rex "popularityIndex=(\")(?P&amp;lt;PI&amp;gt;[^&amp;gt;]+)(\")" | search PI=* | rex "&amp;lt;!--(?P&amp;lt;Channel_Name&amp;gt;[^-]+)" | eval Channel_Name = substr(Channel_Name, 0, len(Channel_Name)-18) | dedup Channel_Name | table Channel_Name PI| rename PI as "Popularity Index" Channel_Name as "Channel" | sort "Popularity Index" | appendcols [search sourcetype=shmapplogs "getMS3SAS ended for - deviceId" | bucket span=1d _time | stats count by _time channelId | sort count desc | lookup youview_channels.csv service_id_truncated AS channelId OUTPUT channel_name_letter | streamstats count AS position by _time | fields channel_name_letter position _time | convert timeformat="%d-%b-%Y" ctime(_time) As Time | chart max(position) over channel_name_letter by Time | rename channel_name_letter as "Channel"] | eval Channel = "NO_HIGHLIGHT_"+Channel
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Javascript&lt;/STRONG&gt;&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 true;
        },
        render: function($td, cell) {
            // Add a class to the cell based on the returned value
            // Apply interpretation for number of historical searches
                //var tdPosition = $td.parent().children().index($td[0]);
                var value = cell.value;
                var isHighlight = (value.search('NO_HIGHLIGHT_') == -1);
                //console.log(tdposition + value);
                //alert(tdposition + value);
            if (isHighlight) {
                    var value = parseInt(value);
                if ((value &amp;gt; 0) &amp;amp;&amp;amp; (value &amp;lt;= 50)) {
                    $td.addClass('range-cell').addClass('range-severe');
                }
                else if ((value &amp;gt; 50) &amp;amp;&amp;amp; (value &amp;lt;= 100)) {
                    $td.addClass('range-cell').addClass('range-elevated');
                }
                else if ((value &amp;gt; 100) &amp;amp;&amp;amp; (value &amp;lt;= 150)) {
                    $td.addClass('range-cell').addClass('range-low');
                }
                    else {
                        $td.addClass('range-cell').addClass('range-empty');
                    }

            }
                else {
                value = value.replace('NO_HIGHLIGHT_','');              
                }
            // Update the cell content
                $td.text(value);
        }
    });
    mvc.Components.get('rettable').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).addClass(this.className);
           // });
        //});
        // Force the table to re-render
        tableView.table.render();
    });
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;CSS&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#rettable td.range-low {
    color: #C0D9D9;
}
#rettable td.range-elevated {
    background-color: #ffc57a !important;
    font-weight: bold;
}
#rettable td.range-severe {
    background-color: #d59392 !important;
    font-weight: bold;
}

#rettable td.range-empty {
    color: #C0D9D9;
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Source Code&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;panel&amp;gt;
  &amp;lt;table id="rettable"&amp;gt;
    &amp;lt;title&amp;gt;RET Statistics&amp;lt;/title&amp;gt;
    &amp;lt;search&amp;gt;
      &amp;lt;query&amp;gt;sourcetype=ret | rex "popularityIndex=(\")(?P&amp;amp;lt;PI&amp;amp;gt;[^&amp;amp;gt;]+)(\")" | search PI=* | rex "&amp;amp;lt;!--(?P&amp;amp;lt;Channel_Name&amp;amp;gt;[^-]+)" | eval Channel_Name = substr(Channel_Name, 0, len(Channel_Name)-18) | dedup Channel_Name | table Channel_Name PI| rename PI as "Popularity Index" Channel_Name as "Channel" | sort "Popularity Index" | appendcols [search sourcetype=shmapplogs "getMS3SAS ended for - deviceId" | bucket span=1d _time | stats count by _time channelId | sort count desc | lookup youview_channels.csv service_id_truncated AS channelId OUTPUT channel_name_letter | streamstats count AS position by _time | fields channel_name_letter position _time | convert timeformat="%d-%b-%Y" ctime(_time) As Time | chart max(position) over channel_name_letter by Time | rename channel_name_letter as "Channel"] | eval Channel = "NO_HIGHLIGHT_"+Channel&amp;lt;/query&amp;gt;
      &amp;lt;earliest&amp;gt;$time.earliest$&amp;lt;/earliest&amp;gt;
      &amp;lt;latest&amp;gt;$time.latest$&amp;lt;/latest&amp;gt;
    &amp;lt;/search&amp;gt;
    &amp;lt;option name="wrap"&amp;gt;undefined&amp;lt;/option&amp;gt;
    &amp;lt;option name="rowNumbers"&amp;gt;undefined&amp;lt;/option&amp;gt;
    &amp;lt;option name="drilldown"&amp;gt;row&amp;lt;/option&amp;gt;
    &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
    &amp;lt;option name="count"&amp;gt;10&amp;lt;/option&amp;gt;
  &amp;lt;/table&amp;gt;
&amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Jun 2015 11:58:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173995#M33178</guid>
      <dc:creator>kabiraj</dc:creator>
      <dc:date>2015-06-24T11:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: Cell Coloring of a Dynamic Column</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173996#M33179</link>
      <description>&lt;P&gt;Thank you vganjare. It works now!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2015 12:41:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173996#M33179</guid>
      <dc:creator>kabiraj</dc:creator>
      <dc:date>2015-06-24T12:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: Cell Coloring of a Dynamic Column</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173997#M33180</link>
      <description>&lt;P&gt;Hi, I noticed in your 2nd last comment on this thread that you said vganjare's solution did not work and then right after you said it did work. Did you do any more to your most recent code to make it work. I was thinking that maybe I missed something between your 2nd last comment and you rlast comment?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 17:38:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173997#M33180</guid>
      <dc:creator>richielynch89</dc:creator>
      <dc:date>2018-06-28T17:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: Cell Coloring of a Dynamic Column</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173998#M33181</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Is it possible to do the same for string values in fields instead of numeric.&lt;/P&gt;

&lt;P&gt;Am trying this but not working any help provided is appreciated.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if (cell.field !== "source_subnet") {
                  if (value !== "100%") {
                      $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;Please ignore am using "100%" as string.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 06:21:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Cell-Coloring-of-a-Dynamic-Column/m-p/173998#M33181</guid>
      <dc:creator>PowerPacked</dc:creator>
      <dc:date>2020-04-27T06:21:19Z</dc:date>
    </item>
  </channel>
</rss>

