整理代码结构,支持Package Manager添加

This commit is contained in:
monitor1394
2019-10-22 04:09:04 +08:00
parent fcae6d3bce
commit 57dd2d704f
218 changed files with 197991 additions and 97171 deletions

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: cc28a4ebefb884f6ab7132e3910b7461
guid: 05b7d15b7a92f4c1eb56dbf47522bf6c
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@@ -1,4 +1,11 @@
using UnityEditor;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 97c0f1cf754c54fd1913ec5b4129c6e5
guid: 2fbbaed3e670f478c844c1bdfc73d433
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,5 +1,12 @@
using UnityEditor;
using UnityEngine;

/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
namespace XCharts
{

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: bc37c9f35cd6b4f0f936526a63fb19a5
guid: 90c1787bea03849c8b6d19be625b7e17
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,17 @@
{
"name": "XCharts.Editor.Demo",
"references": [
"XCharts.Demo.Runtime",
"XCharts.Runtime"
],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2d3606aaaf73f468984f4615b496f408
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +1,6 @@
fileFormatVersion: 2
guid: 2fa21c3b32aa26a49ababb5a99f12222
guid: f67670c9ee0e64262950aaf07562454e
folderAsset: yes
timeCreated: 1555731519
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:

View File

@@ -0,0 +1,197 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace XCharts
{
[System.Serializable]
public class ChartModule
{
[SerializeField] private string m_Name;
[SerializeField] private string m_Title;
[SerializeField] private bool m_Selected;
[SerializeField] private GameObject m_Panel;
public string name { get { return m_Name; } set { m_Name = value; } }
public string title { get { return m_Title; } set { m_Title = value; } }
public bool select { get { return m_Selected; } set { m_Selected = value; } }
public GameObject panel { get { return m_Panel; } set { m_Panel = value; } }
public Button button { get; set; }
}
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Demo : MonoBehaviour
{
[SerializeField] private Color m_ButtonNormalColor;
[SerializeField] private Color m_ButtonSelectedColor;
[SerializeField] private Color m_ButtonHighlightColor;
[SerializeField] private List<ChartModule> m_ChartModule;
private GameObject m_BtnClone;
private Theme m_SelectedTheme;
private int m_LastSelectedModuleIndex;
private Button m_DefaultThemeButton;
private Button m_LightThemeButton;
private Button m_DarkThemeButton;
private Text m_Title;
private ScrollRect m_ScrollRect;
private Mask m_Mark;
void Awake()
{
m_SelectedTheme = Theme.Default;
m_ButtonNormalColor = ChartHelper.GetColor("#293C55FF");
m_ButtonSelectedColor = ChartHelper.GetColor("#e43c59ff");
m_ButtonHighlightColor = ChartHelper.GetColor("#0E151FFF");
m_ScrollRect = transform.Find("chart_detail").GetComponent<ScrollRect>();
m_Mark = transform.Find("chart_detail/Viewport").GetComponent<Mask>();
m_Mark.enabled = true;
m_Title = transform.Find("chart_title/Text").GetComponent<Text>();
InitThemeButton();
InitModuleButton();
}
void Update()
{
#if UNITY_EDITOR
if (m_ChartModule.Count <= 0) return;
int selectedModuleIndex = -1;
for (int i = 0; i < m_ChartModule.Count; i++)
{
if (selectedModuleIndex >= 0 && i > selectedModuleIndex)
{
m_ChartModule[i].select = false;
}
else if (m_ChartModule[i].select)
{
selectedModuleIndex = i;
}
}
if (selectedModuleIndex < 0) selectedModuleIndex = 0;
if (selectedModuleIndex != m_LastSelectedModuleIndex)
{
InitModuleButton();
}
if (!Application.isPlaying) m_Mark.enabled = false;
#endif
}
void InitModuleButton()
{
var btnPanel = transform.Find("chart_list");
m_BtnClone = transform.Find("btn_clone").gameObject;
m_BtnClone.SetActive(false);
ChartHelper.DestoryAllChilds(btnPanel);
foreach (var module in m_ChartModule)
{
var btnName = "btn_" + module.name;
GameObject btn;
if (btnPanel.Find(btnName))
{
btn = btnPanel.Find(btnName).gameObject;
btn.SetActive(true);
}
else
{
btn = GameObject.Instantiate(m_BtnClone);
btn.SetActive(true);
btn.name = btnName;
btn.transform.SetParent(btnPanel);
btn.transform.localPosition = Vector3.zero;
}
btn.transform.localScale = Vector3.one;
module.button = btn.GetComponent<Button>();
module.button.GetComponentInChildren<Text>().text = module.name;
ChartHelper.AddEventListener(btn.gameObject, EventTriggerType.PointerDown, (data) =>
{
ClickModule(module);
});
}
for (int i = 0; i < m_ChartModule.Count; i++)
{
var module = m_ChartModule[i];
if (module.select)
{
ClickModule(module);
m_LastSelectedModuleIndex = i;
break;
}
}
}
void ClickModule(ChartModule selectedModule)
{
foreach (var module in m_ChartModule)
{
if (selectedModule != module)
{
var block = module.button.colors;
block.highlightedColor = m_ButtonHighlightColor;
block.normalColor = m_ButtonNormalColor;
module.button.colors = block;
module.panel.SetActive(false);
module.select = false;
}
else
{
var block = module.button.colors;
block.highlightedColor = m_ButtonSelectedColor;
block.normalColor = m_ButtonSelectedColor;
module.button.colors = block;
module.panel.SetActive(true);
module.select = true;
}
}
m_ScrollRect.content = selectedModule.panel.GetComponent<RectTransform>();
m_Title.text = string.IsNullOrEmpty(selectedModule.title) ?
selectedModule.name : selectedModule.title;
}
void InitThemeButton()
{
m_DefaultThemeButton = transform.Find("chart_theme/btn_default").GetComponent<Button>();
m_LightThemeButton = transform.Find("chart_theme/btn_light").GetComponent<Button>();
m_DarkThemeButton = transform.Find("chart_theme/btn_dark").GetComponent<Button>();
m_DefaultThemeButton.transform.Find("selected").gameObject.SetActive(m_SelectedTheme == Theme.Default);
m_LightThemeButton.transform.Find("selected").gameObject.SetActive(m_SelectedTheme == Theme.Light);
m_DarkThemeButton.transform.Find("selected").gameObject.SetActive(m_SelectedTheme == Theme.Dark);
m_DefaultThemeButton.onClick.AddListener(delegate () { SelecteTheme(Theme.Default); });
m_LightThemeButton.onClick.AddListener(delegate () { SelecteTheme(Theme.Light); });
m_DarkThemeButton.onClick.AddListener(delegate () { SelecteTheme(Theme.Dark); });
//SelecteTheme(Theme.Default);
}
void SelecteTheme(Theme theme)
{
m_SelectedTheme = theme;
m_DefaultThemeButton.transform.Find("selected").gameObject.SetActive(m_SelectedTheme == Theme.Default);
m_LightThemeButton.transform.Find("selected").gameObject.SetActive(m_SelectedTheme == Theme.Light);
m_DarkThemeButton.transform.Find("selected").gameObject.SetActive(m_SelectedTheme == Theme.Dark);
var charts = transform.GetComponentsInChildren<BaseChart>();
foreach (var chart in charts)
{
chart.UpdateTheme(theme);
}
}
}
}

View File

@@ -1,7 +1,5 @@
fileFormatVersion: 2
guid: f2cb45775d5ecfa4488a53912a49a832
timeCreated: 1555862356
licenseType: Free
guid: 85bc0178fe453471fb2706bf81a09235
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,310 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace XCharts
{
[DisallowMultipleComponent]
public class Demo00_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(3);
StartCoroutine(ComponentAxis());
yield return new WaitForSeconds(3);
StartCoroutine(ComponentGrid());
yield return new WaitForSeconds(3);
StartCoroutine(ComponentSerie());
yield return new WaitForSeconds(5);
StartCoroutine(ComponentLegend());
yield return new WaitForSeconds(7);
StartCoroutine(ComponentTheme());
yield return new WaitForSeconds(6);
StartCoroutine(ComponentDataZoom());
yield return new WaitForSeconds(10);
StartCoroutine(ComponentVisualMap());
yield return new WaitForSeconds(5);
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.3f);
}
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.4f);
}
chart.xAxis0.show = true;
chart.yAxis0.show = true;
chart.RefreshChart();
yield return new WaitForSeconds(2f);
}
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.4f);
}
chart.grid.backgroundColor = Color.clear;
chart.RefreshChart();
yield return new WaitForSeconds(2f);
}
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.5f);
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.4f);
}
chart.series.list[0].show = true;
chart.series.list[1].show = true;
chart.RefreshChart();
yield return new WaitForSeconds(2f);
}
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(1.5f);
for (int i = 0; i < 4; i++)
{
chart.legend.show = !chart.legend.show;
chart.RefreshChart();
yield return new WaitForSeconds(0.4f);
}
chart.legend.show = true;
chart.RefreshChart();
yield return new WaitForSeconds(1f);
chart.ClickLegendButton(0, "Line", false);
yield return new WaitForSeconds(0.5f);
chart.ClickLegendButton(0, "Line", true);
yield return new WaitForSeconds(1f);
chart.ClickLegendButton(1, "Bar", false);
yield return new WaitForSeconds(0.5f);
chart.ClickLegendButton(1, "Bar", true);
yield return new WaitForSeconds(1f);
}
IEnumerator ComponentTheme()
{
chart.title.subText = "Theme 主题:可从全局上配置图表的颜色、字体等效果,支持默认主题切换";
yield return new WaitForSeconds(1f);
chart.title.subText = "Theme 主题Light主题";
chart.UpdateTheme(Theme.Light);
yield return new WaitForSeconds(1.5f);
chart.title.subText = "Theme 主题Dark主题";
chart.UpdateTheme(Theme.Dark);
yield return new WaitForSeconds(1.5f);
chart.title.subText = "Theme 主题Default主题";
chart.UpdateTheme(Theme.Default);
yield return new WaitForSeconds(1.5f);
}
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.4f);
}
chart.dataZoom.supportSlider = true;
chart.RefreshChart();
yield return new WaitForSeconds(1f);
while (chart.dataZoom.start < 40)
{
chart.dataZoom.start += speed * Time.deltaTime * 0.5f;
chart.RefreshDataZoom();
chart.RefreshChart();
yield return null;
}
while (chart.dataZoom.end > 60)
{
chart.dataZoom.end -= speed * Time.deltaTime * 0.5f;
chart.RefreshDataZoom();
chart.RefreshChart();
yield return null;
}
while (chart.dataZoom.start > 0)
{
chart.dataZoom.start -= speed * Time.deltaTime * 0.5f;
chart.dataZoom.end -= speed * Time.deltaTime * 0.5f;
chart.RefreshDataZoom();
chart.RefreshChart();
yield return null;
}
while (chart.dataZoom.end < 100)
{
chart.dataZoom.start += speed * Time.deltaTime * 0.5f;
chart.dataZoom.end += speed * Time.deltaTime * 0.5f;
chart.RefreshDataZoom();
chart.RefreshChart();
yield return null;
}
while (chart.dataZoom.start > 0 || chart.dataZoom.end < 100)
{
chart.dataZoom.start -= speed * Time.deltaTime * 0.5f;
chart.dataZoom.end += speed * Time.deltaTime * 0.5f;
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;
}
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 647c504e24cac4f6c864cc855d463a99
guid: 060e74df53e174634b42ea5f3c852e94
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,270 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections;
using UnityEngine;
namespace XCharts
{
[DisallowMultipleComponent]
public class Demo10_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);
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: d85cdc6ed0e52439887e284e08a8456e
guid: ce2fe7c8c98c644b9a8585050ea1d963
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,68 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEngine;
namespace XCharts
{
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Demo11_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);
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: ee2ff4f81f1754f9e8e1df797df8c201
guid: dfc9b72c568f74d1dbf37310311aac8e
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,39 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEngine;
using UnityEngine.UI;
namespace XCharts
{
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Demo12_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);
}
};
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: fa5ea6ac5551141c78d4031bf2aa4140
guid: e27021e8c8377464a8b439cf785080ee
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,48 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEngine;
namespace XCharts
{
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Demo13_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);
for (int i = 0; i < 10; i++)
{
chart.AddXAxisData("x" + i);
chart.AddData(0, Random.Range(10, 20));
}
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: ac1b93a71505541fe9524658982e7051
guid: 75813849985304690b882bdd95364bae
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,167 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections;
using UnityEngine;
namespace XCharts
{
[DisallowMultipleComponent]
public class Demo20_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);
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 8831c4ea94fff40da9a552399d9aab0c
guid: 9b4ec86ec75e9428e878f99c14f7676f
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,206 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections;
using UnityEngine;
namespace XCharts
{
[DisallowMultipleComponent]
public class Demo30_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.pieRadius[0] = 0;
serie.pieRadius[1] = 110;
serie.pieCenter[0] = 0.5f;
serie.pieCenter[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.pieRadius[0] = 2f;
while (serie.pieRadius[0] < serie.pieRadius[1] * 0.7f)
{
serie.pieRadius[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.pieRadius[0] = 0;
serie1.pieRadius[1] = 2f;
serie1.pieCenter[0] = 0.5f;
serie1.pieCenter[1] = 0.4f;
chart.RefreshChart();
while (serie1.pieRadius[1] < serie.pieRadius[0] * 0.75f)
{
serie1.pieRadius[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.pieRadius = serie.pieRadius = 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.pieCenter[0] > 0.25f || serie1.pieCenter[0] < 0.7f)
{
if (serie.pieCenter[0] > 0.25f) serie.pieCenter[0] -= m_CenterSpeed * Time.deltaTime;
if (serie1.pieCenter[0] < 0.7f) serie1.pieCenter[0] += m_CenterSpeed * Time.deltaTime;
chart.RefreshChart();
yield return null;
}
yield return new WaitForSeconds(1);
while (serie.pieRadius[0] > 3f)
{
serie.pieRadius[0] -= m_RadiusSpeed * Time.deltaTime;
serie1.pieRadius[0] -= m_RadiusSpeed * Time.deltaTime;
chart.RefreshChart();
yield return null;
}
serie.pieRadius[0] = 0;
serie1.pieRadius[0] = 0;
serie.pieRoseType = RoseType.Area;
serie1.pieRoseType = RoseType.Radius;
chart.RefreshChart();
yield return new WaitForSeconds(1);
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: c9ee113d74ada442196e4e5587795c61
guid: ccf4c940af6c343e6abea9580e3915bb
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,38 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEngine;
namespace XCharts
{
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Demo50_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);
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: bb4941eb0bbd14736b16b39d256255bd
guid: 9f7e5ced8db104dcc8447f1e5ac903f4
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,104 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEngine;
namespace XCharts
{
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Demo60_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);
}
}
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 616b96a944de949af9aa66767a2fbff7
guid: 14e10f24be7ee4f609b36b904224382d
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,71 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System;
using UnityEngine;
namespace XCharts
{
[DisallowMultipleComponent]
[ExecuteInEditMode]
[RequireComponent(typeof(CoordinateChart))]
public class Demo_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();
}
}
}
}

View File

@@ -1,7 +1,5 @@
fileFormatVersion: 2
guid: 1c3d5e10d25691247b392b09eec051bf
timeCreated: 1557485360
licenseType: Free
guid: d7774c94c82584c0ca35e6f79d1fc29c
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,55 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEngine;
namespace XCharts
{
[DisallowMultipleComponent]
[ExecuteInEditMode]
[RequireComponent(typeof(CoordinateChart))]
public class Demo_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.series.list[0].maxCache = maxCacheDataNumber;
chart.xAxises[0].maxCache = 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"));
}
}
}
}
}

View File

@@ -1,7 +1,5 @@
fileFormatVersion: 2
guid: 0b7f7cfd79a632a46bdc2aac41160f37
timeCreated: 1557485007
licenseType: Free
guid: c777ceb41c4c743d2ba0ea573287be9e
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,46 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEngine;
namespace XCharts
{
[DisallowMultipleComponent]
[ExecuteInEditMode]
[RequireComponent(typeof(PieChart))]
public class Demo_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++;
}
}
}
}

View File

@@ -1,7 +1,5 @@
fileFormatVersion: 2
guid: 1f0aafe148c9e4f4dbf24fc6542722fa
timeCreated: 1557832345
licenseType: Free
guid: 8c85e69c8e4374481be85fda06a45209
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,41 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEngine;
using UnityEngine.UI;
namespace XCharts
{
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Demo_Test : MonoBehaviour
{
LineChart chart;
void Awake()
{
chart = gameObject.GetComponent<LineChart>();
if (chart == null)
{
chart = gameObject.AddComponent<LineChart>();
}
var buttom = transform.parent.gameObject.GetComponentInChildren<Button>();
buttom.onClick.AddListener(AddData);
}
void AddData()
{
chart.series.list[0].ClearData();
chart.series.list[1].ClearData();
for (int i = 0; i < 5; i++)
{
chart.AddData(0, Random.Range(20, 100));
chart.AddData(1, Random.Range(1, 10));
}
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: b3ddaf6c0b1ec40299c2906a968f185b
guid: e538728f2646249ae9c9206b8ceffe25
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,14 @@
{
"name": "XCharts.Demo.Runtime",
"references": [
"XCharts.Runtime"
],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 80ba6ed17de4740039736cf78bca3a17
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,189 +0,0 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using XCharts;
[System.Serializable]
public class ChartModule
{
[SerializeField] private string m_Name;
[SerializeField] private string m_Title;
[SerializeField] private bool m_Selected;
[SerializeField] private GameObject m_Panel;
public string name { get { return m_Name; } set { m_Name = value; } }
public string title { get { return m_Title; } set { m_Title = value; } }
public bool select { get { return m_Selected; } set { m_Selected = value; } }
public GameObject panel { get { return m_Panel; } set { m_Panel = value; } }
public Button button { get; set; }
}
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Demo : MonoBehaviour
{
[SerializeField] private Color m_ButtonNormalColor;
[SerializeField] private Color m_ButtonSelectedColor;
[SerializeField] private Color m_ButtonHighlightColor;
[SerializeField] private List<ChartModule> m_ChartModule;
private GameObject m_BtnClone;
private Theme m_SelectedTheme;
private int m_LastSelectedModuleIndex;
private Button m_DefaultThemeButton;
private Button m_LightThemeButton;
private Button m_DarkThemeButton;
private Text m_Title;
private ScrollRect m_ScrollRect;
private Mask m_Mark;
void Awake()
{
m_SelectedTheme = Theme.Default;
m_ButtonNormalColor = ChartHelper.GetColor("#293C55FF");
m_ButtonSelectedColor = ChartHelper.GetColor("#e43c59ff");
m_ButtonHighlightColor = ChartHelper.GetColor("#0E151FFF");
m_ScrollRect = transform.Find("chart_detail").GetComponent<ScrollRect>();
m_Mark = transform.Find("chart_detail/Viewport").GetComponent<Mask>();
m_Mark.enabled = true;
m_Title = transform.Find("chart_title/Text").GetComponent<Text>();
InitThemeButton();
InitModuleButton();
}
void Update()
{
#if UNITY_EDITOR
if (m_ChartModule.Count <= 0) return;
int selectedModuleIndex = -1;
for (int i = 0; i < m_ChartModule.Count; i++)
{
if (selectedModuleIndex >= 0 && i > selectedModuleIndex)
{
m_ChartModule[i].select = false;
}
else if (m_ChartModule[i].select)
{
selectedModuleIndex = i;
}
}
if (selectedModuleIndex < 0) selectedModuleIndex = 0;
if (selectedModuleIndex != m_LastSelectedModuleIndex)
{
InitModuleButton();
}
if (!Application.isPlaying) m_Mark.enabled = false;
#endif
}
void InitModuleButton()
{
var btnPanel = transform.Find("chart_list");
m_BtnClone = transform.Find("btn_clone").gameObject;
m_BtnClone.SetActive(false);
ChartHelper.DestoryAllChilds(btnPanel);
foreach (var module in m_ChartModule)
{
var btnName = "btn_" + module.name;
GameObject btn;
if (btnPanel.Find(btnName))
{
btn = btnPanel.Find(btnName).gameObject;
btn.SetActive(true);
}
else
{
btn = GameObject.Instantiate(m_BtnClone);
btn.SetActive(true);
btn.name = btnName;
btn.transform.SetParent(btnPanel);
btn.transform.localPosition = Vector3.zero;
}
btn.transform.localScale = Vector3.one;
module.button = btn.GetComponent<Button>();
module.button.GetComponentInChildren<Text>().text = module.name;
ChartHelper.AddEventListener(btn.gameObject, EventTriggerType.PointerDown, (data) =>
{
ClickModule(module);
});
}
for (int i = 0; i < m_ChartModule.Count; i++)
{
var module = m_ChartModule[i];
if (module.select)
{
ClickModule(module);
m_LastSelectedModuleIndex = i;
break;
}
}
}
void ClickModule(ChartModule selectedModule)
{
foreach (var module in m_ChartModule)
{
if (selectedModule != module)
{
var block = module.button.colors;
block.highlightedColor = m_ButtonHighlightColor;
block.normalColor = m_ButtonNormalColor;
module.button.colors = block;
module.panel.SetActive(false);
module.select = false;
}
else
{
var block = module.button.colors;
block.highlightedColor = m_ButtonSelectedColor;
block.normalColor = m_ButtonSelectedColor;
module.button.colors = block;
module.panel.SetActive(true);
module.select = true;
}
}
m_ScrollRect.content = selectedModule.panel.GetComponent<RectTransform>();
m_Title.text = string.IsNullOrEmpty(selectedModule.title) ?
selectedModule.name : selectedModule.title;
}
void InitThemeButton()
{
m_DefaultThemeButton = transform.Find("chart_theme/btn_default").GetComponent<Button>();
m_LightThemeButton = transform.Find("chart_theme/btn_light").GetComponent<Button>();
m_DarkThemeButton = transform.Find("chart_theme/btn_dark").GetComponent<Button>();
m_DefaultThemeButton.transform.Find("selected").gameObject.SetActive(m_SelectedTheme == Theme.Default);
m_LightThemeButton.transform.Find("selected").gameObject.SetActive(m_SelectedTheme == Theme.Light);
m_DarkThemeButton.transform.Find("selected").gameObject.SetActive(m_SelectedTheme == Theme.Dark);
m_DefaultThemeButton.onClick.AddListener(delegate () { SelecteTheme(Theme.Default); });
m_LightThemeButton.onClick.AddListener(delegate () { SelecteTheme(Theme.Light); });
m_DarkThemeButton.onClick.AddListener(delegate () { SelecteTheme(Theme.Dark); });
//SelecteTheme(Theme.Default);
}
void SelecteTheme(Theme theme)
{
m_SelectedTheme = theme;
m_DefaultThemeButton.transform.Find("selected").gameObject.SetActive(m_SelectedTheme == Theme.Default);
m_LightThemeButton.transform.Find("selected").gameObject.SetActive(m_SelectedTheme == Theme.Light);
m_DarkThemeButton.transform.Find("selected").gameObject.SetActive(m_SelectedTheme == Theme.Dark);
var charts = transform.GetComponentsInChildren<BaseChart>();
foreach (var chart in charts)
{
chart.UpdateTheme(theme);
}
}
}

View File

@@ -1,301 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XCharts;
[DisallowMultipleComponent]
public class Demo00_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(3);
StartCoroutine(ComponentAxis());
yield return new WaitForSeconds(3);
StartCoroutine(ComponentGrid());
yield return new WaitForSeconds(3);
StartCoroutine(ComponentSerie());
yield return new WaitForSeconds(5);
StartCoroutine(ComponentLegend());
yield return new WaitForSeconds(7);
StartCoroutine(ComponentTheme());
yield return new WaitForSeconds(6);
StartCoroutine(ComponentDataZoom());
yield return new WaitForSeconds(10);
StartCoroutine(ComponentVisualMap());
yield return new WaitForSeconds(5);
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.3f);
}
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.4f);
}
chart.xAxis0.show = true;
chart.yAxis0.show = true;
chart.RefreshChart();
yield return new WaitForSeconds(2f);
}
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.4f);
}
chart.grid.backgroundColor = Color.clear;
chart.RefreshChart();
yield return new WaitForSeconds(2f);
}
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.5f);
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.4f);
}
chart.series.list[0].show = true;
chart.series.list[1].show = true;
chart.RefreshChart();
yield return new WaitForSeconds(2f);
}
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(1.5f);
for (int i = 0; i < 4; i++)
{
chart.legend.show = !chart.legend.show;
chart.RefreshChart();
yield return new WaitForSeconds(0.4f);
}
chart.legend.show = true;
chart.RefreshChart();
yield return new WaitForSeconds(1f);
chart.ClickLegendButton(0, "Line", false);
yield return new WaitForSeconds(0.5f);
chart.ClickLegendButton(0, "Line", true);
yield return new WaitForSeconds(1f);
chart.ClickLegendButton(1, "Bar", false);
yield return new WaitForSeconds(0.5f);
chart.ClickLegendButton(1, "Bar", true);
yield return new WaitForSeconds(1f);
}
IEnumerator ComponentTheme()
{
chart.title.subText = "Theme 主题:可从全局上配置图表的颜色、字体等效果,支持默认主题切换";
yield return new WaitForSeconds(1f);
chart.title.subText = "Theme 主题Light主题";
chart.UpdateTheme(Theme.Light);
yield return new WaitForSeconds(1.5f);
chart.title.subText = "Theme 主题Dark主题";
chart.UpdateTheme(Theme.Dark);
yield return new WaitForSeconds(1.5f);
chart.title.subText = "Theme 主题Default主题";
chart.UpdateTheme(Theme.Default);
yield return new WaitForSeconds(1.5f);
}
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.4f);
}
chart.dataZoom.supportSlider = true;
chart.RefreshChart();
yield return new WaitForSeconds(1f);
while (chart.dataZoom.start < 40)
{
chart.dataZoom.start += speed * Time.deltaTime * 0.5f;
chart.RefreshDataZoom();
chart.RefreshChart();
yield return null;
}
while (chart.dataZoom.end > 60)
{
chart.dataZoom.end -= speed * Time.deltaTime * 0.5f;
chart.RefreshDataZoom();
chart.RefreshChart();
yield return null;
}
while (chart.dataZoom.start > 0)
{
chart.dataZoom.start -= speed * Time.deltaTime * 0.5f;
chart.dataZoom.end -= speed * Time.deltaTime * 0.5f;
chart.RefreshDataZoom();
chart.RefreshChart();
yield return null;
}
while (chart.dataZoom.end < 100)
{
chart.dataZoom.start += speed * Time.deltaTime * 0.5f;
chart.dataZoom.end += speed * Time.deltaTime * 0.5f;
chart.RefreshDataZoom();
chart.RefreshChart();
yield return null;
}
while (chart.dataZoom.start > 0 || chart.dataZoom.end < 100)
{
chart.dataZoom.start -= speed * Time.deltaTime * 0.5f;
chart.dataZoom.end += speed * Time.deltaTime * 0.5f;
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;
}
}
}

View File

@@ -1,264 +0,0 @@
using System;
using System.Collections;
using UnityEngine;
using XCharts;
[DisallowMultipleComponent]
public class Demo10_LineChart : MonoBehaviour
{
private LineChart chart;
private Serie serie;
private float m_RadiusSpeed = 100f;
private float m_CenterSpeed = 1f;
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);
}
}

View File

@@ -1,59 +0,0 @@
using UnityEngine;
using XCharts;
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Demo11_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);
}
}

View File

@@ -1,29 +0,0 @@
using UnityEngine;
using UnityEngine.UI;
using XCharts;
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Demo12_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);
}
};
}
}

View File

@@ -1,39 +0,0 @@
using UnityEngine;
using XCharts;
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Demo13_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);
for (int i = 0; i < 10; i++)
{
chart.AddXAxisData("x" + i);
chart.AddData(0, Random.Range(10, 20));
}
}
}

View File

@@ -1,163 +0,0 @@
using System;
using System.Collections;
using UnityEngine;
using XCharts;
[DisallowMultipleComponent]
public class Demo20_BarChart : MonoBehaviour
{
private BarChart chart;
private Serie serie, serie2;
private float m_RadiusSpeed = 100f;
private float m_CenterSpeed = 1f;
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);
}
}

View File

@@ -1,197 +0,0 @@
using System.Collections;
using UnityEngine;
using XCharts;
[DisallowMultipleComponent]
public class Demo30_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.pieRadius[0] = 0;
serie.pieRadius[1] = 110;
serie.pieCenter[0] = 0.5f;
serie.pieCenter[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.pieRadius[0] = 2f;
while (serie.pieRadius[0] < serie.pieRadius[1] * 0.7f)
{
serie.pieRadius[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.pieRadius[0] = 0;
serie1.pieRadius[1] = 2f;
serie1.pieCenter[0] = 0.5f;
serie1.pieCenter[1] = 0.4f;
chart.RefreshChart();
while (serie1.pieRadius[1] < serie.pieRadius[0] * 0.75f)
{
serie1.pieRadius[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.pieRadius = serie.pieRadius = 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.pieCenter[0] > 0.25f || serie1.pieCenter[0] < 0.7f)
{
if (serie.pieCenter[0] > 0.25f) serie.pieCenter[0] -= m_CenterSpeed * Time.deltaTime;
if (serie1.pieCenter[0] < 0.7f) serie1.pieCenter[0] += m_CenterSpeed * Time.deltaTime;
chart.RefreshChart();
yield return null;
}
yield return new WaitForSeconds(1);
while (serie.pieRadius[0] > 3f)
{
serie.pieRadius[0] -= m_RadiusSpeed * Time.deltaTime;
serie1.pieRadius[0] -= m_RadiusSpeed * Time.deltaTime;
chart.RefreshChart();
yield return null;
}
serie.pieRadius[0] = 0;
serie1.pieRadius[0] = 0;
serie.pieRoseType = RoseType.Area;
serie1.pieRoseType = RoseType.Radius;
chart.RefreshChart();
yield return new WaitForSeconds(1);
}
}

View File

@@ -1,29 +0,0 @@
using System.Collections.Generic;
using UnityEngine;
using XCharts;
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Demo50_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);
}
}

View File

@@ -1,95 +0,0 @@
using System.Collections.Generic;
using UnityEngine;
using XCharts;
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Demo60_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);
}
}
}
}

View File

@@ -1,62 +0,0 @@
using System;
using UnityEngine;
using XCharts;
[DisallowMultipleComponent]
[ExecuteInEditMode]
[RequireComponent(typeof(CoordinateChart))]
public class Demo_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();
}
}
}

View File

@@ -1,46 +0,0 @@
using UnityEngine;
using XCharts;
[DisallowMultipleComponent]
[ExecuteInEditMode]
[RequireComponent(typeof(CoordinateChart))]
public class Demo_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.series.list[0].maxCache = maxCacheDataNumber;
chart.xAxises[0].maxCache = 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"));
}
}
}
}

View File

@@ -1,37 +0,0 @@
using UnityEngine;
using XCharts;
[DisallowMultipleComponent]
[ExecuteInEditMode]
[RequireComponent(typeof(PieChart))]
public class Demo_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++;
}
}
}

View File

@@ -1,32 +0,0 @@
using UnityEngine;
using UnityEngine.UI;
using XCharts;
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Demo_Test : MonoBehaviour
{
LineChart chart;
void Awake()
{
chart = gameObject.GetComponent<LineChart>();
if (chart == null)
{
chart = gameObject.AddComponent<LineChart>();
}
var buttom = transform.parent.gameObject.GetComponentInChildren<Button>();
buttom.onClick.AddListener(AddData);
}
void AddData()
{
chart.series.list[0].ClearData();
chart.series.list[1].ClearData();
for (int i = 0; i < 5; i++)
{
chart.AddData(0, Random.Range(20, 100));
chart.AddData(1, Random.Range(1, 10));
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,11 @@
using UnityEditor;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
namespace XCharts
{

View File

@@ -1,5 +1,11 @@
using UnityEditor;
using UnityEngine;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
namespace XCharts
{
@@ -26,7 +32,6 @@ namespace XCharts
protected float m_DefaultLabelWidth;
protected float m_DefaultFieldWidth;
private int m_SeriesSize;
private bool m_BaseModuleToggle = false;
protected virtual void OnEnable()
{

View File

@@ -1,5 +1,11 @@
using UnityEditor;
using UnityEngine;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
namespace XCharts
{

View File

@@ -1,4 +1,11 @@
using UnityEditor;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
namespace XCharts
{

View File

@@ -1,4 +1,11 @@
using UnityEditor;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
namespace XCharts
{

View File

@@ -1,4 +1,11 @@
using UnityEditor;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
namespace XCharts
{

View File

@@ -1,4 +1,11 @@
using System.Collections.Generic;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

View File

@@ -1,4 +1,11 @@
using System.Collections.Generic;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

View File

@@ -1,4 +1,11 @@
using System.Collections.Generic;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

View File

@@ -1,4 +1,11 @@
using System.Collections.Generic;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

View File

@@ -1,4 +1,11 @@
using System.Collections.Generic;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

View File

@@ -1,4 +1,11 @@
using System.Collections.Generic;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

View File

@@ -1,4 +1,11 @@
using System.Collections.Generic;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

View File

@@ -1,4 +1,11 @@
using UnityEditor;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts

View File

@@ -1,4 +1,11 @@
using UnityEditor;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts

View File

@@ -1,4 +1,11 @@
using System.Collections.Generic;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

View File

@@ -1,4 +1,11 @@
using UnityEditor;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts

View File

@@ -1,4 +1,11 @@
using System.Collections.Generic;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

View File

@@ -1,4 +1,11 @@
using UnityEditor;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts

View File

@@ -1,4 +1,11 @@
using System.Collections.Generic;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

View File

@@ -1,4 +1,11 @@
using System.Collections.Generic;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

View File

@@ -1,4 +1,11 @@
using UnityEditor;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts

View File

@@ -1,4 +1,11 @@
using System.Collections.Generic;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

View File

@@ -1,4 +1,11 @@
using System.Collections.Generic;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

View File

@@ -1,4 +1,11 @@
using System.Collections.Generic;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
@@ -42,7 +49,6 @@ namespace XCharts
SerializedProperty m_AreaStyle = prop.FindPropertyRelative("m_AreaStyle");
SerializedProperty m_Symbol = prop.FindPropertyRelative("m_Symbol");
SerializedProperty m_RoseType = prop.FindPropertyRelative("m_RoseType");
SerializedProperty m_ClickOffset = prop.FindPropertyRelative("m_ClickOffset");
SerializedProperty m_Space = prop.FindPropertyRelative("m_Space");
SerializedProperty m_Center = prop.FindPropertyRelative("m_Center");
SerializedProperty m_Radius = prop.FindPropertyRelative("m_Radius");

View File

@@ -1,4 +1,11 @@
using System.Collections.Generic;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

View File

@@ -1,4 +1,11 @@
using System.Collections.Generic;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

View File

@@ -1,4 +1,11 @@
using UnityEditor;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts

View File

@@ -1,4 +1,11 @@
using UnityEditor;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts

View File

@@ -1,4 +1,11 @@
using UnityEditor;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;

View File

@@ -1,4 +1,11 @@
using UnityEditor;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts

View File

@@ -1,4 +1,11 @@
using UnityEditor;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts

View File

@@ -1,4 +1,11 @@
using UnityEditor;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts
@@ -24,7 +31,7 @@ namespace XCharts
SerializedProperty m_Max = prop.FindPropertyRelative("m_Max");
SerializedProperty m_Range = prop.FindPropertyRelative("m_Range");
SerializedProperty m_Text = prop.FindPropertyRelative("m_Text");
SerializedProperty m_TextGap = prop.FindPropertyRelative("m_TextGap");
// SerializedProperty m_TextGap = prop.FindPropertyRelative("m_TextGap");
SerializedProperty m_SplitNumber = prop.FindPropertyRelative("m_SplitNumber");
SerializedProperty m_Calculable = prop.FindPropertyRelative("m_Calculable");
SerializedProperty m_ItemWidth = prop.FindPropertyRelative("m_ItemWidth");
@@ -35,7 +42,7 @@ namespace XCharts
SerializedProperty m_Orient = prop.FindPropertyRelative("m_Orient");
SerializedProperty m_Location = prop.FindPropertyRelative("m_Location");
SerializedProperty m_InRange = prop.FindPropertyRelative("m_InRange");
SerializedProperty m_OutOfRange = prop.FindPropertyRelative("m_OutOfRange");
// SerializedProperty m_OutOfRange = prop.FindPropertyRelative("m_OutOfRange");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_VisualMapModuleToggle, "Visual Map", m_Enable);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;

View File

@@ -1,6 +1,11 @@
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
namespace XCharts
{

View File

@@ -1,6 +1,11 @@
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
namespace XCharts
{

View File

@@ -1,4 +1,11 @@
using UnityEditor;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
namespace XCharts
{

View File

@@ -1,4 +1,11 @@
using UnityEditor;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
namespace XCharts
{

View File

@@ -0,0 +1,16 @@
{
"name": "XCharts.Editor",
"references": [
"XCharts.Runtime"
],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9639efc34ea6e4056830a23233b99b16
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +1,6 @@
fileFormatVersion: 2
guid: a3f125a3accd30240b3ca251090f11b4
guid: 986c44b52f57345d1a9b001ee7f99990
folderAsset: yes
timeCreated: 1554216875
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:

View File

@@ -1,4 +1,11 @@
using UnityEngine;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEngine;
using System.Collections.Generic;
using System;
using UnityEngine.UI;

View File

@@ -1,4 +1,11 @@
using System;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System;
using System.Collections.Generic;
using UnityEngine;

View File

@@ -1,4 +1,11 @@
using UnityEngine;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEngine;
namespace XCharts
{

Some files were not shown because too many files have changed in this diff Show More