ChartsOrg / Charts

Beautiful charts for iOS/tvOS/OSX! The Apple side of the crossplatform MPAndroidChart.
Apache License 2.0
27.53k stars 5.99k forks source link

Scientific number formatting for X Axis? #4379

Open PerplexedFox opened 4 years ago

PerplexedFox commented 4 years ago

Hi,

I have noticed that there is no way to have xAxis values formatted as 10^x (.scientific). The only xAxis formatter is of type IAxisValueFormatter and automatically uses stringForValue function. However, this would be a great feature. Could you add it?

bivant commented 4 years ago

Hello @PerplexedFox Why not use an AxisFormatter?

public class AnAxisValueFormatter: NSObject, IAxisValueFormatter {

    public func stringForValue(_ value: Double, axis: AxisBase?) -> String {
        return "What ever you like"
    }
}

//configure part, usually viewDidLoad in a view controller

        let xAxis = chartView.xAxis
        xAxis.valueFormatter = AnAxisValueFormatter()