Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 5    Views: 40

MadRod
Aspiring developer
Profile
Posts: 1853
Reg: Apr 12, 2012
Lisbon
27,930
06/01/15 06:10 AM (9 years ago)

Pie Chart Values

Hey, using the pie chart plugin. How can I get a rounded number to show up? I input 33, and it shows up as 33.00 Thanks Miguel
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
06/01/15 06:23 AM (9 years ago)
I don't have the plugin ... A few suggestions without having seen the code. The reason the decimal point is displayed is because the Pie Slice value is a floating number. You want to change that to be an Integer value. Within the Plugin's code, look for "stringWithFormat". Change %f to %i for going from Float to Integer. You will also have to change the variable holding the value of the Pie Slice into an integer value: Cast the Float value to an Integer value like this: (int)pieSliceValue After you solve it, come on back and give us the solution :-) -- Niraj
 
MadRod
Aspiring developer
Profile
Posts: 1853
Reg: Apr 12, 2012
Lisbon
27,930
like
06/02/15 01:36 AM (9 years ago)
Than you Niraj. I found all the "stringWithFormat" and all those related to the value, (because some are related to percentage) i changed from %.2f to %i Just did that, and all seems ok. Thank you
 
MadRod
Aspiring developer
Profile
Posts: 1853
Reg: Apr 12, 2012
Lisbon
27,930
like
06/02/15 02:00 AM (9 years ago)
Hummm... apparently thats did not solve it. It did change the numbers but is now showing some different numbers from the one configured on the Cpanel....
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
06/02/15 02:57 AM (9 years ago)
Don't change everything. Change one at a time, verify and test each small change :-) -- Niraj
 
MadRod
Aspiring developer
Profile
Posts: 1853
Reg: Apr 12, 2012
Lisbon
27,930
like
06/03/15 11:51 AM (9 years ago)
Found it. I went here: //show title with value underneath BT_item *thisPiece = [self.menuItems objectAtIndex:index]; NSString *titleText = [BT_strings getJsonPropertyValue:thisPiece.jsonVars nameOfProperty:@"titleText" defaultValue:@""]; CGFloat value = [self pieChart:_pieChart valueForSliceAtIndex:index]; textForSlice = [NSString stringWithFormat:@"%@\n%.f", titleText, value]; If had a 2 before the f: textForSlice = [NSString stringWithFormat:@"%@\n%.2f", titleText, value]; I took it off. It seems ok. Thanks.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.