mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-19 15:00:08 +00:00
优化内置的示例代码,Demo改名为Example
This commit is contained in:
8
Examples/Runtime.meta
Normal file
8
Examples/Runtime.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f67670c9ee0e64262950aaf07562454e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
310
Examples/Runtime/Example00_CheatSheet.cs
Normal file
310
Examples/Runtime/Example00_CheatSheet.cs
Normal file
@@ -0,0 +1,310 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[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.title.show = true;
|
||||
chart.title.text = "术语解析-组件";
|
||||
chart.grid.bottom = 30;
|
||||
chart.grid.right = 30;
|
||||
chart.grid.left = 50;
|
||||
chart.grid.top = 80;
|
||||
|
||||
chart.dataZoom.enable = false;
|
||||
chart.visualMap.enable = false;
|
||||
|
||||
chart.RemoveData();
|
||||
|
||||
chart.AddSerie(SerieType.Bar, "Bar");
|
||||
chart.AddSerie(SerieType.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.title.text = "术语解析 - 组件";
|
||||
chart.title.subText = "Title 标题:可指定主标题和子标题";
|
||||
chart.xAxis0.show = true;
|
||||
chart.yAxis0.show = true;
|
||||
chart.series.list[0].show = false;
|
||||
chart.series.list[1].show = false;
|
||||
chart.legend.show = false;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
chart.title.show = !chart.title.show;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
chart.title.show = true;
|
||||
chart.RefreshChart();
|
||||
}
|
||||
|
||||
IEnumerator ComponentAxis()
|
||||
{
|
||||
chart.title.subText = "Axis 坐标轴:配置X和Y轴的轴线、刻度、标签等样式外观配置";
|
||||
chart.series.list[0].show = false;
|
||||
chart.series.list[1].show = false;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
chart.xAxis0.show = !chart.xAxis0.show;
|
||||
chart.yAxis0.show = !chart.yAxis0.show;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
chart.xAxis0.show = true;
|
||||
chart.yAxis0.show = true;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
|
||||
IEnumerator ComponentGrid()
|
||||
{
|
||||
chart.title.subText = "Grid 网格:调整坐标系边距和颜色等";
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
chart.grid.backgroundColor = i % 2 == 0 ? Color.clear : Color.grey;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
chart.grid.backgroundColor = Color.clear;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
|
||||
IEnumerator ComponentSerie()
|
||||
{
|
||||
chart.title.subText = "Serie 系列:调整坐标系边距和颜色等";
|
||||
chart.series.list[0].show = true;
|
||||
chart.series.list[1].show = true;
|
||||
chart.AnimationReset();
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1.2f);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
chart.series.list[0].show = !chart.series.list[0].show;
|
||||
chart.series.list[1].show = !chart.series.list[1].show;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
chart.series.list[0].show = true;
|
||||
chart.series.list[1].show = true;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
|
||||
IEnumerator ComponentLegend()
|
||||
{
|
||||
chart.title.subText = "Legend 图例:展示不同系列的名字和颜色,可控制系列显示等";
|
||||
chart.legend.show = true;
|
||||
chart.grid.top = 80;
|
||||
chart.legend.location.top = 50;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1f);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
chart.legend.show = !chart.legend.show;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
chart.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.title.subText = "Theme 主题:可从全局上配置图表的颜色、字体等效果,支持默认主题切换";
|
||||
yield return new WaitForSeconds(1f);
|
||||
chart.title.subText = "Theme 主题:Light主题";
|
||||
chart.UpdateTheme(Theme.Light);
|
||||
yield return new WaitForSeconds(1f);
|
||||
chart.title.subText = "Theme 主题:Dark主题";
|
||||
chart.UpdateTheme(Theme.Dark);
|
||||
yield return new WaitForSeconds(1f);
|
||||
chart.title.subText = "Theme 主题:Default主题";
|
||||
chart.UpdateTheme(Theme.Default);
|
||||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
|
||||
IEnumerator ComponentDataZoom()
|
||||
{
|
||||
chart.title.subText = "DataZoom 区域缩放:可通过拖、拽、缩小、放大来观察细节数据";
|
||||
chart.grid.bottom = 70;
|
||||
|
||||
chart.dataZoom.enable = true;
|
||||
chart.dataZoom.supportInside = true;
|
||||
chart.dataZoom.supportSlider = true;
|
||||
chart.dataZoom.height = 30;
|
||||
chart.dataZoom.start = 0;
|
||||
chart.dataZoom.end = 100;
|
||||
|
||||
chart.RefreshChart();
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
chart.dataZoom.supportSlider = !chart.dataZoom.supportSlider;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
chart.dataZoom.supportSlider = true;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1f);
|
||||
while (chart.dataZoom.start < 40)
|
||||
{
|
||||
chart.dataZoom.start += speed * Time.deltaTime * 0.8f;
|
||||
chart.RefreshDataZoom();
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
while (chart.dataZoom.end > 60)
|
||||
{
|
||||
chart.dataZoom.end -= speed * Time.deltaTime * 0.8f;
|
||||
chart.RefreshDataZoom();
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
while (chart.dataZoom.start > 0)
|
||||
{
|
||||
chart.dataZoom.start -= speed * Time.deltaTime * 0.8f;
|
||||
chart.dataZoom.end -= speed * Time.deltaTime * 0.8f;
|
||||
chart.RefreshDataZoom();
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
while (chart.dataZoom.end < 100)
|
||||
{
|
||||
chart.dataZoom.start += speed * Time.deltaTime * 0.8f;
|
||||
chart.dataZoom.end += speed * Time.deltaTime * 0.8f;
|
||||
chart.RefreshDataZoom();
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
while (chart.dataZoom.start > 0 || chart.dataZoom.end < 100)
|
||||
{
|
||||
chart.dataZoom.start -= speed * Time.deltaTime * 0.8f;
|
||||
chart.dataZoom.end += speed * Time.deltaTime * 0.8f;
|
||||
chart.RefreshDataZoom();
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator ComponentVisualMap()
|
||||
{
|
||||
chart.title.subText = "VisualMap 视觉映射:可从全局上配置图表的颜色、字体等效果,支持默认主题切换";
|
||||
|
||||
chart.visualMap.enable = true;
|
||||
chart.visualMap.show = true;
|
||||
chart.visualMap.orient = Orient.Vertical;
|
||||
chart.visualMap.calculable = true;
|
||||
chart.visualMap.min = 0;
|
||||
chart.visualMap.max = 100;
|
||||
chart.visualMap.range[0] = 0;
|
||||
chart.visualMap.range[1] = 100;
|
||||
|
||||
var colors = new List<string>{"#313695", "#4575b4", "#74add1", "#abd9e9", "#e0f3f8", "#ffffbf",
|
||||
"#fee090", "#fdae61", "#f46d43", "#d73027", "#a50026"};
|
||||
chart.visualMap.inRange.Clear();
|
||||
foreach (var str in colors)
|
||||
{
|
||||
chart.visualMap.inRange.Add(ThemeInfo.GetColor(str));
|
||||
}
|
||||
chart.grid.left = 80;
|
||||
chart.grid.bottom = 100;
|
||||
chart.RefreshChart();
|
||||
|
||||
yield return new WaitForSeconds(1f);
|
||||
while (chart.visualMap.rangeMin < 40)
|
||||
{
|
||||
chart.visualMap.rangeMin += speed * Time.deltaTime;
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
while (chart.visualMap.rangeMax > 60)
|
||||
{
|
||||
chart.visualMap.rangeMax -= speed * Time.deltaTime;
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
while (chart.visualMap.rangeMin > 0 || chart.visualMap.rangeMax < 100)
|
||||
{
|
||||
chart.visualMap.rangeMin -= speed * Time.deltaTime;
|
||||
chart.visualMap.rangeMax += speed * Time.deltaTime;
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Examples/Runtime/Example00_CheatSheet.cs.meta
Normal file
11
Examples/Runtime/Example00_CheatSheet.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 677b2673e728a4e308f26a5a9b236277
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
52
Examples/Runtime/Example01_UpdateData.cs
Normal file
52
Examples/Runtime/Example01_UpdateData.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[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.series.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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Examples/Runtime/Example01_UpdateData.cs.meta
Normal file
11
Examples/Runtime/Example01_UpdateData.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d369a0cba6716422cb15efa26bef0918
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
270
Examples/Runtime/Example10_LineChart.cs
Normal file
270
Examples/Runtime/Example10_LineChart.cs
Normal file
@@ -0,0 +1,270 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[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.title.text = "LineChart - 折线图";
|
||||
chart.title.subText = "普通折线图";
|
||||
|
||||
chart.yAxis0.minMaxType = Axis.AxisMinMaxType.Custom;
|
||||
chart.yAxis0.min = 0;
|
||||
chart.yAxis0.max = 100;
|
||||
|
||||
chart.RemoveData();
|
||||
serie = chart.AddSerie(SerieType.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.title.subText = "LineTyle - 曲线图";
|
||||
serie.lineType = LineType.Smooth;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.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.title.subText = "LineTyle - 虚线";
|
||||
serie.lineType = LineType.Dash;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.title.subText = "LineTyle - 点线";
|
||||
serie.lineType = LineType.Dot;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.title.subText = "LineTyle - 点划线";
|
||||
serie.lineType = LineType.DashDot;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.title.subText = "LineTyle - 双点划线";
|
||||
serie.lineType = LineType.DashDotDot;
|
||||
chart.RefreshChart();
|
||||
|
||||
serie.lineType = LineType.Normal;
|
||||
chart.RefreshChart();
|
||||
}
|
||||
|
||||
IEnumerator LineAreaStyleSettings()
|
||||
{
|
||||
chart.title.subText = "AreaStyle 面积图";
|
||||
|
||||
serie.areaStyle.show = true;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1f);
|
||||
|
||||
chart.title.subText = "AreaStyle 面积图";
|
||||
serie.lineType = LineType.Smooth;
|
||||
serie.areaStyle.show = true;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1f);
|
||||
|
||||
chart.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.title.subText = "AreaStyle 面积图 - 渐变";
|
||||
serie.areaStyle.toColor = Color.white;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
IEnumerator LineArrowSettings()
|
||||
{
|
||||
chart.title.subText = "LineArrow 头部箭头";
|
||||
serie.lineArrow.show = true;
|
||||
serie.lineArrow.position = LineArrow.Position.Start;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.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.title.subText = "SerieSymbol 图形标记";
|
||||
while (serie.symbol.size < 5)
|
||||
{
|
||||
serie.symbol.size += 2.5f * Time.deltaTime;
|
||||
chart.RefreshChart();
|
||||
yield return null;
|
||||
}
|
||||
chart.title.subText = "SerieSymbol 图形标记 - 空心圆";
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.title.subText = "SerieSymbol 图形标记 - 实心圆";
|
||||
serie.symbol.type = SerieSymbolType.Circle;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.title.subText = "SerieSymbol 图形标记 - 三角形";
|
||||
serie.symbol.type = SerieSymbolType.Triangle;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.title.subText = "SerieSymbol 图形标记 - 正方形";
|
||||
serie.symbol.type = SerieSymbolType.Rect;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.title.subText = "SerieSymbol 图形标记 - 菱形";
|
||||
serie.symbol.type = SerieSymbolType.Diamond;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
chart.title.subText = "SerieSymbol 图形标记";
|
||||
serie.symbol.type = SerieSymbolType.EmptyCircle;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SerieLabel相关配置
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IEnumerator LineLabelSettings()
|
||||
{
|
||||
chart.title.subText = "SerieLabel 文本标签";
|
||||
serie.label.show = true;
|
||||
serie.label.border = false;
|
||||
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);
|
||||
|
||||
serie.label.border = true;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
serie.label.color = Color.white;
|
||||
serie.label.backgroundColor = Color.grey;
|
||||
chart.RefreshLabel();
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
serie.label.show = false;
|
||||
chart.RefreshChart();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加多条线图
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IEnumerator LineMutilSerie()
|
||||
{
|
||||
chart.title.subText = "多系列";
|
||||
var serie2 = chart.AddSerie(SerieType.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(SerieType.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);
|
||||
|
||||
chart.yAxis0.minMaxType = Axis.AxisMinMaxType.Default;
|
||||
chart.title.subText = "多系列 - 堆叠";
|
||||
serie.stack = "samename";
|
||||
serie2.stack = "samename";
|
||||
serie3.stack = "samename";
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Examples/Runtime/Example10_LineChart.cs.meta
Normal file
11
Examples/Runtime/Example10_LineChart.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6155c7e0df4504ebfaf0c671ae200197
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
68
Examples/Runtime/Example11_AddSinCurve.cs
Normal file
68
Examples/Runtime/Example11_AddSinCurve.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[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)
|
||||
{
|
||||
GameObject.DestroyImmediate(chart);
|
||||
}
|
||||
chart = gameObject.AddComponent<LineChart>();
|
||||
chart.title.show = true;
|
||||
chart.title.text = "Sin Curve";
|
||||
|
||||
chart.tooltip.show = true;
|
||||
chart.legend.show = false;
|
||||
|
||||
chart.xAxises[0].show = true;
|
||||
chart.xAxises[1].show = false;
|
||||
chart.yAxises[0].show = true;
|
||||
chart.yAxises[1].show = false;
|
||||
|
||||
chart.xAxises[0].type = Axis.AxisType.Value;
|
||||
chart.yAxises[0].type = Axis.AxisType.Value;
|
||||
|
||||
chart.xAxises[0].boundaryGap = false;
|
||||
chart.xAxises[0].maxCache = 0;
|
||||
chart.series.list[0].maxCache = 0;
|
||||
|
||||
chart.RemoveData();
|
||||
|
||||
var serie = chart.AddSerie(SerieType.Line);
|
||||
serie.symbol.type = SerieSymbolType.None;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Examples/Runtime/Example11_AddSinCurve.cs.meta
Normal file
11
Examples/Runtime/Example11_AddSinCurve.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b380753d3cb4149c4a3a65a1816e0cc7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
39
Examples/Runtime/Example12_CustomDrawing.cs
Normal file
39
Examples/Runtime/Example12_CustomDrawing.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example12_CustomDrawing : MonoBehaviour
|
||||
{
|
||||
LineChart chart;
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<LineChart>();
|
||||
if (chart == null) return;
|
||||
|
||||
chart.customDrawCallback = delegate (VertexHelper vh)
|
||||
{
|
||||
var dataPoints = chart.series.list[0].dataPoints;
|
||||
if (dataPoints.Count > 0)
|
||||
{
|
||||
var pos = dataPoints[3];
|
||||
var zeroPos = new Vector3(chart.coordinateX, chart.coordinateY);
|
||||
var startPos = new Vector3(pos.x, zeroPos.y);
|
||||
var endPos = new Vector3(pos.x, zeroPos.y + chart.coordinateHeight);
|
||||
ChartDrawer.DrawLine(vh, startPos, endPos, 1, Color.blue);
|
||||
ChartDrawer.DrawCricle(vh, pos, 5, Color.blue);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Examples/Runtime/Example12_CustomDrawing.cs.meta
Normal file
11
Examples/Runtime/Example12_CustomDrawing.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da550ad36be5f442e96ad021cc10ca68
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
50
Examples/Runtime/Example13_LineSimple.cs
Normal file
50
Examples/Runtime/Example13_LineSimple.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example13_LineSimple : MonoBehaviour
|
||||
{
|
||||
void Awake()
|
||||
{
|
||||
var chart = gameObject.GetComponent<LineChart>();
|
||||
if (chart == null)
|
||||
{
|
||||
chart = gameObject.AddComponent<LineChart>();
|
||||
}
|
||||
chart.title.show = true;
|
||||
chart.title.text = "Line Simple";
|
||||
|
||||
chart.tooltip.show = true;
|
||||
chart.legend.show = false;
|
||||
|
||||
chart.xAxises[0].show = true;
|
||||
chart.xAxises[1].show = false;
|
||||
chart.yAxises[0].show = true;
|
||||
chart.yAxises[1].show = false;
|
||||
chart.xAxises[0].type = Axis.AxisType.Category;
|
||||
chart.yAxises[0].type = Axis.AxisType.Value;
|
||||
|
||||
chart.xAxises[0].splitNumber = 10;
|
||||
chart.xAxises[0].boundaryGap = true;
|
||||
|
||||
chart.RemoveData();
|
||||
chart.AddSerie(SerieType.Line);
|
||||
chart.AddSerie(SerieType.Line);
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
chart.AddXAxisData("x" + i);
|
||||
chart.AddData(0, Random.Range(10, 20));
|
||||
chart.AddData(1, Random.Range(10, 20));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Examples/Runtime/Example13_LineSimple.cs.meta
Normal file
11
Examples/Runtime/Example13_LineSimple.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6d0f65efd8e14ebdafa172e0ccbd562
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
167
Examples/Runtime/Example20_BarChart.cs
Normal file
167
Examples/Runtime/Example20_BarChart.cs
Normal file
@@ -0,0 +1,167 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[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.title.text = "BarChart - 柱状图";
|
||||
chart.title.subText = "普通柱状图";
|
||||
|
||||
chart.yAxis0.minMaxType = Axis.AxisMinMaxType.Default;
|
||||
|
||||
chart.RemoveData();
|
||||
serie = chart.AddSerie(SerieType.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.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(SerieType.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.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.title.subText = "非堆叠同柱";
|
||||
serie.barType = serie2.barType = BarType.Normal;
|
||||
serie.stack = "";
|
||||
serie2.stack = "";
|
||||
serie.barGap = -1;
|
||||
serie2.barGap = -1;
|
||||
chart.RefreshAxisMinMaxValue();
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
IEnumerator SameBarAndStack()
|
||||
{
|
||||
chart.title.subText = "堆叠同柱";
|
||||
serie.barType = serie2.barType = BarType.Normal;
|
||||
serie.stack = "samename";
|
||||
serie2.stack = "samename";
|
||||
chart.RefreshAxisMinMaxValue();
|
||||
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.title.subText = "百分比堆叠同柱";
|
||||
serie.barType = serie2.barType = BarType.Normal;
|
||||
serie.stack = "samename";
|
||||
serie2.stack = "samename";
|
||||
|
||||
serie.barPercentStack = true;
|
||||
|
||||
serie.label.show = true;
|
||||
serie.label.position = SerieLabel.Position.Center;
|
||||
serie.label.border = false;
|
||||
serie.label.color = Color.white;
|
||||
serie.label.formatter = "{d:f0}%";
|
||||
|
||||
serie2.label.show = true;
|
||||
serie2.label.position = SerieLabel.Position.Center;
|
||||
serie2.label.border = false;
|
||||
serie2.label.color = Color.white;
|
||||
serie2.label.formatter = "{d:f0}%";
|
||||
|
||||
chart.RefreshLabel();
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Examples/Runtime/Example20_BarChart.cs.meta
Normal file
11
Examples/Runtime/Example20_BarChart.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03916f7ca858b446883197ae17e50f16
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
206
Examples/Runtime/Example30_PieChart.cs
Normal file
206
Examples/Runtime/Example30_PieChart.cs
Normal file
@@ -0,0 +1,206 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[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.title.text = "PieChart - 饼图";
|
||||
chart.title.subText = "基础饼图";
|
||||
|
||||
chart.legend.show = true;
|
||||
chart.legend.location.align = Location.Align.TopLeft;
|
||||
chart.legend.location.top = 60;
|
||||
chart.legend.location.left = 2;
|
||||
chart.legend.itemWidth = 70;
|
||||
chart.legend.itemHeight = 20;
|
||||
chart.legend.orient = Orient.Vertical;
|
||||
|
||||
chart.RemoveData();
|
||||
serie = chart.AddSerie(SerieType.Pie, "访问来源");
|
||||
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.RefreshLabel();
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
IEnumerator PieShowLabel()
|
||||
{
|
||||
chart.title.subText = "显示文本标签";
|
||||
|
||||
serie.label.show = true;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
serie.label.lineType = SerieLabel.LineType.Curves;
|
||||
chart.RefreshChart();
|
||||
|
||||
yield return new WaitForSeconds(1);
|
||||
serie.label.lineType = SerieLabel.LineType.HorizontalLine;
|
||||
chart.RefreshChart();
|
||||
|
||||
yield return new WaitForSeconds(1);
|
||||
serie.label.lineType = SerieLabel.LineType.BrokenLine;
|
||||
chart.RefreshChart();
|
||||
|
||||
yield return new WaitForSeconds(1);
|
||||
serie.label.show = false;
|
||||
chart.RefreshChart();
|
||||
}
|
||||
|
||||
IEnumerator Doughnut()
|
||||
{
|
||||
chart.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.pieSpace = 1f;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
serie.data[0].selected = true;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
serie.pieSpace = 0f;
|
||||
serie.data[0].selected = false;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
IEnumerator DoublePie()
|
||||
{
|
||||
chart.title.subText = "多图组合";
|
||||
|
||||
serie1 = chart.AddSerie(SerieType.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 = SerieLabel.Position.Inside;
|
||||
serie1.label.color = Color.white;
|
||||
serie1.label.fontSize = 14;
|
||||
serie1.label.border = false;
|
||||
|
||||
chart.RefreshLabel();
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
IEnumerator RosePie()
|
||||
{
|
||||
chart.title.subText = "玫瑰图";
|
||||
chart.legend.show = false;
|
||||
serie1.ClearData();
|
||||
serie.ClearData();
|
||||
serie1.radius = serie.radius = new float[2] { 0, 80 };
|
||||
serie1.label.position = SerieLabel.Position.Outside;
|
||||
serie1.label.lineType = SerieLabel.LineType.Curves;
|
||||
serie1.label.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Examples/Runtime/Example30_PieChart.cs.meta
Normal file
11
Examples/Runtime/Example30_PieChart.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b8649d38981b4b5bbdf16e8f303fa1e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
124
Examples/Runtime/Example40_Radar.cs
Normal file
124
Examples/Runtime/Example40_Radar.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[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.RemoveRadar();
|
||||
chart.RemoveData();
|
||||
|
||||
chart.title.text = "RadarChart - 雷达图";
|
||||
chart.title.subText = "";
|
||||
|
||||
chart.legend.show = true;
|
||||
chart.legend.location.align = Location.Align.TopLeft;
|
||||
chart.legend.location.top = 60;
|
||||
chart.legend.location.left = 2;
|
||||
chart.legend.itemWidth = 70;
|
||||
chart.legend.itemHeight = 20;
|
||||
chart.legend.orient = Orient.Vertical;
|
||||
|
||||
chart.AddRadar(Radar.Shape.Polygon, new Vector2(0.5f, 0.4f), 0.4f);
|
||||
chart.AddIndicator(0, "indicator1", 0, 100);
|
||||
chart.AddIndicator(0, "indicator2", 0, 100);
|
||||
chart.AddIndicator(0, "indicator3", 0, 100);
|
||||
chart.AddIndicator(0, "indicator4", 0, 100);
|
||||
chart.AddIndicator(0, "indicator5", 0, 100);
|
||||
|
||||
serie = chart.AddSerie(SerieType.Radar, "test");
|
||||
serie.radarIndex = 0;
|
||||
chart.AddData(0, new List<float> { 10, 20, 60, 40, 20 }, "data1");
|
||||
chart.AddData(0, new List<float> { 40, 60, 90, 80, 70 }, "data2");
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
IEnumerator RadarUpdate()
|
||||
{
|
||||
chart.UpdateIndicator(0, 0, "new1", 0, 100);
|
||||
chart.UpdateData(0, 0, new List<float> { 15, 30, 50, 60, 50 });
|
||||
chart.UpdateDataName(0, 0, "new1");
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
|
||||
IEnumerator RadarAddMultiple()
|
||||
{
|
||||
chart.RemoveRadar();
|
||||
chart.RemoveData();
|
||||
|
||||
chart.title.text = "RadarChart - 多雷达图";
|
||||
chart.title.subText = "";
|
||||
|
||||
chart.legend.show = true;
|
||||
chart.legend.location.align = Location.Align.TopLeft;
|
||||
chart.legend.location.top = 60;
|
||||
chart.legend.location.left = 2;
|
||||
chart.legend.itemWidth = 70;
|
||||
chart.legend.itemHeight = 20;
|
||||
chart.legend.orient = Orient.Vertical;
|
||||
|
||||
chart.AddRadar(Radar.Shape.Polygon, new Vector2(0.25f, 0.4f), 0.25f);
|
||||
for (int i = 1; i <= 5; i++)
|
||||
{
|
||||
chart.AddIndicator(0, "radar1" + i, 0, 100);
|
||||
}
|
||||
|
||||
chart.AddRadar(Radar.Shape.Circle, new Vector2(0.75f, 0.4f), 0.25f);
|
||||
for (int i = 1; i <= 5; i++)
|
||||
{
|
||||
chart.AddIndicator(1, "radar2" + i, 0, 100);
|
||||
}
|
||||
|
||||
serie = chart.AddSerie(SerieType.Radar, "test1");
|
||||
serie.radarIndex = 0;
|
||||
chart.AddData(0, new List<float> { 10, 20, 60, 40, 20 }, "data1");
|
||||
|
||||
serie1 = chart.AddSerie(SerieType.Radar, "test2");
|
||||
serie1.radarIndex = 1;
|
||||
chart.AddData(1, new List<float> { 10, 20, 60, 40, 20 }, "data2");
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Examples/Runtime/Example40_Radar.cs.meta
Normal file
11
Examples/Runtime/Example40_Radar.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95a60d7e7a0fc41ecaec5f48823b70bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
38
Examples/Runtime/Example50_Scatter.cs
Normal file
38
Examples/Runtime/Example50_Scatter.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example50_Scatter : MonoBehaviour
|
||||
{
|
||||
private ScatterChart chart;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<ScatterChart>();
|
||||
if (chart == null) return;
|
||||
chart.series.SetSerieSymbolSizeCallback(SymbolSize, SymbolSelectedSize);
|
||||
}
|
||||
|
||||
float SymbolSize(List<float> data)
|
||||
{
|
||||
//return Mathf.Clamp(data[1] * 10,1,100);
|
||||
return (float)(Mathf.Sqrt(data[2]) / 6e2);
|
||||
}
|
||||
|
||||
float SymbolSelectedSize(List<float> data)
|
||||
{
|
||||
//return Mathf.Clamp(data[1] * 10,1,100);
|
||||
return (float)(Mathf.Sqrt(data[2]) / 5e2);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Examples/Runtime/Example50_Scatter.cs.meta
Normal file
11
Examples/Runtime/Example50_Scatter.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e6c9b864ab644b45ae93df3878ab1dd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
104
Examples/Runtime/Example60_Heatmap.cs
Normal file
104
Examples/Runtime/Example60_Heatmap.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example60_Heatmap : MonoBehaviour
|
||||
{
|
||||
private HeatmapChart chart;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<HeatmapChart>();
|
||||
if (chart == null)
|
||||
{
|
||||
chart = gameObject.AddComponent<HeatmapChart>();
|
||||
}
|
||||
chart.title.text = "HeatmapChart";
|
||||
chart.tooltip.type = Tooltip.Type.None;
|
||||
chart.grid.left = 100;
|
||||
chart.grid.right = 60;
|
||||
chart.grid.bottom = 60;
|
||||
//目前只支持Category
|
||||
chart.xAxises[0].type = Axis.AxisType.Category;
|
||||
chart.yAxises[0].type = Axis.AxisType.Category;
|
||||
|
||||
chart.xAxises[0].boundaryGap = true;
|
||||
chart.xAxises[0].boundaryGap = true;
|
||||
|
||||
chart.xAxises[0].splitNumber = 10;
|
||||
chart.yAxises[0].splitNumber = 10;
|
||||
|
||||
//清空数据重新添加
|
||||
chart.RemoveData();
|
||||
var serie = chart.AddSerie(SerieType.Heatmap, "serie1");
|
||||
|
||||
//设置样式
|
||||
serie.itemStyle.show = true;
|
||||
serie.itemStyle.borderWidth = 1;
|
||||
serie.itemStyle.borderColor = Color.clear;
|
||||
|
||||
//设置高亮样式
|
||||
serie.emphasis.show = true;
|
||||
serie.emphasis.itemStyle.show = true;
|
||||
serie.emphasis.itemStyle.borderWidth = 1;
|
||||
serie.emphasis.itemStyle.borderColor = Color.black;
|
||||
|
||||
//设置视觉映射组件
|
||||
chart.visualMap.enable = true;
|
||||
chart.visualMap.max = 10;
|
||||
chart.visualMap.range[0] = 0f;
|
||||
chart.visualMap.range[1] = 10f;
|
||||
chart.visualMap.orient = Orient.Vertical;
|
||||
chart.visualMap.calculable = true;
|
||||
chart.visualMap.location.align = Location.Align.BottomLeft;
|
||||
chart.visualMap.location.bottom = 100;
|
||||
chart.visualMap.location.left = 30;
|
||||
|
||||
//清空颜色重新添加
|
||||
chart.visualMap.inRange.Clear();
|
||||
|
||||
var heatmapGridWid = 10f;
|
||||
int xSplitNumber = (int)(chart.coordinateWidth / heatmapGridWid);
|
||||
int ySplitNumber = (int)(chart.coordinateHeight / heatmapGridWid);
|
||||
var colors = new List<string>{"#313695", "#4575b4", "#74add1", "#abd9e9", "#e0f3f8", "#ffffbf",
|
||||
"#fee090", "#fdae61", "#f46d43", "#d73027", "#a50026"};
|
||||
foreach (var str in colors)
|
||||
{
|
||||
chart.visualMap.inRange.Add(ThemeInfo.GetColor(str));
|
||||
}
|
||||
//添加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<float> { i, j, value };
|
||||
//至少是一个三位数据:(x,y,value)
|
||||
chart.AddData(0, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Examples/Runtime/Example60_Heatmap.cs.meta
Normal file
11
Examples/Runtime/Example60_Heatmap.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e702e0ac05be84dbe9622180d4f6ef71
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
70
Examples/Runtime/Example70_Gauge.cs
Normal file
70
Examples/Runtime/Example70_Gauge.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System.Runtime.InteropServices;
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example70_Gauge : MonoBehaviour
|
||||
{
|
||||
private GaugeChart chart;
|
||||
private float updateTime;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<GaugeChart>();
|
||||
if (chart == null)
|
||||
{
|
||||
chart = gameObject.AddComponent<GaugeChart>();
|
||||
}
|
||||
chart.title.text = "GaugeChart";
|
||||
chart.RemoveData();
|
||||
|
||||
var serie = chart.AddSerie(SerieType.Gauge, "速度");
|
||||
serie.min = 0;
|
||||
serie.max = 220;
|
||||
serie.startAngle = -125;
|
||||
serie.endAngle = 125;
|
||||
serie.center[0] = 0.5f;
|
||||
serie.center[1] = 0.5f;
|
||||
serie.radius[0] = 80;
|
||||
serie.splitNumber = 5;
|
||||
serie.animation.dataChangeEnable = true;
|
||||
serie.roundCap = true;
|
||||
|
||||
serie.titleStyle.show = true;
|
||||
serie.titleStyle.textStyle.offset = new Vector2(0, 20);
|
||||
|
||||
serie.label.show = true;
|
||||
serie.label.offset = new Vector3(0, -20);
|
||||
|
||||
serie.gaugeAxis.show = true;
|
||||
serie.gaugeAxis.axisLine.width = 15;
|
||||
|
||||
serie.gaugePointer.show = true;
|
||||
serie.gaugePointer.width = 15;
|
||||
|
||||
var value = UnityEngine.Random.Range(serie.min, serie.max);
|
||||
chart.AddData(0, value, "km/h");
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
updateTime += Time.deltaTime;
|
||||
if (updateTime > 2)
|
||||
{
|
||||
updateTime = 0;
|
||||
var value = UnityEngine.Random.Range(0, 220);
|
||||
chart.UpdateData(0, 0, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Examples/Runtime/Example70_Gauge.cs.meta
Normal file
11
Examples/Runtime/Example70_Gauge.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3a7b70d5b66640dca4aaecf13d3769f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
71
Examples/Runtime/Example_Dynamic.cs
Normal file
71
Examples/Runtime/Example_Dynamic.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(CoordinateChart))]
|
||||
public class Example_Dynamic : MonoBehaviour
|
||||
{
|
||||
public int maxCacheDataNumber = 100;
|
||||
public float initDataTime = 2;
|
||||
|
||||
private CoordinateChart chart;
|
||||
private float updateTime;
|
||||
private float initTime;
|
||||
private int initCount;
|
||||
private int count;
|
||||
private bool isInited;
|
||||
private DateTime timeNow;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponentInChildren<CoordinateChart>();
|
||||
chart.RemoveData();
|
||||
var serie = chart.AddSerie(SerieType.Line);
|
||||
serie.symbol.type = SerieSymbolType.None;
|
||||
serie.maxCache = maxCacheDataNumber;
|
||||
chart.xAxises[0].maxCache = maxCacheDataNumber;
|
||||
timeNow = DateTime.Now;
|
||||
timeNow = timeNow.AddSeconds(-maxCacheDataNumber);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (initCount < maxCacheDataNumber)
|
||||
{
|
||||
int count = (int)(maxCacheDataNumber / initDataTime * Time.deltaTime);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
timeNow = timeNow.AddSeconds(1);
|
||||
string category = timeNow.ToString("hh:mm:ss");
|
||||
float 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)
|
||||
{
|
||||
updateTime = 0;
|
||||
count++;
|
||||
string category = DateTime.Now.ToString("hh:mm:ss");
|
||||
float value = UnityEngine.Random.Range(60, 150);
|
||||
chart.AddXAxisData(category);
|
||||
chart.AddData(0, value);
|
||||
chart.RefreshChart();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Examples/Runtime/Example_Dynamic.cs.meta
Normal file
11
Examples/Runtime/Example_Dynamic.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 310037ac5daa645058285cf176cc9eab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
54
Examples/Runtime/Example_LargeData.cs
Normal file
54
Examples/Runtime/Example_LargeData.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(CoordinateChart))]
|
||||
public class Example_LargeData : MonoBehaviour
|
||||
{
|
||||
public int maxCacheDataNumber = 3000;
|
||||
public float initDataTime = 5;
|
||||
|
||||
private CoordinateChart chart;
|
||||
private float initTime;
|
||||
private int initCount = 0;
|
||||
private System.DateTime timeNow;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponentInChildren<CoordinateChart>();
|
||||
timeNow = System.DateTime.Now;
|
||||
chart.ClearAxisData();
|
||||
chart.series.ClearData();
|
||||
chart.SetMaxCache(maxCacheDataNumber);
|
||||
chart.title.text = maxCacheDataNumber + "数据";
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (initCount < maxCacheDataNumber)
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
initCount++;
|
||||
if (initCount > maxCacheDataNumber) break;
|
||||
chart.title.text = initCount + "数据";
|
||||
timeNow = timeNow.AddSeconds(1);
|
||||
float xvalue = Mathf.PI / 180 * initCount;
|
||||
float yvalue = Mathf.Sin(xvalue);
|
||||
|
||||
chart.AddData(0, 15 + yvalue * 2);
|
||||
chart.AddXAxisData(timeNow.ToString("hh:mm:ss"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Examples/Runtime/Example_LargeData.cs.meta
Normal file
11
Examples/Runtime/Example_LargeData.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 188d38c155a804c7d9d31730d3b12885
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
46
Examples/Runtime/Example_PieChart.cs
Normal file
46
Examples/Runtime/Example_PieChart.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Examples/Runtime/Example_PieChart.cs.meta
Normal file
11
Examples/Runtime/Example_PieChart.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a36ce96ed11a24212aafad603286a3ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
56
Examples/Runtime/Example_Test.cs
Normal file
56
Examples/Runtime/Example_Test.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[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();
|
||||
}
|
||||
}
|
||||
|
||||
void OnTestBtn()
|
||||
{
|
||||
//chart.ClearData();
|
||||
chart.SetSize(800,400);
|
||||
}
|
||||
|
||||
void AddData()
|
||||
{
|
||||
chart.ClearData();
|
||||
int count = Random.Range(5, 100);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
(chart as CoordinateChart).AddXAxisData("x" + i);
|
||||
if (Random.Range(1, 3) == 2)
|
||||
chart.AddData(0, Random.Range(-110, 200));
|
||||
else
|
||||
chart.AddData(0, Random.Range(-100, 100));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Examples/Runtime/Example_Test.cs.meta
Normal file
11
Examples/Runtime/Example_Test.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bac63bf58d06d47be8e1759189fbd9ed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
Examples/Runtime/XCharts.Examples.Runtime.asmdef
Normal file
14
Examples/Runtime/XCharts.Examples.Runtime.asmdef
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "XCharts.Examples.Runtime",
|
||||
"references": [
|
||||
"XCharts.Runtime"
|
||||
],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": []
|
||||
}
|
||||
7
Examples/Runtime/XCharts.Examples.Runtime.asmdef.meta
Normal file
7
Examples/Runtime/XCharts.Examples.Runtime.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ca8daef375784f86b76407e76c9045a
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user