<?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: Is it possible to show a custom tooltip whenever a user hovers over a slice of a pie chart, or column in a bar chart using Simple XML with splunk js? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202673#M58826</link>
    <description>&lt;P&gt;I meant, take a path from that id instead of &lt;CODE&gt;#highcharts-number-foo&lt;/CODE&gt;, where foo can be arbitrary. Something like this should do it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#src_pie &amp;gt; div.panel-body &amp;gt; div.splunk-view &amp;gt; div &amp;gt; div.chart &amp;gt; div &amp;gt; div &amp;gt; svg &amp;gt; g.highcharts-series-group &amp;gt; g.highcharts-series.highcharts-tracker
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 13 Jan 2016 10:17:41 GMT</pubDate>
    <dc:creator>jeffland</dc:creator>
    <dc:date>2016-01-13T10:17:41Z</dc:date>
    <item>
      <title>Is it possible to show a custom tooltip whenever a user hovers over a slice of a pie chart, or column in a bar chart using Simple XML with splunk js?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202668#M58821</link>
      <description>&lt;P&gt;Is it possible to show a custom tooltip whenever a user hovers over a slice of a pie chart, or column in a bar chart?  I have been looking at this &lt;A href="http://blogs.splunk.com/2014/01/29/add-a-tooltip-to-simple-xml-tables-with-bootstrap-and-a-custom-cell-renderer/"&gt;blog about adding custom tooltip to a table&lt;/A&gt;, but I cannot see how to apply that to a chart.  The ChartView in splunkjs does not have similar methods as the TableView for adding a renderer.  &lt;/P&gt;

&lt;P&gt;I  have data that contains a code (userid) and the name associated with the code (among other things).  I am creating a pie chart to display counts by code.  However, when the user hovers over the pie-slice, I want to display the code, the name and the counts/percentage in the tooltip.  Customers want to count by code, but be able to see what the code maps to in the tooltip.  My search looks like this:&lt;/P&gt;

&lt;P&gt;index=yc | stats sum(counts) as counts values(fullName) as fullName by userid| sort -counts | head 10&lt;/P&gt;

&lt;P&gt;In statistics view, this gives me:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;userid         count                 fullName&lt;/STRONG&gt;&lt;BR /&gt;
jdoe           35424                    John Doe&lt;BR /&gt;
bsmith           4342                 Bob Smith&lt;BR /&gt;
mjones           4212                 Mary Jones&lt;BR /&gt;
jdoeadeer       1234                John Doe&lt;/P&gt;

&lt;P&gt;...     &lt;/P&gt;

&lt;P&gt;So if the user hovers over the largest pie slice I'd like the tooltip to display &lt;BR /&gt;
userid: jdoe&lt;BR /&gt;
fullName: John Doe&lt;BR /&gt;
counts: 35424&lt;BR /&gt;
counts%: 78.2&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2015 21:09:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202668#M58821</guid>
      <dc:creator>lyndac</dc:creator>
      <dc:date>2015-12-29T21:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to show a custom tooltip whenever a user hovers over a slice of a pie chart, or column in a bar chart using Simple XML with splunk js?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202669#M58822</link>
      <description>&lt;P&gt;This is not yet a complete solution, but it should get you going in the right direction. I had some code for this for Splunk 6.2.5, but since then, some things have changed on the dashboards regarding DOM selection... See how far you want to take it from here.&lt;/P&gt;

