작업 조건 분석 기능 개발
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
public class BaseScrollableCategoryData
|
||||
{
|
||||
public string Name;
|
||||
public bool Enabled = true;
|
||||
[HideInInspector]
|
||||
public int ViewOrder = -1;
|
||||
public double? MaxX, MaxY, MinX, MinY, MaxRadius;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c7006a05a5b1994088b734d33541efc
|
||||
timeCreated: 1502383500
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
46
Assets/Chart And Graph/Script/ChartData/BaseSlider.cs
Normal file
46
Assets/Chart And Graph/Script/ChartData/BaseSlider.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
public abstract class BaseSlider
|
||||
{
|
||||
/// <summary>
|
||||
/// Duration of the sliding action
|
||||
/// </summary>
|
||||
public double Duration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Start time of the sliding action
|
||||
/// </summary>
|
||||
public double StartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The bottom right edge of the slider bounding box (use for detemining automatic view size and position)
|
||||
/// </summary>
|
||||
public abstract DoubleVector2 Max { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The top left edge of the slider bounding box (use for detemining automatic view size and position)
|
||||
/// </summary>
|
||||
public abstract DoubleVector2 Min { get; }
|
||||
|
||||
public abstract string Category { get; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public abstract int MinIndex { get; }
|
||||
/// <summary>
|
||||
/// returns true if the slider should be removed after this update. (meaning the slider is done)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual bool Update()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Script/ChartData/BaseSlider.cs.meta
Normal file
12
Assets/Chart And Graph/Script/ChartData/BaseSlider.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 42de3f57996db6449a8ac05a372a94fa
|
||||
timeCreated: 1502395357
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
15
Assets/Chart And Graph/Script/ChartData/IChartData.cs
Normal file
15
Assets/Chart And Graph/Script/ChartData/IChartData.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
public interface IChartData
|
||||
{
|
||||
void Update();
|
||||
void OnAfterDeserialize();
|
||||
void OnBeforeSerialize();
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Script/ChartData/IChartData.cs.meta
Normal file
12
Assets/Chart And Graph/Script/ChartData/IChartData.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 172dda9bf9c4051429ad0bb76be443d5
|
||||
timeCreated: 1502625145
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
457
Assets/Chart And Graph/Script/ChartData/ScrollableChartData.cs
Normal file
457
Assets/Chart And Graph/Script/ChartData/ScrollableChartData.cs
Normal file
@@ -0,0 +1,457 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
public abstract class ScrollableChartData : IChartData, IMixedSeriesProxy
|
||||
{
|
||||
protected List<BaseSlider> mSliders = new List<BaseSlider>();
|
||||
protected Dictionary<string, BaseScrollableCategoryData> mData = new Dictionary<string, BaseScrollableCategoryData>();
|
||||
|
||||
protected event EventHandler DataChanged;
|
||||
protected event EventHandler ViewPortionChanged;
|
||||
protected event Action<int,string> RealtimeDataChanged;
|
||||
|
||||
protected bool mSuspendEvents = false;
|
||||
|
||||
|
||||
[SerializeField]
|
||||
private double automaticVerticalViewGap = 0f;
|
||||
|
||||
/// <summary>
|
||||
/// call this to suspend chart redrawing while updating the data of the chart
|
||||
/// </summary>
|
||||
public void StartBatch()
|
||||
{
|
||||
mSuspendEvents = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// call this after StartBatch , this will apply all the changed made between the StartBatch call to this call
|
||||
/// </summary>
|
||||
public void EndBatch()
|
||||
{
|
||||
mSuspendEvents = false;
|
||||
RaiseDataChanged();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// set this to true to automatically detect the horizontal size of the graph chart
|
||||
/// </summary>
|
||||
public double AutomaticVerticallViewGap
|
||||
{
|
||||
get { return automaticVerticalViewGap; }
|
||||
set
|
||||
{
|
||||
automaticVerticalViewGap = value;
|
||||
RestoreDataValues();
|
||||
RaiseViewPortionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set this to true to automatically detect the horizontal size of the graph chart
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
private bool automaticVerticallView = true;
|
||||
|
||||
/// <summary>
|
||||
/// set this to true to automatically detect the horizontal size of the graph chart
|
||||
/// </summary>
|
||||
public bool AutomaticVerticallView
|
||||
{
|
||||
get { return automaticVerticallView; }
|
||||
set
|
||||
{
|
||||
automaticVerticallView = value;
|
||||
RestoreDataValues();
|
||||
RaiseViewPortionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private double automaticcHorizontaViewGap = 0f;
|
||||
/// set this to true to automatically detect the horizontal size of the graph chart
|
||||
/// </summary>
|
||||
public double AutomaticcHorizontaViewGap
|
||||
{
|
||||
get { return automaticcHorizontaViewGap; }
|
||||
set
|
||||
{
|
||||
automaticcHorizontaViewGap = value;
|
||||
RestoreDataValues();
|
||||
RaiseViewPortionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set this to true to automatically detect the horizontal size of the graph chart
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
private bool automaticHorizontalView = true;
|
||||
|
||||
/// <summary>
|
||||
/// set this to true to automatically detect the horizontal size of the graph chart
|
||||
/// </summary>
|
||||
public bool AutomaticHorizontalView
|
||||
{
|
||||
get { return automaticHorizontalView; }
|
||||
set
|
||||
{
|
||||
automaticHorizontalView = value;
|
||||
RestoreDataValues();
|
||||
RaiseViewPortionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private double horizontalViewSize = 100;
|
||||
|
||||
/// <summary>
|
||||
/// Mannualy set the horizontal view size.
|
||||
/// </summary>
|
||||
public double HorizontalViewSize
|
||||
{
|
||||
get { return horizontalViewSize; }
|
||||
set
|
||||
{
|
||||
horizontalViewSize = value;
|
||||
RaiseViewPortionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[SerializeField]
|
||||
private double horizontalViewOrigin = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Mannualy set the horizontal view origin.
|
||||
/// </summary>
|
||||
public double HorizontalViewOrigin
|
||||
{
|
||||
get { return horizontalViewOrigin; }
|
||||
set
|
||||
{
|
||||
horizontalViewOrigin = value;
|
||||
RaiseViewPortionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private double verticalViewSize = 100;
|
||||
|
||||
/// <summary>
|
||||
/// Mannualy set the horizontal view size.
|
||||
/// </summary>
|
||||
public double VerticalViewSize
|
||||
{
|
||||
get { return verticalViewSize; }
|
||||
set
|
||||
{
|
||||
verticalViewSize = value;
|
||||
RaiseViewPortionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// clears all graph data
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
mSliders.Clear();
|
||||
mData.Clear();
|
||||
RaiseDataChanged();
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private double verticalViewOrigin = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Mannualy set the horizontal view origin.
|
||||
/// </summary>
|
||||
public double VerticalViewOrigin
|
||||
{
|
||||
get { return verticalViewOrigin; }
|
||||
set
|
||||
{
|
||||
verticalViewOrigin = value;
|
||||
RaiseViewPortionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Update()
|
||||
{
|
||||
//bool updated = mSliders.Count > 0;
|
||||
mSliders.RemoveAll(x =>
|
||||
{
|
||||
bool res = x.Update();
|
||||
// if(res == false)
|
||||
// {
|
||||
RaiseRealtimeDataChanged(x.MinIndex,x.Category);
|
||||
// }
|
||||
return res;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns true if the data contains a category by the given name
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <returns></returns>
|
||||
public bool HasCategory(string category)
|
||||
{
|
||||
return mData.ContainsKey(category);
|
||||
}
|
||||
|
||||
protected void ModifyMinMax(BaseScrollableCategoryData data, DoubleVector3 point)
|
||||
{
|
||||
if (data.MaxRadius.HasValue == false || data.MaxRadius.Value < point.z)
|
||||
data.MaxRadius = point.z;
|
||||
if (data.MaxX.HasValue == false || data.MaxX.Value < point.x)
|
||||
data.MaxX = point.x;
|
||||
if (data.MinX.HasValue == false || data.MinX.Value > point.x)
|
||||
data.MinX = point.x;
|
||||
if (data.MaxY.HasValue == false || data.MaxY.Value < point.y)
|
||||
data.MaxY = point.y;
|
||||
if (data.MinY.HasValue == false || data.MinY.Value > point.y)
|
||||
data.MinY = point.y;
|
||||
}
|
||||
|
||||
public double GetMaxYValue()
|
||||
{
|
||||
return GetMaxValue(1, true);
|
||||
}
|
||||
|
||||
public double GetMaxXValue()
|
||||
{
|
||||
return GetMaxValue(0, true);
|
||||
}
|
||||
public double GetMinYValue()
|
||||
{
|
||||
return GetMinValue(1, true);
|
||||
}
|
||||
|
||||
public double GetMinXValue()
|
||||
{
|
||||
return GetMinValue(0, true);
|
||||
}
|
||||
public virtual double GetMaxValue(int axis, bool dataValue)
|
||||
{
|
||||
if (dataValue == false)
|
||||
{
|
||||
if (axis == 0 && automaticHorizontalView == false)
|
||||
{
|
||||
double axisAdd = horizontalViewSize;
|
||||
if (Math.Abs(axisAdd) < 0.0001f)
|
||||
{
|
||||
if (axisAdd < 0)
|
||||
axisAdd = -0.0001f;
|
||||
else
|
||||
axisAdd = 0.0001f;
|
||||
}
|
||||
return HorizontalViewOrigin + axisAdd;
|
||||
}
|
||||
if (axis == 1 && AutomaticVerticallView == false)
|
||||
{
|
||||
double axisAdd = verticalViewSize;
|
||||
if (Math.Abs(axisAdd) < 0.0001f)
|
||||
{
|
||||
if (axisAdd < 0)
|
||||
axisAdd = -0.0001f;
|
||||
else
|
||||
axisAdd = 0.0001f;
|
||||
}
|
||||
return VerticalViewOrigin + axisAdd;
|
||||
}
|
||||
}
|
||||
double? res = null;
|
||||
double add = 0;
|
||||
foreach (BaseScrollableCategoryData cat in mData.Values)
|
||||
{
|
||||
if (cat.Enabled == false)
|
||||
continue;
|
||||
if (cat.MaxRadius.HasValue && add < cat.MaxRadius)
|
||||
add = cat.MaxRadius.Value;
|
||||
if (axis == 0)
|
||||
{
|
||||
if (res.HasValue == false || (cat.MaxX.HasValue && res.Value < cat.MaxX))
|
||||
res = cat.MaxX;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (res.HasValue == false || (cat.MaxY.HasValue && res.Value < cat.MaxY))
|
||||
res = cat.MaxY;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<mSliders.Count; i++)
|
||||
{
|
||||
BaseSlider s = mSliders[i];
|
||||
if (axis == 0)
|
||||
res = ChartCommon.Max(res, s.Max.x);
|
||||
else
|
||||
res = ChartCommon.Max(res, s.Max.y);
|
||||
}
|
||||
if (res.HasValue == false)
|
||||
return 10f;
|
||||
double gap = (axis == 0) ? automaticcHorizontaViewGap : automaticVerticalViewGap;
|
||||
return res.Value + add + gap;
|
||||
}
|
||||
|
||||
public virtual double GetMinValue(int axis, bool dataValue)
|
||||
{
|
||||
if (dataValue == false)
|
||||
{
|
||||
if (axis == 0 && automaticHorizontalView == false)
|
||||
return horizontalViewOrigin;
|
||||
if (axis == 1 && AutomaticVerticallView == false)
|
||||
return verticalViewOrigin;
|
||||
}
|
||||
double? res = null;
|
||||
double add = 0f;
|
||||
|
||||
foreach (BaseScrollableCategoryData cat in mData.Values)
|
||||
{
|
||||
if (cat.Enabled == false)
|
||||
continue;
|
||||
if (cat.MaxRadius.HasValue && add < cat.MaxRadius)
|
||||
add = cat.MaxRadius.Value;
|
||||
|
||||
if (axis == 0)
|
||||
{
|
||||
if (res.HasValue == false || (cat.MinX.HasValue && res.Value > cat.MinX))
|
||||
res = cat.MinX;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (res.HasValue == false || (cat.MinY.HasValue && res.Value > cat.MinY))
|
||||
res = cat.MinY;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < mSliders.Count; i++)
|
||||
{
|
||||
BaseSlider s = mSliders[i];
|
||||
if (axis == 0)
|
||||
res = ChartCommon.Min(res, s.Max.x);
|
||||
else
|
||||
res = ChartCommon.Min(res, s.Max.y);
|
||||
}
|
||||
if (res.HasValue == false)
|
||||
return 0.0;
|
||||
double max = GetMaxValue(axis, dataValue);
|
||||
if (max == res.Value)
|
||||
{
|
||||
if (res.Value == 0.0)
|
||||
return -10.0f;
|
||||
return 0.0;
|
||||
}
|
||||
double gap = (axis == 0) ? automaticcHorizontaViewGap : automaticVerticalViewGap;
|
||||
return res.Value - add - gap;
|
||||
}
|
||||
|
||||
protected void RaiseRealtimeDataChanged(int index,string category)
|
||||
{
|
||||
if (mSuspendEvents)
|
||||
return;
|
||||
|
||||
if (RealtimeDataChanged != null)
|
||||
RealtimeDataChanged(index, category);
|
||||
}
|
||||
|
||||
protected void RaiseViewPortionChanged()
|
||||
{
|
||||
if (mSuspendEvents)
|
||||
return;
|
||||
if (ViewPortionChanged != null)
|
||||
ViewPortionChanged(this, EventArgs.Empty);
|
||||
}
|
||||
protected void RaiseDataChanged()
|
||||
{
|
||||
if (mSuspendEvents)
|
||||
return;
|
||||
if (DataChanged != null)
|
||||
DataChanged(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public void RestoreDataValues()
|
||||
{
|
||||
if (automaticHorizontalView)
|
||||
RestoreDataValues(0);
|
||||
if (AutomaticVerticallView)
|
||||
RestoreDataValues(1);
|
||||
}
|
||||
|
||||
public void RestoreDataValues(int axis)
|
||||
{
|
||||
if (axis == 0)
|
||||
{
|
||||
double maxH = GetMaxValue(0, true);
|
||||
double minH = GetMinValue(0, true);
|
||||
horizontalViewOrigin = minH;
|
||||
horizontalViewSize = maxH - minH;
|
||||
}
|
||||
else
|
||||
{
|
||||
double maxV = GetMaxValue(1, true);
|
||||
double minV = GetMinValue(1, true);
|
||||
verticalViewOrigin = minV;
|
||||
verticalViewSize = maxV - minV;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// clears the specified category from any data
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
protected abstract void InnerClearCategory(string category);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new category based on a BaseScrollableCategoryData object
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
protected abstract bool AddCategory(string category, BaseScrollableCategoryData data);
|
||||
|
||||
protected abstract void AppendDatum(string category, MixedSeriesGenericValue value);
|
||||
protected abstract void AppendDatum(string category, IList<MixedSeriesGenericValue> value);
|
||||
|
||||
/// <summary>
|
||||
/// instanciates a new category object with default settings. returns nulls if not supported
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract BaseScrollableCategoryData GetDefaultCategory();
|
||||
public abstract void OnAfterDeserialize();
|
||||
public abstract void OnBeforeSerialize();
|
||||
|
||||
bool IMixedSeriesProxy.AddCategory(string category, BaseScrollableCategoryData data)
|
||||
{
|
||||
return AddCategory(category, data);
|
||||
}
|
||||
|
||||
bool IMixedSeriesProxy.HasCategory(string catgeory)
|
||||
{
|
||||
return mData.ContainsKey(catgeory);
|
||||
}
|
||||
|
||||
void IMixedSeriesProxy.ClearCategory(string category)
|
||||
{
|
||||
InnerClearCategory(category);
|
||||
}
|
||||
|
||||
void IMixedSeriesProxy.AppendDatum(string category, MixedSeriesGenericValue value)
|
||||
{
|
||||
AppendDatum(category, value);
|
||||
}
|
||||
|
||||
void IMixedSeriesProxy.AppendDatum(string category, IList<MixedSeriesGenericValue> value)
|
||||
{
|
||||
AppendDatum(category, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5927a12575fbc674fbf41f96a09b70cc
|
||||
timeCreated: 1502383500
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user