graph chart引入&骑行结果弹窗

This commit is contained in:
lishuo committed 2021-04-22 19:29:59 +08:00
1 parent 40d118cea3
commit 96f3644b5b
2374 files changed
+485161 -2410

No files matched your search

@@ -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:
@@ -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: