<?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 add custom option to a panel? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-custom-option-to-a-panel/m-p/298504#M18922</link>
    <description>&lt;P&gt;SplunkJS v1.4 (which is SplunkJS in 6.5) definitely changed the structure of the Chart objects. The entire &lt;CODE&gt;options&lt;/CODE&gt; attribute is totally different, and the functions &lt;CODE&gt;settings.set()&lt;/CODE&gt; and &lt;CODE&gt;settings.get()&lt;/CODE&gt; seem to either not work the same way or expect something else from the old way of getting the charting options.&lt;/P&gt;

&lt;P&gt;I can't find any documentation or explanation of how to access the options like you used to, so my fear is that this may have been deprecated.&lt;/P&gt;</description>
    <pubDate>Mon, 20 Feb 2017 11:44:34 GMT</pubDate>
    <dc:creator>rjthibod</dc:creator>
    <dc:date>2017-02-20T11:44:34Z</dc:date>
    <item>
      <title>How to add custom option to a panel?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-custom-option-to-a-panel/m-p/298503#M18921</link>
      <description>&lt;P&gt;For Splunk 6.3.5 custom option things like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;option name="thisIsACustomThingy"&amp;gt;true&amp;lt;/option&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and then using it in a js extension like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;element.options.thisIsACustomThingy
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;worked. Unfortunately I cannot have it do the same in 6.5.1. For the simple xml part it says "unknown option", and the js cannot find this &lt;STRONG&gt;options&lt;/STRONG&gt; member, either. Any ideas on this?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 18:03:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-custom-option-to-a-panel/m-p/298503#M18921</guid>
      <dc:creator>zeinstein</dc:creator>
      <dc:date>2017-02-14T18:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to add custom option to a panel?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-custom-option-to-a-panel/m-p/298504#M18922</link>
      <description>&lt;P&gt;SplunkJS v1.4 (which is SplunkJS in 6.5) definitely changed the structure of the Chart objects. The entire &lt;CODE&gt;options&lt;/CODE&gt; attribute is totally different, and the functions &lt;CODE&gt;settings.set()&lt;/CODE&gt; and &lt;CODE&gt;settings.get()&lt;/CODE&gt; seem to either not work the same way or expect something else from the old way of getting the charting options.&lt;/P&gt;

&lt;P&gt;I can't find any documentation or explanation of how to access the options like you used to, so my fear is that this may have been deprecated.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2017 11:44:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-custom-option-to-a-panel/m-p/298504#M18922</guid>
      <dc:creator>rjthibod</dc:creator>
      <dc:date>2017-02-20T11:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to add custom option to a panel?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-custom-option-to-a-panel/m-p/298505#M18923</link>
      <description>&lt;P&gt;I discovered this as well. We managed to get around it using &lt;CODE&gt;data&lt;/CODE&gt; tags. Since you don't have any other code available, we will make some assumptions. Let's say you have a chart. It's &lt;CODE&gt;id&lt;/CODE&gt; is configured as &lt;CODE&gt;my_chart&lt;/CODE&gt;. I then created a panel such as this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;panel&amp;gt;&amp;lt;html&amp;gt;&amp;lt;div id="my_chart_settings" style="display:none;" data-thisisacustomthingy="true" /&amp;gt; &amp;lt;/html&amp;gt;&amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This item will store the "custom" settings for that chart. Now, in your extension JS, you can reference the data tags.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_(mvc.Components.toJSON()).chain().filter(function(el){
         var myId = $(el).attr("id"),
                custom_settings = $("#" + myId + "_settings").data();
         var my_option = custom_settings["thisisacustomthingy"];
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Without knowing much more than what you have presented, I can't say for certain that this will work 100% out of box. But it should get you starting point. It is more obtuse, but still gives you options.&lt;/P&gt;

