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

BarChart - xAxis Labels disappear if not a min of 2 on the screen #2854

Closed
roxanajula opened this issue Oct 9, 2017 · 12 comments
Closed

BarChart - xAxis Labels disappear if not a min of 2 on the screen #2854

roxanajula opened this issue Oct 9, 2017 · 12 comments

Comments

@roxanajula
Copy link

Hi guys,

I am having an issue with a grouped (by months) yearly bar chart. The chart is dragEnabled so it scrolls as I have a visibleXRange of 1.2 (out of a group/year). The data I have has at least 2 groups/years.

chartView.setVisibleXRange(minXRange: 1.2, maxXRange: 1.2)
chartView.moveViewToX(endYear+1)
chartView.notifyDataSetChanged()

Now the problem is that my labels disappear if there aren't a minimum of 2 visible on the screen. See the gif below.
I already tried the notifyDataSetChanged(). I also tried removing the labelcount min max values from the AxisBase.

chart labels mov

Any help is greatly appreciated. Thanks!

@honcharenko13
Copy link

pls tell how did you implement rounded corners?

@roxanajula
Copy link
Author

@honcharenko13 I modified the BarChartRenderer, in drawDataSet after setting the colors:

//Corner radius
let cornerRadius = CGSize(width: 2, height: 2)
let bezierPath = UIBezierPath(roundedRect: barRect, byRoundingCorners: UIRectCorner.allCorners, cornerRadii: cornerRadius)
context.addPath(bezierPath.cgPath)
context.fillPath()

@honcharenko13
Copy link

@roxanajula thanks. I thought I overlooked some property inside app without pod modification.
So in your case you need to copy library fully to project, right?

@roxanajula
Copy link
Author

@honcharenko13 What i did is I created a CustomBarChartRenderer that inherits from BarChartRenderer, copied the code for drawDataSet from the library and override it, and then use the CustomBarChartRenderer on the chart. But I am not saying it is the best solution 😄

@roxanajula
Copy link
Author

@honcharenko13 you should search in the issues "rounded corners" there were some discussions about this

@honcharenko13
Copy link

@roxanajula thank you for detailed description. I will consider other library that I've found and it has ability to set rounded corners

@roxanajula
Copy link
Author

I have also checked the xAxis.entries in my XAxisRenderer, and when there are 2 years visible they are correct, when the labels are not visible the xAxis.entries is equal to []

@roxanajula
Copy link
Author

@liuxuan30 It seems that in the cases where the labels are not visible the xAxis.entries is empty. (when less than 2 labels are visible) Would you be so kind to point me into the direction at what I should look at/change? Thanks!

@liuxuan30
Copy link
Member

please first take a look at computeAxisValues() if axis.entries are generated correctly. If this is the case, why it's empty?

@luiswolf
Copy link

@roxanajula, can you tell how did you implement the year labels at the top of the chart?

@gitty-kid
Copy link

@roxanajula you got more questions than answers :) your chart looks splendid :) ..

@roxanajula
Copy link
Author

roxanajula commented Oct 24, 2018

I made my own custom renderer based on the framework more than a year ago, the framework has a lot of releases since then, so unfortunately what I did back then won't help much with the current framework. :) Closing the issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants