X-Axis Chart label in swift

1.7k views Asked by At

How to show the last label of time in X-axis

I have used danielgindi/Charts in my xcode project. Here the last time label in x-axis not getting showed. How to show the last time in x-axis label. Image attached below. Below code is used by me :-

   let lineChartDataSet = LineChartDataSet(yVals: dataEntriesline, label: nil)
    lineChartDataSet.drawCirclesEnabled = false
    lineChartDataSet.colors = [NSUIColor(red: CGFloat(228.0/255), green: CGFloat(204.0/255), blue: CGFloat(88.0/255), alpha: 1)]
    lineChartDataSet.lineWidth = 2
    lineChartDataSet.setDrawHighlightIndicators(false)

    let lineChartData = LineChartData(xVals: dataPoints, dataSet: lineChartDataSet)
    magneticChart.xAxis.labelPosition = .Bottom
    magneticChart.data = lineChartData
    magneticChart.animate(xAxisDuration: 3.0, yAxisDuration: 3.0)
    magneticChart.legend.enabled = false
    magneticChart.descriptionText = ""
    magneticChart.data?.setDrawValues(false)
    magneticChart.rightAxis.drawLabelsEnabled = false
    magneticChart.xAxis.setLabelsToSkip(239)
    magneticChart.xAxis.drawLabelsEnabled = true
    magneticChart.drawBordersEnabled = true
    magneticChart.borderColor = UIColor.blackColor()
    dataEntrieslineIntialMarkerMagnetic = dataEntriesline
    magneticChart.xAxis.avoidFirstLastClippingEnabled = false
    magneticChart.xAxis.drawLabelsEnabled = true
1

There are 1 answers

0
Y.Bi On
magneticChart.xAxis.avoidFirstLastClippingEnabled = false

This is the reason. Try to set it to true.