ChartsOrg / ChartsOrg/Charts

IndexAxisValueFormatter behaves not as expected

Open
#5,107 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
28k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

These are my coordinates to draw the scatter plot

[{ "y": 83.0, "x": 0.0 },
{ "y": 73.0, "x": 15.0 },
{ "y": 63.0, "x": 30.0 }.....]

my x axis is incrementing with 15 points. 0,15,30,45,50...

If I do not use IndexAxisValueFormatter, it draws

DefaultIssue

Where as If I use IndexAxisValueFormatter with the values [0,15,30...]. It draws xAxis wrongly
problematicIssue

I'm using following chart properties. My chart is scrollable

chartView.setVisibleXRangeMinimum(3)
chartView.setVisibleXRangeMaximum(200
chartView.setScaleEnabled(false)
chartView.dragEnabled = true
chartView.scaleXEnabled = false
chartView.pinchZoomEnabled = false

//X axis
let xAxis = chartView.xAxis
xAxis.drawGridLinesEnabled = false
xAxis.drawLabelsEnabled = true
xAxis.labelPosition = .bottom

xAxis.granularity = 15

I'm suppose to change this 15, 30, 45 to Date format "hh:mm a" based on the first timestamp. I guess if the IndexAxisValueFormatter draws it correctly, date formatted string will also be correct. Please let me know what went wrong

## What did you do?

ℹ Please replace this with what you did.

## What did you expect to happen?

ℹ Please replace this with what you expected to happen.

## What happened instead?

ℹ Please replace this with of what happened instead.

## DGCharts Environment

**DGCharts version/Branch/Commit Number:**
**Xcode version:**
**Swift version:**
**Platform(s) running DGCharts:**
**macOS version running Xcode:**

## Demo Project

ℹ Please link to or upload a project we can download that reproduces the issue.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the scatter plot with IndexAxisValueFormatter, xAxis.granularity set to 15, and the visible-range and scrolling settings shown in the issue. Compare the formatter and axis-label behavior with and without it; done means the 0, 15, 30, and subsequent labels align with the plotted x-values and can support the requested date formatting.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.