ChartsOrg / ChartsOrg/Charts

Highlight position in `chartValueSelected` is always 0 / nan

Open
#4,998 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
28k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

* [x] I've read, understood, and done my best to follow the [*CONTRIBUTING guidelines](https://github.com/jjatie/Charts/blob/master/CONTRIBUTING.md).

## What did you do?
Created a basic LineChartView, implemented the `chartValueSelected` of the `ChartViewDelegate`.

## What did you expect to happen?
I want to get the xPx and yPx values of the highlight to place a custom UIView on top of the chart at the highlighted position

## What happened instead?
The `chartValueSelected` gets called successfully, but I get weird values for all the positions:
(`highlight.drawX`, `highlight.drawY`) = (`0.0`, `0.0`)
(`highlight.xPx`, `highlight.yPx`) = (`nan`, `nan`)

When setting a breakpoint inside the init method (the one with xPx and yPx) of the Highlight class - the xPx and yPx parameters passed into it are correct. But I assume I'm getting a different Highlight object in the `chartValueSelected` method (the one that's called from `ChartViewBase` -> `highlightValue()`, without xPx and yPx)

## Charts Environment

**Charts version/Branch/Commit Number:*4.1.0*
**Xcode version:*14.0*
**Swift version:*5*
**Platform(s) running Charts:*iOS*
**macOS version running Xcode:*Ventura*

## Demo Project
I don't have a demo project, but can provide it if needed. Currently I just want to verify if it's a global issue

Contributor guide

Open the contributing guide

Research direction

Start in ChartViewBase at highlightValue() and trace the Highlight object passed to chartValueSelected in ChartViewDelegate. Compare that object with the Highlight initializer that receives xPx and yPx; done means the callback exposes the selected highlight's correct drawX, drawY, xPx, and yPx values on iOS.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, swift
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.