pie chart / not showing % option?

by aternoy » Mon Sep 19, 2016 11:45 am

if I create a pie chart such as this:

Image

I can show the label and how the data representing the volume.
But I can't show also the percentage.

Example:"
634 rows / 63%
"
Last edited by aternoy on Tue Sep 20, 2016 8:56 am, edited 1 time in total.
aternoy
 
Posts: 20
Joined: Mon Jun 13, 2016 1:09 pm

by aternoy » Mon Sep 19, 2016 11:45 am

can I do with a piece of code in the chart handler?
aternoy
 
Posts: 20
Joined: Mon Jun 13, 2016 1:09 pm

by Dmitry Kozlov » Mon Sep 19, 2016 12:50 pm

We can't see your screenshot.
User avatar
Dmitry Kozlov
 
Posts: 129
Joined: Wed Nov 12, 2014 3:24 pm

by aternoy » Tue Sep 20, 2016 8:57 am

Better ? (issue with Dropbox, apologies)
aternoy
 
Posts: 20
Joined: Mon Jun 13, 2016 1:09 pm

by Yuriy Medvedev » Wed Sep 21, 2016 9:26 am

You can just put in tab DataSource -> Advanced this code into handler.finish:
Code: Select all
var sum = 0;
  data.items.reduce(function(a, b) {
      sum+=a.value; // value is name of field which you calculate
  return b;
});
  $.each(data.items, function(index,object){
    object.sum = sum;});


and in Dashboard -> Style -> Labels -> template put this:
Code: Select all
#=Math.round((dataItem.value*100/dataItem.sum),1)# %


where "value" is name of field, which value you want to show.
User avatar
Yuriy Medvedev
 
Posts: 6
Joined: Mon Aug 29, 2016 2:27 pm

by aternoy » Thu Sep 22, 2016 10:35 am

added as requested:

Code: Select all
handlers.finish = function(data, logger) {
  logger.debug('Data is processed: ', data);
 
  var sum = 0;
  data.items.reduce(function(a, b) {
      sum+=a.dyrr; // value is name of field which you calculate
  return b;
});
  $.each(data.items, function(index,object){
    object.sum = sum;});
 
  return true;
}


the process failed:

11:35:06 DEBUG - Data is initialized: {
items: [object Object],[object Object],[object Object],[object Object],[object Object]
}
11:35:06 INFO - Initialization succeeded.
11:35:06 INFO - Request initialization succeeded.
11:35:06 INFO - Request succeeded.
11:35:06 INFO - Aggregation succeeded.
11:35:06 DEBUG - Data is processed: {
items: [object Object],
groups: [object Object]
}
11:35:06 ERROR - Post-processing failed: TypeError: data.items.reduce is not a function
aternoy
 
Posts: 20
Joined: Mon Jun 13, 2016 1:09 pm

by YuriyMedvedev » Mon Sep 26, 2016 3:59 pm

Try this one, please

var sum = 0;
$.each( data.items, function(index, object){
sum+= object.dyrr;})
$.each(data.items, function(index,object){
object.sum = sum;});
And tell, please, what browser do you use.
YuriyMedvedev
 
Posts: 14
Joined: Mon Sep 26, 2016 3:05 pm

by Auxak » Thu Oct 20, 2016 9:24 am

Hi,
I’m trying to do the same here and are using the example that you have posted. But I’m just getting NaN % om my graphs, any idea what I’m am doing wrong?
Attachments
2016-10-20_10-37-25.png
2016-10-20_10-37-25.png (11.03 KiB) Viewed 555 times
2016-10-20_10-35-31.png
2016-10-20_10-35-31.png (29.91 KiB) Viewed 555 times
Auxak
 
Posts: 4
Joined: Fri Sep 09, 2016 10:52 am

by Dmitry Kozlov » Thu Oct 20, 2016 9:29 am

Please, provide a screenshot of Dashboard -> Style -> Tooltip section.
User avatar
Dmitry Kozlov
 
Posts: 129
Joined: Wed Nov 12, 2014 3:24 pm

by Auxak » Thu Oct 20, 2016 9:35 am

Here it is.
Attachments
2016-10-20_11-33-33.png
2016-10-20_11-33-33.png (5.31 KiB) Viewed 555 times
Auxak
 
Posts: 4
Joined: Fri Sep 09, 2016 10:52 am

Next

Return to Dashboard Designer for SharePoint 2013

cron