mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-17 05:50:09 +00:00
同步更新部分示例代码对按键的读取逻辑
简化了部分协同程序的使用逻辑
This commit is contained in:
@@ -11,48 +11,38 @@ namespace XCharts.Example
|
||||
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();
|
||||
while (true)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator AddSimpleBar()
|
||||
{
|
||||
chart = gameObject.GetComponent<BarChart>();
|
||||
if (chart == null) chart = gameObject.AddComponent<BarChart>();
|
||||
chart.GetChartComponent<Title>().text = "BarChart - 柱状图";
|
||||
chart.GetChartComponent<Title>().subText = "普通柱状图";
|
||||
chart.EnsureChartComponent<Title>().text = "BarChart - 柱状图";
|
||||
chart.EnsureChartComponent<Title>().subText = "普通柱状图";
|
||||
|
||||
var yAxis = chart.GetChartComponent<YAxis>();
|
||||
var yAxis = chart.EnsureChartComponent<YAxis>();
|
||||
yAxis.minMaxType = Axis.AxisMinMaxType.Default;
|
||||
|
||||
chart.RemoveData();
|
||||
@@ -68,7 +58,7 @@ namespace XCharts.Example
|
||||
|
||||
IEnumerator BarMutilSerie()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "多条柱状图";
|
||||
chart.EnsureChartComponent<Title>().subText = "多条柱状图";
|
||||
|
||||
float now = serie.barWidth - 0.35f;
|
||||
while (serie.barWidth > 0.35f)
|
||||
@@ -90,7 +80,7 @@ namespace XCharts.Example
|
||||
|
||||
IEnumerator ZebraBar()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "斑马柱状图";
|
||||
chart.EnsureChartComponent<Title>().subText = "斑马柱状图";
|
||||
serie.barType = BarType.Zebra;
|
||||
serie2.barType = BarType.Zebra;
|
||||
serie.barZebraWidth = serie.barZebraGap = 4;
|
||||
@@ -101,7 +91,7 @@ namespace XCharts.Example
|
||||
|
||||
IEnumerator SameBarAndNotStack()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "非堆叠同柱";
|
||||
chart.EnsureChartComponent<Title>().subText = "非堆叠同柱";
|
||||
serie.barType = serie2.barType = BarType.Normal;
|
||||
serie.stack = "";
|
||||
serie2.stack = "";
|
||||
@@ -112,7 +102,7 @@ namespace XCharts.Example
|
||||
|
||||
IEnumerator SameBarAndStack()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "堆叠同柱";
|
||||
chart.EnsureChartComponent<Title>().subText = "堆叠同柱";
|
||||
serie.barType = serie2.barType = BarType.Normal;
|
||||
serie.stack = "samename";
|
||||
serie2.stack = "samename";
|
||||
@@ -132,19 +122,25 @@ namespace XCharts.Example
|
||||
|
||||
IEnumerator SameBarAndPercentStack()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "百分比堆叠同柱";
|
||||
chart.EnsureChartComponent<Title>().subText = "百分比堆叠同柱";
|
||||
serie.barType = serie2.barType = BarType.Normal;
|
||||
serie.stack = "samename";
|
||||
serie2.stack = "samename";
|
||||
|
||||
serie.barPercentStack = true;
|
||||
|
||||
serie.AddExtraComponent<LabelStyle>();
|
||||
if (null == serie.label)
|
||||
{
|
||||
serie.AddExtraComponent<LabelStyle>();
|
||||
}
|
||||
serie.label.show = true;
|
||||
serie.label.position = LabelStyle.Position.Center;
|
||||
serie.label.textStyle.color = Color.white;
|
||||
serie.label.formatter = "{d:f0}%";
|
||||
|
||||
if (null == serie2.label)
|
||||
{
|
||||
serie2.AddExtraComponent<LabelStyle>();
|
||||
}
|
||||
serie2.label.show = true;
|
||||
serie2.label.position = LabelStyle.Position.Center;
|
||||
serie2.label.textStyle.color = Color.white;
|
||||
|
||||
Reference in New Issue
Block a user