MPAndroidChart线型图:使用日期,而不是​​字符串X轴 [英] MPAndroidChart LineChart: Using dates instead of Strings for X-axis

查看:1269
本文介绍了MPAndroidChart线型图:使用日期,而不是​​字符串X轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MPAndroidChart <一个href=\"https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartLib/src/com/github/mikephil/charting/data/LineData.java\"相对=nofollow>线型图通过默认接受字符串X轴。有没有一种方法来设置日期为X轴数据类型?

MPAndroidChart LineChart by default accepts Strings for X-axis. Is there a way to set Date as a datatype for the X-axis?

与刚刚转换日期为字符串的问题是,图可以根据数据点来scewed。例如,如果我有并于1月一个数据录入在6月10日的条目,默认图形仅仅是分成11和情节相应。

The problem with just converting Date into strings is that graph can be scewed depending on the data points. For example if I have one data entry on January and 10 entries in June, by default the graph is just split into 11 and plot accordingly.

我希望有一个你体重超过时间图,其中X轴重新presents时间。在随机时间用户的权重,所以一些日期将有进入和一些日期则不会。

I want a "You weight over time" graph, where X-Axis represents time. User weights in at random times, so some dates will have entry and some dates will not.

推荐答案

可以使您以饱满日期新的数组和填充previous值空位置。
例如:
你在做一个数组可能[31]在5月的每一天,initializate它用零,然后做这样的事情:

You can make new array with full dates and fill empty positions with previous values. For example: you making an array may[31] for each day of may, initializate it with zeroes, and then do something like this:

may[1] = values[1];  
for (int i = 2; i <= may.size(); ++i) {
    if (may[i] == 0)
        may[i] = may[i-1];
    }

这篇关于MPAndroidChart线型图:使用日期,而不是​​字符串X轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