graph chart引入&骑行结果弹窗
This commit is contained in:
1 parent
40d118cea3
commit
96f3644b5b
2374 files changed
+485161
-2410
No files matched your search
@@ -0,0 +1,77 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using ChartAndGraph;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Marker : MonoBehaviour
|
||||
{
|
||||
|
||||
public GraphChartBase Chart;
|
||||
public RectTransform LastPoint;
|
||||
public RectTransform Area;
|
||||
public Text MouseText;
|
||||
|
||||
private DoubleRect currentRect = new DoubleRect();
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
{
|
||||
if (Chart != null)
|
||||
{
|
||||
Chart.OnRedraw.AddListener(Redraw);
|
||||
}
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (Chart == null)
|
||||
return;
|
||||
|
||||
if(Chart.IsRectVisible(currentRect) == false)
|
||||
{
|
||||
|
||||
double endX = (float)(Chart.HorizontalScrolling + Chart.DataSource.HorizontalViewSize);
|
||||
double x = endX - 1f;
|
||||
double y = (float)Chart.VerticalScrolling;
|
||||
double endY = (float)Chart.DataSource.GetMaxValue(1, false);
|
||||
currentRect = new DoubleRect(x, y, endX - x, endY - y);
|
||||
}
|
||||
|
||||
DoubleRect trimRect;
|
||||
if (Chart.TrimRect(currentRect, out trimRect))
|
||||
{
|
||||
Chart.RectToCanvas(Area, trimRect);
|
||||
}
|
||||
|
||||
|
||||
DoubleVector3 last;
|
||||
if (Chart.DataSource.GetLastPoint("Player 1", out last))
|
||||
{
|
||||
Vector3 pos;
|
||||
if(Chart.PointToWorldSpace(out pos, last.x, last.y, "Player 1"))
|
||||
{
|
||||
if(LastPoint != null)
|
||||
{
|
||||
LastPoint.transform.position = pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
double mx, my;
|
||||
if (MouseText != null)
|
||||
{
|
||||
if (Chart.MouseToClient(out mx, out my))
|
||||
{
|
||||
MouseText.text = string.Format("{0:0.00} , {1:0.00}", mx, my);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MouseText.text = "";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb49bcddaca291d4d9306cfd3ba83e16
|
||||
timeCreated: 1505744455
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using ChartAndGraph;
|
||||
|
||||
public class MarkerSampleDataInitializer : MonoBehaviour
|
||||
{
|
||||
|
||||
public GraphChartBase graph;
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
{
|
||||
graph.DataSource.ClearCategory("Player 1");
|
||||
var point = FindObjectOfType<MarkerText>();
|
||||
var line = FindObjectOfType<MarkerTextLine>();
|
||||
double prevY = 0.0;
|
||||
for (int i=0; i<10; i++)
|
||||
{
|
||||
|
||||
double y = Random.value * 10f;
|
||||
graph.DataSource.AddPointToCategory("Player 1", i, y);
|
||||
if (i == 5)
|
||||
point.point = new DoubleVector2(i, y);
|
||||
|
||||
if( i==7 )
|
||||
{
|
||||
line.point1 = new DoubleVector2(i - 1,prevY);
|
||||
line.point2 = new DoubleVector2(i , y);
|
||||
}
|
||||
prevY = y;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b8dda9f9d7b65e4ea83786886ec791d
|
||||
timeCreated: 1558363333
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using ChartAndGraph;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MarkerText : MonoBehaviour {
|
||||
|
||||
public GraphChartBase Chart;
|
||||
public Text TextObject;
|
||||
/// <summary>
|
||||
/// the text position in graph coordinates
|
||||
/// </summary>
|
||||
public DoubleVector2 point;
|
||||
|
||||
/// <summary>
|
||||
/// offsets the text on the x axis away from the selected point
|
||||
/// </summary>
|
||||
public float SeperationOffset = 0f;
|
||||
/// <summary>
|
||||
/// offsets the text on the y axus away from the selected point
|
||||
/// </summary>
|
||||
public float ElevationOffset = 0f;
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Chart == null)
|
||||
return;
|
||||
Vector3 res;
|
||||
|
||||
if (Chart.PointToWorldSpace(out res, point.x, point.y))
|
||||
TextObject.transform.position = res + new Vector3(SeperationOffset, ElevationOffset, 0f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b3af3e9270c7f64fbbb3dfd10e72100
|
||||
timeCreated: 1558361222
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06d82586433e17a498f52c9f9a5b57cc
|
||||
timeCreated: 1558361194
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,56 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using ChartAndGraph;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MarkerTextLine : MonoBehaviour {
|
||||
|
||||
public GraphChartBase Chart;
|
||||
public Text TextObject;
|
||||
/// <summary>
|
||||
/// the first line position in graph coordinates
|
||||
/// </summary>
|
||||
public DoubleVector2 point1;
|
||||
/// <summary>
|
||||
/// the second line position in graph coordinates
|
||||
/// </summary>
|
||||
public DoubleVector2 point2;
|
||||
/// <summary>
|
||||
/// offsets the text on the x axis away from the selected point
|
||||
/// </summary>
|
||||
public float SeperationOffset = 0f;
|
||||
/// <summary>
|
||||
/// offsets the text on the y axus away from the selected point
|
||||
/// </summary>
|
||||
public float ElevationOffset = 0f;
|
||||
|
||||
public bool Rotate = true;
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Chart == null)
|
||||
return;
|
||||
Vector3 res1,res2;
|
||||
if (Chart.PointToWorldSpace(out res1, point1.x, point1.y))
|
||||
{
|
||||
if(Chart.PointToWorldSpace(out res2,point2.x,point2.y))
|
||||
{
|
||||
Vector2 finalPos = (res2 + res1) * 0.5f;
|
||||
Vector2 seperationVector = (res2 - res1).normalized;
|
||||
Vector2 elevationVector = ChartCommon.Perpendicular(seperationVector);
|
||||
TextObject.transform.position = finalPos + SeperationOffset * seperationVector + ElevationOffset * elevationVector;
|
||||
if(Rotate)
|
||||
{
|
||||
TextObject.transform.localRotation = Quaternion.Euler(0f, 0f,Mathf.Rad2Deg * Mathf.Atan2(seperationVector.y, seperationVector.x));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b0e59caefc323a4ebd77491fce8c5ee
|
||||
timeCreated: 1558365448
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c91d5b3c8785a5f4585e4a1244b76dad
|
||||
timeCreated: 1505744442
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,161 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using ChartAndGraph;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PointHighlight : MonoBehaviour
|
||||
{
|
||||
public Text TextPrefab;
|
||||
public ChartItemEffect PointHoverPrefab;
|
||||
|
||||
public int FontSize = 5;
|
||||
public Vector3 TextOffset = new Vector3();
|
||||
int fractionDigits = 0;
|
||||
GraphChart mChart;
|
||||
|
||||
class HighLight
|
||||
{
|
||||
public HighLight(Text t,ChartItemEffect p)
|
||||
{
|
||||
mText = t;
|
||||
mPoint = p;
|
||||
}
|
||||
public Text mText;
|
||||
public ChartItemEffect mPoint;
|
||||
public CharItemEffectController mControl;
|
||||
}
|
||||
List<HighLight> mItems = new List<HighLight>();
|
||||
List<HighLight> mRemoved = new List<HighLight>();
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
|
||||
var labels = GetComponent<ItemLabels>();
|
||||
if (labels != null)
|
||||
fractionDigits = labels.FractionDigits;
|
||||
else
|
||||
fractionDigits = 2;
|
||||
|
||||
var graph = GetComponent<GraphChart>();
|
||||
if (graph != null)
|
||||
mChart = graph;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
mRemoved.RemoveAll(x =>
|
||||
{
|
||||
if (!x.mControl.enabled)
|
||||
{
|
||||
ChartCommon.SafeDestroy(x.mText.gameObject);
|
||||
ChartCommon.SafeDestroy(x.mPoint.gameObject);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
IEnumerator SelectText(Text text,GameObject point)
|
||||
{
|
||||
yield return new WaitForEndOfFrame();
|
||||
if (text != null)
|
||||
{
|
||||
ChartItemEvents e = text.GetComponent<ChartItemEvents>();
|
||||
if (e != null)
|
||||
{
|
||||
e.OnMouseHover.Invoke(e.gameObject);
|
||||
}
|
||||
e = point.GetComponent<ChartItemEvents>();
|
||||
if (e != null)
|
||||
{
|
||||
e.OnMouseHover.Invoke(e.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
void ClearHighLight()
|
||||
{
|
||||
for (int i = 0; i < mItems.Count; i++)
|
||||
{
|
||||
RemoveText(mItems[i]);
|
||||
}
|
||||
mItems.Clear();
|
||||
}
|
||||
void RemoveText(HighLight h)
|
||||
{
|
||||
if (h.mText != null)
|
||||
{
|
||||
ChartItemEvents e = h.mText.GetComponent<ChartItemEvents>();
|
||||
h.mControl= h.mText.GetComponent<CharItemEffectController>();
|
||||
if (e != null && h.mControl != null)
|
||||
{
|
||||
e.OnMouseLeave.Invoke(e.gameObject);
|
||||
mRemoved.Add(h);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChartCommon.SafeDestroy(h.mText);
|
||||
}
|
||||
e = h.mPoint.GetComponent<ChartItemEvents>();
|
||||
if (e != null)
|
||||
{
|
||||
e.OnMouseLeave.Invoke(e.gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChartCommon.SafeDestroy(h.mPoint);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void PopText(string data, Vector3 position, bool worldPositionStays)
|
||||
{
|
||||
var canvas = GetComponentInParent<Canvas>();
|
||||
if (canvas == null || TextPrefab == null)
|
||||
return;
|
||||
ClearHighLight();
|
||||
GameObject highlight = (GameObject)GameObject.Instantiate(PointHoverPrefab.gameObject, position, Quaternion.identity);
|
||||
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);
|
||||
highlight.transform.SetParent(transform, false);
|
||||
if (worldPositionStays)
|
||||
{
|
||||
obj.transform.position = position + TextOffset;
|
||||
highlight.transform.position = position;
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.transform.localPosition = position + TextOffset;
|
||||
highlight.transform.localPosition = position;
|
||||
}
|
||||
Vector3 local = obj.transform.localPosition;
|
||||
local.z = 0f;
|
||||
obj.transform.localPosition = local;
|
||||
|
||||
local = highlight.transform.localPosition;
|
||||
local.z = 0f;
|
||||
highlight.transform.localPosition = local;
|
||||
mItems.Add(new HighLight(text, highlight.GetComponent<ChartItemEffect>()));
|
||||
StartCoroutine(SelectText(text, highlight));
|
||||
}
|
||||
|
||||
public void HighlightPoint(string category,int index)
|
||||
{
|
||||
var point = mChart.DataSource.GetPoint(category, index);
|
||||
string text = mChart.FormatItem(point.x, point.y);
|
||||
|
||||
Vector3 position;
|
||||
if (mChart.PointToWorldSpace(out position, point.x, point.y, category))
|
||||
PopText(text, position, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1407a84ca33d384795d08f6b2ba5b5b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff8c7776d481a934884a9c015eea9949
|
||||
timeCreated: 1558361194
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,70 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using ChartAndGraph;
|
||||
using UnityEngine.UI;
|
||||
using System;
|
||||
|
||||
public class TrackerLine : MonoBehaviour {
|
||||
public GraphChartBase Chart;
|
||||
public RectTransform Area;
|
||||
public float lineThickness = 1.0f;
|
||||
public bool TrackLast = true;
|
||||
public float yPosition = 0;
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
if (Chart != null)
|
||||
{
|
||||
Chart.OnRedraw.AddListener(Redraw);
|
||||
}
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (Chart == null)
|
||||
return;
|
||||
DoubleVector3 last;
|
||||
if (Chart.DataSource.GetLastPoint("Player 1", out last))
|
||||
{
|
||||
if(TrackLast == false)
|
||||
last.y = yPosition;
|
||||
DoubleRect rect = new DoubleRect(last.x - Chart.DataSource.HorizontalViewSize, last.y - lineThickness * 0.5f, Chart.DataSource.HorizontalViewSize, lineThickness);
|
||||
DoubleRect trimRect;
|
||||
|
||||
if (Area != null)
|
||||
{
|
||||
Vector3 res;
|
||||
if(Chart.PointToWorldSpace(out res,rect.min.x,rect.min.y))
|
||||
{
|
||||
res.y += lineThickness;
|
||||
double x, y;
|
||||
if(Chart.PointToClient(res,out x,out y))
|
||||
{
|
||||
double thick = Math.Abs(rect.min.y - y);
|
||||
rect = new DoubleRect(last.x - Chart.DataSource.HorizontalViewSize, last.y - thick * 0.5f, Chart.DataSource.HorizontalViewSize, thick);
|
||||
}
|
||||
}
|
||||
if (Chart.TrimRect(rect, out trimRect)) // if the rect is in display
|
||||
{
|
||||
if (Area.gameObject.activeSelf == false) // we draw it
|
||||
Area.gameObject.SetActive(true);
|
||||
Chart.RectToCanvas(Area, trimRect);
|
||||
// Area.sizeDelta = new Vector2(Area.sizeDelta.x, lineThickness);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Area.gameObject.activeSelf == true) // otherwise it is set as incative
|
||||
Area.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a160d77294af0340891aebde9c218dd
|
||||
timeCreated: 1553681288
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using ChartAndGraph;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class highlightTest : MonoBehaviour
|
||||
{
|
||||
public PointHighlight Highlight;
|
||||
public int count;
|
||||
float time = 1f;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
time -= Time.deltaTime;
|
||||
if(time <0f)
|
||||
{
|
||||
time = 2f;
|
||||
Highlight.HighlightPoint("Player 1", Random.Range(0, count));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e733763cd3cd394dbc18a30508a26d9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 797a09ca63b7e4a49839356660cdf9e8
|
||||
timeCreated: 1553681293
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user