2021-12-31 13:00:17 +08:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
2022-02-19 22:37:57 +08:00
|
|
|
namespace XCharts.Runtime
|
2021-12-31 13:00:17 +08:00
|
|
|
{
|
|
|
|
|
[System.Serializable]
|
|
|
|
|
[SerieHandler(typeof(SimplifiedCandlestickHandler), true)]
|
|
|
|
|
[DefaultAnimation(AnimationType.LeftToRight)]
|
|
|
|
|
[SerieExtraComponent()]
|
2022-05-22 22:17:38 +08:00
|
|
|
[SerieDataExtraComponent()]
|
|
|
|
|
[SerieDataExtraField()]
|
2021-12-31 13:00:17 +08:00
|
|
|
public class SimplifiedCandlestick : Serie, INeedSerieContainer, ISimplifiedSerie
|
|
|
|
|
{
|
|
|
|
|
public int containerIndex { get; internal set; }
|
|
|
|
|
public int containterInstanceId { get; internal set; }
|
|
|
|
|
|
2022-01-26 20:47:14 +08:00
|
|
|
public static Serie AddDefaultSerie(BaseChart chart, string serieName)
|
2021-12-31 13:00:17 +08:00
|
|
|
{
|
|
|
|
|
var serie = chart.AddSerie<SimplifiedCandlestick>(serieName);
|
|
|
|
|
|
|
|
|
|
var lastValue = 50d;
|
|
|
|
|
for (int i = 0; i < 50; i++)
|
|
|
|
|
{
|
|
|
|
|
lastValue += UnityEngine.Random.Range(-10, 20);
|
|
|
|
|
var open = lastValue + Random.Range(-10, 5);
|
|
|
|
|
var close = lastValue + Random.Range(-5, 10);
|
|
|
|
|
var lowest = lastValue + Random.Range(-15, -10);
|
|
|
|
|
var heighest = lastValue + Random.Range(10, 20);
|
2022-08-26 23:17:54 +08:00
|
|
|
chart.AddData(serie.index, i, open, close, lowest, heighest);
|
2021-12-31 13:00:17 +08:00
|
|
|
}
|
2022-01-26 20:47:14 +08:00
|
|
|
return serie;
|
2021-12-31 13:00:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static SimplifiedCandlestick CovertSerie(Serie serie)
|
|
|
|
|
{
|
|
|
|
|
var newSerie = serie.Clone<SimplifiedCandlestick>();
|
|
|
|
|
return newSerie;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|