Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

407
Vistas
How to use String values for X-Axis in Charts instead of doubles?

I want to display String values for X-Axis in line chart via using 'Charts' I've followed tutorial for same here. As per wrote there
let lineChartData = LineChartData(xVals: dataPoints, dataSet: lineChartDataSet)
I'm not finding in current latest version of library. In, current library version's demo code I'm only able to fill double type of data for X-axis and Y-axis. Please help me to solve this.
Here is desired output. Line chart

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

There's a protocol IAxisValueFormatter that you can implement and achieve your expected result.

EDIT:
How to use it

While initialising
chartView.xAxis.valueFormatter = self

and implementing protocol.

extension LineChart1ViewController: IAxisValueFormatter {
    func stringForValue(_ value: Double, axis: AxisBase?) -> String {
        let months = ["January","February","March","April","May","June","July","Auguest","September","October","November","December"]
        return months[Int(value)]
    }
}
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda