mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-18 14:30:10 +00:00
增加Serie部分配置修改时的自刷新
This commit is contained in:
28
Examples/Example_TestSerie.cs
Normal file
28
Examples/Example_TestSerie.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
#if INPUT_SYSTEM_ENABLED
|
||||
using Input = XCharts.Runtime.InputHelper;
|
||||
#endif
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class Example_TestSerie : MonoBehaviour
|
||||
{
|
||||
public int maxCache = 100;
|
||||
BaseChart chart;
|
||||
int timestamp;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<BaseChart>();
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.R))
|
||||
{
|
||||
chart.GetSerie(0).radius[1] = Random.Range(50, 80);
|
||||
chart.SetAllDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Examples/Example_TestSerie.cs.meta
Normal file
11
Examples/Example_TestSerie.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf5f1bfed3ae24fcf871087abf8bdb59
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -176,7 +176,7 @@ namespace XCharts.Runtime
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
foreach (var handler in m_SerieHandlers) handler.OnValidate();
|
||||
foreach (var handler in m_SerieHandlers) handler.ForceUpdateSerieContext();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1041,6 +1041,12 @@ namespace XCharts.Runtime
|
||||
titleDirty = true;
|
||||
}
|
||||
|
||||
public override void SetVerticesDirty()
|
||||
{
|
||||
base.SetVerticesDirty();
|
||||
handler.ForceUpdateSerieContext();
|
||||
}
|
||||
|
||||
private bool AnySerieDataVerticesDirty()
|
||||
{
|
||||
if (IsPerformanceMode())
|
||||
|
||||
@@ -29,9 +29,9 @@ namespace XCharts.Runtime
|
||||
public virtual void OnBeginDrag(PointerEventData eventData) { }
|
||||
public virtual void OnEndDrag(PointerEventData eventData) { }
|
||||
public virtual void OnScroll(PointerEventData eventData) { }
|
||||
public virtual void OnValidate() { }
|
||||
public virtual void RefreshLabelNextFrame() { }
|
||||
public virtual void RefreshLabelInternal() { }
|
||||
public virtual void ForceUpdateSerieContext() { }
|
||||
public virtual void UpdateSerieContext() { }
|
||||
public virtual void UpdateTooltipSerieParams(int dataIndex, bool showCategory,
|
||||
string category, string marker,
|
||||
@@ -64,6 +64,9 @@ namespace XCharts.Runtime
|
||||
protected int m_LegendEnterIndex;
|
||||
protected ChartLabel m_EndLabel;
|
||||
|
||||
private float[] m_LastRadius = new float[2] { 0, 0 };
|
||||
private float[] m_LastCenter = new float[2] { 0, 0 };
|
||||
|
||||
public T serie { get; internal set; }
|
||||
public GameObject labelObject { get { return m_SerieLabelRoot; } }
|
||||
|
||||
@@ -75,13 +78,9 @@ namespace XCharts.Runtime
|
||||
AnimationStyleHelper.UpdateSerieAnimation(serie);
|
||||
}
|
||||
|
||||
public override void OnValidate()
|
||||
{
|
||||
m_ForceUpdateSerieContext = true;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
CheckConfigurationChanged();
|
||||
if (m_NeedInitComponent)
|
||||
{
|
||||
m_NeedInitComponent = false;
|
||||
@@ -136,6 +135,27 @@ namespace XCharts.Runtime
|
||||
UpdateSerieContextInternal();
|
||||
}
|
||||
|
||||
public override void ForceUpdateSerieContext()
|
||||
{
|
||||
m_ForceUpdateSerieContext = true;
|
||||
}
|
||||
|
||||
private void CheckConfigurationChanged()
|
||||
{
|
||||
if (m_LastRadius[0] != serie.radius[0] || m_LastRadius[1] != serie.radius[1])
|
||||
{
|
||||
m_LastRadius[0] = serie.radius[0];
|
||||
m_LastRadius[1] = serie.radius[1];
|
||||
serie.SetVerticesDirty();
|
||||
}
|
||||
if (m_LastCenter[0] != serie.center[0] || m_LastCenter[1] != serie.center[1])
|
||||
{
|
||||
m_LastCenter[0] = serie.center[0];
|
||||
m_LastCenter[1] = serie.center[1];
|
||||
serie.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSerieContextInternal()
|
||||
{
|
||||
var lastEnter = serie.context.pointerEnter;
|
||||
|
||||
Reference in New Issue
Block a user