160 lines
4.9 KiB
C#
160 lines
4.9 KiB
C#
using Newtonsoft.Json;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System;
|
|
public class DataVersionPanel : MonoBehaviour
|
|
{
|
|
public Date116 date116;
|
|
[Header("ÈËÊýÔö¼Ó»ò¼õÉÙ")]
|
|
public Image image;
|
|
|
|
public Text Usercount;
|
|
public Sprite Up;
|
|
public Sprite Down;
|
|
|
|
public TextMeshProUGUI count;
|
|
|
|
[Header("±í¸ñ")] public WMG_Axis_Graph WmgAxisGraph;
|
|
|
|
public WMG_Series WmgSeries;
|
|
// Start is called before the first frame update
|
|
async void Start()
|
|
{
|
|
date116 = await OnClick116BpanelAsync();
|
|
Debug.Log(date116.userRegisterDailyResponseVoList.Count);
|
|
Init();
|
|
SETGraph();
|
|
}
|
|
|
|
public void Init()
|
|
{
|
|
count.text = "" + (int)date116.userVoluteCoinCount;
|
|
if (date116.userRegisterDailyResponseVoList[date116.userRegisterDailyResponseVoList.Count-1].registerUser >=date116.userRegisterDailyResponseVoList[date116.userRegisterDailyResponseVoList.Count - 2].registerUser)
|
|
{
|
|
image.sprite= Up;
|
|
Usercount.text = $"<color=red>{(int)date116.userRegisterDailyResponseVoList[date116.userRegisterDailyResponseVoList.Count-1].registerUser- (int)date116.userRegisterDailyResponseVoList[date116.userRegisterDailyResponseVoList.Count - 2].registerUser}</color>";
|
|
}
|
|
else
|
|
{
|
|
image.sprite = Down;
|
|
Usercount.text = $"<color=green>{(int)date116.userRegisterDailyResponseVoList[date116.userRegisterDailyResponseVoList.Count-2].registerUser - (int)date116.userRegisterDailyResponseVoList[date116.userRegisterDailyResponseVoList.Count-1].registerUser}</color>";
|
|
}
|
|
}
|
|
|
|
long FindMinValue()
|
|
{
|
|
long minValue = date116.userRegisterDailyResponseVoList[0].registerUser;
|
|
foreach (var num in date116.userRegisterDailyResponseVoList)
|
|
{
|
|
if (num.registerUser < minValue)
|
|
{
|
|
minValue = num.registerUser;
|
|
}
|
|
}
|
|
return minValue;
|
|
}
|
|
|
|
long FindMaxValue()
|
|
{
|
|
long maxValue = date116.userRegisterDailyResponseVoList[0].registerUser;
|
|
foreach (var num in date116.userRegisterDailyResponseVoList)
|
|
{
|
|
if (num.registerUser > maxValue)
|
|
{
|
|
maxValue = num.registerUser;
|
|
}
|
|
}
|
|
return maxValue;
|
|
}
|
|
|
|
public void SETGraph()
|
|
{
|
|
|
|
WmgAxisGraph.xAxis.AxisNumTicks = date116.userRegisterDailyResponseVoList.Count;//xÖá\
|
|
Debug.Log(WmgAxisGraph.xAxis.AxisNumTicks);
|
|
WmgAxisGraph.xAxis.axisLabels.Clear();
|
|
foreach (var datelist in date116.userRegisterDailyResponseVoList)
|
|
{
|
|
DateTime date = DateTime.Parse(datelist.registerDate);
|
|
int month = date.Month;
|
|
int day = date.Day;
|
|
WmgAxisGraph.xAxis.axisLabels.Add($"{month}-{day}");
|
|
}
|
|
WmgAxisGraph.yAxis.AxisNumTicks = date116.userRegisterDailyResponseVoList.Count;//y
|
|
Debug.Log(WmgAxisGraph.yAxis.AxisNumTicks);
|
|
long minValue = FindMinValue();
|
|
long maxValue = FindMaxValue();
|
|
Debug.Log(minValue);
|
|
Debug.Log(maxValue);
|
|
WmgAxisGraph.yAxis.axisLabels.Clear();
|
|
WmgAxisGraph.yAxis.axisLabels.Add($"{minValue}");
|
|
WmgAxisGraph.yAxis.axisLabels.Add($"{minValue+(maxValue-minValue)*0.5}");
|
|
WmgAxisGraph.yAxis.axisLabels.Add($"{maxValue}");
|
|
//point
|
|
for (int i = 0; i < date116.userRegisterDailyResponseVoList.Count; i++)
|
|
{
|
|
WmgSeries.pointValues.Add(new Vector2(0, date116.userRegisterDailyResponseVoList[i].registerUser));
|
|
}
|
|
|
|
|
|
}
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
public async Task<Date116> OnClick116BpanelAsync()
|
|
{
|
|
// ×¼±¸ÇëÇóµÄÍ·²¿ÐÅÏ¢£¬°üº¬ÊÚȨÁîÅÆ
|
|
Dictionary<string, string> head116 = new Dictionary<string, string>
|
|
{
|
|
{ "Authorization", Global.global.serverResponse.data.token }
|
|
};
|
|
|
|
|
|
|
|
// Òì²½·¢ËÍÇëÇó
|
|
string response118 = await web.SendRequest(web.URL + "/snail/data/queryDaily", "GET", "{}", head116);
|
|
|
|
// µ÷ÊÔÊä³ö½ÓÊÕµ½µÄÏìÓ¦
|
|
Debug.Log("1.16Êý¾Ý¿´°å =====================" + response118);
|
|
|
|
// ½«ÏìÓ¦·´ÐòÁл¯Îª KnightRoomList ¶ÔÏó
|
|
Response116 directlist = JsonConvert.DeserializeObject<Response116>(response118);
|
|
|
|
// ¼ì²é·´ÐòÁл¯ÊÇ·ñ³É¹¦
|
|
if (directlist != null && directlist.data != null)
|
|
{
|
|
|
|
Debug.Log("»ñÈ¡³É¹¦");
|
|
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("directlist Êý¾ÝΪ¿Õ");
|
|
}
|
|
|
|
return directlist.data;
|
|
}
|
|
}
|
|
|
|
public class Response116 : Response
|
|
{
|
|
public Date116 data;
|
|
}
|
|
public class Date116
|
|
{
|
|
public List<datelist116> userRegisterDailyResponseVoList;
|
|
public long userVoluteCoinCount;
|
|
}
|
|
|
|
public class datelist116
|
|
{
|
|
public string registerDate;
|
|
public long registerUser;
|
|
}
|