<?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: Visualizations like Chart , Single View in Modal Window in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Visualizations-like-Chart-Single-View-in-Modal-Window/m-p/486694#M31896</link>
    <description>&lt;P&gt;Great to hear &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Keep breaking those barriers!&lt;/P&gt;</description>
    <pubDate>Wed, 11 Mar 2020 13:24:24 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2020-03-11T13:24:24Z</dc:date>
    <item>
      <title>Visualizations like Chart , Single View in Modal Window</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Visualizations-like-Chart-Single-View-in-Modal-Window/m-p/486691#M31893</link>
      <description>&lt;P&gt;All,&lt;/P&gt;

&lt;P&gt;I was reusing the Modal Window project from Ian Gillespie as described in the Hurricane Labs Tutorial Project . &lt;/P&gt;

&lt;P&gt;This project shows a TABLE in the Modal Window , I would like to have different Visualizations like Chart, Single View Panels etc. &lt;/P&gt;

&lt;P&gt;Instead of using the &lt;STRONG&gt;TableView&lt;/STRONG&gt;, I tried changing it to &lt;STRONG&gt;ChartView&lt;/STRONG&gt; , &lt;STRONG&gt;ChartElement&lt;/STRONG&gt; etc, but I am not able to make it work.&lt;/P&gt;

&lt;P&gt;I still get the output as a Table in the Modal Window. &lt;/P&gt;

&lt;P&gt;Could someone teach me to do that ? It would be really helpful if an example is given on Single View apart from ChartView as well. &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Dashboard Code:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="modalviewsearchapp1.js"&amp;gt;
  &amp;lt;label&amp;gt;Modal Demo&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table id="master"&amp;gt;
        &amp;lt;title&amp;gt;Master&amp;lt;/title&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;-60m@m&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;!-- Set the type of of drilldown, since we will always consume the same field, use row--&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;row&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table id="slave"&amp;gt;
        &amp;lt;title&amp;gt;slave&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_internal 
