Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ open class BarChartDataSet: BarLineScatterCandleBubbleChartDataSet, BarChartData
/// the alpha value (transparency) that is used for drawing the highlight indicator bar. min = 0.0 (fully transparent), max = 1.0 (fully opaque)
open var highlightAlpha = CGFloat(120.0 / 255.0)

/// the value should create a radius in barchart. (0.0 no corner radius)
open var barCornerRadiusFactor: CGFloat = 0.0

// MARK: - NSCopying

open override func copy(with zone: NSZone? = nil) -> Any
Expand Down
3 changes: 3 additions & 0 deletions Source/Charts/Data/Interfaces/BarChartDataSetProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public protocol BarChartDataSetProtocol: BarLineScatterCandleBubbleChartDataSetP

/// the color drawing borders around the bars.
var barBorderColor: NSUIColor { get set }

/// the percentage of corner radius for each bar in chart
var barCornerRadiusFactor: CGFloat { get set }

/// the alpha value (transparency) that is used for drawing the highlight indicator bar. min = 0.0 (fully transparent), max = 1.0 (fully opaque)
var highlightAlpha: CGFloat { get set }
Expand Down
15 changes: 9 additions & 6 deletions Source/Charts/Renderers/BarChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,9 @@ open class BarChartRenderer: BarLineScatterCandleBubbleRenderer
for barRect in buffer where viewPortHandler.isInBoundsLeft(barRect.origin.x + barRect.size.width)
{
guard viewPortHandler.isInBoundsRight(barRect.origin.x) else { break }

context.setFillColor(dataSet.barShadowColor.cgColor)
context.fill(barRect)
let bezierPath = UIBezierPath(roundedRect: barRect, cornerRadius: barRect.width * dataSet.barCornerRadiusFactor)
context.addPath(bezierPath.cgPath)
context.drawPath(using: .fill)
}
}

Expand Down Expand Up @@ -379,7 +379,9 @@ open class BarChartRenderer: BarLineScatterCandleBubbleRenderer
context.setFillColor(dataSet.color(atIndex: j).cgColor)
}

context.fill(barRect)
let bezierPath = UIBezierPath(roundedRect: barRect, cornerRadius: barRect.width * dataSet.barCornerRadiusFactor)
context.addPath(bezierPath.cgPath)
context.drawPath(using: .fill)

if drawBorder
{
Expand Down Expand Up @@ -743,8 +745,9 @@ open class BarChartRenderer: BarLineScatterCandleBubbleRenderer
prepareBarHighlight(x: e.x, y1: y1, y2: y2, barWidthHalf: barData.barWidth / 2.0, trans: trans, rect: &barRect)

setHighlightDrawPos(highlight: high, barRect: barRect)

context.fill(barRect)
let bezierPath = UIBezierPath(roundedRect: barRect, cornerRadius: barRect.width * set.barCornerRadiusFactor)
context.addPath(bezierPath.cgPath)
context.drawPath(using: .fill)
}
}
}
Expand Down