<?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: How to change the width of two dashboard panels in the first row from 50% 50% to 75% 25% in Simple XML for Splunk 6.2? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-change-the-width-of-two-dashboard-panels-in-the-first-row/m-p/189634#M11791</link>
    <description>&lt;P&gt;the .js from the example did the trick! thank you so much &lt;/P&gt;</description>
    <pubDate>Fri, 31 Oct 2014 14:25:46 GMT</pubDate>
    <dc:creator>kkuderko</dc:creator>
    <dc:date>2014-10-31T14:25:46Z</dc:date>
    <item>
      <title>How to change the width of two dashboard panels in the first row from 50% 50% to 75% 25% in Simple XML for Splunk 6.2?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-change-the-width-of-two-dashboard-panels-in-the-first-row/m-p/189632#M11789</link>
      <description>&lt;P&gt;In a simple XML dashboard, how do I change a width of two panels in the first row from 50% 50% to 75% 25% ratio?&lt;BR /&gt;
I tried many solutions from this forum and none worked. I use Splunk 6.2. and tried to restart after any changes I made.&lt;BR /&gt;
I created new files and added &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="custom_width.js" stylesheet="custom_width.css"&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and also edited application.css file in &lt;CODE&gt;c:\Program Files\Splunk\etc\apps\search\appserver\static\&lt;/CODE&gt; but it's like those custom changes dont take priority. &lt;BR /&gt;
I'm also not quite sure what class I should define there. When I inspect element in firefox I can see&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;div id="panel1" class="dashboard-cell" style="width: 50%;"&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and when I edit manually to 75% I get the desired width. So what should I put and in which css to change the panel width?&lt;BR /&gt;
I'm new to splunk and have only been using it for couple of days, but really didn't suspect changing the panel size on the dashboard would be so complicated..&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Fri, 31 Oct 2014 00:10:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-change-the-width-of-two-dashboard-panels-in-the-first-row/m-p/189632#M11789</guid>
      <dc:creator>kkuderko</dc:creator>
      <dc:date>2014-10-31T00:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to change the width of two dashboard panels in the first row from 50% 50% to 75% 25% in Simple XML for Splunk 6.2?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-change-the-width-of-two-dashboard-panels-in-the-first-row/m-p/189633#M11790</link>
      <description>&lt;P&gt;Grab the Splunk 6 Dashboard Examples app from &lt;A href="https://apps.splunk.com/app/1603/"&gt;https://apps.splunk.com/app/1603/&lt;/A&gt; and follow the Layout Customization example.&lt;/P&gt;

&lt;P&gt;In short, Splunk distributes the width evenly automatically, so your CSS is overwritten all the time. You can get around that by supplying a small JavaScript file that sets the width as you need it.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Oct 2014 09:49:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-change-the-width-of-two-dashboard-panels-in-the-first-row/m-p/189633#M11790</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-10-31T09:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to change the width of two dashboard panels in the first row from 50% 50% to 75% 25% in Simple XML for Splunk 6.2?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-change-the-width-of-two-dashboard-panels-in-the-first-row/m-p/189634#M11791</link>
      <description>&lt;P&gt;the .js from the example did the trick! thank you so much &lt;/P&gt;</description>
      <pubDate>Fri, 31 Oct 2014 14:25:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-change-the-width-of-two-dashboard-panels-in-the-first-row/m-p/189634#M11791</guid>
      <dc:creator>kkuderko</dc:creator>
      <dc:date>2014-10-31T14:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to change the width of two dashboard panels in the first row from 50% 50% to 75% 25% in Simple XML for Splunk 6.2?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-change-the-width-of-two-dashboard-panels-in-the-first-row/m-p/189635#M11792</link>
      <description>&lt;P&gt;Is there possibility to do this only in SplunkWeb?&lt;BR /&gt;
