<?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: Table Data Bar - Customize in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Table-Data-Bar-Customize/m-p/326067#M97214</link>
    <description>&lt;P&gt;I managed to achieve this by putting a second div in the background of the table cell.&lt;BR /&gt;
This code updates a column titled: "Progress" in a table with id : "table_instances"&lt;/P&gt;

&lt;P&gt;table_data_bar.js:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'jquery',
    'underscore',
    'splunkjs/mvc',
    'views/shared/results_table/renderers/BaseCellRenderer',
    'splunkjs/mvc/simplexml/ready!'
], function($, _, mvc, BaseCellRenderer) {
    var DataBarCellRenderer = BaseCellRenderer.extend({
        canRender: function(cell) {
            return (cell.field === 'Progress');
        },
        render: function($td, cell) {
            $td.addClass('data-bar-cell').html(_.template('&amp;lt;div class="data-bar-wrapper"&amp;gt;&amp;lt;div class="data-bar-back" style="width:100%"&amp;gt;&amp;lt;div class="data-bar" style="width:&amp;lt;%- percent %&amp;gt;%"&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;', {
                percent: Math.min(Math.max(parseFloat(cell.value), 0), 100)
            }));
        }
    });
    mvc.Components.get('table_instances').getVisualization(function(tableView) {
        tableView.addCellRenderer(new DataBarCellRenderer());
    });
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;table_data_bar.css:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;td.data-bar-cell {
    padding: 7px 4px;
}
td.data-bar-cell .data-bar-wrapper .data-bar-back .data-bar {
    position: relative;
    top: 0;
    right: 0;
    height: 10px;
    min-width: 1px;
    background-color: #30b5e2;
    border-radius: 5px;
}
td.data-bar-cell .data-bar-wrapper .data-bar-back {

    height: 10px;
    min-width: 1px;
    background-color: #e5e5e5;
    border-radius: 5px;
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 29 Sep 2020 18:55:34 GMT</pubDate>
    <dc:creator>roryab</dc:creator>
    <dc:date>2020-09-29T18:55:34Z</dc:date>
    <item>
      <title>Table Data Bar - Customize</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-Data-Bar-Customize/m-p/326064#M97211</link>
      <description>&lt;P&gt;I have a question for someone who's much better at JS and CSS than I am.&lt;/P&gt;

&lt;P&gt;I'm looking to place a data bar within a table, in a dashboard. There is a handy example in the app Splunk 6.x Dashboard Examples called Table Data Bar, which I have successfully used. I will post the code for the example below. The example does nearly exactly what I need, although my management is asking for the "negative space" of the bar to be filled with a color as well. Here's an example of a bar in a table, using green as the percentage marker, and red in the negative space of the bar:&lt;BR /&gt;
&lt;IMG src="https://community.splunk.com/storage/temp/204641-green-red-bar.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;Any help is greatly appreciated. Thank you!&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;App: Splunk 6.x Dashboard Examples&lt;/EM&gt; code:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;custom_table_data_bar.xml:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="table_data_bar.js" stylesheet="table_data_bar.css"&amp;gt;
    &amp;lt;label&amp;gt;Table Data Bar&amp;lt;/label&amp;gt;
    &amp;lt;description&amp;gt;Custom table cell renderer that replaces a field value with a data bar.&amp;lt;/description&amp;gt;
    &amp;lt;row&amp;gt;
        &amp;lt;table id="table1"&amp;gt;
            &amp;lt;title&amp;gt;Top Sourcetypes (Last 24 hours)&amp;lt;/title&amp;gt;
            &amp;lt;search&amp;gt;
                &amp;lt;query&amp;gt;index=_internal | top limit=100 sourcetype source&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;/search&amp;gt;
            &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&amp;gt;
            &amp;lt;option name="rowNumbers"&amp;gt;true&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;cell&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;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;table_data_bar.js:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'jquery',
    'underscore',
    'splunkjs/mvc',
    'views/shared/results_table/renderers/BaseCellRenderer',
    'splunkjs/mvc/simplexml/ready!'
], function($, _, mvc, BaseCellRenderer) {
    var DataBarCellRenderer = BaseCellRenderer.extend({
        canRender: function(cell) {
            return (cell.field === 'percent');
        },
        render: function($td, cell) {
            $td.addClass('data-bar-cell').html(_.template('&amp;lt;div class="data-bar-wrapper"&amp;gt;&amp;lt;div class="data-bar" style="width:&amp;lt;%- percent %&amp;gt;%"&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;', {
                percent: Math.min(Math.max(parseFloat(cell.value), 0), 100)
            }));
        }
    });
    mvc.Components.get('table1').getVisualization(function(tableView) {
        tableView.addCellRenderer(new DataBarCellRenderer());
    });
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;table_data_bar.css:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;td.data-bar-cell {
    padding: 4px 8px;
}
td.data-bar-cell .data-bar-wrapper .data-bar {
    height: 16px;
    min-width: 1px;
    background-color: #5479AF;
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any thoughts?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:18:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-Data-Bar-Customize/m-p/326064#M97211</guid>
      <dc:creator>adamsmith47</dc:creator>
      <dc:date>2020-09-29T14:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: Table Data Bar - Customize</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-Data-Bar-Customize/m-p/326065#M97212</link>
      <description>&lt;P&gt;What is the query for your stats? Or in other what how are you calculating percent? What is it going to represent?&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2017 19:48:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-Data-Bar-Customize/m-p/326065#M97212</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-06-02T19:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: Table Data Bar - Customize</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-Data-Bar-Customize/m-p/326066#M97213</link>
      <description>&lt;P&gt;Number of "foo"s + number of "bar"s = 100%&lt;/P&gt;

&lt;P&gt;When the bar in the table is displayed, I'd like percentage of "foo"s to be represented by a green portion, and percentage of "bar"s to be represented by a red portion, where the green+ red make up the entirety of the bar. (Similar to the pic I posted in the question)&lt;/P&gt;

&lt;P&gt;The form of the examples I've posted works, and I'm not looking for assistance with the calculations, just advice for how to add a second colored bar, to fill the remainder of the empty space above the percentage value. E.g., if the value is 0.30, I'd like bar to be 30% green, and 70% red.&lt;/P&gt;

&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2017 20:08:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-Data-Bar-Customize/m-p/326066#M97213</guid>
      <dc:creator>adamsmith47</dc:creator>
      <dc:date>2017-06-02T20:08:03Z</dc:date>
    </item>
    <item>
      <title>Re: Table Data Bar - Customize</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-Data-Bar-Customize/m-p/326067#M97214</link>
      <description>&lt;P&gt;I managed to achieve this by putting a second div in the background of the table cell.&lt;BR /&gt;
This code updates a column titled: "Progress" in a table with id : "table_instances"&lt;/P&gt;

&lt;P&gt;table_data_bar.js:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'jquery',
    'underscore',
    'splunkjs/mvc',
    'views/shared/results_table/renderers/BaseCellRenderer',
    'splunkjs/mvc/simplexml/ready!'
], function($, _, mvc, BaseCellRenderer) {
    var DataBarCellRenderer = BaseCellRenderer.extend({
        canRender: function(cell) {
            return (cell.field === 'Progress');
        },
        render: function($td, cell) {
            $td.addClass('data-bar-cell').html(_.template('&amp;lt;div class="data-bar-wrapper"&amp;gt;&amp;lt;div class="data-bar-back" style="width:100%"&amp;gt;&amp;lt;div class="data-bar" style="width:&amp;lt;%- percent %&amp;gt;%"&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;', {
                percent: Math.min(Math.max(parseFloat(cell.value), 0), 100)
            }));
        }
    });
    mvc.Components.get('table_instances').getVisualization(function(tableView) {
        tableView.addCellRenderer(new DataBarCellRenderer());
    });
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;table_data_bar.css:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;td.data-bar-cell {
    padding: 7px 4px;
}
td.data-bar-cell .data-bar-wrapper .data-bar-back .data-bar {
    position: relative;
    top: 0;
    right: 0;
    height: 10px;
    min-width: 1px;
    background-color: #30b5e2;
    border-radius: 5px;
}
td.data-bar-cell .data-bar-wrapper .data-bar-back {

    height: 10px;
    min-width: 1px;
    background-color: #e5e5e5;
    border-radius: 5px;
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:55:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-Data-Bar-Customize/m-p/326067#M97214</guid>
      <dc:creator>roryab</dc:creator>
      <dc:date>2020-09-29T18:55:34Z</dc:date>
    </item>
    <item>
      <title>Re: Table Data Bar - Customize</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-Data-Bar-Customize/m-p/326068#M97215</link>
      <description>&lt;P&gt;@roryab [Splunk], I think adding a div will just complicate. All that is required is to add &lt;CODE&gt;background-color&lt;/CODE&gt; as &lt;CODE&gt;red&lt;/CODE&gt; for &lt;CODE&gt;.data-bar-wrapper&lt;/CODE&gt; class and &lt;CODE&gt;green&lt;/CODE&gt; for &lt;CODE&gt;.data-bar&lt;/CODE&gt; class. However, I was not sure of the intention of this request.&lt;/P&gt;

&lt;P&gt;Following is the only change required for &lt;CODE&gt;Splunk Dashboard Example&lt;/CODE&gt; App's &lt;CODE&gt;Table with Data Bars&lt;/CODE&gt; example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;td.data-bar-cell .data-bar-wrapper{
     background-color: red;
}

td.data-bar-cell .data-bar-wrapper .data-bar {
     height: 16px;
     min-width: 1px;
     background-color: green;
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Apr 2018 15:19:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-Data-Bar-Customize/m-p/326068#M97215</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-04-10T15:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Table Data Bar - Customize</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-Data-Bar-Customize/m-p/326069#M97216</link>
      <description>&lt;P&gt;I had added rounded corners to the bar to make it look cool, just changing the background would not have sufficed for me but it looks like it would probably fit the OP's request.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2018 15:29:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-Data-Bar-Customize/m-p/326069#M97216</guid>
      <dc:creator>roryab</dc:creator>
      <dc:date>2018-04-10T15:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Table Data Bar - Customize</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Table-Data-Bar-Customize/m-p/326070#M97217</link>
      <description>&lt;P&gt;@adamsmith47 @roryab, refer to my answer : &lt;A href="https://answers.splunk.com/answers/694309/how-do-you-create-the-below-chart-in-splunk.html#answer-696835"&gt;https://answers.splunk.com/answers/694309/how-do-you-create-the-below-chart-in-splunk.html#answer-696835&lt;/A&gt; to create multiple sections in table data bar based on percent. The example display the value by default but shows actual percent of each segment as Tooltip text.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 21:47:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Table-Data-Bar-Customize/m-p/326070#M97217</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-11-06T21:47:47Z</dc:date>
    </item>
  </channel>
</rss>

