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()
|
|
|
|
|
{
|
2023-02-12 21:22:53 +08:00
|
|
|
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>();
|
|
|
|
|
|
2023-02-12 21:22:53 +08:00
|
|
|
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;
|
2023-02-12 21:22:53 +08:00
|
|
|
var itemStyle = serieData.EnsureComponent<ItemStyle>();
|
2022-03-20 18:52:50 +08:00
|
|
|
itemStyle.color = Color.blue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|