How to get the tooltips to show constantly with the pie chart api

626 views
Skip to first unread message

skally

unread,
Aug 29, 2013, 2:57:46 AM8/29/13
to google-visua...@googlegroups.com


I'm interested in using a google pie chart and need it to display all the tooltips constantly. At the moment they come up individually on hover, just wondered if it's possible to do that by altering the js slightly?

Google says that you can use tooltip.trigger with either 'focus' which displays with hover or 'none' obviously to display nothing, but theres no function for show all. Can it be done by tweaking the javascript?

Heres the code:

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['Task', 'Hours per Day'],
          ['Toe',     38],
          ['Jam',      22],
          ['Earl',  2]
        ]);

        var options = {
          legend: 'none',
          lable: 'none',
          is3D: true,
          pieSliceText: 'none',
          slices: [{offset:0.1}, {offset:0.1}, {offset:0.1},],
          chartArea: {left:70,top:50,width:140,height:140},
          colors: ['#99C9FF','#B7B7B7', '#CCC'],
          pieSliceBorderColor: '#999',

        };

        var chart = new google.visualization.PieChart(document.getElementById('piechart_3d'));
        chart.draw(data, options);
      }
</script>

asgallant

unread,
Aug 29, 2013, 9:59:41 AM8/29/13
to google-visua...@googlegroups.com
No, you can't make all of the tooltips display at once.  You can, however, try using an undocumented option, setting legend.position to "labeled", which will display the slice name and value for each slice with leader lines pointing to the slices.  See an example here: http://jsfiddle.net/asgallant/KXsha/

skally

unread,
Aug 29, 2013, 1:31:29 PM8/29/13
to google-visua...@googlegroups.com

It's a shame because the tooltips look that much better than the labels. I saw that they haven't made any further developments with the pie, was just curious to see if some kind of custom coding would do the trick really.

Anyway, thanks very much for you help, I can see you do quite a lot around here.
Reply all
Reply to author
Forward
0 new messages