|
@@ -3,6 +3,7 @@ using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Threading.Tasks;
|
|
|
using Bitsplash.DatePicker;
|
|
|
+using Newtonsoft.Json;
|
|
|
using UnityEngine;
|
|
|
using UnityEngine.UI;
|
|
|
using XCharts.Runtime;
|
|
@@ -23,6 +24,18 @@ public class WaterTrendPanel : MonoBehaviour
|
|
|
public string startDateStr="";
|
|
|
public string endDateStr="";
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ public void Init()
|
|
|
+ {
|
|
|
+ _LineChart = this.transform.Find("LineChart").GetComponent<LineChart>();
|
|
|
+ listRoot = this.transform.Find("ScrollView/Viewport/Content").transform;
|
|
|
+ closeButton = this.transform.Find("CloseButton").GetComponent<Button>();
|
|
|
+ nameText = this.transform.Find("nameText").GetComponent<Text>();
|
|
|
+ closeButton.onClick.AddListener(() => { Hide(); });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private void Start()
|
|
|
{
|
|
|
DatePicker_Start = this.transform.Find("DatePicker_Start").GetComponent<DatePickerDropDownTextMeshPro>();
|
|
@@ -38,16 +51,6 @@ public class WaterTrendPanel : MonoBehaviour
|
|
|
CheckDate();
|
|
|
};
|
|
|
}
|
|
|
-
|
|
|
- public void Init()
|
|
|
- {
|
|
|
- _LineChart = this.transform.Find("LineChart").GetComponent<LineChart>();
|
|
|
- listRoot = this.transform.Find("ScrollView/Viewport/Content").transform;
|
|
|
- closeButton = this.transform.Find("CloseButton").GetComponent<Button>();
|
|
|
- nameText = this.transform.Find("nameText").GetComponent<Text>();
|
|
|
- closeButton.onClick.AddListener(() => { Hide(); });
|
|
|
- }
|
|
|
-
|
|
|
public void CheckDate()
|
|
|
{
|
|
|
if (!startDateStr.Equals("") && !endDateStr.Equals(""))
|
|
@@ -56,12 +59,52 @@ public class WaterTrendPanel : MonoBehaviour
|
|
|
var endD= DateTime.ParseExact(endDateStr,"yyyy-MM-dd",null);
|
|
|
var disD = endD - startD;
|
|
|
Debug.Log(disD.TotalDays);
|
|
|
- if (disD.TotalDays > 180)
|
|
|
+ if (disD.TotalDays > 183)
|
|
|
{
|
|
|
Debug.Log("时间间隔大于6个月");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 获取时间范围内的趋势图
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="type"></param>
|
|
|
+ /// <param name="gid"></param>
|
|
|
+ /// <param name="sid"></param>
|
|
|
+ /// <param name="startTime"></param>
|
|
|
+ /// <param name="endTime"></param>
|
|
|
+ public async Task GetTrend(int type,string gid,string sid,string startTime,string endTime)
|
|
|
+ {
|
|
|
+ string getJsonStr= await HttpHelper._Instance.GetDeviceTrend(type,gid,sid,startTime,endTime);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ Debug.Log("GetTrend requestData:"+getJsonStr);
|
|
|
+ DeviceTrendRequest requestData = JsonConvert.DeserializeObject<DeviceTrendRequest>(getJsonStr);
|
|
|
+ XAxis tempXaxis = _LineChart.GetChartComponent<XAxis>();
|
|
|
+ tempXaxis.data.Clear();
|
|
|
+ for (int i = 0; i < requestData.data.Length; i++)
|
|
|
+ {
|
|
|
+ tempXaxis.AddData(requestData.data[i].timeGroup);
|
|
|
+ }
|
|
|
+ var tempSeries = _LineChart.series;
|
|
|
+ SerieData[] tempDatas = new SerieData[requestData.data.Length];
|
|
|
+ for (int i = 0; i < tempDatas.Length; i++)
|
|
|
+ {
|
|
|
+ tempDatas[i] = new SerieData();
|
|
|
+ tempDatas[i].data = new List<double>();
|
|
|
+ tempDatas[i].data.Add(i);
|
|
|
+ tempDatas[i].data.Add(float.Parse(requestData.data[i].r1));
|
|
|
+ }
|
|
|
+ tempSeries[0].data.Clear();
|
|
|
+ tempSeries[0].data.AddRange(tempDatas);
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ Debug.Log(e.ToString());
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public async Task Show(string stcd, string name)
|
|
|
{
|