How to use decimal number in core-plot?
I am trying to give float point into core-plot y axis value, it is not working. So is i need to give it as whole number instea开发者_开发问答d of decimal number.If decimal number works please give me the sample code.
Many axis properties take an NSDecimal value. Core Plot includes a number of utility functions to make it easier to create them. You can see examples of the usage throughout the example programs. Look for CPDecimalFromDouble
, CPDecimalFromFloat
, CPDecimalFromString
, etc.
For the plot data, you can provide any NSNumber
instance. Core Plot supports NSDecimalNumber
as well and will use higher-precision calculations when drawing the graph, although this comes at a performance cost.
You can make NSNUmber instance, then assign with NSDecimalNumber value. For example:
NSNumber *tmpNum = nil;
tmpNum = [[NSDecimalNumber decimalNumberWithDecimal:[[NSNumber numberWithFloat:yourFloat] decimalVaue]];
精彩评论