mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-27 03:10:11 +00:00
修复坐标轴刻度刷新会闪屏的问题
This commit is contained in:
@@ -33,6 +33,7 @@ namespace XCharts
|
|||||||
protected override void DrawChart(VertexHelper vh)
|
protected override void DrawChart(VertexHelper vh)
|
||||||
{
|
{
|
||||||
base.DrawChart(vh);
|
base.DrawChart(vh);
|
||||||
|
if (!m_CheckMinMaxValue) return;
|
||||||
bool yCategory = m_YAxises[0].IsCategory() || m_YAxises[1].IsCategory();
|
bool yCategory = m_YAxises[0].IsCategory() || m_YAxises[1].IsCategory();
|
||||||
m_Series.GetStackSeries(ref m_StackSeries);
|
m_Series.GetStackSeries(ref m_StackSeries);
|
||||||
int seriesCount = m_StackSeries.Count;
|
int seriesCount = m_StackSeries.Count;
|
||||||
|
|||||||
@@ -638,7 +638,7 @@ namespace XCharts
|
|||||||
if (max == int.MinValue && min == int.MaxValue)
|
if (max == int.MinValue && min == int.MaxValue)
|
||||||
{
|
{
|
||||||
minVaule = 0;
|
minVaule = 0;
|
||||||
maxValue = 90;
|
maxValue = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,10 +27,12 @@ namespace XCharts
|
|||||||
private Grid m_CheckCoordinate = Grid.defaultGrid;
|
private Grid m_CheckCoordinate = Grid.defaultGrid;
|
||||||
private bool m_XAxisChanged;
|
private bool m_XAxisChanged;
|
||||||
private bool m_YAxisChanged;
|
private bool m_YAxisChanged;
|
||||||
|
protected bool m_CheckMinMaxValue;
|
||||||
|
|
||||||
protected override void Awake()
|
protected override void Awake()
|
||||||
{
|
{
|
||||||
base.Awake();
|
base.Awake();
|
||||||
|
m_CheckMinMaxValue = false;
|
||||||
InitDefaultAxises();
|
InitDefaultAxises();
|
||||||
CheckMinMaxValue();
|
CheckMinMaxValue();
|
||||||
InitDataZoom();
|
InitDataZoom();
|
||||||
@@ -343,6 +345,8 @@ namespace XCharts
|
|||||||
m_YAxises.Add(axis1);
|
m_YAxises.Add(axis1);
|
||||||
m_YAxises.Add(axis2);
|
m_YAxises.Add(axis2);
|
||||||
}
|
}
|
||||||
|
foreach (var axis in m_XAxises) axis.minValue = axis.maxValue = 0;
|
||||||
|
foreach (var axis in m_YAxises) axis.minValue = axis.maxValue = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitAxisY()
|
private void InitAxisY()
|
||||||
@@ -355,8 +359,6 @@ namespace XCharts
|
|||||||
|
|
||||||
private void InitYAxis(int yAxisIndex, YAxis yAxis)
|
private void InitYAxis(int yAxisIndex, YAxis yAxis)
|
||||||
{
|
{
|
||||||
yAxis.minValue = 0;
|
|
||||||
yAxis.maxValue = 100;
|
|
||||||
yAxis.axisLabelTextList.Clear();
|
yAxis.axisLabelTextList.Clear();
|
||||||
|
|
||||||
string objName = yAxisIndex > 0 ? s_DefaultAxisY + "2" : s_DefaultAxisY;
|
string objName = yAxisIndex > 0 ? s_DefaultAxisY + "2" : s_DefaultAxisY;
|
||||||
@@ -366,7 +368,7 @@ namespace XCharts
|
|||||||
axisObj.transform.localPosition = Vector3.zero;
|
axisObj.transform.localPosition = Vector3.zero;
|
||||||
axisObj.SetActive(yAxis.show && yAxis.axisLabel.show);
|
axisObj.SetActive(yAxis.show && yAxis.axisLabel.show);
|
||||||
ChartHelper.HideAllObject(axisObj);
|
ChartHelper.HideAllObject(axisObj);
|
||||||
|
if (yAxis.minValue == 0 && yAxis.maxValue == 0) return;
|
||||||
var labelColor = yAxis.axisLabel.color == Color.clear ?
|
var labelColor = yAxis.axisLabel.color == Color.clear ?
|
||||||
(Color)m_ThemeInfo.axisTextColor :
|
(Color)m_ThemeInfo.axisTextColor :
|
||||||
yAxis.axisLabel.color;
|
yAxis.axisLabel.color;
|
||||||
@@ -462,8 +464,6 @@ namespace XCharts
|
|||||||
|
|
||||||
private void InitXAxis(int xAxisIndex, XAxis xAxis)
|
private void InitXAxis(int xAxisIndex, XAxis xAxis)
|
||||||
{
|
{
|
||||||
xAxis.minValue = 0;
|
|
||||||
xAxis.maxValue = 100;
|
|
||||||
xAxis.axisLabelTextList.Clear();
|
xAxis.axisLabelTextList.Clear();
|
||||||
|
|
||||||
string objName = xAxisIndex > 0 ? ChartHelper.Cancat(s_DefaultAxisX, 2) : s_DefaultAxisX;
|
string objName = xAxisIndex > 0 ? ChartHelper.Cancat(s_DefaultAxisX, 2) : s_DefaultAxisX;
|
||||||
@@ -472,6 +472,7 @@ namespace XCharts
|
|||||||
axisObj.transform.localPosition = Vector3.zero;
|
axisObj.transform.localPosition = Vector3.zero;
|
||||||
axisObj.SetActive(xAxis.show && xAxis.axisLabel.show);
|
axisObj.SetActive(xAxis.show && xAxis.axisLabel.show);
|
||||||
ChartHelper.HideAllObject(axisObj);
|
ChartHelper.HideAllObject(axisObj);
|
||||||
|
if (xAxis.minValue == 0 && xAxis.maxValue == 0) return;
|
||||||
var labelColor = xAxis.axisLabel.color == Color.clear ?
|
var labelColor = xAxis.axisLabel.color == Color.clear ?
|
||||||
(Color)m_ThemeInfo.axisTextColor :
|
(Color)m_ThemeInfo.axisTextColor :
|
||||||
xAxis.axisLabel.color;
|
xAxis.axisLabel.color;
|
||||||
@@ -666,7 +667,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (axis.IsCategory() || !axis.show) return;
|
if (axis.IsCategory() || !axis.show) return;
|
||||||
int tempMinValue = 0;
|
int tempMinValue = 0;
|
||||||
int tempMaxValue = 100;
|
int tempMaxValue = 0;
|
||||||
if (m_XAxises[axisIndex].IsValue() && m_YAxises[axisIndex].IsValue())
|
if (m_XAxises[axisIndex].IsValue() && m_YAxises[axisIndex].IsValue())
|
||||||
{
|
{
|
||||||
if (axis is XAxis)
|
if (axis is XAxis)
|
||||||
@@ -685,6 +686,8 @@ namespace XCharts
|
|||||||
axis.AdjustMinMaxValue(ref tempMinValue, ref tempMaxValue);
|
axis.AdjustMinMaxValue(ref tempMinValue, ref tempMaxValue);
|
||||||
if (tempMinValue != axis.minValue || tempMaxValue != axis.maxValue)
|
if (tempMinValue != axis.minValue || tempMaxValue != axis.maxValue)
|
||||||
{
|
{
|
||||||
|
m_CheckMinMaxValue = true;
|
||||||
|
|
||||||
axis.minValue = tempMinValue;
|
axis.minValue = tempMinValue;
|
||||||
axis.maxValue = tempMaxValue;
|
axis.maxValue = tempMaxValue;
|
||||||
axis.zeroXOffset = 0;
|
axis.zeroXOffset = 0;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ namespace XCharts
|
|||||||
protected override void DrawChart(VertexHelper vh)
|
protected override void DrawChart(VertexHelper vh)
|
||||||
{
|
{
|
||||||
base.DrawChart(vh);
|
base.DrawChart(vh);
|
||||||
|
if (!m_CheckMinMaxValue) return;
|
||||||
if (m_YAxises[0].type == Axis.AxisType.Category
|
if (m_YAxises[0].type == Axis.AxisType.Category
|
||||||
|| m_YAxises[1].type == Axis.AxisType.Category)
|
|| m_YAxises[1].type == Axis.AxisType.Category)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ namespace XCharts
|
|||||||
protected override void DrawChart(VertexHelper vh)
|
protected override void DrawChart(VertexHelper vh)
|
||||||
{
|
{
|
||||||
base.DrawChart(vh);
|
base.DrawChart(vh);
|
||||||
|
if (!m_CheckMinMaxValue) return;
|
||||||
HashSet<string> serieNameSet = new HashSet<string>();
|
HashSet<string> serieNameSet = new HashSet<string>();
|
||||||
int serieNameCount = -1;
|
int serieNameCount = -1;
|
||||||
for (int i = 0; i < m_Series.Count; i++)
|
for (int i = 0; i < m_Series.Count; i++)
|
||||||
|
|||||||
Reference in New Issue
Block a user