ivnsch / SwiftCharts

Easy to use and highly customizable charts library for iOS
Apache License 2.0
2.53k stars 410 forks source link

Rounded corners bar #318

Closed lsnmarcinr closed 6 years ago

lsnmarcinr commented 6 years ago

Why my ViewBar have rounded all corners, even I choose only .topLeft and .topRight? I can't change that. No corners rounded or all corners rounded - nothing else.

let barViewGenerator = {(chartPointModel: ChartPointLayerModel, layer: ChartPointsViewsLayer, chart: Chart) -> UIView? in let bottomLeft = layer.modelLocToScreenLoc(x: 0, y: 0) let barWidth: CGFloat = 30 let settings = ChartBarViewSettings(cornerRadius: 15, roundedCorners: [.topLeft, .topRight]) let (p1, p2): (CGPoint, CGPoint) = { return (CGPoint(x: chartPointModel.screenLoc.x, y: bottomLeft.y), CGPoint(x: chartPointModel.screenLoc.x, y: chartPointModel.screenLoc.y)) }() return ChartPointViewBar(p1: p1, p2: p2, width: barWidth, bgColor: UIColor.blue, settings: settings)}

And preview:

zrzut ekranu 2017-11-30 o 15 42 22
ivnsch commented 6 years ago

Unfortunately selective rounding of corners works only for stacked bars at the moment, see https://github.com/i-schuetz/SwiftCharts/pull/239

Perhaps you can port the functionality to the plain bars. Otherwise I can give it a look in the coming days, though can't guarantee when.

lsnmarcinr commented 6 years ago

True, I created ChartStackedBarsLayer with rounded .topLeft and .topRight corner 👍

ivnsch commented 6 years ago

You can actually always used stacked bars - plain bars having only 1 stack frame, this keeps it also flexible.

arthursady commented 4 years ago

@i-schuetz , If we enable scaleX on the chart, the round corners are lost, is there a work around that issue? or is there a way to set X scroll without changing the scaleX or min and max zoom?