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

Bar Chart Value Labels missing #5135

Open
gabors opened this issue Dec 14, 2023 · 6 comments
Open

Bar Chart Value Labels missing #5135

gabors opened this issue Dec 14, 2023 · 6 comments

Comments

@gabors
Copy link

gabors commented Dec 14, 2023

What did you do?

Create a Bar Chart view. Create a data set where all values are negative.

What did you expect to happen?

Expect the value labels to be rendered.

What happened instead?

Value labels do not always render. They may show up or disappear depending on the size of the chart view or containing view/window.
Easy to see when running in a Mac app and dragging the window size bigger or smaller.

Only seems to happen when all values are negative. With positive bar charts seems to be fine.

DGCharts Environment

DGCharts version/Branch/Commit Number: Current and any previous
Xcode version: 15.x and 14.x
Platform(s) running DGCharts: iOS 15+ and macOS 12+

image image
@gabors gabors changed the title Bar Chart Value Bar Chart Value Labels missing Dec 14, 2023
@ChrisColeTech
Copy link

Same issue here.

It happens randomly. I've tried changing constraints, font sizes, leftAxis spaceTop/spaceBottom and nothing consistently works.

Charts 3.2.2

iPhone 11 Pro Simulator
iOS 14.5
XCode 12.5
Swift 4

@gabors
Copy link
Author

gabors commented Mar 25, 2024

Please help us. Thanks @danielgindi

@liuxuan30
Copy link
Member

are you able to debug a little? it seems you could do this. normally just search for the value labels and see whether it goes into drawText. is it only happens on mac?

@gabors
Copy link
Author

gabors commented Mar 25, 2024

Hi @liuxuan30

I may find some time to debug. But not in the near future.

But it happens in iOS as well. Like I said it's easier to replicate on Mac.
Mac Catalyst in my case. Labels disappear randomly depending on the chart view frame size.
It's really easy to see on Mac as you can freely resize the app window.

On iOS it's a lottery. They can disappear depending what negative values you have. May disappear in portrait but not landscape and vice versa.

You should be able to replicate quite easily.

@cc-signet
Copy link

Same issue here.

It happens randomly. I've tried changing storyboard constraints, font sizes, leftAxis spaceTop/spaceBottom and nothing consistently works.

Charts 3.2.2

iPhone 11 Pro Simulator iOS 14.5 XCode 12.5 Swift 4

Upgraded to version 4.1.0 and the issue still remains.

It seems to only happen when all values are negative, and it is still random.

Expected result:
Expected

Actual result:
Actual

iPhone 15 Pro Simulator
iOS 17.4
XCode 15.3
Swift 4

@cc-signet
Copy link

are you able to debug a little? it seems you could do this. normally just search for the value labels and see whether it goes into drawText. is it only happens on mac?

Thank you for the suggestion. This actually helped!

Starting from drawText,

I was able to determine that the bug is actually caused by the following line of code inside of the drawValues(context: CGContext) method in the BarChartRenderer.swift class:

`
Swift

                    guard viewPortHandler.isInBoundsY(rect.origin.y),
                        viewPortHandler.isInBoundsLeft(x)
                        else { continue }

`

image

And when I comment that code out, it displays the values as expected:

image

Before:
Before

After:
Fixed

If someone could shed some light on this code, and tell us what its doing (and why it is causing this bug) that would be appreciated. Otherwise, its working fine without this code and hopefully it is fixed in the future.

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

4 participants