Fixed bug where GaugeChart does not refresh label when changing splitNumber #167

This commit is contained in:
monitor1394
2021-09-06 21:33:44 +08:00
parent 9167196e25
commit 7f4154b1db
3 changed files with 21 additions and 0 deletions

View File

@@ -40,6 +40,8 @@
## master
* (2021.09.06) Fixed bug where `GaugeChart` changing `splitNumber` with code does not refresh `label` #167
## v2.4.0
### Main points

View File

@@ -40,6 +40,8 @@
## master
* (2021.09.06) 修复`GaugeChart`用代码改变`splitNumber`不会刷新`label`的问题 #167
## v2.4.0
### 版本要点

View File

@@ -9,6 +9,7 @@ using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using XUGL;
using System.Collections.Generic;
namespace XCharts
{
@@ -20,6 +21,7 @@ namespace XCharts
private static readonly string s_AxisLabelObjectName = "axis_label";
private bool m_UpdateTitleText = false;
private bool m_UpdateLabelText = false;
private Dictionary<int, int> m_LastSplitNumber = new Dictionary<int, int>();
public DrawSerieGauge(BaseChart chart)
{
@@ -61,6 +63,21 @@ namespace XCharts
}
}
}
foreach (var serie in chart.series.list)
{
if (serie.type == SerieType.Gauge)
{
if (!m_LastSplitNumber.TryGetValue(serie.index, out var lastSplitNumber))
{
m_LastSplitNumber[serie.index] = lastSplitNumber;
}
else if (serie.splitNumber != lastSplitNumber)
{
m_LastSplitNumber[serie.index] = serie.splitNumber;
InitAxisLabel();
}
}
}
}
public void DrawBase(VertexHelper vh)