<?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: Need a javascript for coloring cells or row based on the condition in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/Need-a-javascript-for-coloring-cells-or-row-based-on-the/m-p/541956#M5093</link>
    <description>&lt;P&gt;Another example&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Splunk-Search/How-to-color-the-columns-based-on-previous-column-value/m-p/538849#M152374" target="_self"&gt;here&lt;/A&gt;&amp;nbsp;where the colour of the cell is based on the relationship to the previous value e.g. less than, equal or greater than.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Mar 2021 12:35:10 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2021-03-02T12:35:10Z</dc:date>
    <item>
      <title>Need a javascript for coloring cells or row based on the condition</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Need-a-javascript-for-coloring-cells-or-row-based-on-the/m-p/541928#M5089</link>
      <description>&lt;P&gt;Below table we have in a dashboard, the cells are highlighted by color using the Javascript. For each cell we wrote the separate javascript file like.,&lt;/P&gt;&lt;P&gt;&amp;lt;dashboard script="Running.js,Ready.js,Stop.js,Pause.js,Emergency.js,CF.js" stylesheet="New.css"&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vengat4043_0-1614679458293.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/13140iF8D41BF6FB9923ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vengat4043_0-1614679458293.png" alt="vengat4043_0-1614679458293.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;what we expect is the color of each cell should be same when the Match field value is "Good", if the Match field value is "Bad", Need to Highlight the whole Row.&lt;/P&gt;&lt;P&gt;//Sample Javascript Code:&lt;/P&gt;&lt;P&gt;require([&lt;BR /&gt;'underscore',&lt;BR /&gt;'jquery',&lt;BR /&gt;'splunkjs/mvc',&lt;BR /&gt;'splunkjs/mvc/tableview',&lt;BR /&gt;'splunkjs/mvc/simplexml/ready!'&lt;BR /&gt;], function(_, $, mvc, TableView) {&lt;/P&gt;&lt;P&gt;// Row Coloring Example with custom, client-side range interpretation&lt;/P&gt;&lt;P&gt;var CustomRangeRenderer = TableView.BaseCellRenderer.extend({&lt;BR /&gt;canRender: function(cell) {&lt;BR /&gt;// Enable this custom cell renderer for the confirm field&lt;BR /&gt;return _(['CF']).contains(cell.field);&lt;BR /&gt;},&lt;BR /&gt;render: function($td, cell) {&lt;BR /&gt;// Add a class to the cell based on the returned value&lt;BR /&gt;var value = parseFloat(cell.value);&lt;/P&gt;&lt;P&gt;// Apply interpretation for number of&lt;BR /&gt;if (cell.field === 'CF') {&lt;BR /&gt;if (value &amp;gt; 0) {&lt;BR /&gt;$td.addClass('range-cell').addClass('range-CF');&lt;BR /&gt;}&lt;BR /&gt;else {&lt;BR /&gt;$td.addClass('range-cell').addClass('range-White');&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;// Update the cell content&lt;BR /&gt;$td.text(value.toFixed()).addClass('numeric');&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;mvc.Components.get('highlight').getVisualization(function(tableView) {&lt;BR /&gt;tableView.addCellRenderer(new CustomRangeRenderer());&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;});&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//Sample .CSS Code&lt;/P&gt;&lt;P&gt;/* Cell Highlighting */&lt;BR /&gt;/*&lt;BR /&gt;#highlight td {&lt;BR /&gt;background-color: #c1ffc3 !important;&lt;BR /&gt;}&lt;BR /&gt;*/&lt;BR /&gt;#highlight td.range-stop {&lt;BR /&gt;background-color: #FF1B09 !important;&lt;BR /&gt;}&lt;BR /&gt;#highlight td.range-Emergency {&lt;BR /&gt;background-color: #CB1708 !important;&lt;BR /&gt;}&lt;BR /&gt;#highlight td.range-Pause {&lt;BR /&gt;background-color: #f7bc38 !important;&lt;BR /&gt;}&lt;BR /&gt;#highlight td.range-Run {&lt;BR /&gt;background-color: #65a637 !important;&lt;BR /&gt;}&lt;BR /&gt;#highlight td.range-Ready {&lt;BR /&gt;background-color: #A2CC3E !important;&lt;BR /&gt;}&lt;BR /&gt;#highlight td.range-CF {&lt;BR /&gt;background-color: #6DB7C6 !important;&lt;BR /&gt;}&lt;BR /&gt;#highlight td.range-MS {&lt;BR /&gt;background-color: #000000 !important;&lt;BR /&gt;}&lt;BR /&gt;#highlight td.range-White {&lt;BR /&gt;background-color: #ffffff !important;&lt;BR /&gt;}&lt;BR /&gt;#highlight td.range-severe {&lt;BR /&gt;background-color: #3358FF !important;&lt;BR /&gt;font-weight: bold;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;How can we do that, can you please help us?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 10:16:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Need-a-javascript-for-coloring-cells-or-row-based-on-the/m-p/541928#M5089</guid>
      <dc:creator>vengat4043</dc:creator>
      <dc:date>2021-03-02T10:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: Need a javascript for coloring cells or row based on the condition</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Need-a-javascript-for-coloring-cells-or-row-based-on-the/m-p/541930#M5090</link>
      <description>&lt;P&gt;You don't need to use javascript, this can be done with just CSS&lt;/P&gt;&lt;P&gt;Based on&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/201110"&gt;@niketn&lt;/a&gt;&amp;nbsp;solution&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Dashboards-Visualizations/How-to-change-font-color-based-on-a-condition-for-a-particular/m-p/487257#M31920" target="_self"&gt;here&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; &amp;lt;row&amp;gt;
  &amp;lt;panel depends="$stayhidden$"&amp;gt;
   &amp;lt;html&amp;gt;
    &amp;lt;style&amp;gt;
     #tableRowColorWithoutJS table tbody td div.multivalue-subcell[data-mv-index="1"]{
      display: none;
     }
    &amp;lt;/style&amp;gt;
   &amp;lt;/html&amp;gt;
  &amp;lt;/panel&amp;gt;
  &amp;lt;panel&amp;gt;
   &amp;lt;table id="tableRowColorWithoutJS"&amp;gt;
    &amp;lt;title&amp;gt;Colour Row by log_level: ERROR INFO and WARN&amp;lt;/title&amp;gt;
     &amp;lt;search&amp;gt;
      &amp;lt;query&amp;gt;index=_internal sourcetype=splunkd
