Skip to content

Commit

Permalink
修复Bar在水平方向时Label设置为Bottom不生效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
monitor1394 committed Sep 29, 2023
1 parent 54bb49d commit 66c01d5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions Documentation~/zh/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ slug: /changelog

## master

* (2023.09.29) 修复`Bar`在水平方向时`Label`设置为`Bottom`不生效的问题
* (2023.09.22) 增加`Line`的平滑曲线对`Dash`虚线的支持
* (2023.09.16) 修复`Tooltip`在类目轴无数据时异常报错的问题 (#279)
* (2023.09.16) 修复`Pie`无数据时绘制异常的问题 (#278)
Expand Down
6 changes: 5 additions & 1 deletion Runtime/Serie/Bar/BarHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ public override Vector3 GetSerieDataLabelPosition(SerieData serieData, LabelStyl
{
case LabelStyle.Position.Bottom:
var center = serieData.context.rect.center;
return new Vector3(center.x, center.y - serieData.context.rect.height / 2);
if(serie.context.isHorizontal)
return new Vector3(center.x - serieData.context.rect.width/2, center.y);
else
return new Vector3(center.x, center.y - serieData.context.rect.height / 2);
case LabelStyle.Position.Center:
case LabelStyle.Position.Inside:
return serieData.context.rect.center;
Expand Down Expand Up @@ -193,6 +196,7 @@ private void DrawBarSerie(VertexHelper vh, Bar serie)
var areaToColor = ColorUtil.clearColor32;
var interacting = false;

serie.context.isHorizontal = isY;
serie.containerIndex = m_SerieGrid.index;
serie.containterInstanceId = m_SerieGrid.instanceId;
serie.animation.InitProgress(axisXY, axisXY + axisLength);
Expand Down
1 change: 1 addition & 0 deletions Runtime/Serie/Line/LineHandler.GridCoord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ private void DrawLineSerie(VertexHelper vh, Line serie)
var lineWidth = LineHelper.GetLineWidth(ref interacting, serie, chart.theme.serie.lineWidth);

axis.context.scaleWidth = scaleWid;
serie.context.isHorizontal = isY;
serie.containerIndex = m_SerieGrid.index;
serie.containterInstanceId = m_SerieGrid.instanceId;

Expand Down
4 changes: 4 additions & 0 deletions Runtime/Serie/SerieContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,9 @@ public class SerieContext
public Tooltip.Type tooltipType;
public Tooltip.Trigger tooltipTrigger;
public int totalDataIndex;
/// <summary>
/// 水平方向的
/// </summary>
public bool isHorizontal;
}
}

0 comments on commit 66c01d5

Please sign in to comment.