diff --git a/ARCharts/ARChartLabel.swift b/ARCharts/ARChartLabel.swift index 0d4bf1a..3b5e2f8 100644 --- a/ARCharts/ARChartLabel.swift +++ b/ARCharts/ARChartLabel.swift @@ -14,13 +14,14 @@ public class ARChartLabel: SCNNode { public enum LabelType { case index case series + case title } - /// Type of label, either `.series` or `.index`. + /// Type of label, either `.series` or `.index` or `.title`. // I added BarNode name public let type: LabelType /// Numeric identifier for the label. - /// Index number if `type` is `.index`, series number if `type` is `.series`. + /// Index number if `type` is `.index`, series number if `type` is `.series`, series number with postfix as index number if `type` is `.title`. public let id: Int public override var description: String { @@ -29,6 +30,8 @@ public class ARChartLabel: SCNNode { return "IndexLabel(\(id))" case .series: return "SeriesLabel(\(id))" + case .title: + return "BarNameLabel(\(id))" } } @@ -43,15 +46,15 @@ public class ARChartLabel: SCNNode { super.init() self.geometry = text - let backgroundWidth = CGFloat(1.05 * (text.boundingBox.max.x - text.boundingBox.min.x)) - let backgroundHeight = CGFloat(1.2 * (text.boundingBox.max.y - text.boundingBox.min.y)) + let backgroundWidth = CGFloat(1.1 * (text.boundingBox.max.x - text.boundingBox.min.x)) + let backgroundHeight = CGFloat(1.3 * (text.boundingBox.max.y - text.boundingBox.min.y)) let backgroundPlane = SCNPlane(width: backgroundWidth, height: backgroundHeight) backgroundPlane.cornerRadius = 0.15 * min(backgroundPlane.width, backgroundPlane.height) backgroundPlane.firstMaterial?.diffuse.contents = backgroundColor let backgroundNode = SCNNode(geometry: backgroundPlane) // TODO: Position values came from trial-and-error. The positioning doesn't make any sense. backgroundNode.position = SCNVector3(0.495 * backgroundWidth, - 0.7 * backgroundHeight, + 0.6 * backgroundHeight, -0.05) self.addChildNode(backgroundNode)