修复BarChart清空数据重新赋值后SerieLabel显示异常的问题

This commit is contained in:
monitor1394
2019-11-22 09:46:30 +08:00
parent 5aaa53c503
commit 110f4ee5f8
3 changed files with 17 additions and 10 deletions

View File

@@ -1,7 +1,8 @@
# 更新日志
* (2019.11.16) 修复`SerieLabel`设置`color`不生效的问题
* (2019.11.22) 修复`BarChart`清空数据重新赋值后`SerieLabel`显示异常的问题
* (2019.11.16) 修复`SerieLabel`设置`color`等参数不生效的问题
* (2019.11.12) 发布`v1.0.5`版本
* (2019.11.12) 修复`2018.3`以下版本打开项目报错的问题
* (2019.11.12) 增加`IconStyle`子组件,优化`SerieData`的图标配置

View File

@@ -82,7 +82,7 @@ namespace XCharts
/// 标志位置。
/// </summary>
public Vector3 labelPosition { get; set; }
public bool m_CanShowLabel = true;
private bool m_CanShowLabel = true;
/// <summary>
/// 是否可以显示Label
/// </summary>

View File

@@ -23,7 +23,7 @@ namespace XCharts
if (!yAxis.show) yAxis = m_YAxises[(serie.axisIndex + 1) % m_YAxises.Count];
var showData = serie.GetDataList(m_DataZoom);
float categoryWidth = yAxis.GetDataWidth(coordinateHeight,showData.Count, m_DataZoom);
float categoryWidth = yAxis.GetDataWidth(coordinateHeight, showData.Count, m_DataZoom);
float barGap = GetBarGap();
float totalBarWidth = GetBarTotalWidth(categoryWidth, barGap);
float barWidth = serie.GetBarWidth(categoryWidth);
@@ -49,6 +49,8 @@ namespace XCharts
{
seriesHig.Add(0);
}
var serieData = showData[i];
serieData.canShowLabel = true;
float value = showData[i].data[1];
float pX = seriesHig[i] + coordinateX + xAxis.runtimeZeroXOffset + yAxis.axisLine.width;
float pY = coordinateY + +i * categoryWidth;
@@ -59,14 +61,15 @@ namespace XCharts
if (isPercentStack)
{
valueTotal = GetSameStackTotalValue(serie.stack, i);
barHig = value / valueTotal * coordinateWidth;
barHig = valueTotal != 0 ? (value / valueTotal * coordinateWidth) : 0;
seriesHig[i] += barHig;
}
else
{
valueTotal = xAxis.runtimeMaxValue - xAxis.runtimeMinValue;
barHig = (xAxis.runtimeMinValue > 0 ? value - xAxis.runtimeMinValue : value)
/ valueTotal * coordinateWidth;
if (valueTotal != 0)
barHig = (xAxis.runtimeMinValue > 0 ? value - xAxis.runtimeMinValue : value)
/ valueTotal * coordinateWidth;
seriesHig[i] += barHig;
}
@@ -132,7 +135,7 @@ namespace XCharts
var xAxis = m_XAxises[serie.axisIndex];
if (!xAxis.show) xAxis = m_XAxises[(serie.axisIndex + 1) % m_XAxises.Count];
float categoryWidth = xAxis.GetDataWidth(coordinateWidth,showData.Count, m_DataZoom);
float categoryWidth = xAxis.GetDataWidth(coordinateWidth, showData.Count, m_DataZoom);
float barGap = GetBarGap();
float totalBarWidth = GetBarTotalWidth(categoryWidth, barGap);
float barWidth = serie.GetBarWidth(categoryWidth);
@@ -158,6 +161,8 @@ namespace XCharts
{
seriesHig.Add(0);
}
var serieData = showData[i];
serieData.canShowLabel = true;
float value = showData[i].data[1];
float pX = coordinateX + i * categoryWidth;
float zeroY = coordinateY + yAxis.runtimeZeroYOffset;
@@ -169,14 +174,15 @@ namespace XCharts
if (isPercentStack)
{
valueTotal = GetSameStackTotalValue(serie.stack, i);
barHig = value / valueTotal * coordinateHeight;
barHig = valueTotal != 0 ? (value / valueTotal * coordinateHeight) : 0;
seriesHig[i] += barHig;
}
else
{
valueTotal = yAxis.runtimeMaxValue - yAxis.runtimeMinValue;
barHig = (yAxis.runtimeMinValue > 0 ? value - yAxis.runtimeMinValue : value)
/ valueTotal * coordinateHeight;
if (valueTotal != 0)
barHig = (yAxis.runtimeMinValue > 0 ? value - yAxis.runtimeMinValue : value)
/ valueTotal * coordinateHeight;
seriesHig[i] += barHig;
}