Aimbot Enviroment very first
Basic environment include Multi scene, Reward Change, Visible chart, etc....
This commit is contained in:
@@ -0,0 +1,322 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class Example00_CheatSheet : MonoBehaviour
|
||||
{
|
||||
private LineChart chart;
|
||||
private float speed = 100f;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
LoopDemo();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
LoopDemo();
|
||||
}
|
||||
|
||||
void LoopDemo()
|
||||
{
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(CheatSheet());
|
||||
}
|
||||
|
||||
IEnumerator CheatSheet()
|
||||
{
|
||||
StartCoroutine(InitChart());
|
||||
StartCoroutine(ComponentTitle());
|
||||
yield return new WaitForSeconds(2);
|
||||
StartCoroutine(ComponentAxis());
|
||||
yield return new WaitForSeconds(2);
|
||||
StartCoroutine(ComponentGrid());
|
||||
yield return new WaitForSeconds(2);
|
||||
StartCoroutine(ComponentSerie());
|
||||
yield return new WaitForSeconds(4);
|
||||
StartCoroutine(ComponentLegend());
|
||||
yield return new WaitForSeconds(4);
|
||||
StartCoroutine(ComponentTheme());
|
||||
yield return new WaitForSeconds(4);
|
||||
StartCoroutine(ComponentDataZoom());
|
||||
yield return new WaitForSeconds(5);
|
||||
StartCoroutine(ComponentVisualMap());
|
||||
yield return new WaitForSeconds(3);
|
||||
LoopDemo();
|
||||
}
|
||||
|
||||
IEnumerator InitChart()
|
||||
{
|
||||
chart = gameObject.GetComponent<LineChart>();
|
||||
if (chart == null) gameObject.AddComponent<LineChart>();
|
||||
|
||||
chart.GetChartComponent<Title>().show = true;
|
||||
chart.GetChartComponent<Title>().text = "术语解析-组件";
|
||||
|
||||
var grid = chart.GetOrAddChartComponent<GridCoord>();
|
||||
grid.bottom = 30;
|
||||
grid.right = 30;
|
||||
grid.left = 50;
|
||||
grid.top = 80;
|
||||
|
||||
chart.RemoveChartComponent<VisualMap>();
|
||||
|
||||
chart.RemoveData();
|
||||
|
||||
chart.AddSerie<Bar>("Bar");
|
||||
chart.AddSerie<Line>("Line");
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
chart.AddXAxisData("x" + (i + 1));
|
||||
chart.AddData(0, Random.Range(10, 100));
|
||||
chart.AddData(1, Random.Range(30, 100));
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
|
||||
IEnumerator ComponentTitle()
|
||||
{
|
||||
chart.GetChartComponent<Title>().text = "术语解析 - 组件";
|
||||
chart.GetChartComponent<Title>().subText = "Title 标题:可指定主标题和子标题";
|
||||
chart.GetChartComponent<XAxis>().show = true;
|
||||
chart.GetChartComponent<YAxis>().show = true;
|
||||
chart.GetChartComponent<Legend>().show = false;
|
||||
chart.series[0].show = false;
|
||||
chart.series[1].show = false;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
chart.GetChartComponent<Title>().show = !chart.GetChartComponent<Title>().show;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
chart.GetChartComponent<Title>().show = true;
|
||||
chart.RefreshChart();
|
||||
}
|
||||
|
||||
IEnumerator ComponentAxis()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "Axis 坐标轴:配置X和Y轴的轴线、刻度、标签等样式外观配置";
|
||||
chart.series[0].show = false;
|
||||
chart.series[1].show = false;
|
||||
var xAxis = chart.GetChartComponent<XAxis>();
|
||||
var yAxis = chart.GetChartComponent<YAxis>();
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
xAxis.show = !xAxis.show;
|
||||
yAxis.show = !yAxis.show;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
xAxis.show = true;
|
||||
yAxis.show = true;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
|
||||
IEnumerator ComponentGrid()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "Grid 网格:调整坐标系边距和颜色等";
|
||||
var grid = chart.GetChartComponent<GridCoord>();
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
grid.backgroundColor = i % 2 == 0 ? Color.clear : Color.grey;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
grid.backgroundColor = Color.clear;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
|
||||
IEnumerator ComponentSerie()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "Serie 系列:调整坐标系边距和颜色等";
|
||||
chart.series[0].show = true;
|
||||
chart.series[1].show = true;
|
||||
chart.AnimationReset();
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1.2f);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
chart.series[0].show = !chart.series[0].show;
|
||||
chart.series[1].show = !chart.series[1].show;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
chart.series[0].show = true;
|
||||
chart.series[1].show = true;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
|
||||
IEnumerator ComponentLegend()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "Legend 图例:展示不同系列的名字和颜色,可控制系列显示等";
|
||||
var legend = chart.GetChartComponent<Legend>();
|
||||
legend.show = true;
|
||||
var grid = chart.GetChartComponent<GridCoord>();
|
||||
grid.top = 80;
|
||||
legend.location.top = 50;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1f);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
legend.show = !legend.show;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
legend.show = true;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1f);
|
||||
chart.ClickLegendButton(0, "Line", false);
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
chart.ClickLegendButton(0, "Line", true);
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
chart.ClickLegendButton(1, "Bar", false);
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
chart.ClickLegendButton(1, "Bar", true);
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
}
|
||||
|
||||
IEnumerator ComponentTheme()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "Theme 主题:可从全局上配置图表的颜色、字体等效果,支持默认主题切换";
|
||||
yield return new WaitForSeconds(1f);
|
||||
chart.GetChartComponent<Title>().subText = "Theme 主题:Light主题";
|
||||
chart.UpdateTheme(ThemeType.Light);
|
||||
yield return new WaitForSeconds(1f);
|
||||
chart.GetChartComponent<Title>().subText = "Theme 主题:Dark主题";
|
||||
chart.UpdateTheme(ThemeType.Dark);
|
||||
yield return new WaitForSeconds(1f);
|
||||
chart.GetChartComponent<Title>().subText = "Theme 主题:Default主题";
|
||||
chart.UpdateTheme(ThemeType.Default);
|
||||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
|
||||
IEnumerator ComponentDataZoom()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "DataZoom 区域缩放:可通过拖、拽、缩小、放大来观察细节数据";
|
||||
var grid = chart.GetChartComponent<GridCoord>();
|
||||
grid.bottom = 70;
|
||||
|
||||
var dataZoom = chart.GetOrAddChartComponent<DataZoom>();
|
||||
dataZoom.enable = true;
|
||||
dataZoom.supportInside = true;
|
||||
dataZoom.supportSlider = true;
|
||||
dataZoom.start = 0;
|
||||
dataZoom.end = 100;
|
||||
|
||||
chart.RefreshChart();
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
dataZoom.supportSlider = !dataZoom.supportSlider;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
dataZoom.supportSlider = true;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1f);
|
||||
while (dataZoom.start < 40)
|
||||
{
|
||||
dataZoom.start += speed * Time.deltaTime * 0.8f;
|
||||
chart.RefreshDataZoom();
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
while (dataZoom.end > 60)
|
||||
{
|
||||
dataZoom.end -= speed * Time.deltaTime * 0.8f;
|
||||
chart.RefreshDataZoom();
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
while (dataZoom.start > 0)
|
||||
{
|
||||
dataZoom.start -= speed * Time.deltaTime * 0.8f;
|
||||
dataZoom.end -= speed * Time.deltaTime * 0.8f;
|
||||
chart.RefreshDataZoom();
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
while (dataZoom.end < 100)
|
||||
{
|
||||
dataZoom.start += speed * Time.deltaTime * 0.8f;
|
||||
dataZoom.end += speed * Time.deltaTime * 0.8f;
|
||||
chart.RefreshDataZoom();
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
while (dataZoom.start > 0 || dataZoom.end < 100)
|
||||
{
|
||||
dataZoom.start -= speed * Time.deltaTime * 0.8f;
|
||||
dataZoom.end += speed * Time.deltaTime * 0.8f;
|
||||
chart.RefreshDataZoom();
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator ComponentVisualMap()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "VisualMap 视觉映射:可从全局上配置图表的颜色、字体等效果,支持默认主题切换";
|
||||
|
||||
var visualMap = chart.GetOrAddChartComponent<VisualMap>();
|
||||
visualMap.show = true;
|
||||
visualMap.showUI = true;
|
||||
visualMap.orient = Orient.Vertical;
|
||||
visualMap.calculable = true;
|
||||
visualMap.min = 0;
|
||||
visualMap.max = 100;
|
||||
visualMap.range[0] = 0;
|
||||
visualMap.range[1] = 100;
|
||||
|
||||
var colors = new List<string>
|
||||
{
|
||||
"#313695",
|
||||
"#4575b4",
|
||||
"#74add1",
|
||||
"#abd9e9",
|
||||
"#e0f3f8",
|
||||
"#ffffbf",
|
||||
"#fee090",
|
||||
"#fdae61",
|
||||
"#f46d43",
|
||||
"#d73027",
|
||||
"#a50026"
|
||||
};
|
||||
visualMap.AddColors(colors);
|
||||
var grid = chart.GetChartComponent<GridCoord>();
|
||||
grid.left = 80;
|
||||
grid.bottom = 100;
|
||||
chart.RefreshChart();
|
||||
|
||||
yield return new WaitForSeconds(1f);
|
||||
while (visualMap.rangeMin < 40)
|
||||
{
|
||||
visualMap.rangeMin += speed * Time.deltaTime;
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
while (visualMap.rangeMax > 60)
|
||||
{
|
||||
visualMap.rangeMax -= speed * Time.deltaTime;
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
while (visualMap.rangeMin > 0 || visualMap.rangeMax < 100)
|
||||
{
|
||||
visualMap.rangeMin -= speed * Time.deltaTime;
|
||||
visualMap.rangeMax += speed * Time.deltaTime;
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 677b2673e728a4e308f26a5a9b236277
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,46 @@
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example01_UpdateData : MonoBehaviour
|
||||
{
|
||||
private float updateTime = 0;
|
||||
BaseChart chart;
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<BaseChart>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
updateTime += Time.deltaTime;
|
||||
if (chart && updateTime > 2)
|
||||
{
|
||||
updateTime = 0;
|
||||
var serie = chart.GetSerie(0);
|
||||
//serie.animation.dataChangeEnable = true;
|
||||
var dataCount = serie.dataCount;
|
||||
if (chart is RadarChart)
|
||||
{
|
||||
var dimension = serie.GetSerieData(0).data.Count - 1;
|
||||
chart.UpdateData(0, 0, Random.Range(0, dimension + 1), Random.Range(0, 100));
|
||||
}
|
||||
else if (chart is HeatmapChart)
|
||||
{
|
||||
var dimension = serie.GetSerieData(0).data.Count - 1;
|
||||
for (int i = 0; i < dataCount; i++)
|
||||
{
|
||||
chart.UpdateData(0, i, dimension, Random.Range(0, 10));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
chart.UpdateData(0, Random.Range(0, dataCount), Random.Range(10, 90));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d369a0cba6716422cb15efa26bef0918
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,58 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example02_ChartEvent : MonoBehaviour
|
||||
{
|
||||
BaseChart chart;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<BaseChart>();
|
||||
if (chart == null)
|
||||
{
|
||||
chart = gameObject.AddComponent<LineChart>();
|
||||
}
|
||||
chart.onPointerEnter = OnPointerEnter;
|
||||
chart.onPointerExit = OnPointerExit;
|
||||
chart.onPointerDown = OnPointerDown;
|
||||
chart.onPointerUp = OnPointerUp;
|
||||
chart.onPointerClick = OnPointerClick;
|
||||
chart.onScroll = OnScroll;
|
||||
}
|
||||
|
||||
void OnPointerEnter(PointerEventData eventData, BaseGraph chart)
|
||||
{
|
||||
//Debug.LogError("enter:" + chart);
|
||||
}
|
||||
|
||||
void OnPointerExit(PointerEventData eventData, BaseGraph chart)
|
||||
{
|
||||
//Debug.LogError("exit:" + chart);
|
||||
}
|
||||
|
||||
void OnPointerDown(PointerEventData eventData, BaseGraph chart)
|
||||
{
|
||||
//Debug.LogError("down:" + chart);
|
||||
}
|
||||
|
||||
void OnPointerUp(PointerEventData eventData, BaseGraph chart)
|
||||
{
|
||||
//Debug.LogError("up:" + chart);
|
||||
}
|
||||
|
||||
void OnPointerClick(PointerEventData eventData, BaseGraph chart)
|
||||
{
|
||||
//Debug.LogError("click:" + chart);
|
||||
}
|
||||
|
||||
void OnScroll(PointerEventData eventData, BaseGraph chart)
|
||||
{
|
||||
//Debug.LogError("scroll:" + chart);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c549dc496cd86467e8286252906562cc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,37 @@
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example03_ChartAnimation : MonoBehaviour
|
||||
{
|
||||
BaseChart chart;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<BaseChart>();
|
||||
if (chart == null)
|
||||
{
|
||||
chart = gameObject.AddComponent<BarChart>();
|
||||
}
|
||||
var serie = chart.GetSerie(0);
|
||||
serie.animation.enable = true;
|
||||
//自定义每个数据项的渐入延时
|
||||
serie.animation.fadeInDelayFunction = CustomFadeInDelay;
|
||||
//自定义每个数据项的渐入时长
|
||||
serie.animation.fadeInDurationFunction = CustomFadeInDuration;
|
||||
}
|
||||
|
||||
float CustomFadeInDelay(int dataIndex)
|
||||
{
|
||||
return dataIndex * 1000;
|
||||
}
|
||||
|
||||
float CustomFadeInDuration(int dataIndex)
|
||||
{
|
||||
return dataIndex * 1000 + 1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6258ca3b055714eac92804f501011b53
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,266 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class Example10_LineChart : MonoBehaviour
|
||||
{
|
||||
private LineChart chart;
|
||||
private Serie serie;
|
||||
private int m_DataNum = 8;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
LoopDemo();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
LoopDemo();
|
||||
}
|
||||
|
||||
void LoopDemo()
|
||||
{
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(PieDemo());
|
||||
}
|
||||
|
||||
IEnumerator PieDemo()
|
||||
{
|
||||
StartCoroutine(AddSimpleLine());
|
||||
yield return new WaitForSeconds(2);
|
||||
StartCoroutine(ChangeLineType());
|
||||
yield return new WaitForSeconds(8);
|
||||
StartCoroutine(LineAreaStyleSettings());
|
||||
yield return new WaitForSeconds(5);
|
||||
StartCoroutine(LineArrowSettings());
|
||||
yield return new WaitForSeconds(2);
|
||||
StartCoroutine(LineSymbolSettings());
|
||||
yield return new WaitForSeconds(7);
|
||||
StartCoroutine(LineLabelSettings());
|
||||
yield return new WaitForSeconds(3);
|
||||
StartCoroutine(LineMutilSerie());
|
||||
yield return new WaitForSeconds(5);
|
||||
LoopDemo();
|
||||
}
|
||||
|
||||
IEnumerator AddSimpleLine()
|
||||
{
|
||||
chart = gameObject.GetComponent<LineChart>();
|
||||
if (chart == null) chart = gameObject.AddComponent<LineChart>();
|
||||
chart.GetChartComponent<Title>().text = "LineChart - 折线图";
|
||||
chart.GetChartComponent<Title>().subText = "普通折线图";
|
||||
|
||||
var yAxis = chart.GetChartComponent<YAxis>();
|
||||
yAxis.minMaxType = Axis.AxisMinMaxType.Custom;
|
||||
yAxis.min = 0;
|
||||
yAxis.max = 100;
|
||||
|
||||
chart.RemoveData();
|
||||
serie = chart.AddSerie<Line>("Line");
|
||||
|
||||
for (int i = 0; i < m_DataNum; i++)
|
||||
{
|
||||
chart.AddXAxisData("x" + (i + 1));
|
||||
chart.AddData(0, UnityEngine.Random.Range(30, 90));
|
||||
}
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
IEnumerator ChangeLineType()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "LineTyle - 曲线图";
|
||||
serie.lineType = LineType.Smooth;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.GetChartComponent<Title>().subText = "LineTyle - 阶梯线图";
|
||||
serie.lineType = LineType.StepStart;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
serie.lineType = LineType.StepMiddle;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
serie.lineType = LineType.StepEnd;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.GetChartComponent<Title>().subText = "LineTyle - 虚线";
|
||||
serie.lineStyle.type = LineStyle.Type.Dashed;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.GetChartComponent<Title>().subText = "LineTyle - 点线";
|
||||
serie.lineStyle.type = LineStyle.Type.Dotted;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.GetChartComponent<Title>().subText = "LineTyle - 点划线";
|
||||
serie.lineStyle.type = LineStyle.Type.DashDot;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.GetChartComponent<Title>().subText = "LineTyle - 双点划线";
|
||||
serie.lineStyle.type = LineStyle.Type.DashDotDot;
|
||||
chart.RefreshChart();
|
||||
|
||||
serie.lineType = LineType.Normal;
|
||||
chart.RefreshChart();
|
||||
}
|
||||
|
||||
IEnumerator LineAreaStyleSettings()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "AreaStyle 面积图";
|
||||
|
||||
serie.AddExtraComponent<AreaStyle>();
|
||||
serie.areaStyle.show = true;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1f);
|
||||
|
||||
chart.GetChartComponent<Title>().subText = "AreaStyle 面积图";
|
||||
serie.lineType = LineType.Smooth;
|
||||
serie.areaStyle.show = true;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1f);
|
||||
|
||||
chart.GetChartComponent<Title>().subText = "AreaStyle 面积图 - 调整透明度";
|
||||
while (serie.areaStyle.opacity > 0.4)
|
||||
{
|
||||
serie.areaStyle.opacity -= 0.6f * Time.deltaTime;
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.GetChartComponent<Title>().subText = "AreaStyle 面积图 - 渐变";
|
||||
serie.areaStyle.toColor = Color.white;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
IEnumerator LineArrowSettings()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "LineArrow 头部箭头";
|
||||
chart.GetSerie(0).AddExtraComponent<LineArrow>();
|
||||
serie.lineArrow.show = true;
|
||||
serie.lineArrow.position = LineArrow.Position.Start;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.GetChartComponent<Title>().subText = "LineArrow 尾部箭头";
|
||||
serie.lineArrow.position = LineArrow.Position.End;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
serie.lineArrow.show = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SerieSymbol 相关设置
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IEnumerator LineSymbolSettings()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "SerieSymbol 图形标记";
|
||||
while (serie.symbol.size < 5)
|
||||
{
|
||||
serie.symbol.size += 2.5f * Time.deltaTime;
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
chart.GetChartComponent<Title>().subText = "SerieSymbol 图形标记 - 空心圆";
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.GetChartComponent<Title>().subText = "SerieSymbol 图形标记 - 实心圆";
|
||||
serie.symbol.type = SymbolType.Circle;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.GetChartComponent<Title>().subText = "SerieSymbol 图形标记 - 三角形";
|
||||
serie.symbol.type = SymbolType.Triangle;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.GetChartComponent<Title>().subText = "SerieSymbol 图形标记 - 正方形";
|
||||
serie.symbol.type = SymbolType.Rect;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.GetChartComponent<Title>().subText = "SerieSymbol 图形标记 - 菱形";
|
||||
serie.symbol.type = SymbolType.Diamond;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.GetChartComponent<Title>().subText = "SerieSymbol 图形标记";
|
||||
serie.symbol.type = SymbolType.EmptyCircle;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SerieLabel相关配置
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IEnumerator LineLabelSettings()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "SerieLabel 文本标签";
|
||||
serie.AddExtraComponent<LabelStyle>();
|
||||
chart.RefreshChart();
|
||||
while (serie.label.offset[1] < 20)
|
||||
{
|
||||
serie.label.offset = new Vector3(serie.label.offset.x, serie.label.offset.y + 20f * Time.deltaTime);
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
serie.label.textStyle.color = Color.white;
|
||||
serie.label.background.color = Color.grey;
|
||||
serie.labelDirty = true;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
serie.label.show = false;
|
||||
chart.RefreshChart();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加多条线图
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IEnumerator LineMutilSerie()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "多系列";
|
||||
var serie2 = chart.AddSerie<Line>("Line2");
|
||||
serie2.lineType = LineType.Normal;
|
||||
for (int i = 0; i < m_DataNum; i++)
|
||||
{
|
||||
chart.AddData(1, UnityEngine.Random.Range(30, 90));
|
||||
}
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
var serie3 = chart.AddSerie<Line>("Line3");
|
||||
serie3.lineType = LineType.Normal;
|
||||
for (int i = 0; i < m_DataNum; i++)
|
||||
{
|
||||
chart.AddData(2, UnityEngine.Random.Range(30, 90));
|
||||
}
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
var yAxis = chart.GetChartComponent<YAxis>();
|
||||
yAxis.minMaxType = Axis.AxisMinMaxType.Default;
|
||||
chart.GetChartComponent<Title>().subText = "多系列 - 堆叠";
|
||||
serie.stack = "samename";
|
||||
serie2.stack = "samename";
|
||||
serie3.stack = "samename";
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6155c7e0df4504ebfaf0c671ae200197
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,62 @@
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example11_AddSinCurve : MonoBehaviour
|
||||
{
|
||||
private float time;
|
||||
public int angle;
|
||||
private LineChart chart;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<LineChart>();
|
||||
if (chart == null)
|
||||
{
|
||||
chart = gameObject.AddComponent<LineChart>();
|
||||
}
|
||||
chart.GetChartComponent<Title>().show = true;
|
||||
chart.GetChartComponent<Title>().text = "Sin Curve";
|
||||
|
||||
chart.GetChartComponent<Tooltip>().show = true;
|
||||
chart.GetChartComponent<Legend>().show = false;
|
||||
|
||||
var xAxis = chart.GetChartComponent<XAxis>();
|
||||
var yAxis = chart.GetChartComponent<YAxis>();
|
||||
|
||||
xAxis.show = true;
|
||||
yAxis.show = true;
|
||||
|
||||
xAxis.type = Axis.AxisType.Value;
|
||||
yAxis.type = Axis.AxisType.Value;
|
||||
|
||||
xAxis.boundaryGap = false;
|
||||
xAxis.maxCache = 0;
|
||||
chart.series[0].maxCache = 0;
|
||||
|
||||
chart.RemoveData();
|
||||
|
||||
var serie = chart.AddSerie<Line>();
|
||||
serie.symbol.show = false;
|
||||
serie.lineType = LineType.Normal;
|
||||
for (angle = 0; angle < 1080; angle++)
|
||||
{
|
||||
float xvalue = Mathf.PI / 180 * angle;
|
||||
float yvalue = Mathf.Sin(xvalue);
|
||||
chart.AddData(0, xvalue, yvalue);
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (angle > 3000) return;
|
||||
angle++;
|
||||
float xvalue = Mathf.PI / 180 * angle;
|
||||
float yvalue = Mathf.Sin(xvalue);
|
||||
chart.AddData(0, xvalue, yvalue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b380753d3cb4149c4a3a65a1816e0cc7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XCharts.Runtime;
|
||||
using XUGL;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example12_CustomDrawing : MonoBehaviour
|
||||
{
|
||||
LineChart chart;
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<LineChart>();
|
||||
if (chart == null) return;
|
||||
|
||||
chart.onDraw = delegate(VertexHelper vh) { };
|
||||
// or
|
||||
chart.onDrawBeforeSerie = delegate(VertexHelper vh, Serie serie) { };
|
||||
// or
|
||||
chart.onDrawAfterSerie = delegate(VertexHelper vh, Serie serie)
|
||||
{
|
||||
if (serie.index != 0) return;
|
||||
var dataPoints = serie.context.dataPoints;
|
||||
if (dataPoints.Count > 0)
|
||||
{
|
||||
var pos = dataPoints[3];
|
||||
var grid = chart.GetChartComponent<GridCoord>();
|
||||
var zeroPos = new Vector3(grid.context.x, grid.context.y);
|
||||
var startPos = new Vector3(pos.x, zeroPos.y);
|
||||
var endPos = new Vector3(pos.x, zeroPos.y + grid.context.height);
|
||||
UGL.DrawLine(vh, startPos, endPos, chart.theme.serie.lineWidth, Color.blue);
|
||||
UGL.DrawCricle(vh, pos, 5, Color.blue);
|
||||
}
|
||||
};
|
||||
// or
|
||||
chart.onDrawTop = delegate(VertexHelper vh) { };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da550ad36be5f442e96ad021cc10ca68
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,59 @@
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example13_LineSimple : MonoBehaviour
|
||||
{
|
||||
void Awake()
|
||||
{
|
||||
AddData();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
AddData();
|
||||
}
|
||||
}
|
||||
|
||||
void AddData()
|
||||
{
|
||||
var chart = gameObject.GetComponent<SimplifiedLineChart>();
|
||||
if (chart == null)
|
||||
{
|
||||
chart = gameObject.AddComponent<SimplifiedLineChart>();
|
||||
chart.Init();
|
||||
chart.SetSize(580, 300);
|
||||
}
|
||||
chart.GetOrAddChartComponent<Title>().show = true;
|
||||
chart.GetOrAddChartComponent<Title>().text = "Line Simple";
|
||||
|
||||
chart.GetOrAddChartComponent<Tooltip>().show = true;
|
||||
chart.GetOrAddChartComponent<Legend>().show = false;
|
||||
|
||||
var xAxis = chart.GetOrAddChartComponent<XAxis>();
|
||||
var yAxis = chart.GetOrAddChartComponent<YAxis>();
|
||||
xAxis.show = true;
|
||||
yAxis.show = true;
|
||||
xAxis.type = Axis.AxisType.Category;
|
||||
yAxis.type = Axis.AxisType.Value;
|
||||
|
||||
xAxis.splitNumber = 10;
|
||||
xAxis.boundaryGap = true;
|
||||
|
||||
chart.RemoveData();
|
||||
chart.AddSerie<SimplifiedLine>();
|
||||
chart.AddSerie<SimplifiedLine>();
|
||||
for (int i = 0; i < 200; i++)
|
||||
{
|
||||
chart.AddXAxisData("x" + i);
|
||||
chart.AddData(0, Random.Range(10, 20));
|
||||
chart.AddData(1, Random.Range(10, 20));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6d0f65efd8e14ebdafa172e0ccbd562
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,158 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class Example20_BarChart : MonoBehaviour
|
||||
{
|
||||
private BarChart chart;
|
||||
private Serie serie, serie2;
|
||||
private int m_DataNum = 5;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
LoopDemo();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
LoopDemo();
|
||||
}
|
||||
|
||||
void LoopDemo()
|
||||
{
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(PieDemo());
|
||||
}
|
||||
|
||||
IEnumerator PieDemo()
|
||||
{
|
||||
StartCoroutine(AddSimpleBar());
|
||||
yield return new WaitForSeconds(2);
|
||||
StartCoroutine(BarMutilSerie());
|
||||
yield return new WaitForSeconds(3);
|
||||
StartCoroutine(ZebraBar());
|
||||
yield return new WaitForSeconds(3);
|
||||
StartCoroutine(SameBarAndNotStack());
|
||||
yield return new WaitForSeconds(3);
|
||||
StartCoroutine(SameBarAndStack());
|
||||
yield return new WaitForSeconds(3);
|
||||
StartCoroutine(SameBarAndPercentStack());
|
||||
yield return new WaitForSeconds(10);
|
||||
|
||||
LoopDemo();
|
||||
}
|
||||
|
||||
IEnumerator AddSimpleBar()
|
||||
{
|
||||
chart = gameObject.GetComponent<BarChart>();
|
||||
if (chart == null) chart = gameObject.AddComponent<BarChart>();
|
||||
chart.GetChartComponent<Title>().text = "BarChart - 柱状图";
|
||||
chart.GetChartComponent<Title>().subText = "普通柱状图";
|
||||
|
||||
var yAxis = chart.GetChartComponent<YAxis>();
|
||||
yAxis.minMaxType = Axis.AxisMinMaxType.Default;
|
||||
|
||||
chart.RemoveData();
|
||||
serie = chart.AddSerie<Bar>("Bar1");
|
||||
|
||||
for (int i = 0; i < m_DataNum; i++)
|
||||
{
|
||||
chart.AddXAxisData("x" + (i + 1));
|
||||
chart.AddData(0, UnityEngine.Random.Range(30, 90));
|
||||
}
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
IEnumerator BarMutilSerie()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "多条柱状图";
|
||||
|
||||
float now = serie.barWidth - 0.35f;
|
||||
while (serie.barWidth > 0.35f)
|
||||
{
|
||||
serie.barWidth -= now * Time.deltaTime;
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
|
||||
serie2 = chart.AddSerie<Bar>("Bar2");
|
||||
serie2.lineType = LineType.Normal;
|
||||
serie2.barWidth = 0.35f;
|
||||
for (int i = 0; i < m_DataNum; i++)
|
||||
{
|
||||
chart.AddData(1, UnityEngine.Random.Range(20, 90));
|
||||
}
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
IEnumerator ZebraBar()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "斑马柱状图";
|
||||
serie.barType = BarType.Zebra;
|
||||
serie2.barType = BarType.Zebra;
|
||||
serie.barZebraWidth = serie.barZebraGap = 4;
|
||||
serie2.barZebraWidth = serie2.barZebraGap = 4;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
IEnumerator SameBarAndNotStack()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "非堆叠同柱";
|
||||
serie.barType = serie2.barType = BarType.Normal;
|
||||
serie.stack = "";
|
||||
serie2.stack = "";
|
||||
serie.barGap = -1;
|
||||
serie2.barGap = -1;
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
IEnumerator SameBarAndStack()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "堆叠同柱";
|
||||
serie.barType = serie2.barType = BarType.Normal;
|
||||
serie.stack = "samename";
|
||||
serie2.stack = "samename";
|
||||
yield return new WaitForSeconds(1);
|
||||
float now = 0.6f - serie.barWidth;
|
||||
while (serie.barWidth < 0.6f)
|
||||
{
|
||||
serie.barWidth += now * Time.deltaTime;
|
||||
serie2.barWidth += now * Time.deltaTime;
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
serie.barWidth = serie2.barWidth;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
IEnumerator SameBarAndPercentStack()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "百分比堆叠同柱";
|
||||
serie.barType = serie2.barType = BarType.Normal;
|
||||
serie.stack = "samename";
|
||||
serie2.stack = "samename";
|
||||
|
||||
serie.barPercentStack = true;
|
||||
|
||||
serie.AddExtraComponent<LabelStyle>();
|
||||
serie.label.show = true;
|
||||
serie.label.position = LabelStyle.Position.Center;
|
||||
serie.label.textStyle.color = Color.white;
|
||||
serie.label.formatter = "{d:f0}%";
|
||||
|
||||
serie2.label.show = true;
|
||||
serie2.label.position = LabelStyle.Position.Center;
|
||||
serie2.label.textStyle.color = Color.white;
|
||||
serie2.label.formatter = "{d:f0}%";
|
||||
serie2.labelDirty = true;
|
||||
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03916f7ca858b446883197ae17e50f16
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,46 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class Example21_BarRace : MonoBehaviour
|
||||
{
|
||||
private BarChart chart;
|
||||
private float lastTime;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<BarChart>();
|
||||
chart.ClearData();
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
chart.AddYAxisData("y" + i);
|
||||
chart.AddData(0, Random.Range(0, 200));
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Time.time - lastTime >= 3f)
|
||||
{
|
||||
lastTime = Time.time;
|
||||
UpdateData();
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateData()
|
||||
{
|
||||
var serie = chart.GetSerie(0);
|
||||
|
||||
for (int i = 0; i < serie.dataCount; i++)
|
||||
{
|
||||
if (Random.Range(0, 1f) > 0.9f)
|
||||
chart.UpdateData(0, i, chart.GetData(0, i) + Mathf.Round(Random.Range(0, 2000)));
|
||||
else
|
||||
chart.UpdateData(0, i, chart.GetData(0, i) + Mathf.Round(Random.Range(0, 200)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9842ca7fe07044666950b6f53ef65fdb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,205 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class Example30_PieChart : MonoBehaviour
|
||||
{
|
||||
private PieChart chart;
|
||||
private Serie serie, serie1;
|
||||
private float m_RadiusSpeed = 100f;
|
||||
private float m_CenterSpeed = 1f;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
LoopDemo();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
LoopDemo();
|
||||
}
|
||||
|
||||
void LoopDemo()
|
||||
{
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(PieDemo());
|
||||
}
|
||||
|
||||
IEnumerator PieDemo()
|
||||
{
|
||||
StartCoroutine(PieAdd());
|
||||
yield return new WaitForSeconds(2);
|
||||
StartCoroutine(PieShowLabel());
|
||||
yield return new WaitForSeconds(4);
|
||||
StartCoroutine(Doughnut());
|
||||
yield return new WaitForSeconds(3);
|
||||
StartCoroutine(DoublePie());
|
||||
yield return new WaitForSeconds(2);
|
||||
StartCoroutine(RosePie());
|
||||
yield return new WaitForSeconds(5);
|
||||
LoopDemo();
|
||||
}
|
||||
|
||||
IEnumerator PieAdd()
|
||||
{
|
||||
chart = gameObject.GetComponent<PieChart>();
|
||||
if (chart == null) chart = gameObject.AddComponent<PieChart>();
|
||||
chart.GetChartComponent<Title>().text = "PieChart - 饼图";
|
||||
chart.GetChartComponent<Title>().subText = "基础饼图";
|
||||
|
||||
var legend = chart.GetChartComponent<Legend>();
|
||||
legend.show = true;
|
||||
legend.location.align = Location.Align.TopLeft;
|
||||
legend.location.top = 60;
|
||||
legend.location.left = 2;
|
||||
legend.itemWidth = 70;
|
||||
legend.itemHeight = 20;
|
||||
legend.orient = Orient.Vertical;
|
||||
|
||||
chart.RemoveData();
|
||||
serie = chart.AddSerie<Bar>("访问来源");
|
||||
serie.radius[0] = 0;
|
||||
serie.radius[1] = 110;
|
||||
serie.center[0] = 0.5f;
|
||||
serie.center[1] = 0.4f;
|
||||
chart.AddData(0, 335, "直接访问");
|
||||
chart.AddData(0, 310, "邮件营销");
|
||||
chart.AddData(0, 243, "联盟广告");
|
||||
chart.AddData(0, 135, "视频广告");
|
||||
chart.AddData(0, 1548, "搜索引擎");
|
||||
|
||||
chart.onPointerClickPie = delegate(PointerEventData e, int serieIndex, int dataIndex)
|
||||
{
|
||||
|
||||
};
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
IEnumerator PieShowLabel()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "显示文本标签";
|
||||
|
||||
serie.AddExtraComponent<LabelStyle>();
|
||||
serie.label.show = true;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
serie.labelLine.lineType = LabelLine.LineType.Curves;
|
||||
chart.RefreshChart();
|
||||
|
||||
yield return new WaitForSeconds(1);
|
||||
serie.labelLine.lineType = LabelLine.LineType.HorizontalLine;
|
||||
chart.RefreshChart();
|
||||
|
||||
yield return new WaitForSeconds(1);
|
||||
serie.labelLine.lineType = LabelLine.LineType.BrokenLine;
|
||||
chart.RefreshChart();
|
||||
|
||||
yield return new WaitForSeconds(1);
|
||||
serie.labelLine.show = false;
|
||||
chart.RefreshChart();
|
||||
}
|
||||
|
||||
IEnumerator Doughnut()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "圆环图";
|
||||
serie.radius[0] = 2f;
|
||||
while (serie.radius[0] < serie.radius[1] * 0.7f)
|
||||
{
|
||||
serie.radius[0] += m_RadiusSpeed * Time.deltaTime;
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
serie.gap = 1f;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
serie.data[0].selected = true;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
serie.gap = 0f;
|
||||
serie.data[0].selected = false;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
IEnumerator DoublePie()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "多图组合";
|
||||
|
||||
serie1 = chart.AddSerie<Pie>("访问来源2");
|
||||
chart.AddData(1, 335, "直达");
|
||||
chart.AddData(1, 679, "营销广告");
|
||||
chart.AddData(1, 1548, "搜索引擎");
|
||||
serie1.radius[0] = 0;
|
||||
serie1.radius[1] = 2f;
|
||||
serie1.center[0] = 0.5f;
|
||||
serie1.center[1] = 0.4f;
|
||||
chart.RefreshChart();
|
||||
while (serie1.radius[1] < serie.radius[0] * 0.75f)
|
||||
{
|
||||
serie1.radius[1] += m_RadiusSpeed * Time.deltaTime;
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
|
||||
serie1.label.show = true;
|
||||
serie1.label.position = LabelStyle.Position.Inside;
|
||||
serie1.label.textStyle.color = Color.white;
|
||||
serie1.label.textStyle.fontSize = 14;
|
||||
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
IEnumerator RosePie()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "玫瑰图";
|
||||
chart.GetChartComponent<Legend>().show = false;
|
||||
serie1.ClearData();
|
||||
serie.ClearData();
|
||||
serie1.radius = serie.radius = new float[2] { 0, 80 };
|
||||
serie1.label.position = LabelStyle.Position.Outside;
|
||||
serie1.labelLine.lineType = LabelLine.LineType.Curves;
|
||||
serie1.label.textStyle.color = Color.clear;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
chart.AddData(i, 10, "rose1");
|
||||
chart.AddData(i, 5, "rose2");
|
||||
chart.AddData(i, 15, "rose3");
|
||||
chart.AddData(i, 25, "rose4");
|
||||
chart.AddData(i, 20, "rose5");
|
||||
chart.AddData(i, 35, "rose6");
|
||||
chart.AddData(i, 30, "rose7");
|
||||
chart.AddData(i, 40, "rose8");
|
||||
}
|
||||
|
||||
while (serie.center[0] > 0.25f || serie1.center[0] < 0.7f)
|
||||
{
|
||||
if (serie.center[0] > 0.25f) serie.center[0] -= m_CenterSpeed * Time.deltaTime;
|
||||
if (serie1.center[0] < 0.7f) serie1.center[0] += m_CenterSpeed * Time.deltaTime;
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
yield return new WaitForSeconds(1);
|
||||
while (serie.radius[0] > 3f)
|
||||
{
|
||||
serie.radius[0] -= m_RadiusSpeed * Time.deltaTime;
|
||||
serie1.radius[0] -= m_RadiusSpeed * Time.deltaTime;
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
|
||||
serie.radius[0] = 0;
|
||||
serie1.radius[0] = 0;
|
||||
serie.pieRoseType = RoseType.Area;
|
||||
serie1.pieRoseType = RoseType.Radius;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b8649d38981b4b5bbdf16e8f303fa1e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,74 @@
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example31_PieUpdateName : MonoBehaviour
|
||||
{
|
||||
PieChart chart;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<PieChart>();
|
||||
if (chart == null)
|
||||
{
|
||||
chart = gameObject.AddComponent<PieChart>();
|
||||
}
|
||||
var serieIndex = 0;
|
||||
var serie = chart.GetSerie(serieIndex);
|
||||
if (serie == null) return;
|
||||
serie.AddExtraComponent<LabelStyle>();
|
||||
serie.label.show = true;
|
||||
serie.label.position = LabelStyle.Position.Outside;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
ClearAndAddData();
|
||||
//UpdateDataName();
|
||||
//UpdateDataName();
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateDataName()
|
||||
{
|
||||
var serieIndex = 0;
|
||||
var serie = chart.GetSerie(serieIndex);
|
||||
if (serie == null) return;
|
||||
for (int i = 0; i < serie.dataCount; i++)
|
||||
{
|
||||
var value = Random.Range(10, 100);
|
||||
chart.UpdateData(serieIndex, i, value);
|
||||
chart.UpdateDataName(serieIndex, i, "value=" + value);
|
||||
}
|
||||
}
|
||||
|
||||
void ResetSameName()
|
||||
{
|
||||
var serieIndex = 0;
|
||||
var serie = chart.GetSerie(serieIndex);
|
||||
if (serie == null) return;
|
||||
for (int i = 0; i < serie.dataCount; i++)
|
||||
{
|
||||
chart.UpdateDataName(serieIndex, i, "piename");
|
||||
}
|
||||
}
|
||||
|
||||
void ClearAndAddData()
|
||||
{
|
||||
var serieIndex = 0;
|
||||
var serie = chart.GetSerie(serieIndex);
|
||||
if (serie == null) return;
|
||||
int count = serie.dataCount;
|
||||
serie.ClearData();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
chart.AddData(0, Random.Range(0, 100), "pie" + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41195ee7a652f4ef79c22c365d314621
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,135 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class Example40_Radar : MonoBehaviour
|
||||
{
|
||||
private RadarChart chart;
|
||||
private Serie serie, serie1;
|
||||
void Awake()
|
||||
{
|
||||
LoopDemo();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
LoopDemo();
|
||||
}
|
||||
|
||||
void LoopDemo()
|
||||
{
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(RadarDemo());
|
||||
}
|
||||
|
||||
IEnumerator RadarDemo()
|
||||
{
|
||||
StartCoroutine(RadarAdd());
|
||||
yield return new WaitForSeconds(2);
|
||||
StartCoroutine(RadarUpdate());
|
||||
yield return new WaitForSeconds(2);
|
||||
StartCoroutine(RadarAddMultiple());
|
||||
yield return new WaitForSeconds(2);
|
||||
LoopDemo();
|
||||
}
|
||||
|
||||
IEnumerator RadarAdd()
|
||||
{
|
||||
chart = gameObject.GetComponent<RadarChart>();
|
||||
if (chart == null) chart = gameObject.AddComponent<RadarChart>();
|
||||
|
||||
chart.RemoveChartComponents<RadarCoord>();
|
||||
chart.RemoveData();
|
||||
|
||||
chart.GetChartComponent<Title>().text = "RadarChart - 雷达图";
|
||||
chart.GetChartComponent<Title>().subText = "";
|
||||
|
||||
var legend = chart.GetChartComponent<Legend>();
|
||||
legend.show = true;
|
||||
legend.location.align = Location.Align.TopLeft;
|
||||
legend.location.top = 60;
|
||||
legend.location.left = 2;
|
||||
legend.itemWidth = 70;
|
||||
legend.itemHeight = 20;
|
||||
legend.orient = Orient.Vertical;
|
||||
|
||||
var radarCoord = chart.AddChartComponent<RadarCoord>();
|
||||
radarCoord.shape = RadarCoord.Shape.Polygon;
|
||||
radarCoord.center[0] = 0.5f;
|
||||
radarCoord.center[1] = 0.4f;
|
||||
radarCoord.radius = 0.4f;
|
||||
|
||||
radarCoord.AddIndicator("indicator1", 0, 100);
|
||||
radarCoord.AddIndicator("indicator2", 0, 100);
|
||||
radarCoord.AddIndicator("indicator3", 0, 100);
|
||||
radarCoord.AddIndicator("indicator4", 0, 100);
|
||||
radarCoord.AddIndicator("indicator5", 0, 100);
|
||||
|
||||
serie = chart.AddSerie<Radar>("test");
|
||||
serie.radarIndex = 0;
|
||||
chart.AddData(0, new List<double> { 10, 20, 60, 40, 20 }, "data1");
|
||||
chart.AddData(0, new List<double> { 40, 60, 90, 80, 70 }, "data2");
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
IEnumerator RadarUpdate()
|
||||
{
|
||||
var radarCoord = chart.GetChartComponent<RadarCoord>();
|
||||
radarCoord.UpdateIndicator(0, "new1", 0, 100);
|
||||
chart.UpdateData(0, 0, new List<double> { 15, 30, 50, 60, 50 });
|
||||
chart.UpdateDataName(0, 0, "new1");
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
IEnumerator RadarAddMultiple()
|
||||
{
|
||||
chart.RemoveChartComponents<RadarCoord>();
|
||||
chart.RemoveData();
|
||||
|
||||
chart.GetChartComponent<Title>().text = "RadarChart - 多雷达图";
|
||||
chart.GetChartComponent<Title>().subText = "";
|
||||
|
||||
var legend = chart.GetChartComponent<Legend>();
|
||||
legend.show = true;
|
||||
legend.location.align = Location.Align.TopLeft;
|
||||
legend.location.top = 60;
|
||||
legend.location.left = 2;
|
||||
legend.itemWidth = 70;
|
||||
legend.itemHeight = 20;
|
||||
legend.orient = Orient.Vertical;
|
||||
|
||||
var radarCoord = chart.AddChartComponent<RadarCoord>();
|
||||
radarCoord.shape = RadarCoord.Shape.Polygon;
|
||||
radarCoord.center[0] = 0.25f;
|
||||
radarCoord.center[1] = 0.4f;
|
||||
radarCoord.radius = 0.25f;
|
||||
for (int i = 1; i <= 5; i++)
|
||||
{
|
||||
radarCoord.AddIndicator("radar1" + i, 0, 100);
|
||||
}
|
||||
|
||||
var radarCoord2 = chart.AddChartComponent<RadarCoord>();
|
||||
radarCoord2.shape = RadarCoord.Shape.Polygon;
|
||||
radarCoord2.center[0] = 0.75f;
|
||||
radarCoord2.center[1] = 0.4f;
|
||||
radarCoord2.radius = 0.25f;
|
||||
for (int i = 1; i <= 5; i++)
|
||||
{
|
||||
radarCoord2.AddIndicator("radar2" + i, 0, 100);
|
||||
}
|
||||
|
||||
serie = chart.AddSerie<Radar>("test1");
|
||||
serie.radarIndex = 0;
|
||||
chart.AddData(0, new List<double> { 10, 20, 60, 40, 20 }, "data1");
|
||||
|
||||
serie1 = chart.AddSerie<Radar>("test2");
|
||||
serie1.radarIndex = 1;
|
||||
chart.AddData(1, new List<double> { 10, 20, 60, 40, 20 }, "data2");
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95a60d7e7a0fc41ecaec5f48823b70bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,73 @@
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example41_RadarUpdate : MonoBehaviour
|
||||
{
|
||||
RadarChart chart;
|
||||
int count = 0;
|
||||
double max = 0;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<RadarChart>();
|
||||
if (chart == null)
|
||||
{
|
||||
chart = gameObject.AddComponent<RadarChart>();
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
UpdateData();
|
||||
count++;
|
||||
}
|
||||
UpdateMax();
|
||||
}
|
||||
|
||||
void UpdateData()
|
||||
{
|
||||
var serieIndex = 0;
|
||||
var serie = chart.GetSerie(serieIndex);
|
||||
if (serie == null) return;
|
||||
if (serie.radarType == RadarType.Multiple)
|
||||
{
|
||||
for (int i = 0; i < serie.dataCount; i++)
|
||||
{
|
||||
var serieData = serie.GetSerieData(i);
|
||||
for (int j = 0; j < serieData.data.Count; j++)
|
||||
{
|
||||
var value = Random.Range(10, 100);
|
||||
chart.UpdateData(serieIndex, i, j, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < serie.dataCount; i++)
|
||||
{
|
||||
var value = Random.Range(10, 100);
|
||||
chart.UpdateData(serieIndex, i, value);
|
||||
}
|
||||
}
|
||||
chart.GetChartComponent<Title>().subText = "max:" + serie.context.dataMax;
|
||||
}
|
||||
|
||||
void UpdateMax()
|
||||
{
|
||||
var serieIndex = 0;
|
||||
var serie = chart.GetSerie(serieIndex);
|
||||
if (serie == null) return;
|
||||
if (serie.context.dataMax != max)
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "max:" + serie.context.dataMax;
|
||||
max = serie.context.dataMax;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a2ad6907bd5045ec920b4f0e359535e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example50_Scatter : MonoBehaviour
|
||||
{
|
||||
private ScatterChart chart;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<ScatterChart>();
|
||||
if (chart == null) return;
|
||||
foreach (var serie in chart.series)
|
||||
{
|
||||
serie.symbol.sizeFunction = SymbolSize;
|
||||
serie.symbol.selectedSizeFunction = SymbolSelectedSize;
|
||||
}
|
||||
}
|
||||
|
||||
float SymbolSize(List<double> data)
|
||||
{
|
||||
return (float) (Math.Sqrt(data[2]) / 6e2);
|
||||
}
|
||||
|
||||
float SymbolSelectedSize(List<double> data)
|
||||
{
|
||||
return (float) (Math.Sqrt(data[2]) / 5e2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e6c9b864ab644b45ae93df3878ab1dd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,111 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example60_Heatmap : MonoBehaviour
|
||||
{
|
||||
private HeatmapChart chart;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<HeatmapChart>();
|
||||
if (chart == null)
|
||||
{
|
||||
chart = gameObject.AddComponent<HeatmapChart>();
|
||||
}
|
||||
chart.GetChartComponent<Title>().text = "HeatmapChart";
|
||||
chart.GetChartComponent<Tooltip>().type = Tooltip.Type.None;
|
||||
|
||||
var grid = chart.GetChartComponent<GridCoord>();
|
||||
grid.left = 100;
|
||||
grid.right = 60;
|
||||
grid.bottom = 60;
|
||||
|
||||
var xAxis = chart.GetChartComponent<XAxis>();
|
||||
var yAxis = chart.GetChartComponent<YAxis>();
|
||||
//目前只支持Category
|
||||
xAxis.type = Axis.AxisType.Category;
|
||||
yAxis.type = Axis.AxisType.Category;
|
||||
|
||||
xAxis.boundaryGap = true;
|
||||
xAxis.boundaryGap = true;
|
||||
|
||||
xAxis.splitNumber = 10;
|
||||
yAxis.splitNumber = 10;
|
||||
|
||||
//清空数据重新添加
|
||||
chart.RemoveData();
|
||||
var serie = chart.AddSerie<Heatmap>("serie1");
|
||||
|
||||
//设置样式
|
||||
serie.itemStyle.show = true;
|
||||
serie.itemStyle.borderWidth = 1;
|
||||
serie.itemStyle.borderColor = Color.clear;
|
||||
|
||||
//设置高亮样式
|
||||
serie.AddExtraComponent<EmphasisItemStyle>();
|
||||
serie.emphasisItemStyle.show = true;
|
||||
serie.emphasisItemStyle.borderWidth = 1;
|
||||
serie.emphasisItemStyle.borderColor = Color.black;
|
||||
|
||||
//设置视觉映射组件
|
||||
var visualMap = chart.GetChartComponent<VisualMap>();
|
||||
visualMap.max = 10;
|
||||
visualMap.range[0] = 0f;
|
||||
visualMap.range[1] = 10f;
|
||||
visualMap.orient = Orient.Vertical;
|
||||
visualMap.calculable = true;
|
||||
visualMap.location.align = Location.Align.BottomLeft;
|
||||
visualMap.location.bottom = 100;
|
||||
visualMap.location.left = 30;
|
||||
|
||||
//清空颜色重新添加
|
||||
|
||||
var heatmapGridWid = 10f;
|
||||
int xSplitNumber = (int) (grid.context.width / heatmapGridWid);
|
||||
int ySplitNumber = (int) (grid.context.height / heatmapGridWid);
|
||||
var colors = new List<string>
|
||||
{
|
||||
"#313695",
|
||||
"#4575b4",
|
||||
"#74add1",
|
||||
"#abd9e9",
|
||||
"#e0f3f8",
|
||||
"#ffffbf",
|
||||
"#fee090",
|
||||
"#fdae61",
|
||||
"#f46d43",
|
||||
"#d73027",
|
||||
"#a50026"
|
||||
};
|
||||
visualMap.AddColors(colors);
|
||||
//添加xAxis的数据
|
||||
for (int i = 0; i < xSplitNumber; i++)
|
||||
{
|
||||
chart.AddXAxisData((i + 1).ToString());
|
||||
}
|
||||
//添加yAxis的数据
|
||||
for (int i = 0; i < ySplitNumber; i++)
|
||||
{
|
||||
chart.AddYAxisData((i + 1).ToString());
|
||||
}
|
||||
for (int i = 0; i < xSplitNumber; i++)
|
||||
{
|
||||
for (int j = 0; j < ySplitNumber; j++)
|
||||
{
|
||||
var value = 0f;
|
||||
var rate = Random.Range(0, 101);
|
||||
if (rate > 70) value = Random.Range(8f, 10f);
|
||||
else value = Random.Range(1f, 8f);
|
||||
var list = new List<double> { i, j, value };
|
||||
//至少是一个三位数据:(x,y,value)
|
||||
chart.AddData(0, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e702e0ac05be84dbe9622180d4f6ef71
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,52 @@
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example80_Polar : MonoBehaviour
|
||||
{
|
||||
private BaseChart chart;
|
||||
private float updateTime;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<BaseChart>();
|
||||
if (chart == null)
|
||||
{
|
||||
chart = gameObject.AddComponent<BaseChart>();
|
||||
}
|
||||
chart.GetOrAddChartComponent<PolarCoord>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
AddData();
|
||||
}
|
||||
}
|
||||
|
||||
void AddData()
|
||||
{
|
||||
chart.RemoveData();
|
||||
chart.GetChartComponent<Tooltip>().type = Tooltip.Type.Corss;
|
||||
var angleAxis = chart.GetChartComponent<AngleAxis>();
|
||||
angleAxis.type = Axis.AxisType.Value;
|
||||
angleAxis.minMaxType = Axis.AxisMinMaxType.Custom;
|
||||
angleAxis.min = 0;
|
||||
angleAxis.max = 360;
|
||||
angleAxis.startAngle = Random.Range(0, 90);
|
||||
chart.AddSerie<Line>("line1");
|
||||
|
||||
var rate = Random.Range(1, 4);
|
||||
for (int i = 0; i <= 360; i++)
|
||||
{
|
||||
var t = i / 180f * Mathf.PI;
|
||||
var r = Mathf.Sin(2 * t) * Mathf.Cos(2 * t) * rate;
|
||||
chart.AddData(0, Mathf.Abs(r), i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca29783da761a4e0e9c5204d5b24b610
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,68 @@
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example90_Candlestick : MonoBehaviour
|
||||
{
|
||||
private CandlestickChart chart;
|
||||
private float updateTime;
|
||||
public int dataCount = 100;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<CandlestickChart>();
|
||||
if (chart == null)
|
||||
{
|
||||
chart = gameObject.AddComponent<CandlestickChart>();
|
||||
}
|
||||
GenerateOHLC(dataCount);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
AddData();
|
||||
}
|
||||
}
|
||||
|
||||
void AddData() { }
|
||||
|
||||
void GenerateOHLC(int count)
|
||||
{
|
||||
chart.ClearData();
|
||||
|
||||
var xValue = System.DateTime.Now;
|
||||
var baseValue = Random.Range(0f, 1f) * 12000;
|
||||
var boxVals = new float[4];
|
||||
var dayRange = 12;
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
baseValue = baseValue + Random.Range(0f, 1f) * 30 - 10;
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
boxVals[j] = (Random.Range(0f, 1f) - 0.5f) * dayRange + baseValue;
|
||||
}
|
||||
System.Array.Sort(boxVals);
|
||||
var openIdx = Mathf.RoundToInt(Random.Range(0f, 1f) * 3);
|
||||
var closeIdx = Mathf.RoundToInt(Random.Range(0f, 1f) * 2);
|
||||
if (openIdx == closeIdx)
|
||||
{
|
||||
closeIdx++;
|
||||
}
|
||||
//var volumn = boxVals[3]*(1000+Random.Range(0f,1f) * 500);
|
||||
var open = boxVals[openIdx];
|
||||
var close = boxVals[closeIdx];
|
||||
var lowest = boxVals[0];
|
||||
var heighest = boxVals[3];
|
||||
|
||||
chart.AddXAxisData(i.ToString());
|
||||
chart.AddData(0, open, close, lowest, heighest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69c7f3bf337c843888b4a7031eef1027
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,66 @@
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
//[ExecuteInEditMode]
|
||||
public class Example_AddChart : MonoBehaviour
|
||||
{
|
||||
BaseChart chart;
|
||||
void Awake()
|
||||
{
|
||||
//AddChart();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
AddChart();
|
||||
}
|
||||
}
|
||||
|
||||
void AddChart()
|
||||
{
|
||||
chart = gameObject.GetComponent<BaseChart>();
|
||||
if (chart == null)
|
||||
{
|
||||
chart = gameObject.AddComponent<LineChart>();
|
||||
chart.Init();
|
||||
chart.SetSize(1200, 600);
|
||||
}
|
||||
var title = chart.GetOrAddChartComponent<Title>();
|
||||
title.text = "Simple LineChart";
|
||||
title.subText = "normal line";
|
||||
|
||||
var tooltip = chart.GetOrAddChartComponent<Tooltip>();
|
||||
tooltip.show = true;
|
||||
|
||||
var legend = chart.GetOrAddChartComponent<Legend>();
|
||||
legend.show = false;
|
||||
|
||||
var xAxis = chart.GetOrAddChartComponent<XAxis>();
|
||||
xAxis.splitNumber = 10;
|
||||
xAxis.boundaryGap = true;
|
||||
xAxis.type = Axis.AxisType.Category;
|
||||
|
||||
var yAxis = chart.GetOrAddChartComponent<YAxis>();
|
||||
yAxis.type = Axis.AxisType.Value;
|
||||
|
||||
chart.RemoveData();
|
||||
chart.AddSerie<Line>("line");
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
chart.AddXAxisData("x" + i);
|
||||
chart.AddData(0, Random.Range(10, 20));
|
||||
}
|
||||
}
|
||||
|
||||
void ModifyComponent()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e5c24ed461624b8d924dfb1285e0a95
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,35 @@
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
//[ExecuteInEditMode]
|
||||
public class Example_Component : MonoBehaviour
|
||||
{
|
||||
BaseChart chart;
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<BaseChart>();
|
||||
}
|
||||
|
||||
void ModifyComponent()
|
||||
{
|
||||
var title = chart.GetOrAddChartComponent<Title>();
|
||||
title.text = "Simple LineChart";
|
||||
title.subText = "normal line";
|
||||
|
||||
var serie1 = chart.AddSerie<Line>();
|
||||
//var serie2 = chart.GetSerie<Line>();
|
||||
|
||||
serie1.AddExtraComponent<AreaStyle>();
|
||||
var label = serie1.AddExtraComponent<LabelStyle>();
|
||||
label.offset = new Vector3(0, 20, 0);
|
||||
|
||||
var serieData = chart.AddData(0, 20);
|
||||
serieData.radius = 10;
|
||||
var itemStyle = serieData.GetOrAddComponent<ItemStyle>();
|
||||
itemStyle.color = Color.blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e9941e7d67e44b18899e6048d4ef25a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
//[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(BaseChart))]
|
||||
public class Example_Dynamic : MonoBehaviour
|
||||
{
|
||||
public int maxCacheDataNumber = 100;
|
||||
public float initDataTime = 2;
|
||||
public bool insertDataToHead = true;
|
||||
|
||||
private BaseChart chart;
|
||||
private float updateTime;
|
||||
private float initTime;
|
||||
private int initCount;
|
||||
private int count;
|
||||
private bool isInited;
|
||||
private DateTime timeNow;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<BaseChart>();
|
||||
var serie = chart.GetSerie(0);
|
||||
serie.symbol.show = false;
|
||||
serie.maxCache = maxCacheDataNumber;
|
||||
|
||||
var xAxis = chart.GetOrAddChartComponent<XAxis>();
|
||||
xAxis.maxCache = maxCacheDataNumber;
|
||||
timeNow = DateTime.Now;
|
||||
timeNow = timeNow.AddSeconds(-maxCacheDataNumber);
|
||||
|
||||
serie.insertDataToHead = insertDataToHead;
|
||||
xAxis.insertDataToHead = insertDataToHead;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (initCount < maxCacheDataNumber)
|
||||
{
|
||||
int count = (int) (maxCacheDataNumber / initDataTime * Time.deltaTime);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
timeNow = timeNow.AddSeconds(1);
|
||||
var category = timeNow.ToString("hh:mm:ss");
|
||||
var value = UnityEngine.Random.Range(60, 150);
|
||||
chart.AddXAxisData(category);
|
||||
chart.AddData(0, value);
|
||||
initCount++;
|
||||
if (initCount > maxCacheDataNumber) break;
|
||||
}
|
||||
chart.RefreshChart();
|
||||
}
|
||||
updateTime += Time.deltaTime;
|
||||
if (updateTime >= 1)
|
||||
{
|
||||
var category = DateTime.Now.ToString("hh:mm:ss");
|
||||
var value = UnityEngine.Random.Range(60, 150);
|
||||
updateTime = 0;
|
||||
count++;
|
||||
chart.AddXAxisData(category);
|
||||
chart.AddData(0, value);
|
||||
chart.RefreshChart();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 310037ac5daa645058285cf176cc9eab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,52 @@
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(BaseChart))]
|
||||
public class Example_LargeData : MonoBehaviour
|
||||
{
|
||||
public int maxCacheDataNumber = 1000;
|
||||
public float initDataTime = 5;
|
||||
|
||||
private BaseChart chart;
|
||||
private float initTime;
|
||||
private int initCount = 0;
|
||||
private System.DateTime timeNow;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponentInChildren<BaseChart>();
|
||||
timeNow = System.DateTime.Now;
|
||||
chart.ClearData();
|
||||
chart.SetMaxCache(maxCacheDataNumber);
|
||||
chart.GetChartComponent<Title>().text = maxCacheDataNumber + "数据";
|
||||
}
|
||||
|
||||
private double lastValue = 0d;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (initCount < maxCacheDataNumber)
|
||||
{
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
initCount++;
|
||||
if (initCount > maxCacheDataNumber) break;
|
||||
chart.GetChartComponent<Title>().text = initCount + "数据";
|
||||
|
||||
timeNow = timeNow.AddSeconds(1);
|
||||
if (lastValue < 20)
|
||||
lastValue += UnityEngine.Random.Range(0, 5);
|
||||
else
|
||||
lastValue += UnityEngine.Random.Range(-5f, 5f);
|
||||
chart.AddData(0, lastValue);
|
||||
|
||||
chart.AddXAxisData(timeNow.ToString("hh:mm:ss"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 188d38c155a804c7d9d31730d3b12885
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(PieChart))]
|
||||
public class Example_PieChart : MonoBehaviour
|
||||
{
|
||||
private PieChart chart;
|
||||
private float time;
|
||||
private int count = 0;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
chart = transform.GetComponent<PieChart>();
|
||||
chart.ClearData();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
time += Time.deltaTime;
|
||||
if (time > 1)
|
||||
{
|
||||
time = 0;
|
||||
if (count < 5)
|
||||
{
|
||||
chart.AddData(0, Random.Range(10, 100), "time" + count);
|
||||
}
|
||||
else
|
||||
{
|
||||
int index = count % 5;
|
||||
chart.UpdateData(0, Random.Range(10, 100), index);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a36ce96ed11a24212aafad603286a3ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,66 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example_Test : MonoBehaviour
|
||||
{
|
||||
BaseChart chart;
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<BaseChart>();
|
||||
var btnTrans = transform.parent.Find("Button");
|
||||
if (btnTrans)
|
||||
{
|
||||
btnTrans.gameObject.GetComponent<Button>().onClick.AddListener(OnTestBtn);
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
AddData();
|
||||
//OnTestBtn();
|
||||
}
|
||||
}
|
||||
|
||||
void OnTestBtn()
|
||||
{
|
||||
object[][] m_TestData = new object[][]
|
||||
{
|
||||
new object[] { "01/06/20", 2.2d, 5.6d },
|
||||
new object[] { "22/06/20", 2.4d, 5.3d },
|
||||
new object[] { "04/08/21", 4.5d, 5.4d },
|
||||
new object[] { "05/08/21", 6.3d, 6.4d },
|
||||
new object[] { "06/08/21", 3.1d, 6.4d },
|
||||
new object[] { "09/08/21", 3.9d, 6.3d },
|
||||
new object[] { "10/08/21", 1.9d, 4.6d },
|
||||
};
|
||||
chart.ClearData();
|
||||
foreach (var list in m_TestData)
|
||||
{
|
||||
chart.AddXAxisData((string) list[0]);
|
||||
chart.AddData(0, (double) list[1]);
|
||||
chart.AddData(1, (double) list[2]);
|
||||
}
|
||||
}
|
||||
|
||||
void AddData()
|
||||
{
|
||||
chart.ClearData();
|
||||
int count = Random.Range(5, 100);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
chart.AddXAxisData("x" + i);
|
||||
if (Random.Range(1, 3) == 2)
|
||||
chart.AddData(0, Random.Range(-110, 200));
|
||||
else
|
||||
chart.AddData(0, Random.Range(-100, 100));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bac63bf58d06d47be8e1759189fbd9ed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,50 @@
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example_TestTime : MonoBehaviour
|
||||
{
|
||||
public int maxCache = 100;
|
||||
LineChart chart;
|
||||
int timestamp;
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<LineChart>();
|
||||
AddData();
|
||||
chart.SetMaxCache(maxCache);
|
||||
}
|
||||
|
||||
float m_LastTime = 0;
|
||||
double m_Value = 100;
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
//AddData();
|
||||
}
|
||||
if (Time.time - m_LastTime > 0.1f)
|
||||
{
|
||||
timestamp += 3600;
|
||||
m_Value += 10;
|
||||
chart.AddData(0, timestamp, m_Value);
|
||||
m_LastTime = Time.time;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void AddData()
|
||||
{
|
||||
chart.ClearData();
|
||||
timestamp = DateTimeUtil.GetTimestamp() - 10;
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
timestamp += i * 3600;
|
||||
double value = Random.Range(50, 200);
|
||||
chart.AddData(0, timestamp, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43b48222f7ffc420098593a8fe4bfc24
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "XCharts.Examples",
|
||||
"references": [
|
||||
"XCharts.Runtime"
|
||||
],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": []
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ca8daef375784f86b76407e76c9045a
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user