1、今日进度表:
2、今日完成:
浏览15天体温记录(折线图)
lineActivity
package com.example.reporttemperature; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.os.Bundle; import android.view.View; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.Button; public class LineActivity extends AppCompatActivity { private EchartView lineChart; private MyOpenHelper helper=new MyOpenHelper(this); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_line); setTitle("15天体温统计图"); getById(); lineChart.setWebViewClient(new WebViewClient(){ @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); //最好在h5页面加载完毕后再加载数据,防止html的标签还未加载完成,不能正常显示 String[]result_date=get_date(); String []result_tem=get_tem(); refreshLineChart(result_date,result_tem); } }); } private void getById(){ lineChart = findViewById(R.id.lineChart); } private void refreshLineChart(String[]a,String []b){ Object[] x = new Object[]{ a[14],a[13],a[12], a[11],a[10],a[9], a[8],a[7],a[6], a[5],a[4],a[3], a[2],a[1],a[0] //"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }; Object[] y = new Object[]{ b[14],b[13],b[12], b[11],b[10],b[9], b[8],b[7],b[6], b[5],b[4],b[3], b[2],b[1],b[0] //820, 932, 901, 934, 1290, 1330, 1320 }; lineChart.refreshEchartsWithOption(EchartOptionUtil.getLineChartOptions(x, y)); } //获取日期 private String[]get_date(){ SQLiteDatabase db=helper.getReadableDatabase(); Cursor cursor = db.rawQuery("select * from temperature", null); String [] list1=new String[100]; int i=0; while (cursor.moveToNext()) { String newDate = cursor.getString(cursor.getColumnIndex("date")); String r=newDate.substring(5,6)+"-"+newDate.substring(7,9); list1[i]=r; ++i; } cursor.close(); db.close(); String []list2=new String[i]; int k=i; for(int j=0;j<15&&k>0;j++){ --k; list2[k]=list1[j]; } return list2; } //获取体温 private String[]get_tem(){ SQLiteDatabase db=helper.getReadableDatabase(); Cursor cursor = db.rawQuery("select * from temperature", null); String [] list1=new String[100]; int i=0; while (cursor.moveToNext()) { String newTem = cursor.getString(cursor.getColumnIndex("temperature")); list1[i]=newTem; ++i; } cursor.close(); db.close(); String []list2=new String[i]; int k=i; for(int j=0;j<15&&k>0;j++){ --k; list2[k]=list1[j]; } return list2; } }
实现截图: