작업 조건 분석 기능 개발
This commit is contained in:
9
Assets/Chart And Graph/Script/Utils/Animation.meta
Normal file
9
Assets/Chart And Graph/Script/Utils/Animation.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1639f945436894a49af2cd9d146d238d
|
||||
folderAsset: yes
|
||||
timeCreated: 1560548194
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,55 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using ChartAndGraph;
|
||||
|
||||
public class BarAnimation : MonoBehaviour
|
||||
{
|
||||
public AnimationCurve Curve = AnimationCurve.Linear(0f, 0f, 1f, 1f);
|
||||
public bool AnimateOnStart = true;
|
||||
// public bool AnimateOnEnable = true;
|
||||
public float AnimationTime = 3f;
|
||||
BarChart barChart;
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
{
|
||||
barChart = GetComponent<BarChart>();
|
||||
if (AnimateOnStart)
|
||||
Animate();
|
||||
}
|
||||
/* public void OnEnable()
|
||||
{
|
||||
barChart = GetComponent<BarChart>();
|
||||
if (AnimateOnEnable)
|
||||
Animate();
|
||||
}*/
|
||||
public void Animate()
|
||||
{
|
||||
if(barChart != null)
|
||||
{
|
||||
double max = barChart.DataSource.GetMaxValue();
|
||||
double min = barChart.DataSource.GetMinValue();
|
||||
barChart.DataSource.StartBatch();
|
||||
barChart.DataSource.AutomaticMaxValue = false;
|
||||
barChart.DataSource.AutomaticMinValue = false;
|
||||
barChart.DataSource.MaxValue = max;
|
||||
barChart.DataSource.MinValue = min;
|
||||
for (int i=0; i<barChart.DataSource.TotalCategories; i++)
|
||||
for(int j=0; j<barChart.DataSource.TotalGroups; j++)
|
||||
{
|
||||
string category = barChart.DataSource.GetCategoryName(i);
|
||||
string group = barChart.DataSource.GetGroupName(j);
|
||||
double val = barChart.DataSource.GetValue(category, group);
|
||||
barChart.DataSource.SetValue(category, group,0.0);
|
||||
barChart.DataSource.SlideValue(category, group, val, AnimationTime, Curve);
|
||||
}
|
||||
barChart.DataSource.EndBatch();
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8fa3c1507f66ca24fa9c929b5fae69a5
|
||||
timeCreated: 1481393289
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
141
Assets/Chart And Graph/Script/Utils/Animation/GraphAnimation.cs
Normal file
141
Assets/Chart And Graph/Script/Utils/Animation/GraphAnimation.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using ChartAndGraph;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
public class GraphAnimation : MonoBehaviour
|
||||
{
|
||||
GraphChartBase graphChart;
|
||||
public float AnimationTime = 3f;
|
||||
public bool ModifyRange = true;
|
||||
Dictionary<String, InnerAnimation> mAnimations = new Dictionary<string, InnerAnimation>();
|
||||
|
||||
class InnerAnimation
|
||||
{
|
||||
public double maxX, minX, maxY, minY;
|
||||
public float totalTime = 3f;
|
||||
public float next = -1f;
|
||||
public string category;
|
||||
public List<DoubleVector2> points;
|
||||
public int index;
|
||||
|
||||
public void Update(GraphChartBase graphChart)
|
||||
{
|
||||
|
||||
if (graphChart == null || points == null || points.Count == 0)
|
||||
return;
|
||||
if (index >= points.Count)
|
||||
return;
|
||||
float leapTime = totalTime / (float)points.Count;
|
||||
if (next == -1f)
|
||||
next = leapTime*2;
|
||||
next += Time.deltaTime;
|
||||
if (next >= leapTime)
|
||||
{
|
||||
int totalLeaps = (int)(next / (leapTime));
|
||||
|
||||
for (int i = 0; i < totalLeaps && index<points.Count; i++)
|
||||
{
|
||||
DoubleVector2 point = points[index];
|
||||
graphChart.DataSource.AddPointToCategoryRealtime(category, point.x, point.y, leapTime);
|
||||
++index;
|
||||
}
|
||||
next -= leapTime * totalLeaps;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
graphChart = GetComponent<GraphChartBase>();
|
||||
}
|
||||
|
||||
bool IsValidDouble(double val)
|
||||
{
|
||||
if (double.IsNaN(val))
|
||||
return false;
|
||||
if (double.IsInfinity(val))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Animate(string category, List<DoubleVector2> points,float totalTime)
|
||||
{
|
||||
graphChart = GetComponent<GraphChartBase>();
|
||||
if (graphChart == null)
|
||||
return;
|
||||
if (points == null)
|
||||
return;
|
||||
if (points.Count == 0)
|
||||
return;
|
||||
InnerAnimation anim = new InnerAnimation();
|
||||
anim.maxX = float.MinValue;
|
||||
anim.maxY = float.MinValue;
|
||||
anim.minX = float.MaxValue;
|
||||
anim.minY = float.MaxValue;
|
||||
|
||||
for (int i = 0; i < points.Count; ++i)
|
||||
{
|
||||
anim.maxX = Math.Max(points[i].x, anim.maxX);
|
||||
anim.maxY = Math.Max(points[i].y, anim.maxY);
|
||||
anim.minX = Math.Min(points[i].x, anim.minX);
|
||||
anim.minY = Math.Min(points[i].y, anim.minY);
|
||||
}
|
||||
|
||||
if (ModifyRange)
|
||||
{
|
||||
double maxX = anim.maxX;
|
||||
double maxY = anim.maxY;
|
||||
double minX = anim.minX;
|
||||
double minY = anim.minY;
|
||||
foreach (InnerAnimation a in mAnimations.Values)
|
||||
{
|
||||
maxX = Math.Max(maxX, a.maxX);
|
||||
maxY = Math.Max(maxY, a.maxY);
|
||||
minX = Math.Min(minX, a.minX);
|
||||
minY = Math.Min(minY, a.minY);
|
||||
}
|
||||
IInternalGraphData g = graphChart.DataSource;
|
||||
maxX = (float)Math.Max(g.GetMaxValue(0, true),maxX);
|
||||
minX = (float)Math.Min(g.GetMinValue(0, true), minX);
|
||||
maxY = (float)Math.Max(g.GetMaxValue(1, true), maxY);
|
||||
minY = (float)Math.Min(g.GetMinValue(1, true), minY);
|
||||
|
||||
if (IsValidDouble(maxX) && IsValidDouble(maxY) && IsValidDouble(minX) && IsValidDouble(minY))
|
||||
{
|
||||
graphChart.DataSource.StartBatch();
|
||||
graphChart.DataSource.AutomaticHorizontalView = false;
|
||||
graphChart.DataSource.AutomaticVerticallView = false;
|
||||
graphChart.DataSource.HorizontalViewSize = (maxX - minX);
|
||||
graphChart.DataSource.HorizontalViewOrigin = minX;
|
||||
graphChart.DataSource.VerticalViewSize = (maxY - minY);
|
||||
graphChart.DataSource.VerticalViewOrigin = minY;
|
||||
graphChart.DataSource.EndBatch();
|
||||
}
|
||||
}
|
||||
|
||||
anim.points = points;
|
||||
anim.index = 0;
|
||||
anim.next = 0;
|
||||
anim.totalTime = totalTime;
|
||||
anim.category = category;
|
||||
graphChart.DataSource.ClearCategory(category);
|
||||
mAnimations[category] = anim;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void FixedUpdate()
|
||||
{
|
||||
graphChart = GetComponent<GraphChartBase>();
|
||||
if (graphChart == null)
|
||||
return;
|
||||
foreach(InnerAnimation anim in mAnimations.Values)
|
||||
{
|
||||
anim.Update(graphChart);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70c1abbbcf5655346b75bc72dd74a703
|
||||
timeCreated: 1496382902
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,61 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using UnityEngine;
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
public class PieAnimation : MonoBehaviour
|
||||
{
|
||||
public bool AnimateOnStart = true;
|
||||
public bool AnimateOnEnable = true;
|
||||
[Range(0f,360f)]
|
||||
public float AnimateSpan = 360f;
|
||||
public float AnimationTime =2f;
|
||||
public AnimationCurve Curve = AnimationCurve.Linear(0f, 0f, 1f, 1f);
|
||||
PieChart pieChart;
|
||||
float StartTime = -1f;
|
||||
|
||||
void Start()
|
||||
{
|
||||
pieChart = GetComponent<PieChart>();
|
||||
if(AnimateOnStart)
|
||||
Animate();
|
||||
}
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
pieChart = GetComponent<PieChart>();
|
||||
if (AnimateOnEnable)
|
||||
Animate();
|
||||
}
|
||||
public void Animate()
|
||||
{
|
||||
if (pieChart != null)
|
||||
{
|
||||
if(StartTime <0f)
|
||||
AnimateSpan = pieChart.AngleSpan;
|
||||
pieChart.AngleSpan = Curve.Evaluate(0f);
|
||||
StartTime = Time.time;
|
||||
}
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
if(StartTime >= 0f && pieChart != null)
|
||||
{
|
||||
float curveTime = 0f;
|
||||
if (Curve.length > 0)
|
||||
curveTime = Curve.keys[Curve.length - 1].time;
|
||||
float elasped = Time.time - StartTime;
|
||||
elasped /= AnimationTime;
|
||||
float blend = elasped;
|
||||
elasped *= curveTime;
|
||||
elasped = Curve.Evaluate(elasped);
|
||||
if (blend >= 1f)
|
||||
{
|
||||
pieChart.AngleSpan = AnimateSpan;
|
||||
StartTime = -1f;
|
||||
}
|
||||
else
|
||||
pieChart.AngleSpan = Mathf.Lerp(0f, AnimateSpan, elasped);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97a90fab185f83f4bb1b1df9f16c7732
|
||||
timeCreated: 1481392424
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
Assets/Chart And Graph/Script/Utils/AxisCoordinates.cs
Normal file
32
Assets/Chart And Graph/Script/Utils/AxisCoordinates.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AxisCoordinates : MonoBehaviour
|
||||
{
|
||||
public string TextFormat = "{0} : {1}";
|
||||
public Text Coordinates;
|
||||
public RectTransform Prefab;
|
||||
|
||||
RectTransform mVertical;
|
||||
RectTransform mHorizontal;
|
||||
|
||||
// Use this for initialization
|
||||
|
||||
void Start()
|
||||
{
|
||||
if(Prefab != null)
|
||||
{
|
||||
mVertical = GameObject.Instantiate(Prefab);
|
||||
mHorizontal = GameObject.Instantiate(Prefab);
|
||||
mVertical.gameObject.SetActive(false);
|
||||
mHorizontal.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Update () {
|
||||
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Script/Utils/AxisCoordinates.cs.meta
Normal file
12
Assets/Chart And Graph/Script/Utils/AxisCoordinates.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c978a3d46dd28646ab006e59f02df12
|
||||
timeCreated: 1505839505
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/Chart And Graph/Script/Utils/GraphDataVisualEditor.cs
Normal file
16
Assets/Chart And Graph/Script/Utils/GraphDataVisualEditor.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class GraphDataVisualEditor : MonoBehaviour {
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbe07ad864591f847908ca515fd73bf2
|
||||
timeCreated: 1584545585
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
35
Assets/Chart And Graph/Script/Utils/HoverText.Extension.cs
Normal file
35
Assets/Chart And Graph/Script/Utils/HoverText.Extension.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
//using UnityEngine;
|
||||
//using System.Collections;
|
||||
//using ChartAndGraph;
|
||||
|
||||
//public partial class HoverText
|
||||
//{
|
||||
|
||||
// partial void HoverStart()
|
||||
// {
|
||||
// var candle = GetComponent<CandleChart>();
|
||||
// if (candle != null)
|
||||
// {
|
||||
// mChart = candle;
|
||||
// candle.CandleHovered.AddListener(CandleHover);
|
||||
// candle.NonHovered.AddListener(NonHover);
|
||||
// }
|
||||
// }
|
||||
|
||||
// void CandleHover(CandleChart.CandleEventArgs args)
|
||||
// {
|
||||
// string data = "";
|
||||
// string open, high, low, close, start, duration;
|
||||
// ((CandleChart)mChart).FormatCandleValue(args.CandleValue, fractionDigits, out open, out high, out low, out close, out start, out duration);
|
||||
// if (args.IsBodyEvent)
|
||||
// data = ((CandleChart)mChart).FormatBody(open, close, high, low, start, duration);
|
||||
// else if (args.IsHighEvent)
|
||||
// data = ((CandleChart)mChart).FormatHigh(open, close, high, low, start, duration);
|
||||
// else if (args.IsLowEvent)
|
||||
// data = ((CandleChart)mChart).FormatLow(open, close, high, low, start, duration);
|
||||
// PopText(data, args.Position, true);
|
||||
// }
|
||||
|
||||
|
||||
//}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c4b3a5c7420d64a47ad65292ba0b1e82
|
||||
timeCreated: 1505900951
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
153
Assets/Chart And Graph/Script/Utils/HoverText.cs
Normal file
153
Assets/Chart And Graph/Script/Utils/HoverText.cs
Normal file
@@ -0,0 +1,153 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using ChartAndGraph;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public partial class HoverText : MonoBehaviour
|
||||
{
|
||||
public Text TextPrefab;
|
||||
public int FontSize = 5;
|
||||
public Vector3 TextOffset = new Vector3();
|
||||
int fractionDigits = 0;
|
||||
AnyChart mChart;
|
||||
|
||||
List<Text> mItems = new List<Text>();
|
||||
List<CharItemEffectController> mRemoved = new List<CharItemEffectController>();
|
||||
|
||||
partial void HoverStart();
|
||||
void Start ()
|
||||
{
|
||||
var graph = GetComponent<GraphChart>();
|
||||
|
||||
var labels = GetComponent<ItemLabels>();
|
||||
if (labels != null)
|
||||
fractionDigits = labels.FractionDigits;
|
||||
else
|
||||
fractionDigits = 2;
|
||||
|
||||
if (graph != null)
|
||||
{
|
||||
mChart = graph;
|
||||
graph.PointHovered.AddListener(GraphHover);
|
||||
graph.NonHovered.AddListener(NonHover);
|
||||
return;
|
||||
}
|
||||
|
||||
var bar = GetComponent<CanvasBarChart>();
|
||||
if (bar != null)
|
||||
{
|
||||
mChart = bar;
|
||||
bar.BarHovered.AddListener(BarHover);
|
||||
bar.NonHovered.AddListener(NonHover);
|
||||
return;
|
||||
}
|
||||
var pie = GetComponent<PieChart>();
|
||||
if(pie != null)
|
||||
{
|
||||
mChart = pie;
|
||||
pie.PieHovered.AddListener(PieHover);
|
||||
pie.NonHovered.AddListener(NonHover);
|
||||
}
|
||||
HoverStart();
|
||||
}
|
||||
|
||||
void NonHover()
|
||||
{
|
||||
for (int i = 0; i < mItems.Count; i++)
|
||||
{
|
||||
RemoveText(mItems[i]);
|
||||
}
|
||||
mItems.Clear();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
mRemoved.RemoveAll(x =>
|
||||
{
|
||||
if(!x.enabled)
|
||||
{
|
||||
ChartCommon.SafeDestroy(x.gameObject);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
IEnumerator SelectText(Text text)
|
||||
{
|
||||
yield return new WaitForEndOfFrame();
|
||||
if (text != null)
|
||||
{
|
||||
ChartItemEvents e = text.GetComponent<ChartItemEvents>();
|
||||
if (e != null)
|
||||
{
|
||||
e.OnMouseHover.Invoke(e.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveText(Text text)
|
||||
{
|
||||
if (text != null)
|
||||
{
|
||||
ChartItemEvents e = text.GetComponent<ChartItemEvents>();
|
||||
CharItemEffectController control = text.GetComponent<CharItemEffectController>();
|
||||
if (e != null && control != null)
|
||||
{
|
||||
e.OnMouseLeave.Invoke(e.gameObject);
|
||||
mRemoved.Add(control);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChartCommon.SafeDestroy(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PopText(string data,Vector3 position,bool worldPositionStays)
|
||||
{
|
||||
var canvas = GetComponentInParent<Canvas>();
|
||||
if (canvas == null || TextPrefab == null)
|
||||
return;
|
||||
NonHover();
|
||||
GameObject obj =(GameObject) GameObject.Instantiate(TextPrefab.gameObject, position + TextOffset, Quaternion.identity);
|
||||
var text = obj.GetComponent<Text>();
|
||||
text.maskable = false;
|
||||
text.text = data;
|
||||
text.fontSize = FontSize;
|
||||
obj.transform.SetParent(transform, false);
|
||||
if (worldPositionStays)
|
||||
obj.transform.position = position + TextOffset;
|
||||
else
|
||||
obj.transform.localPosition = position + TextOffset;
|
||||
Vector3 local = obj.transform.localPosition;
|
||||
local.z = 0f;
|
||||
obj.transform.localPosition = local;
|
||||
mItems.Add(text);
|
||||
StartCoroutine(SelectText(text));
|
||||
}
|
||||
void PieHover(PieChart.PieEventArgs args)
|
||||
{
|
||||
String data = ChartAdancedSettings.Instance.FormatFractionDigits(fractionDigits, args.Value);
|
||||
PopText(data, args.LabelPosition, true);
|
||||
}
|
||||
void BarHover(BarChart.BarEventArgs args)
|
||||
{
|
||||
String data = ChartAdancedSettings.Instance.FormatFractionDigits(fractionDigits, args.Value);
|
||||
PopText(data, args.TopPosition,true);
|
||||
}
|
||||
void GraphHover(GraphChartBase.GraphEventArgs args)
|
||||
{
|
||||
var graph = mChart as GraphChart;
|
||||
var point = graph.DataSource.GetPoint(args.Category, args.Index);
|
||||
Vector3 position;
|
||||
if(graph.PointToWorldSpace(out position, point.x, point.y, args.Category))
|
||||
PopText(args.XString + ":" + args.YString, position, true);
|
||||
else
|
||||
PopText(args.XString + ":" + args.YString, args.Position,false);
|
||||
}
|
||||
|
||||
}
|
||||
12
Assets/Chart And Graph/Script/Utils/HoverText.cs.meta
Normal file
12
Assets/Chart And Graph/Script/Utils/HoverText.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53bfaf390f2349b4894f21c310d420b2
|
||||
timeCreated: 1504892729
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/Chart And Graph/Script/Utils/InfoBox.meta
Normal file
9
Assets/Chart And Graph/Script/Utils/InfoBox.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a08ac3975ab3aea4f86c113d4b38f16c
|
||||
folderAsset: yes
|
||||
timeCreated: 1481298721
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
153
Assets/Chart And Graph/Script/Utils/InfoBox/InfoBox.cs
Normal file
153
Assets/Chart And Graph/Script/Utils/InfoBox/InfoBox.cs
Normal file
@@ -0,0 +1,153 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.UI;
|
||||
using System;
|
||||
|
||||
namespace ChartAndGraph
|
||||
{
|
||||
/// <summary>
|
||||
/// this class demonstrates the use of chart events
|
||||
/// </summary>
|
||||
public partial class InfoBox : MonoBehaviour
|
||||
{
|
||||
public PieChart[] PieChart;
|
||||
public BarChart[] BarChart;
|
||||
public GraphChartBase[] GraphChart;
|
||||
public RadarChart[] RadarChart;
|
||||
public PyramidChart[] PyramidChart;
|
||||
public Text infoText;
|
||||
|
||||
void BarHovered(BarChart.BarEventArgs args)
|
||||
{
|
||||
|
||||
infoText.text = string.Format("({0},{1}) : {2}", args.Category, args.Group, args.Value);
|
||||
}
|
||||
|
||||
void RadarHovered(RadarChart.RadarEventArgs args)
|
||||
{
|
||||
infoText.text = string.Format("{0},{1} : {2}", args.Category, args.Group, ChartAdancedSettings.Instance.FormatFractionDigits(2, args.Value));
|
||||
}
|
||||
void GraphClicked(GraphChartBase.GraphEventArgs args)
|
||||
{
|
||||
if (args.Magnitude < 0f)
|
||||
infoText.text = string.Format("{0} : {1},{2} Clicked", args.Category, args.XString, args.YString);
|
||||
else
|
||||
infoText.text = string.Format("{0} : {1},{2} : Sample Size {3} Clicked", args.Category, args.XString, args.YString, args.Magnitude);
|
||||
}
|
||||
|
||||
void GraphHoverd(GraphChartBase.GraphEventArgs args)
|
||||
{
|
||||
if (args.Magnitude < 0f)
|
||||
infoText.text = string.Format("{0} : {1},{2}", args.Category, args.XString, args.YString);
|
||||
else
|
||||
infoText.text = string.Format("{0} : {1},{2} : Sample Size {3}", args.Category, args.XString, args.YString, args.Magnitude);
|
||||
}
|
||||
|
||||
void GraphLineClicked(GraphChartBase.GraphEventArgs args)
|
||||
{
|
||||
if (args.Magnitude < 0f)
|
||||
infoText.text = string.Format("Line Start at {0} : {1},{2} Clicked", args.Category, args.XString, args.YString);
|
||||
else
|
||||
infoText.text = string.Format("Line Start at{0} : {1},{2} : Sample Size {3} Clicked", args.Category, args.XString, args.YString, args.Magnitude);
|
||||
}
|
||||
|
||||
void GraphLineHoverd(GraphChartBase.GraphEventArgs args)
|
||||
{
|
||||
if (args.Magnitude < 0f)
|
||||
infoText.text = string.Format("Line Start at {0} : {1},{2}", args.Category, args.XString, args.YString);
|
||||
else
|
||||
infoText.text = string.Format("Line Start at {0} : {1},{2} : Sample Size {3}", args.Category, args.XString, args.YString, args.Magnitude);
|
||||
}
|
||||
|
||||
void PieHovered(PieChart.PieEventArgs args)
|
||||
{
|
||||
infoText.text = string.Format("{0} : {1}", args.Category, args.Value);
|
||||
}
|
||||
void PyramidHovered(PyramidChart.PyramidEventArgs args)
|
||||
{
|
||||
infoText.text = string.Format("{0} : {1}", args.Title, args.Text);
|
||||
}
|
||||
|
||||
|
||||
void NonHovered()
|
||||
{
|
||||
infoText.text = "";
|
||||
}
|
||||
|
||||
partial void HookCandle();
|
||||
|
||||
public void HookChartEvents()
|
||||
{
|
||||
if (PieChart != null)
|
||||
{
|
||||
foreach (PieChart pie in PieChart)
|
||||
{
|
||||
if (pie == null)
|
||||
continue;
|
||||
pie.PieHovered.AddListener(PieHovered); // add listeners for the pie chart events
|
||||
pie.NonHovered.AddListener(NonHovered);
|
||||
}
|
||||
}
|
||||
if(PyramidChart != null)
|
||||
{
|
||||
foreach (PyramidChart pyramid in PyramidChart)
|
||||
{
|
||||
if (pyramid == null)
|
||||
continue;
|
||||
pyramid.ItemHovered.AddListener(PyramidHovered); // add listeners for the pie chart events
|
||||
pyramid.NonHovered.AddListener(NonHovered);
|
||||
}
|
||||
}
|
||||
if (BarChart != null)
|
||||
{
|
||||
foreach (BarChart bar in BarChart)
|
||||
{
|
||||
if (bar == null)
|
||||
continue;
|
||||
bar.BarHovered.AddListener(BarHovered); // add listeners for the bar chart events
|
||||
bar.NonHovered.AddListener(NonHovered);
|
||||
}
|
||||
}
|
||||
|
||||
if(GraphChart != null)
|
||||
{
|
||||
foreach(GraphChartBase graph in GraphChart)
|
||||
{
|
||||
if (graph == null)
|
||||
continue;
|
||||
graph.PointClicked.AddListener(GraphClicked);
|
||||
graph.PointHovered.AddListener(GraphHoverd);
|
||||
if(graph is GraphChart)
|
||||
{
|
||||
((GraphChart)graph).LineClicked.AddListener(GraphLineClicked);
|
||||
((GraphChart)graph).LineHovered.AddListener(GraphLineHoverd);
|
||||
}
|
||||
graph.NonHovered.AddListener(NonHovered);
|
||||
}
|
||||
}
|
||||
HookCandle();
|
||||
if (RadarChart != null)
|
||||
{
|
||||
foreach (RadarChart radar in RadarChart)
|
||||
{
|
||||
if (radar == null)
|
||||
continue;
|
||||
radar.PointHovered.AddListener(RadarHovered);
|
||||
radar.NonHovered.AddListener(NonHovered);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
HookChartEvents();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Script/Utils/InfoBox/InfoBox.cs.meta
Normal file
12
Assets/Chart And Graph/Script/Utils/InfoBox/InfoBox.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13b7d1752c63ca442b31308855f1370b
|
||||
timeCreated: 1481298731
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed85cbeda1d763342b040f4d7c5cd461
|
||||
folderAsset: yes
|
||||
timeCreated: 1480963541
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using ChartAndGraph;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class MultipleGraphDemo : MonoBehaviour
|
||||
{
|
||||
public GraphChart Graph;
|
||||
// public GraphAnimation Animation;
|
||||
public int TotalPoints = 5;
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (Graph == null) // the ChartGraph info is obtained via the inspector
|
||||
return;
|
||||
|
||||
List<DoubleVector2> animationPoints = new List<DoubleVector2>();
|
||||
float x = 0f;
|
||||
Graph.HorizontalValueToStringMap.Add(10, "Ten");
|
||||
Graph.VerticalValueToStringMap.Add(10, "$$");
|
||||
Graph.DataSource.StartBatch(); // calling StartBatch allows changing the graph data without redrawing the graph for every change
|
||||
Graph.DataSource.ClearCategory("Player 2"); // clear the "Player 2" category. this category is defined using the GraphChart inspector
|
||||
|
||||
for (int i = 0; i < TotalPoints; i++) //add random points to the graph
|
||||
{
|
||||
Graph.DataSource.AddPointToCategory("Player 1", System.DateTime.Now + System.TimeSpan.FromDays(x), Random.value * 20f + 10f); // each time we call AddPointToCategory
|
||||
Graph.DataSource.AddPointToCategory("Player 2", System.DateTime.Now + System.TimeSpan.FromDays(x), Random.value * 20f + 10f); // each time we call AddPointToCategory
|
||||
//animationPoints.Add(new DoubleVector2(ChartDateUtility.DateToValue(System.DateTime.Now + System.TimeSpan.FromDays(x)), Random.value * 10f));
|
||||
x += 3;
|
||||
}
|
||||
|
||||
Graph.DataSource.EndBatch(); // finally we call EndBatch , this will cause the GraphChart to redraw itself
|
||||
//if (Animation != null)
|
||||
//{
|
||||
//if (Graph.DataSource.HasCategory("Player 2"))
|
||||
// Animation.Animate("Player 2", animationPoints, 6f);
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a164fb56dfb16e4f9c9c564daf9f5c8
|
||||
timeCreated: 1480963554
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d094036da9a3f04b84929c65de899b0
|
||||
folderAsset: yes
|
||||
timeCreated: 1480961725
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using ChartAndGraph;
|
||||
using System;
|
||||
|
||||
public class SimpleGraphDemo : MonoBehaviour
|
||||
{
|
||||
public GraphChart Graph;
|
||||
public int TotalPoints = 10;
|
||||
void Start () {
|
||||
|
||||
if (Graph == null) // the ChartGraph info is obtained via the inspector
|
||||
return;
|
||||
DateTime x = DateTime.Now.AddDays(TotalPoints); // x is marked as a date
|
||||
Graph.DataSource.StartBatch(); // calling StartBatch allows changing the graph data without redrawing the graph for every change
|
||||
Graph.DataSource.ClearCategory("Achivments Per Day"); // clear the "test" category. this category is defined using the GraphChart inspector
|
||||
for (int i=0; i< TotalPoints; i++) //add random points to the graph
|
||||
{
|
||||
Graph.DataSource.AddPointToCategory("Achivments Per Day", x, UnityEngine.Random.value*30f); // each time we call AddPointToCategory
|
||||
x += TimeSpan.FromDays(1);
|
||||
}
|
||||
Graph.DataSource.EndBatch(); // finally we call EndBatch , this will cause the GraphChart to redraw itself
|
||||
}
|
||||
|
||||
void Update () {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 932bc7424c0ae484b9f7b8d1e8646e3f
|
||||
timeCreated: 1480961870
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user