Project

General

Profile

Actions

Bug #3533

closed

WPieChart label percentages are sometimes wrong

Added by Stefan Ruppert over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
08/19/2014
Due date:
% Done:

0%

Estimated time:

Description

Hi,

see attached screenshot. More than 100% ;-)

To resolve this issue I would propose to add a setPercentagePrecision() method:

emun Precision
{
   PrecisionAuto, ///< %.3g
   Precision0,    ///< %.0f
   Precision1,    ///< %.1f
   Precision2,    ///< %.2f
   Precision3,    ///< %.3f
};

WPieChart::setPercentagePrecision(Precision prec)
{
   prec_ = prec;
}

WPieChart::labelText()
{
   ...
   double per = val / total * 100.0;
   switch(prec_) {
   case PrecisionAuto:
      snprintf(buf, sizeof(buf), "%.3g%%", pre);
      break;
   case Precision0:
      snprintf(buf, sizeof(buf), "%.0f%%", pre);
      break;
   case Precision1:
      snprintf(buf, sizeof(buf), "%.1f%%", pre);
      break;
      ....
   }
   ...
}

and using:

setPercentagePrecision(Precision2);

Any comments?

Stefan


Files

WPieChart-issue.png (8.01 KB) WPieChart-issue.png Stefan Ruppert, 08/19/2014 09:35 PM
Actions #1

Updated by Stefan Ruppert over 9 years ago

Here are the counts:

Good count: 6824

Not Stopped count: 1

Total count: 6825

Actions #2

Updated by Koen Deforche over 9 years ago

  • Status changed from New to InProgress
  • Assignee set to Koen Deforche
  • Target version set to 3.3.4
Actions #3

Updated by Koen Deforche over 9 years ago

  • Status changed from InProgress to Resolved

We've added a WPieChart::setLabelFormat() method which behaves in the same way as WAxis::setLabelFormat().

In this way you can use setLabelFormat(".2f%");

Actions #4

Updated by Koen Deforche over 9 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF