Skip to content

Commit

Permalink
Add more render options for y axis labels
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrepty committed Apr 18, 2018
1 parent 6b730a0 commit 4b00c8f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Source/Charts/Components/YAxis.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ open class YAxis: AxisBase

/// the position of the y-labels relative to the chart
@objc open var labelPosition = LabelPosition.outsideChart

/// the alignment of the text in the y-label
@objc open var labelAlignment: NSTextAlignment = .left

/// the horizontal offset of the y-label
@objc open var labelXOffset: CGFloat = 10.0

/// the side this axis object represents
private var _axisDependency = AxisDependency.left
Expand Down
7 changes: 5 additions & 2 deletions Source/Charts/Renderers/YAxisRendererRadarChart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ open class YAxisRendererRadarChart: YAxisRenderer

let from = yAxis.isDrawBottomYLabelEntryEnabled ? 0 : 1
let to = yAxis.isDrawTopYLabelEntryEnabled ? yAxis.entryCount : (yAxis.entryCount - 1)

let alignment: NSTextAlignment = yAxis.labelAlignment
let xOffset: CGFloat = yAxis.labelXOffset

for j in stride(from: from, to: to, by: 1)
{
Expand All @@ -193,8 +196,8 @@ open class YAxisRendererRadarChart: YAxisRenderer
ChartUtils.drawText(
context: context,
text: label,
point: CGPoint(x: p.x + 10.0, y: p.y - labelLineHeight),
align: .left,
point: CGPoint(x: p.x + xOffset, y: p.y - labelLineHeight),
align: alignment,
attributes: [
NSAttributedStringKey.font: labelFont,
NSAttributedStringKey.foregroundColor: labelTextColor
Expand Down

0 comments on commit 4b00c8f

Please sign in to comment.