public void NullDate() { DeleteLinePrefabs(); LineChart_Y_value.DateY(0); List <float> data = new List <float>(); PersonnelLineChart.Inject(data); PersonnelLineChart.enabled = false;//这样处理不用点击一下Inspector里面的东西,柱状图才可以出来 PersonnelLineChart.enabled = true; return; }
private void Awake() { IList <float> bars = new List <float>() { 0.6f, 0.8f, 0.1f, 0.2f, 0.5f }; IList <float>[] barss = new IList <float>[] { new List <float>() { 0.1f, 0.7f, 0.2f }, new List <float>() { 0.2f, 0.4f, 0.9f }, new List <float>() { 0.5f, 0.1f, 0.2f }, new List <float>() { 0.8f, 0.2f, 0.8f }, }; BarChart.Inject(barss); BarChart.UnitEnable(true); }
public void ShowLineChartInfo(List <PositionList> PosList, string Name) { PerName = Name; promptText.text = Convert.ToDateTime(StrText).ToString("yyyy年MM月dd日") + PerName + "定位数据量折线图";; DeleteLinePrefabsX(); if (PosList == null) { return; } if (PosList.Count == 0) { return; } PersonnelScreenPositionList = new List <PositionList>(); for (int i = 0; i < PosList.Count; i++) { if (PosList[i].Name.Contains("1970") || PosList[i].Name.Contains("1974")) { Debug.Log("数据有问题,去掉1970年的和1974年的"); } else { PersonnelScreenPositionList.Add(PosList[i]); } } PersonnelScreenPositionList.Sort((x, y) => { return(x.Count.CompareTo(y.Count)); });//根据数量排列 LineChart_Y_value.DateY(PersonnelScreenPositionList[PersonnelScreenPositionList.Count - 1].Count); int MaxNum = PersonnelScreenPositionList[PersonnelScreenPositionList.Count - 1].Count; List <float> data = new List <float>(); PersonnelScreenPositionList.Sort((x, y) => { return(x.Name.CompareTo(y.Name)); }); DateTime dt = Convert.ToDateTime(PersonnelScreenPositionList[PersonnelScreenPositionList.Count - 1].Name + ":00:00"); string DT = dt.ToString(("yyyy-MM-dd")); DateTime MinDt = Convert.ToDateTime(DT); int DifferencetIME = 24; for (int i = 0; i < DifferencetIME; i++) { TimeInstantiateLine(); DateTime HoursAdd = MinDt.AddHours(i); string TimeT = HoursAdd.ToString(("yyyy-MM-dd HH")); PositionList item = PersonnelScreenPositionList.Find(j => j.Name.Contains(TimeT)); if (item != null) { data.Add((float)item.Count / MaxNum); //TimeScreenPositionList.Remove(item); } else { data.Add(0);//没有数据的日期补上0 } } SetHourLineChartDate(PersonnelScreenPositionList, MinDt, 24); PersonnelLineChart.Inject(data); PersonnelLineChart.enabled = false;//这样处理不用点击一下Inspector里面的东西,柱状图才可以出来 PersonnelLineChart.enabled = true; }