嗨,我刚开始学习Swift,并设法使用CorePlot导入CocoaPods,并通过桥接头进行导入。我还设法为我的图形创建了轴:
class ViewController: UIViewController {
@IBOutlet weak var graphView: CPTGraphHostingView!
override func viewDidLoad() {
super.viewDidLoad()
// create graph
var graph = CPTXYGraph(frame: CGRectZero)
graph.paddingLeft = 5
graph.paddingTop = 5
graph.paddingRight = 5
graph.paddingBottom = 5
// Axes
var axes = graph.axisSet as CPTXYAxisSet
var lineStyle = CPTMutableLineStyle()
lineStyle.lineWidth = 2
axes.xAxis.axisLineStyle = lineStyle
axes.yAxis.axisLineStyle = lineStyle
self.graphView.hostedGraph = graph
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}1)我的问题是,我如何标记轴(使用数组)?
( 2)是否有办法按比例计算标签之间的距离,还是自动这样做?
我的主要问题是我不知道如何用Swift编写Objective语法。有很多objc的例子,但我需要迅速。
提前感谢您的耐心和帮助!
发布于 2015-02-13 17:36:35
轴labelingPolicy控制滴答间距和标签。使用自定义标签(CPTAxisLabelingPolicyNone),由您指定每个标签的位置。如果希望使用勾标和/或网格线,则需要分别设置这些位置(majorTickLocations和/或minorTickLocations)。
有一个标签策略演示在图片库示例应用程序,显示了可用的选项。
https://stackoverflow.com/questions/28488914
复制相似问题