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

Marker Position #1876

Closed
diogoAntunes opened this issue Nov 23, 2016 · 6 comments
Closed

Marker Position #1876

diogoAntunes opened this issue Nov 23, 2016 · 6 comments

Comments

@diogoAntunes
Copy link

I've implemented a custom MarkerView, but every time the delegate function is called:

func chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight) {
        let position = chartView.getMarkerPosition(highlight: highlight)
}

The value of the position is always (0.0, 0.0). But the marker is being designed:

Image of MarkerView

@liuxuan30
Copy link
Member

liuxuan30 commented Nov 29, 2016

    open func getMarkerPosition(highlight: Highlight) -> CGPoint
    {
        return CGPoint(x: highlight.drawX, y: highlight.drawY)
    }

Would you please debug highlight.drawX and drawY, to see what's the problem? I tried in ChartsDemo, it's fine.

@Rnorback
Copy link

Rnorback commented Nov 30, 2016

so the way to get the markerPosition now seems to be by getting the hightlight.xPx and highlight.xPy. However, these values are given within the bounds of the chartView.

@Neral
Copy link

Neral commented Nov 30, 2016

Yes, it seems that highlight.drawX and drawY always returns values (0.0, 0.0).

As mentioned @Rnorback you could use highlight.xPx & highlight.yPx. Marker position could be converted to any view like this:

let rectInTableView = chartView.convert(CGRect(x: highlight.xPx, y: highlight.yPx, width: 0, height: 0), to: tableView)

@liuxuan30
Copy link
Member

I guess you may have to debug why highlight.drawX is 0.0. In charts demo, I am seeing valid values.

@jndefosse
Copy link

jndefosse commented Sep 19, 2017

Tested on ChartDemo with LineChart1ViewController.

Breakpoint at

  • (void)chartValueSelected:(ChartViewBase * __nonnull)chartView entry:(ChartDataEntry * __nonnull)entry highlight:(ChartHighlight * __nonnull)highlight

Result :
capture d ecran 2017-09-19 a 10 25 44

@liuxuan30
Copy link
Member

liuxuan30 commented Sep 21, 2017

@jndefosse It's an old issue; are you breaking at the beginning?

            let x = high.x // get the x-position
            let y = high.y * Double(animator.phaseY)
            
            if x > chartXMax * animator.phaseX
            {
                continue
            }
            
            let trans = dataProvider.getTransformer(forAxis: set.axisDependency)
            
            let pt = trans.pixelForValues(x: x, y: y)

There is chance that x, y is 0 when chart just starts. You are welcome to debug, as I don't know the real issue. No update for quite a while, and Chart marker seems working all the time.

@jjatie jjatie closed this as completed Apr 1, 2018
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

6 participants