1

I'm working on drawing the line chart with data like: [50,40,60,-,80,-,70,10] and couldn't figure out how I draw the line for these data.

"-" means no value, not zero.

Guessed that Charts would accept nil for it, but it doesn't.

Please let me know if you have the answer for this.

Thank you in advance.

1 Answers1

3

U can pass Double.nan to the dataSet for nil value entries.

swift

let value = ChartDataEntry(x:Double(i),y:Double.nan)

but u should separate two datasets for no value data and numeric values data if not the line won't be connected each other.

Dmitrii Leonov
  • 1,331
  • 1
  • 15
  • 25
  • This approach didn't work for me, encountered error - Error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API and this value is being ignored. Please fix this problem. Please suggest a solution for this if possible. – Rocky Sep 10 '22 at 17:54