<?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 do I get results from Splunk searchmanager JavaScript into Google JavaScript API to draw charts? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-results-from-Splunk-searchmanager-JavaScript-into/m-p/174754#M50150</link>
    <description>&lt;P&gt;Thanks for the input.&lt;BR /&gt;
There are two problems with this approach.&lt;BR /&gt;
First row with data is assigned to fields and Splunk returns all data as string (even numbers), so Google API can`t draw charts (but can show it as a table).&lt;/P&gt;

&lt;P&gt;[]'s&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jun 2015 12:25:53 GMT</pubDate>
    <dc:creator>pedromvieira</dc:creator>
    <dc:date>2015-06-25T12:25:53Z</dc:date>
    <item>
      <title>How do I get results from Splunk searchmanager JavaScript into Google JavaScript API to draw charts?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-results-from-Splunk-searchmanager-JavaScript-into/m-p/174752#M50148</link>
      <description>&lt;P&gt;How to get data results from a searchmanager javascript into google jsapi to draw charts?&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;All My Searches and PostProcess are working.&lt;/LI&gt;
&lt;LI&gt;I can draw charts with Splunk Components.&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;I can get results to my console&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        var Data1 = splunkjs.mvc.Components.getInstance("SEARCH_1");
        var Data1_Results = Data1.data("results") ;
        Data1_Results.on("data", function() {
            console.log("Has data? ", Data1_Results.hasData());
            console.log("Data (rows): ", Data1_Results.data().rows);
            console.log("Backbone collection: (rows) ", Data1_Results.collection().raw.rows);
        });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also can test Google JS API inside my site:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;script type="text/javascript" src="https://www.google.com/jsapi"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type="text/javascript"&amp;gt;
    google.load("visualization", "1", {packages:["corechart"]});
    google.setOnLoadCallback(drawChart);
    function drawChart() {
        var data = google.visualization.arrayToDataTable([
            ['OPTION', '#'],
            ['YES', 4],
            ['NO', 7]
        ]);
        var options = {
            // title: 'Clicked',
            is3D: true,
            legend: 'none',
            pieHole: 0.4,
            pieSliceText: 'label',
            slices: {
                0: { color: 'red', offset: 0.6 }, // YES
                1: { color: 'gray', offset: 0.0 } // NO
            },
        };
        var chart = new google.visualization.PieChart(document.getElementById('g_chart_1'));
        chart.draw(data, options);
    }
&amp;lt;/script&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can I use my Search Results (Data1_Results) to populate my Google Chart data?&lt;/P&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2015 21:11:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-results-from-Splunk-searchmanager-JavaScript-into/m-p/174752#M50148</guid>
      <dc:creator>pedromvieira</dc:creator>
      <dc:date>2015-06-24T21:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get results from Splunk searchmanager JavaScript into Google JavaScript API to draw charts?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-results-from-Splunk-searchmanager-JavaScript-into/m-p/174753#M50149</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;You can validate if the Google API visualization is working for a dummy data or not.  This dummy data should be an array and should be passed externally. &lt;/P&gt;

&lt;P&gt;Once this is working, then simply replace the dummy array with &lt;STRONG&gt;Data1_Results.data().rows&lt;/STRONG&gt;. Basically, pass this data to Google API as if you are passing a JSON object to API.&lt;/P&gt;

&lt;P&gt;Thanks!!&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2015 10:41:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-results-from-Splunk-searchmanager-JavaScript-into/m-p/174753#M50149</guid>
      <dc:creator>vganjare</dc:creator>
      <dc:date>2015-06-25T10:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get results from Splunk searchmanager JavaScript into Google JavaScript API to draw charts?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-results-from-Splunk-searchmanager-JavaScript-into/m-p/174754#M50150</link>
      <description>&lt;P&gt;Thanks for the input.&lt;BR /&gt;
There are two problems with this approach.&lt;BR /&gt;
First row with data is assigned to fields and Splunk returns all data as string (even numbers), so Google API can`t draw charts (but can show it as a table).&lt;/P&gt;

&lt;P&gt;[]'s&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2015 12:25:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-results-from-Splunk-searchmanager-JavaScript-into/m-p/174754#M50150</guid>
      <dc:creator>pedromvieira</dc:creator>
      <dc:date>2015-06-25T12:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get results from Splunk searchmanager JavaScript into Google JavaScript API to draw charts?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-results-from-Splunk-searchmanager-JavaScript-into/m-p/174755#M50151</link>
      <description>&lt;P&gt;Not sure if your comment is trimmed.&lt;/P&gt;

&lt;P&gt;For the data type issues, you can create a &lt;STRONG&gt;parser&lt;/STRONG&gt; module. Depending on the column name, it can return the number or string or boolean from the module (or function) itself.&lt;/P&gt;

&lt;P&gt;Again, this is just an approach and not a complete solution.&lt;/P&gt;

&lt;P&gt;Thanks!!&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2015 12:36:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-results-from-Splunk-searchmanager-JavaScript-into/m-p/174755#M50151</guid>
      <dc:creator>vganjare</dc:creator>
      <dc:date>2015-06-25T12:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get results from Splunk searchmanager JavaScript into Google JavaScript API to draw charts?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-results-from-Splunk-searchmanager-JavaScript-into/m-p/174756#M50152</link>
      <description>&lt;P&gt;My current code that works only for Tables:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;                data.addColumn('string', 'OPTION');
                data.addColumn('string', '#');
                var rows = Data5.data().rows;
                data.addRows(rows);
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My Data is like:&lt;/P&gt;

&lt;P&gt;[&lt;BR /&gt;
          ['Option', '#'],&lt;BR /&gt;
          ['Work',     11],&lt;BR /&gt;
          ['Eat',      2],&lt;BR /&gt;
          ['Commute',  2],&lt;BR /&gt;
          ['Watch TV', 2],&lt;BR /&gt;
          ['Sleep',    7]&lt;BR /&gt;
        ]&lt;/P&gt;

&lt;P&gt;Is there a way to parseInt the return of Splunk data().rows?&lt;BR /&gt;
Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2015 14:14:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-results-from-Splunk-searchmanager-JavaScript-into/m-p/174756#M50152</guid>
      <dc:creator>pedromvieira</dc:creator>
      <dc:date>2015-06-25T14:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get results from Splunk searchmanager JavaScript into Google JavaScript API to draw charts?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-results-from-Splunk-searchmanager-JavaScript-into/m-p/174757#M50153</link>
      <description>&lt;P&gt;You will have to write new function to create data in expected format. Something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var parseSplunkData = function(rows){
    var parsedData = [];
    for(var i in rows){
        if(i &amp;amp;&amp;amp; rows[i]){
            var row = rows[i];
            var data = {
                'Option' : row.option, //Validate is row.option is available or not
                'Count' : parseInt(row.count) //Validate is row.count is available or not
            }
            parsedData.push(data);
        }
    }
    //Use the parsedData and pass it to Google API.
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Jun 2015 06:25:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-results-from-Splunk-searchmanager-JavaScript-into/m-p/174757#M50153</guid>
      <dc:creator>vganjare</dc:creator>
      <dc:date>2015-06-26T06:25:45Z</dc:date>
    </item>
  </channel>
</rss>