If not, you would have to contact Splunk-Admins each time you want to edit panel-width?!&lt;/P&gt;</description>
      <pubDate>Thu, 27 Nov 2014 11:01:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-change-the-width-of-two-dashboard-panels-in-the-first-row/m-p/189635#M11792</guid>
      <dc:creator>goelli</dc:creator>
      <dc:date>2014-11-27T11:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to change the width of two dashboard panels in the first row from 50% 50% to 75% 25% in Simple XML for Splunk 6.2?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-change-the-width-of-two-dashboard-panels-in-the-first-row/m-p/189636#M11793</link>
      <description>&lt;P&gt;You can solve that by making the JS a bit smarter, for example like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require(['jquery', 'splunkjs/mvc/simplexml/ready!'], function($) {
    $("[id*=setWidth]").each(function() {
        var match = /setWidth_(\d+(?:_\d+)?)/.exec($(this).attr('id'));
        if (match[1]) {
            $(this).closest(".dashboard-cell").css('width', match[1].replace("_", ".") + '%');
        }
    });
    // Force visualizations (esp. charts) to be redrawn with their new size
    $(window).trigger('resize');
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Using this, you can append &lt;CODE&gt;setWidth_12_34&lt;/CODE&gt; to your panel's &lt;CODE&gt;id&lt;/CODE&gt; attribute and the JS will set the width for that panel to &lt;CODE&gt;12.34%&lt;/CODE&gt;. Using that, you can produce dashboards like this&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/134i7F1EB3DD68C2D817/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;with one generic .js file and setting the width from within SimpleXML. The first row has the width set for all panels, the second row for no panels, and the third row only for the second and third panel, adding up to two thirds of course.&lt;/P&gt;

&lt;P&gt;Dashboard XML looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="custom_layout_width.js"&amp;gt;
  &amp;lt;label&amp;gt;JS Width&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel id="panel1_setWidth_30"&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;search&amp;gt;&amp;lt;query&amp;gt;| stats count | eval count = 1&amp;lt;/query&amp;gt;&amp;lt;/search&amp;gt;
      &amp;lt;/single&amp;gt;
    &amp;lt;/panel&amp;gt;
    &amp;lt;panel id="panel2_setWidth_30"&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;search&amp;gt;&amp;lt;query&amp;gt;| stats count | eval count = 2&amp;lt;/query&amp;gt;&amp;lt;/search&amp;gt;
      &amp;lt;/single&amp;gt;
    &amp;lt;/panel&amp;gt;
    &amp;lt;panel id="panel3_setWidth_40"&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;search&amp;gt;&amp;lt;query&amp;gt;| stats count | eval count = 3&amp;lt;/query&amp;gt;&amp;lt;/search&amp;gt;
      &amp;lt;/single&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
...
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Nov 2014 20:57:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-change-the-width-of-two-dashboard-panels-in-the-first-row/m-p/189636#M11793</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-11-27T20:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to change the width of two dashboard panels in the first row from 50% 50% to 75% 25% in Simple XML for Splunk 6.2?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-change-the-width-of-two-dashboard-panels-in-the-first-row/m-p/189637#M11794</link>
      <description>&lt;P&gt;I took Martins approach and changed it a little. Now you can:&lt;BR /&gt;
(a) use the pixel unit ( myidname_setWidth_200px)&lt;BR /&gt;
(b) remove the width property of a panel (myidname_none)&lt;BR /&gt;
(c) use "percent" as default unit (myidname_setWidth_30 OR myidname_setWidth_30_percent)&lt;BR /&gt;
(d) fill up the remaining space of fixed panels (panel1_setWidth_300px and panel2_setWidth_fill_300)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require(['jquery', 'splunkjs/mvc/simplexml/ready!'], function($) {
    $("[id*=setWidth]").each(function() {
        var match = /setWidth_(\d+)?(_)?(percent|px|pixel|none|fill)?(_)?(\d+)?(_)?(left|right)?/.exec($(this).attr('id'));
        console.log("matches\nmatch 1: "+match[1]+"\nmatch 2: "+match[2]+"\nmatch 3:"+match[3]+"\n");
        if (match[1]) {
            if (match[3] == 'percent' || match[3] == '') {
                $(this).closest(".dashboard-cell").css('width', match[1]+'%');
            }
            else if (match[3] == 'px' || match[3] == 'pixel') {
                $(this).closest(".dashboard-cell").css('width', match[1]+'px');
            }
        }
        else if (match[3] == 'none') {
            $(this).closest(".dashboard-cell").css('width', '');
        }
        else if (match[3] == 'fill') {
            if (match[5]) {
                $(this).closest(".dashboard-cell").css('width', 'calc(100% - '+match[5]+'px)');
            }
        }
    });
    $(window).trigger('resize');
});
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:28:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-change-the-width-of-two-dashboard-panels-in-the-first-row/m-p/189637#M11794</guid>
      <dc:creator>bjoernjensen</dc:creator>
      <dc:date>2020-09-28T18:28:47Z</dc:date>
    </item>
  </channel>
</rss>

