작업 시간 분석 기능 수정
This commit is contained in:
@@ -133,9 +133,9 @@ namespace CHN
|
||||
public void LoadCompleteTimeData()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
filePath = "../ChunilENG/CompleteTimeAlarmInfo.json";
|
||||
filePath = "./CompleteTimeAlarmInfo.json";
|
||||
#else
|
||||
filePath = "../ChunilENG_Build/CompleteTimeAlarmInfo.json";
|
||||
filePath = "./CompleteTimeAlarmInfo.json";
|
||||
#endif
|
||||
|
||||
saveData.Clear();
|
||||
|
||||
@@ -11,15 +11,20 @@ using UnityEngine.EventSystems;
|
||||
public class UI_BarChart : UIBase
|
||||
{
|
||||
private BarChart barChart;
|
||||
private UI_StackBar stackBar;
|
||||
private UI_StackBar prefab_stackBar;
|
||||
private UI_DateTime prefab_DateTime;
|
||||
private RectTransform StackBarParent;
|
||||
private RectTransform DateTimeParent;
|
||||
|
||||
private Dictionary<UI_StackBar, Vector3> stackBarPos = new();
|
||||
public List<BarChartData> barChartDatas = new List<BarChartData>();
|
||||
public UI_BarChartData barChartData;
|
||||
private bool isClickChart;
|
||||
public Vector2 labelOffset;
|
||||
public override void AfterAwake()
|
||||
{
|
||||
prefab_stackBar = Resources.Load<UI_StackBar>("Prefabs/UI/PRF_UI_StackBar");
|
||||
prefab_DateTime = Resources.Load<UI_DateTime>("Prefabs/UI/PRF_UI_DateTime");
|
||||
barChart = GetComponentInChildren<BarChart>();
|
||||
stackBar = GetComponentInChildren<UI_StackBar>(true);
|
||||
barChartData = GetComponentInChildren<UI_BarChartData>(true);
|
||||
}
|
||||
void Update()
|
||||
@@ -29,10 +34,6 @@ public class UI_BarChart : UIBase
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(barChartData.rectTransform, Input.mousePosition))
|
||||
return;
|
||||
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(stackBar.rectTransform, Input.mousePosition))
|
||||
return;
|
||||
|
||||
stackBar.SetActive(false);
|
||||
barChartData.SetActive(false);
|
||||
}
|
||||
}
|
||||
@@ -49,16 +50,53 @@ public class UI_BarChart : UIBase
|
||||
barChart.DataSource.SetValue("TargetCycleTime", i.ToString(), barChartData[i].targetCycleTime);
|
||||
barChart.DataSource.SetValue("CycleTime", i.ToString(), barChartData[i].cycleTime);
|
||||
}
|
||||
|
||||
this.barChartDatas.AddRange(barChartData);
|
||||
//GUI ´Ù ±×·ÁÁö±â Àü±îÁö ´ë±â
|
||||
barChart.OnRedraw.AddListener(SetStackBarData);
|
||||
barChart.OnRedraw.AddListener(SetChartLabels);
|
||||
}
|
||||
|
||||
public void OnClickItem(BarEventArgs arg)
|
||||
private void SetStackBarData()
|
||||
{
|
||||
int.TryParse(arg.Group, out var index);
|
||||
barChart.GetBarTrackPosition("CycleTime", index.ToString(), out var topPosition);
|
||||
barChartData.SetData(barChartDatas[index], topPosition);
|
||||
stackBarPos.Clear();
|
||||
|
||||
var bottomPosition = new Vector3(topPosition.x, rectTransform.rect.height / 2, 0);
|
||||
stackBar.SetStackBar(barChartDatas[index], topPosition, bottomPosition);
|
||||
for (int i = 0; i < barChartDatas.Count; i++)
|
||||
{
|
||||
var stackBar = Instantiate(prefab_stackBar, StackBarParent);
|
||||
barChart.GetBarTrackPosition("CycleTime", i.ToString(), out var topPosition);
|
||||
var bottomPosition = new Vector3(topPosition.x, rectTransform.rect.height / 2, 0);
|
||||
|
||||
stackBar.SetStackBar(barChartDatas[i], topPosition, bottomPosition);
|
||||
stackBar.onClickStackBar += OnClickStackBar;
|
||||
stackBarPos.Add(stackBar, bottomPosition);
|
||||
}
|
||||
}
|
||||
private void SetChartLabels()
|
||||
{
|
||||
ClearChartLabels();
|
||||
|
||||
for (int i = 0; i < barChartDatas.Count; i++)
|
||||
{
|
||||
barChart.GetBarTrackPosition("CycleTime", i.ToString(), out var topPosition);
|
||||
var bottomPosition = new Vector3(topPosition.x, rectTransform.rect.height / 2, 0);
|
||||
|
||||
var dateTime = Instantiate(prefab_DateTime, DateTimeParent);
|
||||
dateTime.transform.position = new Vector3(bottomPosition.x + labelOffset.x, bottomPosition.y + labelOffset.y, 0);
|
||||
dateTime.SetDateTime(barChartDatas[i]._time);
|
||||
}
|
||||
}
|
||||
private void ClearChartLabels()
|
||||
{
|
||||
if (DateTimeParent.childCount <= 0)
|
||||
return;
|
||||
|
||||
for(int i = 0; i < DateTimeParent.childCount; i++)
|
||||
{
|
||||
Destroy(DateTimeParent.transform.GetChild(i).gameObject);
|
||||
}
|
||||
}
|
||||
private void OnClickStackBar(UI_StackBar stackBar)
|
||||
{
|
||||
barChartData.SetData(stackBar.barChartData, stackBarPos[stackBar]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@ public class UI_BarChartData : UIBase
|
||||
private TextMeshProUGUI WeighingTimeData;
|
||||
private TextMeshProUGUI ETCData;
|
||||
|
||||
public TextMeshProUGUI DateTime;
|
||||
|
||||
public Vector3 offset;
|
||||
|
||||
public override void AfterAwake()
|
||||
@@ -27,24 +25,12 @@ public class UI_BarChartData : UIBase
|
||||
HoldingPressureTimeData.SetText(ConvertFloatToString(data.holdingPressureTime));
|
||||
WeighingTimeData.SetText(ConvertFloatToString(data.weighingTime));
|
||||
ETCData.SetText(ConvertFloatToString(data.etc));
|
||||
|
||||
DateTime.SetText(SplitString(data._time));
|
||||
}
|
||||
private string ConvertFloatToString(float value)
|
||||
{
|
||||
float truncatedFloat = Mathf.Floor(value * 100f) / 100f;
|
||||
return truncatedFloat.ToString() + " ÃÊ";
|
||||
}
|
||||
private string SplitString(string value)
|
||||
{
|
||||
var splitText_1 = value.Substring(0, value.IndexOf("T") + 1);
|
||||
var splitText_2 = value.Substring(value.IndexOf("T") + 1).Trim();
|
||||
|
||||
var lineBreakText = splitText_1 + "\n" + splitText_2;
|
||||
return lineBreakText;
|
||||
}
|
||||
|
||||
|
||||
void ShowUINextToClickedUI(Vector3 topPosition)
|
||||
{
|
||||
rectTransform.localPosition = new Vector2(topPosition.x + offset.x, offset.y);
|
||||
|
||||
@@ -14,6 +14,14 @@ public class UI_DateTime : UIBase
|
||||
}
|
||||
public void SetDateTime(string time)
|
||||
{
|
||||
dateTime.SetText(time);
|
||||
dateTime.SetText(SplitString(time));
|
||||
}
|
||||
private string SplitString(string value)
|
||||
{
|
||||
var splitText_1 = value.Substring(0, value.IndexOf("T") + 1);
|
||||
var splitText_2 = value.Substring(value.IndexOf("T") + 1).Trim();
|
||||
|
||||
var lineBreakText = splitText_1 + "\n" + splitText_2;
|
||||
return lineBreakText;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,17 @@ using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using WI;
|
||||
using UnityEngine.EventSystems;
|
||||
using System;
|
||||
|
||||
public class UI_StackBar : UIBase
|
||||
public class UI_StackBar : UIBase, IPointerClickHandler
|
||||
{
|
||||
public Image targetImage;
|
||||
public List<float> segmentRatios = new List<float>();
|
||||
|
||||
public Image[] stackedImages;
|
||||
public Action<UI_StackBar> onClickStackBar;
|
||||
public BarChartData barChartData;
|
||||
|
||||
public override void AfterAwake()
|
||||
{
|
||||
@@ -22,7 +26,7 @@ public class UI_StackBar : UIBase
|
||||
public void SetStackBar(BarChartData barChartData, Vector3 topPosition, Vector3 bottomPosition)
|
||||
{
|
||||
SetActive(true);
|
||||
|
||||
this.barChartData = barChartData;
|
||||
transform.position = topPosition;
|
||||
|
||||
var height = (transform.localPosition.y + bottomPosition.y);
|
||||
@@ -59,4 +63,8 @@ public class UI_StackBar : UIBase
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
onClickStackBar?.Invoke(this);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user