| stats count last(component) as component 
  last(statusee) as statusee last(publisher) as publisher last(eventType) as eventType by log_level
| foreach * [| eval &amp;amp;lt;&amp;amp;lt;FIELD&amp;amp;gt;&amp;amp;gt;=if("&amp;amp;lt;&amp;amp;lt;FIELD&amp;amp;gt;&amp;amp;gt;"=="log_level",log_level,mvappend('&amp;amp;lt;&amp;amp;lt;FIELD&amp;amp;gt;&amp;amp;gt;',log_level))]&amp;lt;/query&amp;gt;
      &amp;lt;earliest&amp;gt;-15m&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="refresh.display"&amp;gt;progressbar&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;format type="color"&amp;gt;
      &amp;lt;colorPalette type="expression"&amp;gt;case (match(value,"ERROR"), "#DC4E41",match(value,"WARN"), "#F8BE34",match(value,"INFO"),"#53A051",true(),"#C3CBD4")&amp;lt;/colorPalette&amp;gt;
     &amp;lt;/format&amp;gt;
    &amp;lt;/table&amp;gt;
   &amp;lt;/panel&amp;gt;
 &amp;lt;/row&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 10:31:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Need-a-javascript-for-coloring-cells-or-row-based-on-the/m-p/541930#M5090</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-03-02T10:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: Need a javascript for coloring cells or row based on the condition</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Need-a-javascript-for-coloring-cells-or-row-based-on-the/m-p/541952#M5091</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Yes that css done the great job of coloring a row based on the condition, but here we need to if condition for coloring, if Match="Good" the fields (Running, Ready,Pause, Stop, CF) have the color&amp;nbsp; respectively like(DarkGreen, Green, Orange, Red, Blue) and if Match="Bad" the entire row should be on Dark Blue color.&lt;/P&gt;&lt;P&gt;is it possible?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 12:20:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Need-a-javascript-for-coloring-cells-or-row-based-on-the/m-p/541952#M5091</guid>
      <dc:creator>vengat4043</dc:creator>
      <dc:date>2021-03-02T12:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need a javascript for coloring cells or row based on the condition</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Need-a-javascript-for-coloring-cells-or-row-based-on-the/m-p/541954#M5092</link>
      <description>&lt;P&gt;So, rather than appending the value foreach field, have a separate eval for each field you want coloured, which appends either the state&amp;nbsp;&lt;SPAN&gt;(Running, Ready,Pause, Stop, CF) which you colour based on its value, or perhaps more simply you append the name of the colour you want to be used and map that to the colour.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The key point of the technique is to use a multi-value field where you set display to none for one of the indexes, but you evaluate which colour to use based on that hidden value.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 12:31:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Need-a-javascript-for-coloring-cells-or-row-based-on-the/m-p/541954#M5092</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-03-02T12:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Need a javascript for coloring cells or row based on the condition</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Need-a-javascript-for-coloring-cells-or-row-based-on-the/m-p/541956#M5093</link>
      <description>&lt;P&gt;Another example&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Splunk-Search/How-to-color-the-columns-based-on-previous-column-value/m-p/538849#M152374" target="_self"&gt;here&lt;/A&gt;&amp;nbsp;where the colour of the cell is based on the relationship to the previous value e.g. less than, equal or greater than.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 12:35:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Need-a-javascript-for-coloring-cells-or-row-based-on-the/m-p/541956#M5093</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-03-02T12:35:10Z</dc:date>
    </item>
  </channel>
</rss>

