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

Bug: BarChartView Highlight Can Select Some Bar On Chart #4641

Closed
SchwartzLizer opened this issue May 11, 2021 · 11 comments
Closed

Bug: BarChartView Highlight Can Select Some Bar On Chart #4641

SchwartzLizer opened this issue May 11, 2021 · 11 comments

Comments

@SchwartzLizer
Copy link

What did you do?

Create BarChartView

What did you expect to happen?

Can touch all bar in the chart

What happened instead?

which bar can select, some can't select

Charts Environment

Charts version/Branch/Commit Number: 4.0.1 Via SPM (Install Charts Only , Chart-Dynamic Didn't (Is show no no such module algorithms))
Xcode version: 12.5
Swift version: 5
Platform(s) running Charts: iOS
macOS version running Xcode: 11.3.1

Demo Project

CleanShot 2021-05-11 at 11 29 04

On My Projects

CleanShot 2021-05-11 at 11 48 24

@SchwartzLizer
Copy link
Author

Update Infomation: When I back to version 3.6.0 via SPM it still worked I hope this bug will be fixed soon (V4.0.0 is still not working too)

@orolhawion
Copy link

I can confirm this issue and also experience it with line charts. However, markers in pie charts are working as expected.

@Lee-Waire-Health
Copy link

Lee-Waire-Health commented May 24, 2021

var entries: [ChartDataEntry] = []


var i = 0
while i < 38 {
    entries.append(ChartDataEntry(x: Double(round(1621858800.0+(Double(i)*60.0))), y: Double(Float.random(in: 70...73))))
    i+=1
}

let set = ChartDataSet(entries: entries)

let res = set.entriesForXValue(Double(1621860300))

let test1 = entries.partitioningIndex { $0.x == Double(1621860300) }
let test2 = entries.partition { $0.x >= Double(1621860300) }

^ ^ simplest for of replication think it points to bad use or partitioningIndex, use comments suggest this generally should only be run on a partitioned set.

Not suggesting a fix here as I don't know what other unintended side effects just switching to partition would result in.

@ARASHz4
Copy link

ARASHz4 commented Jul 20, 2021

I have same problem in bar chart

@hojatdelfan
Copy link

I have the same problem too

@BeCrecker
Copy link

Having same issue too

@yusufonderd
Copy link

yusufonderd commented Dec 28, 2021

Same issue in bar chart

@ajkiosd
Copy link

ajkiosd commented Feb 25, 2022

subclass ChartDataSet like below and using it will fixes this issue for now:


class CustomBarChartDataSet: BarChartDataSet {

    override func entriesForXValue(_ xValue: Double) -> [ChartDataEntry] {
        let i = partitioningIndex(where: { $0.x >= xValue })
        guard i < endIndex, self[i].x == xValue else {
            return []
        }
        return self[i...].prefix { $0.x == xValue }
    }
}

@ashrobo
Copy link

ashrobo commented Mar 15, 2022

subclass ChartDataSet like below and using it will fixes this issue for now:


class CustomBarChartDataSet: BarChartDataSet {

    override func entriesForXValue(_ xValue: Double) -> [ChartDataEntry] {
        let i = partitioningIndex(where: { $0.x >= xValue })
        guard i < endIndex, self[i].x == xValue else {
            return []
        }
        return self[i...].prefix { $0.x == xValue }
    }
}

That's close but doesn't quite fix it for me, still seeing weird behaviour where some clicks work and some don't. Reverting to v3.6.0 seems to completely fix the issue.

@gurpreetKobe
Copy link

This really needs to be fixed on priority. I also had to use V3.6.0 for this. @danielgindi

@pmairoldi
Copy link
Collaborator

Closed by #4721

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