1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- 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;
- }
- }
- }
- }
- }
|