Search code examples
iosswiftcursorios-charts

How to create a cursor with ios-charts


Is there a way to create a cursor with ios-charts in a LineGraph in the x-axys? enter image description here I read all the doc. but the most similar thing that I found ware the Markers.


Solution

  • You can highlight value by enable chartDataSet.setDrawHighlightIndicators(true) it will show highlighted value with vertical line on your lineChart.

    Swift Code :

    let chartDataSet = LineChartDataSet(values: dataEntries, label: label)
    
    chartDataSet.setDrawHighlightIndicators(true)
    
    chartDataSet.highlightColor = .blue
    chartDataSet.highlightLineWidth = 1
    

    By above code you can enable this vertical line.

    sample screen shot :

    enter image description here

    Hope this will helps to highlight your Value in line chart.