Charts: Cant able to set XAxis Range for custom DateTime formatter

Created on 6 Jun 2018  路  4Comments  路  Source: danielgindi/Charts

screen shot 2018-06-06 at 06 41 04

I have created a line graph with Date Time format on X Axis.The values are plotting correctly,but i would like to be shown 1 hour interval based.Right now its showing directly the xvalue as ranges.Can anyone help how to set ranges for this, i am struck for almost a day in this.Thanks

let xAxis = self.chartView.xAxis
xAxis.labelFont = .systemFont(ofSize: 10)
xAxis.labelTextColor = .black
xAxis.drawAxisLineEnabled = false
xAxis.valueFormatter = DateValueFormatter()

public class DateValueFormatter: NSObject, IAxisValueFormatter {
private let dateFormatter = DateFormatter()

override init() {
    super.init()
    dateFormatter.dateFormat = "HH:mm"
}

public func stringForValue(_ value: Double, axis: AxisBase?) -> String {
    return dateFormatter.string(from: Date(timeIntervalSince1970: value))
}

}

All 4 comments

@leniyadav i have same issue. have you find any solution?

@shahchirag Still have the issue.Do let me know if you find any solution.Thanks

@shahchirag2110 @leniyadav have you guys found any solution? Thanks

please ask on stack overflow.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brytnvmg picture brytnvmg  路  4Comments

Bharati555 picture Bharati555  路  4Comments

kirti0525 picture kirti0525  路  3Comments

anhltse03448 picture anhltse03448  路  3Comments

sjdevlin picture sjdevlin  路  3Comments