B4J Question Passing .csv coordinates to Scatter Chart

Cal4th

Member
I am trying to plot coordinates that i have in a .csv file that is divided by ",". the .csv looks like this:
1,0.00158
0.95,0.01008
0.9,0.0181
...
...
0,0
Being the first number the X coordinate and the second the Y coordinate
The code Im using is :
B4X:
Public XY As List
    XY.Initialize
    XY = su.LoadCSV(File.DirApp, "coordinates.csv", ",")
    Dim Plot As XYSeries
    Plot.Initialize("plot")
    For i= 0 To XY.Size-1
        Dim c(2) As Double = XY.Get(i)
   Plot.Add(c(0), c(1))
    Next
ScatterChart.AddSeries(Plot)
When I load the file it is saved as this:

XY
Element Data
  • 0
    • 0=1
    • 1=0.00158
  • 1
    • 0=0.95
    • 1=0.01008
  • 2
    • 0=0.9
    • 1=0.0181
etc...

I am trying to plot them as shown in https://www.b4x.com/android/forum/threads/passing-data-from-csv-to-scatter-chart-of-jchart.87910/
but is not working.
 
Top