ChartsOrg / ChartsOrg/Charts

Try to change xAxis Label

Open
#4,735 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

Hi Guys,

I'm looking for changing xAxis label but it doesn't work.

![MicrosoftTeams-image](https://user-images.githubusercontent.com/68468903/136997132-1efefc29-2e34-4ef7-afb8-220d44216697.png)

I use the below but its not working as I expect it.
Is it a bug or I am not using the right component ?

```swift
class BarChartDateAxisValueFormatter: DateAxisValueFormatter {
override func stringForValue(_ value: Double, axis: AxisBase?) -> String {
switch periodRelay.value {
case let .daily(startDate, _):
let calendar = Calendar.current
let valueAsInt = Int(ceil(value))
var dateComponents = calendar.dateComponents([.year, .month, .day, .hour, .minute], from: startDate)
dateComponents.hour = valueAsInt
dateComponents.minute = 0

let date = calendar.date(from: dateComponents)
return date?.timeString ?? ""

case .monthly, .yearly, .none:
return super.stringForValue(value, axis: axis)
}
}
}
```
Could anyone help me please ?

Thanks you very much for all.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the x-axis label behavior with the provided BarChartDateAxisValueFormatter and determine whether the formatter or the selected axis component controls the displayed labels. The issue does not name a source file, test, or specific expected output; done would require a confirmed explanation and a clearly defined correction or usage guidance.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
data-visualization, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
18/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.