mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-21 07:50:16 +00:00
修复图表在LayoutGroup控制下时可能显示错乱的问题 #121
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
|
||||
## Latest
|
||||
|
||||
* (2021.02.19) Fixed an issue where charts could appear abnormal when under `LayoutGroup` control #121
|
||||
* (2021.02.18) Fixed an issue where the `Radar` could not refresh itself after parameter changing #122
|
||||
|
||||
## v2.0.0
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
|
||||
## Latest
|
||||
|
||||
* (2021.02.18) 修复`Radar`参数变更后无法自刷新的问题
|
||||
* (2021.02.19) 修复图表在`LayoutGroup`控制下时可能显示错乱的问题 #121
|
||||
* (2021.02.18) 修复`Radar`参数变更后无法自刷新的问题 #122
|
||||
|
||||
## 2.0.0
|
||||
|
||||
|
||||
@@ -350,18 +350,16 @@ namespace XCharts
|
||||
}
|
||||
private void InitTitle(Title title)
|
||||
{
|
||||
title.OnChanged();
|
||||
var anchorMin = title.location.runtimeAnchorMin;
|
||||
var anchorMax = title.location.runtimeAnchorMax;
|
||||
var pivot = title.location.runtimePivot;
|
||||
var titleObject = ChartHelper.AddObject(s_TitleObjectName + title.index, transform, anchorMin, anchorMax,
|
||||
pivot, m_ChartSizeDelta);
|
||||
title.gameObject = titleObject;
|
||||
title.painter = null;
|
||||
title.refreshComponent = delegate ()
|
||||
{
|
||||
if (titleObject == null) return;
|
||||
title.OnChanged();
|
||||
var anchorMin = title.location.runtimeAnchorMin;
|
||||
var anchorMax = title.location.runtimeAnchorMax;
|
||||
var pivot = title.location.runtimePivot;
|
||||
var titleObject = ChartHelper.AddObject(s_TitleObjectName + title.index, transform, anchorMin, anchorMax,
|
||||
pivot, m_ChartSizeDelta);
|
||||
title.gameObject = titleObject;
|
||||
anchorMin = title.location.runtimeAnchorMin;
|
||||
anchorMax = title.location.runtimeAnchorMax;
|
||||
pivot = title.location.runtimePivot;
|
||||
@@ -405,15 +403,13 @@ namespace XCharts
|
||||
|
||||
private void InitLegend(Legend legend)
|
||||
{
|
||||
legend.OnChanged();
|
||||
var legendObject = ChartHelper.AddObject(s_LegendObjectName + legend.index, transform, m_ChartMinAnchor,
|
||||
m_ChartMaxAnchor, m_ChartPivot, m_ChartSizeDelta);
|
||||
legend.gameObject = legendObject;
|
||||
legend.painter = null; // legend component does not need to paint
|
||||
legend.refreshComponent = delegate ()
|
||||
{
|
||||
if (legendObject == null) return;
|
||||
legend.OnChanged();
|
||||
var legendObject = ChartHelper.AddObject(s_LegendObjectName + legend.index, transform, m_ChartMinAnchor,
|
||||
m_ChartMaxAnchor, m_ChartPivot, m_ChartSizeDelta);
|
||||
legend.gameObject = legendObject;
|
||||
legendObject.hideFlags = chartHideFlags;
|
||||
SeriesHelper.UpdateSerieNameList(m_Series, ref m_LegendRealShowName);
|
||||
List<string> datas;
|
||||
@@ -596,12 +592,11 @@ namespace XCharts
|
||||
|
||||
private void InitTooltip()
|
||||
{
|
||||
tooltip.gameObject = ChartHelper.AddObject("tooltip", transform, m_ChartMinAnchor,
|
||||
m_ChartMaxAnchor, m_ChartPivot, m_ChartSizeDelta);
|
||||
tooltip.painter = m_PainterTop;
|
||||
tooltip.refreshComponent = delegate ()
|
||||
{
|
||||
if (tooltip.gameObject == null) return;
|
||||
tooltip.gameObject = ChartHelper.AddObject("tooltip", transform, m_ChartMinAnchor,
|
||||
m_ChartMaxAnchor, m_ChartPivot, m_ChartSizeDelta);
|
||||
var tooltipObject = tooltip.gameObject;
|
||||
tooltipObject.transform.localPosition = Vector3.zero;
|
||||
tooltipObject.hideFlags = chartHideFlags;
|
||||
@@ -752,10 +747,7 @@ namespace XCharts
|
||||
m_ChartSizeDelta = m_GraphSizeDelta;
|
||||
m_ChartRect = m_GraphRect;
|
||||
|
||||
m_Background.SetAllDirty();
|
||||
foreach (var title in m_Titles) title.SetAllDirty();
|
||||
foreach (var legend in m_Legends) legend.SetAllDirty();
|
||||
tooltip.SetAllDirty();
|
||||
SetAllComponentDirty();
|
||||
m_Series.SetLabelDirty();
|
||||
m_ReinitLabel = true;
|
||||
RefreshChart();
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace XCharts
|
||||
protected Vector2 m_GraphMaxAnchor;
|
||||
protected Vector2 m_GraphPivot;
|
||||
protected Vector2 m_GraphSizeDelta;
|
||||
protected Vector2 m_GraphAnchoredPosition;
|
||||
protected Rect m_GraphRect = new Rect(0, 0, 0, 0);
|
||||
protected bool m_RefreshChart = false;
|
||||
protected bool m_ForceOpenRaycastTarget;
|
||||
@@ -197,13 +198,12 @@ namespace XCharts
|
||||
|
||||
private void InitBackground()
|
||||
{
|
||||
var backgroundObj = ChartHelper.AddObject(s_BackgroundObjectName, transform, m_GraphMinAnchor,
|
||||
m_GraphMaxAnchor, m_GraphPivot, m_GraphSizeDelta);
|
||||
m_Background.gameObject = backgroundObj;
|
||||
m_Background.painter = m_Painter;
|
||||
m_Background.refreshComponent = delegate ()
|
||||
{
|
||||
if (backgroundObj == null) return;
|
||||
var backgroundObj = ChartHelper.AddObject(s_BackgroundObjectName, transform, m_GraphMinAnchor,
|
||||
m_GraphMaxAnchor, m_GraphPivot, m_GraphSizeDelta);
|
||||
m_Background.gameObject = backgroundObj;
|
||||
backgroundObj.hideFlags = chartHideFlags;
|
||||
var backgroundImage = ChartHelper.GetOrAddComponent<Image>(backgroundObj);
|
||||
ChartHelper.UpdateRectTransform(backgroundObj, m_GraphMinAnchor,
|
||||
@@ -235,8 +235,11 @@ namespace XCharts
|
||||
Awake();
|
||||
}
|
||||
|
||||
if (m_GraphWidth != currWidth || m_GraphHeight != currHeight ||
|
||||
m_GraphMinAnchor != rectTransform.anchorMin || m_GraphMaxAnchor != rectTransform.anchorMax)
|
||||
if (m_GraphWidth != currWidth
|
||||
|| m_GraphHeight != currHeight
|
||||
|| m_GraphMinAnchor != rectTransform.anchorMin
|
||||
|| m_GraphMaxAnchor != rectTransform.anchorMax
|
||||
|| m_GraphAnchoredPosition != rectTransform.anchoredPosition)
|
||||
{
|
||||
UpdateSize();
|
||||
}
|
||||
@@ -255,6 +258,7 @@ namespace XCharts
|
||||
m_GraphMaxAnchor = rectTransform.anchorMax;
|
||||
m_GraphMinAnchor = rectTransform.anchorMin;
|
||||
m_GraphSizeDelta = rectTransform.sizeDelta;
|
||||
m_GraphAnchoredPosition = rectTransform.anchoredPosition;
|
||||
|
||||
rectTransform.pivot = LayerHelper.ResetChartPositionAndPivot(m_GraphMinAnchor, m_GraphMaxAnchor,
|
||||
m_GraphWidth, m_GraphHeight, ref m_GraphX, ref m_GraphY);
|
||||
|
||||
@@ -61,15 +61,6 @@ namespace XCharts
|
||||
Awake();
|
||||
}
|
||||
#endif
|
||||
protected override void SetAllComponentDirty()
|
||||
{
|
||||
base.SetAllComponentDirty();
|
||||
foreach (var dataZoom in m_DataZooms) dataZoom.SetAllDirty();
|
||||
foreach (var visualMap in m_VisualMaps) visualMap.SetAllDirty();
|
||||
foreach (var grid in m_Grids) grid.SetAllDirty();
|
||||
foreach (var axis in m_XAxes) axis.SetAllDirty();
|
||||
foreach (var axis in m_YAxes) axis.SetAllDirty();
|
||||
}
|
||||
|
||||
private void RefreshSeriePainterByGridIndex(int gridIndex)
|
||||
{
|
||||
@@ -499,14 +490,13 @@ namespace XCharts
|
||||
|
||||
private void InitYAxis(int yAxisIndex, YAxis yAxis)
|
||||
{
|
||||
string objName = ChartCached.GetYAxisName(yAxisIndex);
|
||||
var axisObj = ChartHelper.AddObject(objName, transform, graphAnchorMin,
|
||||
graphAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));
|
||||
yAxis.gameObject = axisObj;
|
||||
yAxis.painter = m_Painter;
|
||||
yAxis.refreshComponent = delegate ()
|
||||
{
|
||||
if (axisObj == null) return;
|
||||
string objName = ChartCached.GetYAxisName(yAxisIndex);
|
||||
var axisObj = ChartHelper.AddObject(objName, transform, graphAnchorMin,
|
||||
graphAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));
|
||||
yAxis.gameObject = axisObj;
|
||||
yAxis.axisLabelTextList.Clear();
|
||||
axisObj.SetActive(yAxis.show && yAxis.axisLabel.show);
|
||||
axisObj.hideFlags = chartHideFlags;
|
||||
@@ -610,14 +600,13 @@ namespace XCharts
|
||||
|
||||
private void InitXAxis(int xAxisIndex, XAxis xAxis)
|
||||
{
|
||||
string objName = ChartCached.GetXAxisName(xAxisIndex);
|
||||
var axisObj = ChartHelper.AddObject(objName, transform, graphAnchorMin,
|
||||
graphAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));
|
||||
xAxis.gameObject = axisObj;
|
||||
xAxis.painter = m_Painter;
|
||||
xAxis.refreshComponent = delegate ()
|
||||
{
|
||||
if (axisObj == null) return;
|
||||
string objName = ChartCached.GetXAxisName(xAxisIndex);
|
||||
var axisObj = ChartHelper.AddObject(objName, transform, graphAnchorMin,
|
||||
graphAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));
|
||||
xAxis.gameObject = axisObj;
|
||||
xAxis.axisLabelTextList.Clear();
|
||||
axisObj.SetActive(xAxis.show && xAxis.axisLabel.show);
|
||||
axisObj.hideFlags = chartHideFlags;
|
||||
@@ -716,13 +705,12 @@ namespace XCharts
|
||||
{
|
||||
var dataZoom = m_DataZooms[i];
|
||||
dataZoom.index = i;
|
||||
var dataZoomObject = ChartHelper.AddObject(s_DefaultDataZoom + i, transform, graphAnchorMin,
|
||||
graphAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));
|
||||
dataZoom.gameObject = dataZoomObject;
|
||||
dataZoom.painter = m_PainterTop;
|
||||
dataZoom.refreshComponent = delegate ()
|
||||
{
|
||||
if (dataZoomObject == null) return;
|
||||
var dataZoomObject = ChartHelper.AddObject(s_DefaultDataZoom + i, transform, graphAnchorMin,
|
||||
graphAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));
|
||||
dataZoom.gameObject = dataZoomObject;
|
||||
dataZoomObject.hideFlags = chartHideFlags;
|
||||
ChartHelper.HideAllObject(dataZoomObject);
|
||||
var startLabel = ChartHelper.AddTextObject(s_DefaultDataZoom + "start", dataZoomObject.transform,
|
||||
|
||||
Reference in New Issue
Block a user