&lt;P&gt;Find me on Slack/IRC if you want to discuss in real time.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 13:58:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-custom-option-to-a-panel/m-p/298505#M18923</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2017-02-21T13:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to add custom option to a panel?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-custom-option-to-a-panel/m-p/298506#M18924</link>
      <description>&lt;P&gt;I contacted the Devs behind the SplunkJS, and they were unaware 1) that is was possible to do that, and 2) people were doing that. The settings are now much stricter than before, which puts us out of luck. &lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 13:59:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-custom-option-to-a-panel/m-p/298506#M18924</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2017-02-21T13:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to add custom option to a panel?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-custom-option-to-a-panel/m-p/298507#M18925</link>
      <description>&lt;P&gt;Neat, I'll try it, thanks!&lt;BR /&gt;
(Btw, all the option name things work if I convert my whole dashboard to HTML.)&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 17:26:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-custom-option-to-a-panel/m-p/298507#M18925</guid>
      <dc:creator>zeinstein</dc:creator>
      <dc:date>2017-02-28T17:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to add custom option to a panel?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-custom-option-to-a-panel/m-p/298508#M18926</link>
      <description>&lt;P&gt;That's strange. I mean, it sounds like the new SplunkJS has less possibilities now than the previous one had... Thanks for contacting the Devs and letting me know this!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 17:28:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-custom-option-to-a-panel/m-p/298508#M18926</guid>
      <dc:creator>zeinstein</dc:creator>
      <dc:date>2017-02-28T17:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to add custom option to a panel?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-custom-option-to-a-panel/m-p/298509#M18927</link>
      <description>&lt;P&gt;Hey, so I've tried the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'jquery',
    'underscore',
    'splunkjs/mvc',
    'splunkjs/mvc/simplexml/ready!'
], function($, _, mvc) {
    _(mvc.Components.toJSON()).chain().each(function(el) {
        console.log($(el).attr("id"));
    });
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but it's not giving me anything for&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="test.js"&amp;gt;
  &amp;lt;label&amp;gt;test&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Test&amp;lt;/title&amp;gt;
      &amp;lt;chart id="my_chart"&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_internal | stats count by sourcetype&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-1d@d&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="charting.chart"&amp;gt;pie&amp;lt;/option&amp;gt;
        &amp;lt;option name="height"&amp;gt;357&amp;lt;/option&amp;gt;
      &amp;lt;/chart&amp;gt;
      &amp;lt;html id="my_chart_settings"&amp;gt;
        &amp;lt;div style="display:none;" data-thisisacustomthingy="true" /&amp;gt;
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I could get close to data-thisisacustomthingy by&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_(mvc.Components.toJSON()).chain().filter(function(el){
    if(el.id &amp;amp;&amp;amp; (el.id.match(/_settings$/) != null)) { return el;}
}).each(function(el){
    console.log(el.$(el).prevObject[0].children[0].firstChild);
(...)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but that looks so ugly (and it's not even there yet...).&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 11:53:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-custom-option-to-a-panel/m-p/298509#M18927</guid>
      <dc:creator>zeinstein</dc:creator>
      <dc:date>2017-03-01T11:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to add custom option to a panel?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-custom-option-to-a-panel/m-p/298510#M18928</link>
      <description>&lt;P&gt;so yeah, do that &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_(mvc_chain_function){
          return el;
}.each(function(el) {
    var elId = el.settings.get("id"),
           data =  $("#" + elId + "_settings").data();
 /// do stuff with data
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And your div needs to be:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;div id="my_chart_settings" data-thisisacustomthingy="true" /&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Don't name the HTML panel, name the element with the data.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 12:37:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-custom-option-to-a-panel/m-p/298510#M18928</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2017-03-01T12:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to add custom option to a panel?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-custom-option-to-a-panel/m-p/298511#M18929</link>
      <description>&lt;P&gt;Omg, it works. Thank you so much! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 15:51:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-custom-option-to-a-panel/m-p/298511#M18929</guid>
      <dc:creator>zeinstein</dc:creator>
      <dc:date>2017-03-01T15:51:25Z</dc:date>
    </item>
  </channel>
</rss>

