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

negative y value overlay with x labels #481

Open
liuxuan30 opened this issue Oct 19, 2015 · 8 comments
Open

negative y value overlay with x labels #481

liuxuan30 opened this issue Oct 19, 2015 · 8 comments
Labels

Comments

@liuxuan30
Copy link
Member

Reproducible with ChartsDemo,

Just use negative values for a bar chart:

[yVals addObject:[[BarChartDataEntry alloc] initWithValue:-val xIndex:i]];

ne

@liuxuan30 liuxuan30 added the bug label Oct 19, 2015
@vigyanhoon
Copy link

I second that!

simulator screen shot 31-oct-2015 2 00 36 pm

@liuxuan30
Copy link
Member Author

Well I guess it's not as easy as it looks like. The label will always take up some space.. you could turn it off or add some offset for it to work around it for now.

@vigyanhoon
Copy link

@liuxuan30 Can we have marker popup shown only for negative bars, as I want to hide negative bar values to avoid overlapping but positive bar values doesn't have overlapping problem as I don't have right y axis labels?

@liuxuan30
Copy link
Member Author

Of couse you can, but you have to write your own code, it does not support this by default.

@vigyanhoon
Copy link

screen shot 2015-12-01 at 7 36 45 am

I moved negative bar values to top and right aligned, fixed bar space to accommodate values just above bar:
Changes made to HorizontalBarChartRenderer
Added at line 320:
re-align negative values to avoid overlapping with y axis
var xPos = valuePoints[j].x + (val >= 0.0 ? posOffset : negOffset)
var yPos = valuePoints[j].y + yOffset

                    if val < 0 {
                        xPos = xPos + valueTextWidth + 2
                        yPos = yPos - 15
                    }

                    drawValue(
                        context: context,
                        value: valueText,
                        xPos: xPos,
                        yPos: yPos,
                        font: valueFont,
                        align: textAlign,
                        color: valueTextColor)

Hope this helps someone desperate to get it fixed:

@liuxuan30
Copy link
Member Author

Well done! - Closing

@liuxuan30
Copy link
Member Author

reopen as the issue is not resolved. I mistakenly closed it.
Still, a solution is needed how we draw text if there are overlap.

@danielerne
Copy link

danielerne commented Jun 11, 2021

Really? Still open?

Workaround: xAxis.yOffset = 10

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

No branches or pull requests

3 participants