优化SerieData设置ignoreformatter的忽略问题

This commit is contained in:
monitor1394
2023-11-02 22:37:11 +08:00
parent e8204fc41e
commit f51e5f1859
2 changed files with 18 additions and 6 deletions

View File

@@ -69,6 +69,7 @@ slug: /changelog
## master
* (2023.11.02) 优化`SerieData`设置`ignore``formatter`的忽略问题
* (2023.11.01) 增加`MarkLine``onTop`设置是否显示在最上层
* (2023.10.21) 修复`Pie`有0数据时`Label`的位置异常的问题
* (2023.10.21) 增加`Axis`的对数轴支持子刻度

View File

@@ -154,6 +154,7 @@ namespace XCharts.Runtime
numericFormatter = SerieHelper.GetNumericFormatter(serie, serie.GetSerieData(bIndex), "");
}
var value = serie.GetData(bIndex, dimensionIndex);
var ignore = serie.IsIgnoreIndex(bIndex);
if (isPercent)
{
var total = serie.GetDataTotal(dimensionIndex, serie.GetSerieData(bIndex));
@@ -167,7 +168,10 @@ namespace XCharts.Runtime
}
else
{
content = content.Replace(old, ChartCached.FloatToStr(value, numericFormatter));
if (ignore)
content = content.Replace(old, "-");
else
content = content.Replace(old, ChartCached.FloatToStr(value, numericFormatter));
}
}
}
@@ -214,14 +218,21 @@ namespace XCharts.Runtime
}
else if (p == 'd' || p == 'D')
{
var rate = pIndex >= 0 && serieData != null ?
(value == 0 ? 0 : serieData.GetData(pIndex) / value * 100) :
(total == 0 ? 0 : value / total * 100);
content = content.Replace(old, ChartCached.NumberToStr(rate, numericFormatter));
if (serieData != null && serieData.ignore)
content = content.Replace(old, "-");
else
{
var rate = pIndex >= 0 && serieData != null ?
(value == 0 ? 0 : serieData.GetData(pIndex) / value * 100) :
(total == 0 ? 0 : value / total * 100);
content = content.Replace(old, ChartCached.NumberToStr(rate, numericFormatter));
}
}
else if (p == 'c' || p == 'C')
{
if (pIndex >= 0 && serieData != null)
if (serieData != null && serieData.ignore)
content = content.Replace(old, "-");
else if (serieData != null && pIndex >= 0)
content = content.Replace(old, ChartCached.NumberToStr(serieData.GetData(pIndex), numericFormatter));
else
content = content.Replace(old, ChartCached.NumberToStr(value, numericFormatter));