我正在使用自动标注(CPTAxisLabelingPolicyAutomatic)和CPTCalendarFormatter格式化程序来格式化我的x轴 - 到目前为止一直很好。
但是,我的图表在其容器中是全宽的,因此,图表边缘的2个标签被剪裁。见下文:
是否有一种简单的方法来格式化第一个和最后一个标签上的填充,以便它们位于图形中,而不是超出它?
谢谢!
答案 0 :(得分:2)
如果我理解你的问题,你希望标签适合图表,(不要超出图的边缘)。
我认为你有两种选择:
如何设置自己的标签位置示例:
CPTXYAxisSet *axisSet; //your graph's axis set;
NSSet *labelPositions; //some set containing positions of all labels stored as NSNumbers
[axisSet.xAxis setLabelingPolicy:CPTAxisLabelingPolicyLocationsProvided];
[axisSet.xAxis setMajorTickLocations:labelPositions];
答案 1 :(得分:0)
在绘图区域框架上设置一些填充,为标签留出空间:
graph.plotAreaFrame.paddingLeft = 20.0;
graph.plotAreaFrame.paddingRight = 20.0;