ChartsOrg / ChartsOrg/Charts

lowestVisibleX and highestVisibleX Accuracy problem

Open
#5,094 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
28k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

The accuracy problem will cause the maximum and minimum values in the screen to change, causing the Chart to shake up and down.

Cause of the problem

In my project lowestVisibleX sometimes returns 386.5 and sometimes returns 386.49999999999999.
When calling the following method

image

When the value of lowestVisibleX is 386.5 and the value of indexFrom is 387, when the value of lowestVisibleX is 386.49999999999999, indexFrom only returns 386. As a result, the maximum value of the Y value in the screen has been changing. which in turn causes the screen graph to jump。Is there any good solution?

##Charts Environment

Charts 4.1.0
14.3.1:
5.7:
iOS running Charts:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported difference between lowestVisibleX values of 386.5 and 386.49999999999999, then trace how indexFrom uses that value. Verify the behavior on the reported Charts 4.1.0 and iOS environment. Done means the visible range and resulting Y-axis bounds remain stable for equivalent values.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.