save user data during a day (the same day -> many user data)

百般思念 提交于 2019-11-29 14:02:43

This is an AChartEngine issue indeed. The internal model used to be kept in ArrayLists and these issues didn't exist. At some point there was a community effort to make AChartEngine faster with a lot of data points. At that point, the model started to use a Map instead of an ArrayList. This implementation prevented having the same X value added several times. However, in order to fix this, I add a very small value to X, if it already exists. In your example, the first value is 20/04/2013 00:00:00.0, the second one is at 20/04/2013 00:00:00.001 and the third is 20/04/2013 00:00:00.002.

Now, the solution to your problem is to have a wider range on the X axis.

renderer.setXAxisMax(someDate.getTime());

where someDate can be something like 21/04/2013.

ok.

When you call new Date(), you also determine time of creation (default format is: January 1, 1970, 00:00:00 GMT). Because your points are created in different time but same date, your points are not aligned.

So you should do it like this:

Calendar thisDay = Calendar.getInstance();
thisDay.set(Calendar.HOUR, 0);
thisDay.set(Calendar.MINUTE, 0);
thisDay.set(Calendar.SECOND, 0);
Date d=thisDay.getTime();//this returns Date :) - it is funny but true

then you can use d as current date :).

Hope it is true and it helps, Toni

There are a few possible solutions for this problem:

  1. instead of a date, put the unix time of the date (long value) . in order to show it, you can convert the unix time to formatted date .

  2. since excel can handle dates, edit the output file and use "=Date(year,month,day)" or "=DATEVALUE("2013/4/20")"

this is all because the problem isn't even related to android. it's about showing the data. the data is ok. it's just how you show it.

If I am not very much mistaken this is not a problem of saving or loading the data but simply of displaying the data. Your graph algorithm should recognize equal dates and do not make a new entry for it.

As it is, it seem like the date is treated as label, not as x-axis value, which would be reasonable because the date string is not numeric.

I suggest to check achartengine if there is a way to additional provide x-values and then let them only increase if the date string of the next entry is different of the previous entry.

You probably have to give a different model to achartengine.

I don't think it is a save problem because well the date stored is the right one, so any behavior there is mostly as expected.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!