| dedup group 
| table group&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-60m@m&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;!-- Set the type of of drilldown, since we will always consume the same field, use row--&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;row&amp;lt;/option&amp;gt;
      &amp;lt;/table&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;&lt;STRONG&gt;Script - "modalviewsearchapp1.js"&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'underscore',
    'backbone',
    '../app/search/components/ModalViews',
    'splunkjs/mvc',
    'splunkjs/mvc/searchmanager',
    'splunkjs/mvc/simplexml/ready!'
], function(_, Backbone, ModalView, mvc, SearchManager) {

    var master = mvc.Components.get("master");
    var tokens = mvc.Components.getInstance("submitted");
    var slave = mvc.Components.get("slave");

    var detailSearch = new SearchManager({
            id: "detailSearch",
            earliest_time: "-24h@h",
            latest_time: "now",
            preview: true,
            cache: false,
            search: "index=_internal sourcetype=$sourcetype$ | timechart count" 
    }, {tokens: true, tokenNamespace: "submitted"});  

    var detailedSearch = new SearchManager({
            id: "detailedSearch",
            earliest_time: "-24h@h",
            latest_time: "now",
            preview: true,
            cache: false,
            search: "index=_internal group=$group$ | chart count by sourcetype" 
    }, {tokens: true, tokenNamespace: "submitted"});  

    master.on("click", function(e) {
        e.preventDefault();
        if(e.field === "sourcetype") {
            var _title = e.data['click.value'];
            tokens.set('sourcetype', _title);
            var modal = new ModalView({ title: _title, search: detailSearch });
            modal.show();
        }

    });

        slave.on("click", function(e) {
        e.preventDefault();
        if(e.field === "group") {
            var _title = e.data['click.value'];
            tokens.set('group', _title);
            var modal = new ModalView({ title: _title, search: detailedSearch });
            modal.show();
        }

    });

});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Script - ModalViews&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;define([
    'underscore',
    'backbone',
    'jquery',
    'splunkjs/mvc',
    'splunkjs/mvc/searchmanager',
    'splunkjs/mvc/simplexml/element/table',
    'splunkjs/mvc/chartview',
    'splunkjs/mvc/simplexml/element/chart',
    'splunkjs/ready!'

    ], function(_, Backbone, $, mvc, SearchManager, ChartElement) {

        var modalTemplate = "&amp;lt;div id=\"pivotModal\" class=\"modal\"&amp;gt;" +
                       "&amp;lt;div class=\"modal-header\"&amp;gt;&amp;lt;h3&amp;gt;&amp;lt;%- title %&amp;gt;&amp;lt;/h3&amp;gt;&amp;lt;button class=\"close\"&amp;gt;Close&amp;lt;/button&amp;gt;&amp;lt;/div&amp;gt;" +
                       "&amp;lt;div class=\"modal-body\"&amp;gt;&amp;lt;/div&amp;gt;" +
                       "&amp;lt;div class=\"modal-footer\"&amp;gt;&amp;lt;/div&amp;gt;" +
                       "&amp;lt;/div&amp;gt;" +
                       "&amp;lt;div class=\"modal-backdrop\"&amp;gt;&amp;lt;/div&amp;gt;";

        var ModalView = Backbone.View.extend({

            defaults: {
               title: 'Not set'
            },        

            initialize: function(options) {
                this.options = options;
                this.options = _.extend({}, this.defaults, this.options);
                this.childViews = [];
                console.log('Hello from the modal window: ', this.options.title);
                this.template = _.template(modalTemplate);
            },

            events: {
               'click .close': 'close',
               'click .modal-backdrop': 'close'
            },

            render: function() {
                var data = { title : this.options.title };
                this.$el.html(this.template(data));
                return this;
            },

            show: function() {
                $(document.body).append(this.render().el);

                $(this.el).find('.modal-body').append('&amp;lt;div id="modalVizualization"/&amp;gt;');

                $(this.el).find('.modal').css({
                    width:'90%',
                    height:'auto',
                    left: '5%',
                    'margin-left': '0',
                    'max-height':'100%'
                });

                var search = mvc.Components.get(this.options.search.id);

                var detailTable = new ChartElement({
                        id: "detailTable",
                'charting.chart': 'pie'
                        managerid: search.name,

                        el: $('#modalVizualization')

                }).render();

                this.childViews.push(detailTable);
                search.startSearch();                
            },

            close: function() {
               this.unbind();
               this.remove();
               _.each(this.childViews, function(childView) {

                   childView.unbind();
                   childView.remove();

               });
            }

        });

        return ModalView;

});
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Mar 2020 11:10:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Visualizations-like-Chart-Single-View-in-Modal-Window/m-p/486691#M31893</guid>
      <dc:creator>njohnson7</dc:creator>
      <dc:date>2020-03-06T11:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Visualizations like Chart , Single View in Modal Window</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Visualizations-like-Chart-Single-View-in-Modal-Window/m-p/486692#M31894</link>
      <description>&lt;P&gt;@njohnson7 please consider the 10th topic of @jconger 's .Conf Presentation &lt;A href="https://conf.splunk.com/watch/conf-online.html?search=FN1278#/"&gt;10 Tips, Tricks and Hacks for Better Dashboards in Splunk&lt;/A&gt;, which is about &lt;CODE&gt;Event Handler + Token + Table Cell Render + Modal + Splunk Web Framework&lt;/CODE&gt;. If you follow his code you will find the working example of opening a Chart as Modal pop-up based on click on a table cell.&lt;/P&gt;

&lt;P&gt;Please try out and confirm!&lt;/P&gt;</description>
      <pubDate>Sat, 07 Mar 2020 13:43:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Visualizations-like-Chart-Single-View-in-Modal-Window/m-p/486692#M31894</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-03-07T13:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: Visualizations like Chart , Single View in Modal Window</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Visualizations-like-Chart-Single-View-in-Modal-Window/m-p/486693#M31895</link>
      <description>&lt;P&gt;@niketnilay - Thankyou , I did look at the material you suggested and I realized I was actually in the right direction- but for some reason it didn't work at that time. After seeing jconger's code, i tried modifying the code i posted above with ChartView, SingleView etc again and I achieved what I wanted , thank you once again. &lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 11:52:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Visualizations-like-Chart-Single-View-in-Modal-Window/m-p/486693#M31895</guid>
      <dc:creator>njohnson7</dc:creator>
      <dc:date>2020-03-11T11:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: Visualizations like Chart , Single View in Modal Window</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Visualizations-like-Chart-Single-View-in-Modal-Window/m-p/486694#M31896</link>
      <description>&lt;P&gt;Great to hear &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Keep breaking those barriers!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 13:24:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Visualizations-like-Chart-Single-View-in-Modal-Window/m-p/486694#M31896</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-03-11T13:24:24Z</dc:date>
    </item>
  </channel>
</rss>

