Files
XCharts/Examples/Example_Component.cs

35 lines
977 B
C#
Raw Normal View History

2022-03-20 18:52:50 +08:00
using UnityEngine;
using XCharts.Runtime;
namespace XCharts.Example
{
[DisallowMultipleComponent]
//[ExecuteInEditMode]
public class Example_Component : MonoBehaviour
{
BaseChart chart;
void Awake()
{
chart = gameObject.GetComponent<BaseChart>();
}
void ModifyComponent()
{
var title = chart.EnsureChartComponent<Title>();
2022-03-20 18:52:50 +08:00
title.text = "Simple LineChart";
title.subText = "normal line";
var serie1 = chart.AddSerie<Line>();
//var serie2 = chart.GetSerie<Line>();
serie1.EnsureComponent<AreaStyle>();
var label = serie1.EnsureComponent<LabelStyle>();
2022-03-20 18:52:50 +08:00
label.offset = new Vector3(0, 20, 0);
var serieData = chart.AddData(0, 20);
2022-05-22 22:17:38 +08:00
serieData.radius = 10;
var itemStyle = serieData.EnsureComponent<ItemStyle>();
2022-03-20 18:52:50 +08:00
itemStyle.color = Color.blue;
}
}
}