&lt;P&gt;The idea is to fetch the required field, in your case fullName, from the search manager and add a new row to the tooltip containing that info. You need to add some javascript to your dashboard:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'underscore',
    'jquery',
    'splunkjs/mvc',
    'splunkjs/mvc/searchmanager',
    'splunkjs/mvc/simplexml/ready!'
], function (_, $, mvc, SearchManager) {
    // get the search manager
    var search = splunkjs.mvc.Components.getInstance("pie");
    // get its results
    var myResults = search.data("results");
    var resultArray = [];
    myResults.on("data", function() {
        resultArray = myResults.data().rows;
    });
    // add info when opening tooltip (delegate event listening)
    $("#chart").on("mouseover", "#highcharts-0 &amp;gt; svg &amp;gt; g.highcharts-series-group &amp;gt; g.highcharts-series.highcharts-tracker", function(){
        // get title to compare which series of the chart we're looking at
        var title = $("table.highcharts-tooltip &amp;gt; tbody &amp;gt; tr:nth-child(1) &amp;gt; td:nth-child(2)").text();
        // select right row
        var fullName = "";
        for (var i = 0; i &amp;lt; resultArray.length; i++){
            if (title == resultArray[i][0]){
                fullName = resultArray[i][2];
                break;
            }
        }
        // add (or change) the date shown in the tooltip
        var text = '&amp;lt;tr class="unique"&amp;gt;&amp;lt;td style="text-align: left; color: #cccccc; max-width: 663.9180019451253px;"&amp;gt;Full Name&amp;lt;/td&amp;gt;&amp;lt;td style="text-align: right; color: #ffffff; max-width: 572.0819980548747px;"&amp;gt;';
        if ($("table.highcharts-tooltip &amp;gt; tbody").find("tr.unique").length == 0) {
            $("table.highcharts-tooltip &amp;gt; tbody").append(text+fullName+'&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;');
        } else {
            $("table.highcharts-tooltip &amp;gt; tbody &amp;gt; tr.unique").replaceWith(text+fullName+'&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;');
        }
        // re-calculate the size of the black box behind the text
        var height = $("table.highcharts-tooltip").height();
        var width = $("table.highcharts-tooltip").width();
        var node = $("g.highcharts-tooltip")[0];
        var bbox = node.getBBox();
        var w = width / bbox.width;
        var h = height / bbox.height;
        var scalex = w*1.15, scaley = h*1.15;
        var scalestr = scalex + ',' + scaley;
        var regex = /(\w+\(\d+\,\d+\))/; // one way to make sure we only add scale once
        node.setAttribute('transform',regex.exec(node.getAttribute("transform"))[0]+'scale('+scalestr+')');
    });
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This assumes your search manager has an id "pie", and your chart has an id "chart". This particular example works for the first chart on a dashboard, you will have to adjust the selectors accordingly.&lt;BR /&gt;
Feel free to come back with any questions!&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2016 14:40:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202669#M58822</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2016-01-11T14:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to show a custom tooltip whenever a user hovers over a slice of a pie chart, or column in a bar chart using Simple XML with splunk js?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202670#M58823</link>
      <description>&lt;P&gt;I implemented this javascript and it worked great until the brower cache got cleared!  &lt;/P&gt;

&lt;P&gt;On line 16, you use highcharts-0 since you are working with the first chart.  I determined that chart I want to work with is #highcharts-24.  That worked great yesterday.  But today, the name is highcharts-22 and it changes sometimes when I do a ctrl-refresh.  It has been highcharts-22, highcharts-18, highcharts-16.  Is there a way to make that name static so I can rely on it in the javascript?  Or some other way around this issue?&lt;/P&gt;

&lt;P&gt;Thanks for your help&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2016 15:31:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202670#M58823</guid>
      <dc:creator>lyndac</dc:creator>
      <dc:date>2016-01-12T15:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to show a custom tooltip whenever a user hovers over a slice of a pie chart, or column in a bar chart using Simple XML with splunk js?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202671#M58824</link>
      <description>&lt;P&gt;You could give your chart an id and go from there.&lt;BR /&gt;
I know it's a mess when you start to fiddle with this stuff... &lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2016 15:54:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202671#M58824</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2016-01-12T15:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to show a custom tooltip whenever a user hovers over a slice of a pie chart, or column in a bar chart using Simple XML with splunk js?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202672#M58825</link>
      <description>&lt;P&gt;The chart does have an id:  in simple xml, i set chart id="src_pie"&lt;/P&gt;

&lt;P&gt;My javascript looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var srcpie=splunkjs.mvc.Components.getInstance("src_pie");
var searchMgr = srcpie.settings.get("managerid");
var search= splunkjs.mvc.Components.get(searchMgr);

var myResults = search.data("results");
var resultArray = [];
myResults.on("data", function() {
     resultArray=myResults.data().rows;
});

$("#src_pie").on("mouseover", "#highcharts-24.highcharts-container &amp;gt; svg &amp;gt; g.highcharts-series-group &amp;gt; g.highcharts-series.highcharts-tracker", function() {
...
});
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Jan 2016 16:30:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202672#M58825</guid>
      <dc:creator>lyndac</dc:creator>
      <dc:date>2016-01-12T16:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to show a custom tooltip whenever a user hovers over a slice of a pie chart, or column in a bar chart using Simple XML with splunk js?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202673#M58826</link>
      <description>&lt;P&gt;I meant, take a path from that id instead of &lt;CODE&gt;#highcharts-number-foo&lt;/CODE&gt;, where foo can be arbitrary. Something like this should do it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#src_pie &amp;gt; div.panel-body &amp;gt; div.splunk-view &amp;gt; div &amp;gt; div.chart &amp;gt; div &amp;gt; div &amp;gt; svg &amp;gt; g.highcharts-series-group &amp;gt; g.highcharts-series.highcharts-tracker
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jan 2016 10:17:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202673#M58826</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2016-01-13T10:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to show a custom tooltip whenever a user hovers over a slice of a pie chart, or column in a bar chart using Simple XML with splunk js?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202674#M58827</link>
      <description>&lt;P&gt;I got it to work by using:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; $("#src_pie").on("mouseover", "[id^highcharts].highcharts-container &amp;gt; svg &amp;gt; g.highcharts-series-group &amp;gt; g.highcharts-series.highcharts-tracker", function() {
 ...
 })
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks for all your help!&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2016 19:05:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202674#M58827</guid>
      <dc:creator>lyndac</dc:creator>
      <dc:date>2016-01-15T19:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to show a custom tooltip whenever a user hovers over a slice of a pie chart, or column in a bar chart using Simple XML with splunk js?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202675#M58828</link>
      <description>&lt;P&gt;kindly explain what do you mean by [id^highcharts] this code . and can we use .".highcharts-container &amp;gt; svg &amp;gt; g.highcharts-series-group &amp;gt; g.highcharts-series.highcharts-tracker"&lt;BR /&gt;
this directly ?&lt;/P&gt;</description>
      <pubDate>Sat, 09 Apr 2016 14:30:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202675#M58828</guid>
      <dc:creator>splunk24</dc:creator>
      <dc:date>2016-04-09T14:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to show a custom tooltip whenever a user hovers over a slice of a pie chart, or column in a bar chart using Simple XML with splunk js?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202676#M58829</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
What do you mean by [id^highcharts] ? you replace it by something ?&lt;BR /&gt;
Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 10:21:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202676#M58829</guid>
      <dc:creator>mleProso</dc:creator>
      <dc:date>2016-11-21T10:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to show a custom tooltip whenever a user hovers over a slice of a pie chart, or column in a bar chart using Simple XML with splunk js?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202677#M58830</link>
      <description>&lt;P&gt;Hi. Where should I define the id=pie using search manager?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 09:18:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202677#M58830</guid>
      <dc:creator>michaelrosello</dc:creator>
      <dc:date>2018-07-06T09:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to show a custom tooltip whenever a user hovers over a slice of a pie chart, or column in a bar chart using Simple XML with splunk js?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202678#M58831</link>
      <description>&lt;P&gt;You assign it in Simple XML like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
&amp;lt;chart&amp;gt;
  &amp;lt;search id="pie"&amp;gt;
    &amp;lt;query&amp;gt;...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Aug 2018 06:09:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-show-a-custom-tooltip-whenever-a-user-hovers/m-p/202678#M58831</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2018-08-03T06:09:15Z</dc:date>
    </item>
  </channel>
</rss>

