-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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 rounded corners on the bar chart #1066 #1917
Conversation
Great! Looks like my investigation and someone finally did it :) A corner case would be, if the bar is very thin, the rounded bar looks like a thin oval.. That's what I am not satisfied with the CG API |
This is great, would be awesome if we could get these for candlestick charts as well :) |
Any idea when the rounded corner feature will be merged ? I am using cocoapods (pod 'Charts') in my app and wanted to check this patch . |
No ETA, as @danielgindi is quite busy recently. For those want to try out, you should use source code instead of carthage, pod. More flexible. |
@Neral Awesome work! Building on top of your work, I made cornerRadius a user input or default to half the barRect as you had it https://github.com/omsignal/Charts |
Noticed that we need to consider when the bar is stacked, currently it rounds all entries |
@Neral Also I noticed if the axisMinimum is not set to 0, the bottom corners don't show |
i couldn't find "isDrawRoundedBarEnabled" property for Bar chart. I'm using Swift 3.0. Please let me know |
this has not been merged yet. and why @gsolanki1509 you are reviewers... |
context.stroke(barRect) | ||
let cornerRadius = CGSize(width: barRect.width / 2.0, height: barRect.width / 2.0) | ||
#if os(OSX) | ||
let bezierPath = NSBezierPath(roundedRect: barRect, xRadius: cornerRadius.width, yRadius: cornerRadius.height) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just FYI, I came across API like CGPathCreateWithRoundedRect()
and CGPathAddRoundedRect()
, looks like we can replace the UIBezierPath APIs?
context.setStrokeColor(borderColor.cgColor) | ||
context.setLineWidth(borderWidth) | ||
context.stroke(barRect) | ||
let cornerRadius = CGSize(width: barRect.width / 2.0, height: barRect.width / 2.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if this was a property instead, so that we can specify a custom corner radius.
It would be great that someone could merge this feature soon :) |
is the rounded bars option coming soon? Like on the Apple's activity tracker app? |
@vivianegon00 I think it's different. It's just bars with rounded corner. |
@liuxuan30 that's exactly what I need, bars with rounded corners... this option is not available now |
any chance this will be merged soon ? |
@liuxuan30 a lot of people need need this function, is there any hope that it will merge? :) |
I have said long time ago here, though it looks nice, but when bar becomes thinner, it will looks like oval instead of rounded bars, so it's kind of flaws. I'm not sure if there are any better solutions, so this is postponed. you guys are ok with thin bars? |
This would be awesome to have!!! Needing this asap!! |
@liuxuan30 Looks like this is a heavily desired feature, and the author has abandoned the PR. Shall I reimplement this? I think the thin bar issue is fine. If a consumer doesn't like it they can turn off rounded corners. |
@jjatie if thin bar is acceptable, then we can move forward. But I am still struggling with it, as when the bars become a little bit more, it will look more like an oval, which is not ideal. We could first write a solid and flexible code base for this, and if we have better solutions, we can easily switch them. Don't be limited at my raw implementation about |
@@ -180,4 +194,7 @@ open class BarChartView: BarLineChartViewBase, BarChartDataProvider | |||
|
|||
/// - returns: `true` if drawing shadows (maxvalue) for each bar is enabled, `false` ifnot | |||
open var isDrawBarShadowEnabled: Bool { return drawBarShadowEnabled } | |||
|
|||
/// - returns: `true` if drawing rounded bars is enabled, `false` ifnot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ifnot
typo
One year in review? Really? |
@mikestalker it's open source and you have all the code you need. Either you could merge yourself or wait. At least you didn't pay me/us to do this, and we all have a job to do. Besides I have said the implementation I found is not satisfying. You can contribute a better one rather than complain. |
@liuxuan30 any ETA on this? |
+1 |
@danielgindi @liuxuan30 almost 2 years in review? |
@acegreen , @liuxuan30 already answered (=
|
Until a better solution emerge. As I said long time ago, this solution is not perfect (more bars, the oval become sharp). I don't think this is worth merging yet. I keep this open is some people could live with the defect. Use at your own risk |
Added ability to draw rounded corners on each bar.
By default rounded corners is disabled and to enable it
isDrawRoundedBarEnabled
should be used.Also using
barRoundingCorners
could be decided which corners should be rounded (reference).Feature: #1066