GraphView icon indicating copy to clipboard operation
GraphView copied to clipboard

IllegalArgumentException: new x-value must be greater then the last value. x-values has to be ordered in ASC.

Open evgenij1987 opened this issue 8 years ago • 5 comments

02-15 19:17:02.035 15379-15379/com.example.ti.ble.sensortag E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.ti.ble.sensortag, PID: 15379 Theme: themes:{default=overlay:system, iconPack:system, fontPkg:system, com.android.systemui=overlay:system, com.android.systemui.navbar=overlay:system} java.lang.IllegalArgumentException: new x-value must be greater then the last value. x-values has to be ordered in ASC. at com.jjoe64.graphview.series.BaseSeries.checkValueOrder(BaseSeries.java:486) at com.jjoe64.graphview.series.BaseSeries.appendData(BaseSeries.java:408) at com.jjoe64.graphview.series.LineGraphSeries.appendData(LineGraphSeries.java:646) at com.jjoe64.graphview.series.BaseSeries.appendData(BaseSeries.java:464) at com.example.ti.internal.sensors.InternalWifiRssiProfile.updateValue(InternalWifiRssiProfile.java:33) at com.example.ti.services.measurement.PhoneSensorListener.notifySensorProfiles(PhoneSensorListener.java:46) at com.example.ti.services.measurement.PhoneSensorListener.onCustomSensorChanged(PhoneSensorListener.java:25) at com.example.ti.services.measurement.MeasurementService$2.run(MeasurementService.java:68) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5461) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Hi, the GraphView works like a sharm, BUT I experience the following issue when running this code periodically:

`public void updateValue( ) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo();

    values[0]=new Point3D(wifiInfo.getRssi(),0,0);

    series.appendData(new DataPoint(new Date(),values[0].v), true,200);
    sensorValue.setText(String.format("%.1f", values[0].v));
}`

Thus, basically Date is used as x of the graph, such that this error shouldn't occur. Any ideas?

Many thanks in advance! :-)

evgenij1987 avatar Feb 15 '17 18:02 evgenij1987

Try resetting the line series associated with the graphview. series.resetData(new DataPoint[] {})

mnsekh111 avatar Mar 31 '17 09:03 mnsekh111

I meet the same Bug. I used a sortedMap to solve the problem. Part of my code is here:

var sortedMap = sortedMapOf<Double,Double>()
while (cursor.moveToNext()) {
    val year = cursor.getInt(cursor.getColumnIndex("year"))
    var rank = cursor.getInt(cursor.getColumnIndex("rank"))
    sortedMap.put(year.toDouble(),rank.toDouble())
    Log.d("Tag","name = $name, year = $year, rank = $rank")
}
   cursor.close()
    // foreach a map in kotlin 
   for ((year,rank) in sortedMap) {
        series.appendData(DataPoint(year.toDouble(),rank.toDouble()),false,maxPoints)
   }
graph_view.removeAllSeries()
graph_view.addSeries(series)

littlecurl avatar Apr 19 '19 15:04 littlecurl

Having the same issue, my csv is from a dataset where the X is time so it's impossible to not be in an ASC order

Ali-Nass avatar May 01 '19 14:05 Ali-Nass

For me too, the X axis is dates that are already in ascending order.

RiaAsgekar avatar Apr 26 '22 11:04 RiaAsgekar

how do I update a graph in real time (as in a scope), with data arriving several times per second? It would be nice to have appendRoundRobin method that would append data to the right and remove it from the left...

thirstyone avatar Feb 02 '23 10:02 thirstyone