Browse Source

折线显示完成

FANGLH 8 years ago
parent
commit
80d4c7d007

+ 1 - 1
app_modular/appme/src/main/java/com/uas/appme/pedometer/constant/Constant.java

@@ -23,5 +23,5 @@ public class Constant {
     public static final int BASE_COLUMN = 100000000;
     public static String TRACK_STEP = "TRACKSTEP";
     public static String BASE_STEP_URL = "http://113.105.74.140:8092/user/";
-
+//    public static String BASE_STEP_URL = "http://192.168.253.136:8092/user/";
 }

+ 5 - 5
app_modular/appme/src/main/java/com/uas/appme/pedometer/utils/PolylineUtils.java

@@ -29,21 +29,21 @@ public class PolylineUtils {
      * @param lineChart   控件id 的对象
      * @param cBeanList     包含 X,y轴对象的列表
      */
-    private static void initLineChart(LineChartView lineChart,List<ComPolylineBean> cBeanList){
+    public static void initLineChart(LineChartView lineChart,List<ComPolylineBean> cBeanList){
 
-         List<PointValue> mPointValues = new ArrayList<PointValue>();
-         List<AxisValue> mAxisXValues = new ArrayList<AxisValue>();
+         List<PointValue> mPointValues = new ArrayList<>();
+         List<AxisValue> mAxisXValues = new ArrayList<>();
 
         getAxisXLables(mAxisXValues,cBeanList);//获取x轴的标注
         getAxisPoints(mPointValues,cBeanList);//获取坐标点
 
         Line line = new Line(mPointValues).setColor(Color.parseColor("#5DB7CF"));  //折线的颜色
-        List<Line> lines = new ArrayList<Line>();
+        List<Line> lines = new ArrayList<>();
         line.setShape(ValueShape.CIRCLE);//折线图上每个数据点的形状  这里是圆形 (有三种 :ValueShape.SQUARE  ValueShape.CIRCLE  ValueShape.SQUARE)
         line.setCubic(false);//曲线是否平滑
         line.setStrokeWidth(1);//线条的粗细,默认是3
         line.setFilled(false);//是否填充曲线的面积
-        line.setHasLabels(false);//曲线的数据坐标是否加上备注
+        line.setHasLabels(true);//曲线的数据坐标是否加上备注
 //		line.setHasLabelsOnlyForSelected(true);//点击数据坐标提示数据(设置了这个line.setHasLabels(true);就无效)
         line.setHasLines(true);//是否用直线显示。如果为false 则没有曲线只有点显示
         line.setHasPoints(true);//是否显示圆点 如果为false 则没有原点只有点显示

+ 16 - 3
app_modular/appme/src/main/java/com/uas/appme/pedometer/view/PersonalPageActivity.java

@@ -28,11 +28,16 @@ import com.me.network.app.http.Method;
 import com.me.network.app.http.rx.ResultListener;
 import com.me.network.app.http.rx.ResultSubscriber;
 import com.uas.appme.R;
+import com.uas.appme.pedometer.bean.ComPolylineBean;
 import com.uas.appme.pedometer.bean.PersonalStepBean;
 import com.uas.appme.pedometer.constant.Constant;
+import com.uas.appme.pedometer.utils.PolylineUtils;
 import com.uas.appme.pedometer.utils.TimeUtil;
 
 import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
 
 import lecho.lib.hellocharts.view.LineChartView;
 
@@ -118,13 +123,21 @@ public class PersonalPageActivity extends BaseActivity implements View.OnClickLi
 
     //初始化折线数据
     private void initPolylineData() {
-       /* if (mPersonalStepBean == null) return;
+        if (mPersonalStepBean == null) return;
         if (ListUtils.isEmpty(mPersonalStepBean.getMonthSteps()))  return;
         List<ComPolylineBean> polyList = new ArrayList<>();
         for (int i=0;i<mPersonalStepBean.getMonthSteps().size();i++){
             if (!StringUtil.isEmpty(mPersonalStepBean.getMonthSteps().get(i).getAs_date())
-                    !&&)
-        }*/
+                    && !StringUtil.isEmpty(mPersonalStepBean.getMonthSteps().get(i).getAs_uusteps())){
+
+                long l = DateFormatUtil.str2Long(mPersonalStepBean.getMonthSteps().get(i).getAs_date(),"yyyy-MM-dd");
+                String date = DateFormatUtil.getStrDate4Date(new Date(l), "MM-dd");
+                ComPolylineBean cBean = new ComPolylineBean(date,CommonUtil.getNumByString(mPersonalStepBean.getMonthSteps().get(i).getAs_uusteps()));
+                polyList.add(cBean);
+                if (i == mPersonalStepBean.getMonthSteps().size()-1)
+                    PolylineUtils.initLineChart(lineChart,polyList);
+            }
+        }
     }
 
     private void showStepsInfo() {