<?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: To change the colour of the value in statistics table not the back ground in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/To-change-the-colour-of-the-value-in-statistics-table-not-the/m-p/499975#M139262</link>
    <description>&lt;P&gt;@kamlesh_vaghela recommended approach would be to add classes through JS and then override color through CSS. So that there is a separation of concern. Your approach applies CSS through JS directly.&lt;/P&gt;

&lt;P&gt;As mentioned in the previous answer by @vnravikumar all that is required to change in the Simple XML JS/CSS extension of table is that instead of &lt;CODE&gt;background-color&lt;/CODE&gt; the &lt;CODE&gt;color&lt;/CODE&gt; style attribute needs to be overridden through CSS.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Adding a div to each of the table cell rendered and then applying CSS style is an overhead and also does not follow separation of concern.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/798513/how-to-change-the-colour-of-the-value-based-on-the.html"&gt;https://answers.splunk.com/answers/798513/how-to-change-the-colour-of-the-value-based-on-the.html&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Feb 2020 06:24:57 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2020-02-06T06:24:57Z</dc:date>
    <item>
      <title>To change the colour of the value in statistics table not the back ground</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-change-the-colour-of-the-value-in-statistics-table-not-the/m-p/499971#M139258</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;

&lt;P&gt;I have a statistics table in which each column contains different value  for eg:&lt;/P&gt;

&lt;P&gt;Application Name  Application ID  Functional Fitness  Digital Fitness&lt;BR /&gt;
A                                   123                          0.2                            0.5&lt;BR /&gt;
B                                   456                            3                               5&lt;BR /&gt;
C                                    789                           1                              1.5&lt;/P&gt;

&lt;P&gt;So now i want to change the color of the value (not the background) present in functional fitness and digital fitness based on the range, if the range is from 0 to 0.5 -- green colour,    0.6 to 3 --- red colour,    3.5 to 5 --- yellow colour&lt;/P&gt;

&lt;P&gt;So can you please help me in changing the colour of the value present in each column based on the range.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2020 07:56:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-change-the-colour-of-the-value-in-statistics-table-not-the/m-p/499971#M139258</guid>
      <dc:creator>shruthiangadi</dc:creator>
      <dc:date>2020-02-03T07:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: To change the colour of the value in statistics table not the back ground</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-change-the-colour-of-the-value-in-statistics-table-not-the/m-p/499972#M139259</link>
      <description>&lt;P&gt;@shruthiangadi &lt;/P&gt;

&lt;P&gt;You can achieve this using javascript and css. Please check below XML and Javascript.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;XML&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form script="status_dashboard.js"&amp;gt;
  &amp;lt;label&amp;gt;Table Cell Value Color&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table id="table1"&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults 
