mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-16 05:10:12 +00:00
[feature][datazoom] 增加DataZoom的MarqueeStyle支持框选区域
This commit is contained in:
50
Examples/Example04_DataZoom.cs
Normal file
50
Examples/Example04_DataZoom.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example04_DataZoom : MonoBehaviour
|
||||
{
|
||||
BaseChart chart;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<BaseChart>();
|
||||
if (chart == null) return;
|
||||
var dataZoom = chart.GetChartComponent<DataZoom>();
|
||||
if (dataZoom == null) return;
|
||||
dataZoom.marqueeStyle.onStart = OnMarqueeStart;
|
||||
dataZoom.marqueeStyle.onEnd = OnMarqueeEnd;
|
||||
dataZoom.marqueeStyle.onGoing = OnMarquee;
|
||||
}
|
||||
|
||||
void OnMarqueeStart(DataZoom dataZoom)
|
||||
{
|
||||
//Debug.Log("OnMarqueeStart:" + dataZoom);
|
||||
}
|
||||
|
||||
void OnMarquee(DataZoom dataZoom)
|
||||
{
|
||||
//Debug.Log("OnMarquee:" + dataZoom);
|
||||
}
|
||||
|
||||
void OnMarqueeEnd(DataZoom dataZoom)
|
||||
{
|
||||
//Debug.Log("OnMarqueeEnd:" + dataZoom);
|
||||
var serie = chart.GetSerie(0);
|
||||
foreach (var serieData in serie.data)
|
||||
{
|
||||
if (dataZoom.IsInMarqueeArea(serieData))
|
||||
{
|
||||
serieData.GetOrAddComponent<ItemStyle>().color = Color.red;
|
||||
}
|
||||
else
|
||||
{
|
||||
serieData.GetOrAddComponent<ItemStyle>().color = Color.clear;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user