Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/102.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Coreplot中的轴标签修改_Ios_Cocoa Touch_Core Plot_Nsnumberformatter - Fatal编程技术网

Ios Coreplot中的轴标签修改

Ios Coreplot中的轴标签修改,ios,cocoa-touch,core-plot,nsnumberformatter,Ios,Cocoa Touch,Core Plot,Nsnumberformatter,我正在用自动命名策略在核心图中绘制一个图形 我的问题是图表中的数字非常高 例如,轴具有1000000.0 2000000.0 3000000.0 我想用某种方法把它们重写成1.00m、2.00m和3.00m 我查看了axis委托,但它只返回bool,而不是特定的标签。我还探讨了如何设置axis标签格式化程序,但这不能在末尾添加“m”,也不能将数字转换为类似于科学记数法的小数,而在末尾没有指数 答案是在轴上设置标签格式化程序。快速查看NSNumberFormatter的文档,您似乎可以通过组合使用

我正在用自动命名策略在核心图中绘制一个图形

我的问题是图表中的数字非常高

例如,轴具有1000000.0 2000000.0 3000000.0

我想用某种方法把它们重写成1.00m、2.00m和3.00m


我查看了axis委托,但它只返回bool,而不是特定的标签。我还探讨了如何设置axis标签格式化程序,但这不能在末尾添加“m”,也不能将数字转换为类似于科学记数法的小数,而在末尾没有指数

答案是在轴上设置标签格式化程序。快速查看NSNumberFormatter的文档,您似乎可以通过组合使用
setPositiveFormat
setMultiplier
setPositiveSuffix
来完成所需的工作

比如:

NSNumberFormatter *labelFormatter = [[NSNumberFormatter alloc] init];
[labelFormatter setPositiveFormat:@"#.##"];
[labelFormatter setPositiveSuffix:@"m"];
[labelFormatter setMultiplier:[NSNumber numberWithDouble:0.000001]];
axisSet.yAxis.labelFormatter = labelFormatter;
[labelFormatter release];
FWIW,这里不需要调用
setPositiveSuffix
,只需在格式字符串中包含“m”(
[labelFormatter setPositiveFormat:@“#.###m”]
),如果需要,可以省略该调用。为了完整起见,我将其包含在这里,以防您需要进行比此更复杂的格式化