From 8df1dbe0fb1d457be0316080cfe58d59c86fb94a Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Tue, 29 Aug 2023 22:20:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`Pie`=E5=92=8C`Radar`?= =?UTF-8?q?=E7=9A=84`gridIndex`=E6=94=AF=E6=8C=81=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E7=BD=91=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/en/configuration.md | 6 +- Documentation~/zh/changelog.md | 1 + Documentation~/zh/configuration.md | 4 +- Editor/MainComponents/GridCoordEditor.cs | 13 ++- ...ordLayoutEditor.cs => GridLayoutEditor.cs} | 1 + ...ditor.cs.meta => GridLayoutEditor.cs.meta} | 2 +- Editor/MainComponents/RadarCoordEditor.cs | 1 + Runtime/Component/Axis/AxisHelper.cs | 6 +- Runtime/Component/Radar/RadarCoord.cs | 25 ++++- Runtime/Component/Radar/RadarCoordHandler.cs | 4 +- Runtime/Coord/Grid/GridCoord.cs | 96 +++++++++++++++---- Runtime/Coord/Grid/GridCoordContext.cs | 4 - Runtime/Coord/Grid/GridLayoutContext.cs | 4 - .../Grid/{GridLayout.cs => XGridLayout.cs} | 48 +++++++--- ...GridLayout.cs.meta => XGridLayout.cs.meta} | 2 +- Runtime/Serie/Serie.cs | 2 +- Runtime/Serie/SerieHelper.cs | 8 +- 17 files changed, 164 insertions(+), 63 deletions(-) rename Editor/MainComponents/{GridCoordLayoutEditor.cs => GridLayoutEditor.cs} (93%) rename Editor/MainComponents/{GridCoordLayoutEditor.cs.meta => GridLayoutEditor.cs.meta} (83%) rename Runtime/Coord/Grid/{GridLayout.cs => XGridLayout.cs} (72%) rename Runtime/Coord/Grid/{GridLayout.cs.meta => XGridLayout.cs.meta} (83%) diff --git a/Documentation~/en/configuration.md b/Documentation~/en/configuration.md index 0df65741..cf255867 100644 --- a/Documentation~/en/configuration.md +++ b/Documentation~/en/configuration.md @@ -953,7 +953,7 @@ Grid component. |field|default|since|comment| |--|--|--|--| |show|true||Whether to show the grid in rectangular coordinate. -|layoutIndex|-1|v3.8.0| +|layoutIndex|-1|v3.8.0|The index of the grid layout component to which the grid belongs. The default is -1, which means that it does not belong to any grid layout component. When this value is set, the left, right, top, and bottom properties will be invalid. |left|0.1f||Distance between grid component and the left side of the container. |right|0.08f||Distance between grid component and the right side of the container. |top|0.22f||Distance between grid component and the top side of the container. @@ -990,6 +990,7 @@ Grid layout component. Used to manage the layout of multiple `GridCoord`, and th |row|2||the row count of grid layout. |column|2||the column count of grid layout. |spacing|Vector2.zero||the spacing of grid layout. +|inverse|false||Whether to inverse the grid layout. ```mdx-code-block @@ -1096,6 +1097,7 @@ Indicator of radar chart, which is used to assign multiple variables(dimensions) |connectCenter|false||Whether serie data connect to radar center with line. |lineGradient|true||Whether need gradient for data line. |startAngle||v3.4.0|起始角度。和时钟一样,12点钟位置是0度,顺时针到360度。 +|gridIndex|-1|v3.8.0|Index of layout component that serie uses. Default is -1 means not use layout, otherwise use the first layout component. |indicatorList|||the indicator list. ```mdx-code-block @@ -1734,7 +1736,7 @@ Configurations of select state. |polarIndex|0||Index of polar component that serie uses. |singleAxisIndex|0||Index of single axis component that serie uses. |parallelIndex|0||Index of parallel coord component that serie uses. -|gridIndex|-1|v3.8.0|Index of layout component that serie uses. +|gridIndex|-1|v3.8.0|Index of layout component that serie uses. Default is -1 means not use layout, otherwise use the first layout component. |minShow|||The min number of data to show in chart. |maxShow|||The max number of data to show in chart. |maxCache|||The max number of serie data cache. The first data will be remove when the size of serie data is larger then maxCache. diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 5f59420f..ddf2a6cd 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -78,6 +78,7 @@ slug: /changelog 日志详情: +* (2023.08.29) 增加`Pie`和`Radar`的`gridIndex`支持设置指定网格 * (2023.08.29) 增加`GridLayout`网格布局组件用于管理多个`GridCoord`的布局 * (2023.08.25) 修复`MarkLine`多个时只显示一个`Label`的问题 * (2023.08.25) 修复`MarkLine`在开启`Clip`后还绘制在坐标系外的问题 diff --git a/Documentation~/zh/configuration.md b/Documentation~/zh/configuration.md index ebca2c77..ffd95ff1 100644 --- a/Documentation~/zh/configuration.md +++ b/Documentation~/zh/configuration.md @@ -953,7 +953,7 @@ Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart |field|default|since|comment| |--|--|--|--| |show|true||是否显示直角坐标系网格。 -|layoutIndex|-1|v3.8.0| +|layoutIndex|-1|v3.8.0|网格所属的网格布局组件的索引。默认为-1,表示不属于任何网格布局组件。当设置了该值时,left、right、top、bottom属性将失效。 |left|0.1f||grid 组件离容器左侧的距离。 |right|0.08f||grid 组件离容器右侧的距离。 |top|0.22f||grid 组件离容器上侧的距离。 @@ -990,6 +990,7 @@ Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart |row|2||网格布局的行数。 |column|2||网格布局的列数。 |spacing|Vector2.zero||网格布局的间距。 +|inverse|false||是否反转网格布局。 ```mdx-code-block @@ -1096,6 +1097,7 @@ Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart |connectCenter|false||数值是否连线到中心点。 |lineGradient|true||数值线段是否需要渐变。 |startAngle||v3.4.0|起始角度。和时钟一样,12点钟位置是0度,顺时针到360度。 +|gridIndex|-1|v3.8.0|所使用的 layout 组件的 index。 默认为-1不指定index, 当为大于或等于0时, 为第一个layout组件的第index个格子。 |indicatorList|||指示器列表。 ```mdx-code-block diff --git a/Editor/MainComponents/GridCoordEditor.cs b/Editor/MainComponents/GridCoordEditor.cs index 11456043..cc39f58b 100644 --- a/Editor/MainComponents/GridCoordEditor.cs +++ b/Editor/MainComponents/GridCoordEditor.cs @@ -9,12 +9,15 @@ namespace XCharts.Editor public override void OnInspectorGUI() { ++EditorGUI.indentLevel; + var layoutIndex = baseProperty.FindPropertyRelative("m_LayoutIndex").intValue; PropertyField("m_LayoutIndex"); - - PropertyField("m_Left"); - PropertyField("m_Right"); - PropertyField("m_Top"); - PropertyField("m_Bottom"); + if (layoutIndex < 0) + { + PropertyField("m_Left"); + PropertyField("m_Right"); + PropertyField("m_Top"); + PropertyField("m_Bottom"); + } PropertyField("m_BackgroundColor"); PropertyField("m_ShowBorder"); PropertyField("m_BorderWidth"); diff --git a/Editor/MainComponents/GridCoordLayoutEditor.cs b/Editor/MainComponents/GridLayoutEditor.cs similarity index 93% rename from Editor/MainComponents/GridCoordLayoutEditor.cs rename to Editor/MainComponents/GridLayoutEditor.cs index e73dec62..b20aea51 100644 --- a/Editor/MainComponents/GridCoordLayoutEditor.cs +++ b/Editor/MainComponents/GridLayoutEditor.cs @@ -16,6 +16,7 @@ namespace XCharts.Editor PropertyField("m_Row"); PropertyField("m_Column"); PropertyField("m_Spacing"); + PropertyField("m_Inverse"); --EditorGUI.indentLevel; } } diff --git a/Editor/MainComponents/GridCoordLayoutEditor.cs.meta b/Editor/MainComponents/GridLayoutEditor.cs.meta similarity index 83% rename from Editor/MainComponents/GridCoordLayoutEditor.cs.meta rename to Editor/MainComponents/GridLayoutEditor.cs.meta index 21238096..54b6ae71 100644 --- a/Editor/MainComponents/GridCoordLayoutEditor.cs.meta +++ b/Editor/MainComponents/GridLayoutEditor.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 97c3db8110ca44c3bb088f8af9c56aa6 +guid: 4288bf299494d43d497436ace4b7a5a3 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Editor/MainComponents/RadarCoordEditor.cs b/Editor/MainComponents/RadarCoordEditor.cs index c3a3420a..8caf9527 100644 --- a/Editor/MainComponents/RadarCoordEditor.cs +++ b/Editor/MainComponents/RadarCoordEditor.cs @@ -10,6 +10,7 @@ namespace XCharts.Editor public override void OnInspectorGUI() { ++EditorGUI.indentLevel; + PropertyField("m_GridIndex"); PropertyField("m_Shape"); PropertyField("m_PositionType"); PropertyTwoFiled("m_Center"); diff --git a/Runtime/Component/Axis/AxisHelper.cs b/Runtime/Component/Axis/AxisHelper.cs index 7d750607..ff39cb7b 100644 --- a/Runtime/Component/Axis/AxisHelper.cs +++ b/Runtime/Component/Axis/AxisHelper.cs @@ -621,7 +621,8 @@ namespace XCharts.Runtime var startY = grid.context.y + xAxis.offset; if (xAxis.IsTop()) startY += grid.context.height; - else if (xAxis.axisLine.onZero && relativedAxis.IsValue() && relativedAxis.gridIndex == xAxis.gridIndex) + else if (xAxis.axisLine.onZero && relativedAxis != null && relativedAxis.IsValue() + && relativedAxis.gridIndex == xAxis.gridIndex) startY += relativedAxis.context.offset; return startY; } @@ -631,7 +632,8 @@ namespace XCharts.Runtime var startX = grid.context.x + yAxis.offset; if (yAxis.IsRight()) startX += grid.context.width; - else if (yAxis.axisLine.onZero && relativedAxis.IsValue() && relativedAxis.gridIndex == yAxis.gridIndex) + else if (yAxis.axisLine.onZero && relativedAxis != null && relativedAxis.IsValue() + && relativedAxis.gridIndex == yAxis.gridIndex) startX += relativedAxis.context.offset; return startX; } diff --git a/Runtime/Component/Radar/RadarCoord.cs b/Runtime/Component/Radar/RadarCoord.cs index 250659af..cb107240 100644 --- a/Runtime/Component/Radar/RadarCoord.cs +++ b/Runtime/Component/Radar/RadarCoord.cs @@ -109,6 +109,7 @@ namespace XCharts.Runtime [SerializeField] private bool m_ConnectCenter = false; [SerializeField] private bool m_LineGradient = true; [SerializeField][Since("v3.4.0")] private float m_StartAngle; + [SerializeField][Since("v3.8.0")] private int m_GridIndex = -1; [SerializeField] private List m_IndicatorList = new List(); public RadarCoordContext context = new RadarCoordContext(); @@ -120,6 +121,15 @@ namespace XCharts.Runtime /// public bool show { get { return m_Show; } set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); } } /// + /// Index of layout component that serie uses. Default is -1 means not use layout, otherwise use the first layout component. + /// |所使用的 layout 组件的 index。 默认为-1不指定index, 当为大于或等于0时, 为第一个layout组件的第index个格子。 + /// + public int gridIndex + { + get { return m_GridIndex; } + set { if (PropertyUtil.SetStruct(ref m_GridIndex, value)) SetVerticesDirty(); } + } + /// /// Radar render type, in which 'Polygon' and 'Circle' are supported. /// |雷达图绘制类型,支持 'Polygon' 和 'Circle'。 /// @@ -286,6 +296,7 @@ namespace XCharts.Runtime public override void SetDefaultValue() { m_Show = true; + m_GridIndex = -1; m_Shape = Shape.Polygon; m_Radius = 0.35f; m_SplitNumber = 5; @@ -341,9 +352,21 @@ namespace XCharts.Runtime return 0; } - internal void UpdateRadarCenter(Vector3 chartPosition, float chartWidth, float chartHeight) + internal void UpdateRadarCenter(BaseChart chart) { if (center.Length < 2) return; + var chartPosition = chart.chartPosition; + var chartWidth = chart.chartWidth; + var chartHeight = chart.chartWidth; + if (gridIndex >= 0) + { + var layout = chart.GetChartComponent(0); + if (layout != null) + { + layout.UpdateRuntimeData(chart); + layout.UpdateGridContext(gridIndex, ref chartPosition, ref chartWidth, ref chartHeight); + } + } var centerX = center[0] <= 1 ? chartWidth * center[0] : center[0]; var centerY = center[1] <= 1 ? chartHeight * center[1] : center[1]; context.center = chartPosition + new Vector3(centerX, centerY); diff --git a/Runtime/Component/Radar/RadarCoordHandler.cs b/Runtime/Component/Radar/RadarCoordHandler.cs index 8de4db62..8c16175f 100644 --- a/Runtime/Component/Radar/RadarCoordHandler.cs +++ b/Runtime/Component/Radar/RadarCoordHandler.cs @@ -39,7 +39,7 @@ namespace XCharts.Runtime radar.painter = chart.GetPainter(radar.index); radar.refreshComponent = delegate() { - radar.UpdateRadarCenter(chart.chartPosition, chart.chartWidth, chart.chartHeight); + radar.UpdateRadarCenter(chart); var radarObject = ChartHelper.AddObject("Radar" + radar.index, chart.transform, chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); radar.gameObject = radarObject; @@ -64,7 +64,7 @@ namespace XCharts.Runtime private void DrawRadarCoord(VertexHelper vh, RadarCoord radar) { if (!radar.show) return; - radar.UpdateRadarCenter(chart.chartPosition, chart.chartWidth, chart.chartHeight); + radar.UpdateRadarCenter(chart); if (radar.shape == RadarCoord.Shape.Circle) { DrawCricleRadar(vh, radar); diff --git a/Runtime/Coord/Grid/GridCoord.cs b/Runtime/Coord/Grid/GridCoord.cs index 30995274..2e2760e1 100644 --- a/Runtime/Coord/Grid/GridCoord.cs +++ b/Runtime/Coord/Grid/GridCoord.cs @@ -37,6 +37,13 @@ namespace XCharts.Runtime get { return m_Show; } set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); } } + /// + /// The index of the grid layout component to which the grid belongs. + /// The default is -1, which means that it does not belong to any grid layout component. + /// When this value is set, the left, right, top, and bottom properties will be invalid. + /// |网格所属的网格布局组件的索引。默认为-1,表示不属于任何网格布局组件。当设置了该值时,left、right、top、bottom属性将失效。 + /// + /// public int layoutIndex { get { return m_LayoutIndex; } @@ -115,67 +122,108 @@ namespace XCharts.Runtime set { if (PropertyUtil.SetColor(ref m_BorderColor, value)) SetVerticesDirty(); } } - public bool IsPointerEnter() - { - return context.isPointerEnter; - } - public void UpdateRuntimeData(BaseChart chart) { + var chartX = chart.chartX; + var chartY = chart.chartY; + var chartWidth = chart.chartWidth; + var chartHeight = chart.chartHeight; if (layoutIndex >= 0) { var layout = chart.GetChartComponent(layoutIndex); if (layout != null) { layout.UpdateRuntimeData(chart); - layout.UpdateGridContext(index, ref context); - return; + layout.UpdateGridContext(index, ref chartX, ref chartY, ref chartWidth, ref chartHeight); } } - var chartX = chart.chartX; - var chartY = chart.chartY; - var chartWidth = chart.chartWidth; - var chartHeight = chart.chartHeight; - context.left = left <= 1 ? left * chartWidth : left; - context.bottom = bottom <= 1 ? bottom * chartHeight : bottom; - context.top = top <= 1 ? top * chartHeight : top; - context.right = right <= 1 ? right * chartWidth : right; - context.x = chartX + context.left; - context.y = chartY + context.bottom; - context.width = chartWidth - context.left - context.right; - context.height = chartHeight - context.top - context.bottom; + var actualLeft = left <= 1 ? left * chartWidth : left; + var actualBottom = bottom <= 1 ? bottom * chartHeight : bottom; + var actualTop = top <= 1 ? top * chartHeight : top; + var actualRight = right <= 1 ? right * chartWidth : right; + context.x = chartX + actualLeft; + context.y = chartY + actualBottom; + context.width = chartWidth - actualLeft - actualRight; + context.height = chartHeight - actualTop - actualBottom; context.position = new Vector3(context.x, context.y); context.center = new Vector3(context.x + context.width / 2, context.y + context.height / 2); } + /// + /// Whether the pointer is in the grid. + /// |指针是否在网格内。 + /// + /// + public bool IsPointerEnter() + { + return context.isPointerEnter; + } + + /// + /// Whether the given position is in the grid. + /// |给定的位置是否在网格内。 + /// + /// + /// public bool Contains(Vector3 pos) { return Contains(pos.x, pos.y); } + /// + /// Whether the given position is in the grid. + /// |给定的位置是否在网格内。 + /// + /// + /// + /// [Since("v3.7.0")] public bool Contains(Vector3 pos, bool isYAxis) { return isYAxis ? ContainsY(pos.y) : ContainsX(pos.x); } + /// + /// Whether the given position is in the grid. + /// |给定的位置是否在网格内。 + /// + /// + /// + /// public bool Contains(float x, float y) { return ContainsX(x) && ContainsY(y); } + /// + /// Whether the given x is in the grid. + /// |给定的x是否在网格内。 + /// + /// + /// [Since("v3.7.0")] public bool ContainsX(float x) { return x >= context.x && x <= context.x + context.width; } + /// + /// Whether the given y is in the grid. + /// |给定的y是否在网格内。 + /// + /// + /// [Since("v3.7.0")] public bool ContainsY(float y) { return y >= context.y && y <= context.y + context.height; } + /// + /// Clamp the position of pos to the grid. + /// |将位置限制在网格内。 + /// + /// [Since("v3.7.0")] public void Clamp(ref Vector3 pos) { @@ -183,6 +231,11 @@ namespace XCharts.Runtime ClampY(ref pos); } + /// + /// Clamp the x position of pos to the grid. + /// |将位置的X限制在网格内。 + /// + /// [Since("v3.7.0")] public void ClampX(ref Vector3 pos) { @@ -190,6 +243,11 @@ namespace XCharts.Runtime else if (pos.x > context.x + context.width) pos.x = context.x + context.width; } + /// + /// Clamp the y position of pos to the grid. + /// |将位置的Y限制在网格内。 + /// + /// [Since("v3.7.0")] public void ClampY(ref Vector3 pos) { diff --git a/Runtime/Coord/Grid/GridCoordContext.cs b/Runtime/Coord/Grid/GridCoordContext.cs index be4ac7a7..5f794d7e 100644 --- a/Runtime/Coord/Grid/GridCoordContext.cs +++ b/Runtime/Coord/Grid/GridCoordContext.cs @@ -11,10 +11,6 @@ namespace XCharts.Runtime public float height; public Vector3 position; public Vector3 center; - public float left; - public float right; - public float bottom; - public float top; public bool isPointerEnter; public List endLabelList = new List(); } diff --git a/Runtime/Coord/Grid/GridLayoutContext.cs b/Runtime/Coord/Grid/GridLayoutContext.cs index f4ea2dc2..bc107bac 100644 --- a/Runtime/Coord/Grid/GridLayoutContext.cs +++ b/Runtime/Coord/Grid/GridLayoutContext.cs @@ -6,10 +6,6 @@ namespace XCharts.Runtime public float y; public float width; public float height; - public float left; - public float right; - public float bottom; - public float top; public float eachWidth; public float eachHeight; } diff --git a/Runtime/Coord/Grid/GridLayout.cs b/Runtime/Coord/Grid/XGridLayout.cs similarity index 72% rename from Runtime/Coord/Grid/GridLayout.cs rename to Runtime/Coord/Grid/XGridLayout.cs index abf32352..3a28fba3 100644 --- a/Runtime/Coord/Grid/GridLayout.cs +++ b/Runtime/Coord/Grid/XGridLayout.cs @@ -20,6 +20,7 @@ namespace XCharts.Runtime [SerializeField] private int m_Row = 2; [SerializeField] private int m_Column = 2; [SerializeField] private Vector2 m_Spacing = Vector2.zero; + [SerializeField] protected bool m_Inverse = false; public GridLayoutContext context = new GridLayoutContext(); @@ -95,6 +96,15 @@ namespace XCharts.Runtime get { return m_Spacing; } set { if (PropertyUtil.SetStruct(ref m_Spacing, value)) SetAllDirty(); } } + /// + /// Whether to inverse the grid layout. + /// |是否反转网格布局。 + /// + public bool inverse + { + get { return m_Inverse; } + set { if (PropertyUtil.SetStruct(ref m_Inverse, value)) SetAllDirty(); } + } public void UpdateRuntimeData(BaseChart chart) { @@ -102,29 +112,37 @@ namespace XCharts.Runtime var chartY = chart.chartY; var chartWidth = chart.chartWidth; var chartHeight = chart.chartHeight; - context.left = left <= 1 ? left * chartWidth : left; - context.bottom = bottom <= 1 ? bottom * chartHeight : bottom; - context.top = top <= 1 ? top * chartHeight : top; - context.right = right <= 1 ? right * chartWidth : right; - context.x = chartX + context.left; - context.y = chartY + context.bottom; - context.width = chartWidth - context.left - context.right; - context.height = chartHeight - context.top - context.bottom; + var actualLeft = left <= 1 ? left * chartWidth : left; + var actualBottom = bottom <= 1 ? bottom * chartHeight : bottom; + var actualTop = top <= 1 ? top * chartHeight : top; + var actualRight = right <= 1 ? right * chartWidth : right; + context.x = chartX + actualLeft; + context.y = chartY + actualBottom; + context.width = chartWidth - actualLeft - actualRight; + context.height = chartHeight - actualTop - actualBottom; context.eachWidth = (context.width - spacing.x * (column - 1)) / column; context.eachHeight = (context.height - spacing.y * (row - 1)) / row; } - internal void UpdateGridContext(int index, ref GridCoordContext gridContext) + internal void UpdateGridContext(int index, ref float x, ref float y, ref float width, ref float height) { var row = index / m_Column; var column = index % m_Column; - gridContext.x = context.x + column * (context.eachWidth + spacing.x); - gridContext.y = context.y + row * (context.eachHeight + spacing.y); - gridContext.width = context.eachWidth; - gridContext.height = context.eachHeight; - gridContext.position = new Vector3(gridContext.x, gridContext.y); - gridContext.center = new Vector3(gridContext.x + gridContext.width / 2, gridContext.y + gridContext.height / 2); + x = context.x + column * (context.eachWidth + spacing.x); + if(m_Inverse) + y = context.y + row * (context.eachHeight + spacing.y); + else + y = context.y + context.height - (row + 1) * context.eachHeight - row * spacing.y; + width = context.eachWidth; + height = context.eachHeight; + } + + internal void UpdateGridContext(int index, ref Vector3 position, ref float width, ref float height) + { + float x = 0, y = 0; + UpdateGridContext(index, ref x, ref y, ref width, ref height); + position = new Vector3(x, y); } } } \ No newline at end of file diff --git a/Runtime/Coord/Grid/GridLayout.cs.meta b/Runtime/Coord/Grid/XGridLayout.cs.meta similarity index 83% rename from Runtime/Coord/Grid/GridLayout.cs.meta rename to Runtime/Coord/Grid/XGridLayout.cs.meta index f18b1c38..84093dae 100644 --- a/Runtime/Coord/Grid/GridLayout.cs.meta +++ b/Runtime/Coord/Grid/XGridLayout.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 9abc8e277fa0f41c1a0b13133bb736c4 +guid: 691ae1f57760b4a948c94f3faa0ef6f4 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/Serie/Serie.cs b/Runtime/Serie/Serie.cs index 0125b00c..f5bc888e 100644 --- a/Runtime/Serie/Serie.cs +++ b/Runtime/Serie/Serie.cs @@ -478,7 +478,7 @@ namespace XCharts.Runtime set { if (PropertyUtil.SetStruct(ref m_ParallelIndex, value)) SetAllDirty(); } } /// - /// Index of layout component that serie uses. + /// Index of layout component that serie uses. Default is -1 means not use layout, otherwise use the first layout component. /// |所使用的 layout 组件的 index。 默认为-1不指定index, 当为大于或等于0时, 为第一个layout组件的第index个格子。 /// public int gridIndex diff --git a/Runtime/Serie/SerieHelper.cs b/Runtime/Serie/SerieHelper.cs index 484bda25..039aae40 100644 --- a/Runtime/Serie/SerieHelper.cs +++ b/Runtime/Serie/SerieHelper.cs @@ -221,12 +221,10 @@ namespace XCharts.Runtime var chartHeight = chart.chartHeight; if (serie.gridIndex >= 0) { - var grid = chart.GetChartComponent(serie.gridIndex); - if (grid != null) + var layout = chart.GetChartComponent(0); + if (layout != null) { - chartPosition = grid.context.position; - chartWidth = grid.context.width; - chartHeight = grid.context.height; + layout.UpdateGridContext(serie.gridIndex, ref chartPosition, ref chartWidth, ref chartHeight); } } var centerX = serie.center[0] <= 1 ? chartWidth * serie.center[0] : serie.center[0];