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 rounded corners on the bar chart #1066 #1917

Closed
wants to merge 2 commits into from

Conversation

Neral
Copy link

@Neral Neral commented Dec 5, 2016

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

charts

@liuxuan30
Copy link
Member

liuxuan30 commented Dec 6, 2016

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

@arronhunt
Copy link

This is great, would be awesome if we could get these for candlestick charts as well :)

@vinodha88
Copy link

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 .

@liuxuan30
Copy link
Member

No ETA, as @danielgindi is quite busy recently.
Besides, such feature needs to be considered for Android, so it usually take a very long time.

For those want to try out, you should use source code instead of carthage, pod. More flexible.

@acegreen
Copy link

acegreen commented Feb 17, 2017

@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

@acegreen
Copy link

Noticed that we need to consider when the bar is stacked, currently it rounds all entries

@acegreen
Copy link

@Neral Also I noticed if the axisMinimum is not set to 0, the bottom corners don't show

@gsolanki1509
Copy link

i couldn't find "isDrawRoundedBarEnabled" property for Bar chart.

I'm using Swift 3.0. Please let me know

@liuxuan30
Copy link
Member

liuxuan30 commented Mar 29, 2017

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)
Copy link
Member

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?

jacobminer added a commit to jacobminer/Charts that referenced this pull request Apr 21, 2017
context.setStrokeColor(borderColor.cgColor)
context.setLineWidth(borderWidth)
context.stroke(barRect)
let cornerRadius = CGSize(width: barRect.width / 2.0, height: barRect.width / 2.0)

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.

@Kit-OS
Copy link

Kit-OS commented Sep 8, 2017

It would be great that someone could merge this feature soon :)

@vivianegon00
Copy link

is the rounded bars option coming soon? Like on the Apple's activity tracker app?

@liuxuan30
Copy link
Member

@vivianegon00 I think it's different. It's just bars with rounded corner.

@vivianegon00
Copy link

@liuxuan30 that's exactly what I need, bars with rounded corners... this option is not available now

@kacperios
Copy link

kacperios commented Oct 17, 2017

any chance this will be merged soon ?

@weet1
Copy link

weet1 commented Nov 13, 2017

@liuxuan30 a lot of people need need this function, is there any hope that it will merge? :)

@liuxuan30
Copy link
Member

liuxuan30 commented Nov 15, 2017

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?

@juangz
Copy link

juangz commented Dec 11, 2017

This would be awesome to have!!! Needing this asap!!

@jjatie
Copy link
Collaborator

jjatie commented Jan 22, 2018

@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.

@liuxuan30
Copy link
Member

liuxuan30 commented Jan 23, 2018

@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 UIBezierPath(roundedRect: barRect, byRoundingCorners: dataSet.barRoundingCorners, cornerRadii: cornerRadius), maybe we could take a look at CGPathCreateWithRoundedRect() and CGPathAddRoundedRect()
and other possible solution.

@jjatie jjatie added this to the Future milestone Jan 23, 2018
@@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ifnot typo

@mikestalker
Copy link

One year in review? Really?

@liuxuan30
Copy link
Member

liuxuan30 commented Feb 20, 2018

@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.

@ravipxm
Copy link

ravipxm commented Apr 6, 2018

@liuxuan30 any ETA on this?

@renatamakuch
Copy link

+1

@acegreen
Copy link

acegreen commented Sep 7, 2018

@danielgindi @liuxuan30 almost 2 years in review?

@mikestalker
Copy link

@acegreen , @liuxuan30 already answered (=

@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
Copy link
Member

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

@jjatie
Copy link
Collaborator

jjatie commented Mar 9, 2019

#3754

@jjatie jjatie closed this Mar 9, 2019
@ChartsOrg ChartsOrg locked and limited conversation to collaborators Mar 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.