[ 3 posts ]

Martin Lindhe

  • Username: martin_lindhe
  • Joined: Fri Jan 14, 2011 2:42 am
  • Posts: 3
  • Offline
  • Profile

YUI3 PieChart and percentages

Post Posted: Fri Jan 21, 2011 1:56 am
+0-
Hello. I made a pie chart and wanted to make percentages show on tooltips.

I couldnt figure out if the "sum of all values" are available somewhere in the scope of the YUI chart so i ended up calculating it again.

However I was wondering since that value is calculated for the pie chart to be drawn anyway, if it could be exposed somehow for usage in tooltips

I ended up with something like this

Code:
$total_items = 0;
foreach ($this->data_source as $i)
    $total_items += $i['value'];


...

Code:
markerLabelFunction: function(categoryItem, valueItem, itemIndex, series, seriesIndex)
{
    return
    "<span style=\"text-decoration:underline\">" + categoryItem.value + "</span><br/><div style=\"margin-top:5px;font-weight:bold\">" + valueItem.value + " (" + Math.round(valueItem.value / '.$total_items.' * 100) + " %)</div>"
}

Tripp Bridges

YUI Developer

  • Username: tripp
  • Joined: Wed Jan 07, 2009 1:54 pm
  • Posts: 435
  • GitHub: tripp
  • Gists: tripp
  • YUI Developer
  • Offline
  • Profile
Tags:

Re: YUI3 PieChart and percentages

Post Posted: Fri Jan 21, 2011 9:30 am
+0-
Hi Martin,
You are correct. The total should be available. Please file a ticket and I will take care of it.

http://yuilibrary.com/projects/yui3/newticket

Thanks,
Tripp

Tripp Bridges

YUI Developer

  • Username: tripp
  • Joined: Wed Jan 07, 2009 1:54 pm
  • Posts: 435
  • GitHub: tripp
  • Gists: tripp
  • YUI Developer
  • Offline
  • Profile
Tags:

Re: YUI3 PieChart and percentages

Post Posted: Wed Jan 26, 2011 11:42 am
+0-
Ticket:
http://yuilibrary.com/projects/yui3/ticket/2529878
  [ 3 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum