We are updating our code to work with DGCharts v.4.0 (previously Charts) and our previously working solution for adding labels for the x and y axis (see below) is now no longer working, as "ChartUtils" cannot be found.
Does anyone know how this can be achieved with DGCharts?
private extension LineChartYAxisRenderer {
func renderTitle(title: String, inContext context: CGContext, x: CGFloat) {
var foregroundColor = UIColor.darkGray
foregroundColor = UIColor.secondaryLabel
let attributes: [NSAttributedString.Key: Any] = [
.font: self.axis.labelFont,
.foregroundColor: foregroundColor
]
// Determine the chart title's y-position.
let titleSize = title.size(withAttributes: attributes)
let verticalTitleSize = CGSize(width: titleSize.height, height: titleSize.width)
let point = CGPoint(x: x, y: ((viewPortHandler.chartHeight - verticalTitleSize.height) / 2)-30)
// Render the chart title.
ChartUtils.drawText(context: context,
text: title,
point: point,
attributes: attributes,
anchor: .zero,
angleRadians: .pi / -2)
Does anyone know how this can be achieved with DGCharts?
We're using Swift5.