Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more render options for y axis labels #3406

Merged
merged 1 commit into from
Jun 10, 2018
Merged
Show file tree
Hide file tree
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
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