增加TooltipitemFormatter设置{f0}支持

This commit is contained in:
monitor1394
2024-12-25 21:39:13 +08:00
parent d1438dd76f
commit 6e9d9bfd3d
4 changed files with 14 additions and 4 deletions

View File

@@ -78,6 +78,7 @@ slug: /changelog
## master ## master
* (2024.12.25) 增加`Tooltip``itemFormatter`设置`{f0}`支持
* (2024.12.25) 修复`YAxis`在范围变更刷新时部分label可能不显示的问题 * (2024.12.25) 修复`YAxis`在范围变更刷新时部分label可能不显示的问题
* (2024.12.23) 增加`SymbolStyle``borderWidth``emptyColor`配置 * (2024.12.23) 增加`SymbolStyle``borderWidth``emptyColor`配置
* (2024.12.17) 增加`UISlider`扩展组件 * (2024.12.17) 增加`UISlider`扩展组件

View File

@@ -45,7 +45,7 @@ namespace XCharts.Runtime
{ {
var content = serieLabel.formatter; var content = serieLabel.formatter;
FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, serie.dataCount, dataValue, FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, serie.dataCount, dataValue,
dataTotal, serieName, dataName, dataName, color, serieData, chart); dataTotal, serieName, dataName, dataName, color, serieData, chart, serie.index);
if (serieLabel.formatterFunction == null) if (serieLabel.formatterFunction == null)
return content; return content;
else else

View File

@@ -44,7 +44,8 @@ namespace XCharts.Runtime
param.serieData.name, param.serieData.name,
param.color, param.color,
param.serieData, param.serieData,
chart); chart,
param.serieIndex);
foreach (var item in content.Split('|')) foreach (var item in content.Split('|'))
{ {
param.columns.Add(item); param.columns.Add(item);

View File

@@ -149,7 +149,7 @@ namespace XCharts.Runtime
else if (p == 'c' || p == 'C' || p == 'd' || p == 'D' || p == 'f' || p == 'f') else if (p == 'c' || p == 'C' || p == 'd' || p == 'D' || p == 'f' || p == 'f')
{ {
var isPercent = p == 'd' || p == 'D'; var isPercent = p == 'd' || p == 'D';
var isTotal = p == 'f' || p == 'f'; var isTotal = p == 'f' || p == 'F';
var bIndex = dataIndex; var bIndex = dataIndex;
var dimensionIndex = -1; var dimensionIndex = -1;
if (argsCount >= 2) if (argsCount >= 2)
@@ -211,7 +211,7 @@ namespace XCharts.Runtime
} }
public static void ReplaceSerieLabelContent(ref string content, string numericFormatter, int dataCount, double value, double total, public static void ReplaceSerieLabelContent(ref string content, string numericFormatter, int dataCount, double value, double total,
string serieName, string category, string dataName, Color color, SerieData serieData, BaseChart chart = null) string serieName, string category, string dataName, Color color, SerieData serieData, BaseChart chart = null, int serieIndex = 0)
{ {
var mc = s_RegexForSerieLabel.Matches(content); var mc = s_RegexForSerieLabel.Matches(content);
foreach (var m in mc) foreach (var m in mc)
@@ -270,6 +270,14 @@ namespace XCharts.Runtime
} }
else if (p == 'f' || p == 'f') else if (p == 'f' || p == 'f')
{ {
if (pIndex != 1 && chart != null)
{
var serie = chart.GetSerie(serieIndex);
if (serie != null)
{
total = serie.GetDataTotal(pIndex, serieData);
}
}
content = content.Replace(old, ChartCached.NumberToStr(total, numericFormatter)); content = content.Replace(old, ChartCached.NumberToStr(total, numericFormatter));
} }
else if (p == 'g' || p == 'G') else if (p == 'g' || p == 'G')