| eval _raw="
Application_Name,Application_ID,Functional_Fitness,Digital_Fitness
A,123,0.2,0.5
B,456,3,5
C,789,1,1.5" | multikv forceheader=1 | table Application_Name,Application_ID,Functional_Fitness,Digital_Fitness&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="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&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) {

    var CustomRangeRenderer = TableView.BaseCellRenderer.extend({
        canRender: function(cell) {
            return _(['Functional_Fitness','Digital_Fitness']).contains(cell.field);
        },
        render: function($td, cell) {
            var value = parseFloat(cell.value);
            console.log(value);

            if(value&amp;gt;=0 &amp;amp;&amp;amp; value&amp;lt;=0.5) {
                $td.html("&amp;lt;div style=\"color: green;font-weight: bold;\"&amp;gt;"+value+"&amp;lt;/div&amp;gt;")
            }
            else if(value&amp;gt;0.5 &amp;amp;&amp;amp; value&amp;lt;=3.0) { 
                $td.html("&amp;lt;div style=\"color: red;font-weight: bold;\"&amp;gt;"+value+"&amp;lt;/div&amp;gt;")
            }
            else if(value&amp;gt;3.5 &amp;amp;&amp;amp; value&amp;lt;=5.0) { 
                $td.html("&amp;lt;div style=\"color: yellow;font-weight: bold;\"&amp;gt;"+value+"&amp;lt;/div&amp;gt;")
            }
            else{
                $td.html("&amp;lt;div&amp;gt;"+value+"&amp;lt;/div&amp;gt;")
            }
        }
    });

    //List of table IDs to add icon
    var tableIDs = ["table1"];
    for (i=0;i&amp;lt;tableIDs.length;i++) {
        var sh = mvc.Components.get(tableIDs[i]);
        if(typeof(sh)!="undefined") {
            sh.getVisualization(function(tableView) {
                // Add custom cell renderer and force re-render
                tableView.table.addCellRenderer(new CustomRangeRenderer());
                tableView.table.render();
            });
        }
    }    
});
&lt;/CODE&gt;&lt;/PRE&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/8311i6EA953C67B706758/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;BR /&gt;
&lt;STRONG&gt;Note:&lt;/STRONG&gt;  Here I have used inline CSS ( &lt;CODE&gt;$td.html("&amp;lt;div style=\"color: green;font-weight: bold;\"&amp;gt;"+value+"&amp;lt;/div&amp;gt;")&lt;/CODE&gt; )  and you can use css class and use it in javaScript. You can change the &lt;CODE&gt;if&lt;/CODE&gt; condition as per your requirement ( &lt;CODE&gt;if(value&amp;gt;=0 &amp;amp;&amp;amp; value&amp;lt;=0.5) {&lt;/CODE&gt; ). I hope after taking this exampl as reference you will achieve your requirement.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2020 15:13:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-change-the-colour-of-the-value-in-statistics-table-not-the/m-p/499972#M139259</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2020-02-03T15:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: To change the colour of the value in statistics table not the back ground</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-change-the-colour-of-the-value-in-statistics-table-not-the/m-p/499973#M139260</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;It looks duplicate questions of&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/799479/how-to-change-colors-in-a-table.html"&gt;https://answers.splunk.com/answers/799479/how-to-change-colors-in-a-table.html&lt;/A&gt; and&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/798513/how-to-change-the-colour-of-the-value-based-on-the.html"&gt;https://answers.splunk.com/answers/798513/how-to-change-the-colour-of-the-value-based-on-the.html&lt;/A&gt; Please don't post same question multiple times.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2020 03:50:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-change-the-colour-of-the-value-in-statistics-table-not-the/m-p/499973#M139260</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2020-02-04T03:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: To change the colour of the value in statistics table not the back ground</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-change-the-colour-of-the-value-in-statistics-table-not-the/m-p/499974#M139261</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Thank you it worked&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 06:12:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-change-the-colour-of-the-value-in-statistics-table-not-the/m-p/499974#M139261</guid>
      <dc:creator>shruthiangadi</dc:creator>
      <dc:date>2020-02-06T06:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: To change the colour of the value in statistics table not the back ground</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-change-the-colour-of-the-value-in-statistics-table-not-the/m-p/499975#M139262</link>
      <description>&lt;P&gt;@kamlesh_vaghela recommended approach would be to add classes through JS and then override color through CSS. So that there is a separation of concern. Your approach applies CSS through JS directly.&lt;/P&gt;

&lt;P&gt;As mentioned in the previous answer by @vnravikumar all that is required to change in the Simple XML JS/CSS extension of table is that instead of &lt;CODE&gt;background-color&lt;/CODE&gt; the &lt;CODE&gt;color&lt;/CODE&gt; style attribute needs to be overridden through CSS.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Adding a div to each of the table cell rendered and then applying CSS style is an overhead and also does not follow separation of concern.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/798513/how-to-change-the-colour-of-the-value-based-on-the.html"&gt;https://answers.splunk.com/answers/798513/how-to-change-the-colour-of-the-value-based-on-the.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 06:24:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-change-the-colour-of-the-value-in-statistics-table-not-the/m-p/499975#M139262</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-02-06T06:24:57Z</dc:date>
    </item>
  </channel>
</rss>

