Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions ARCharts/ARChartLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -29,6 +30,8 @@ public class ARChartLabel: SCNNode {
return "IndexLabel(\(id))"
case .series:
return "SeriesLabel(\(id))"
case .title:
return "BarNameLabel(\(id))"
}
}

Expand All @@ -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)
Expand Down