增加{y}通配符用于获取Y轴的类目名

This commit is contained in:
monitor1394
2024-01-23 22:56:03 +08:00
parent 9e39150009
commit 61a2da10ba
9 changed files with 74 additions and 21 deletions

View File

@@ -123,13 +123,14 @@ namespace XCharts.Runtime
/// Template placeholder have the following, some of which apply only to fixed components: <br />
/// `{.}` : indicates the dot mark. <br />
/// `{a}` : indicates the series name. <br />
/// `{b}` : category value or data name. <br />
/// `{b}` : category value of x axis or data name. <br />
/// `{c}` : data value. <br />
/// `{d}` : percentage. <br />
/// `{e}` : indicates the data name. <br />
/// `{f}` : data sum. <br />
/// `{g}` : indicates the total number of data. <br />
/// `{h}` : hexadecimal color value. <br />
/// `{y}` : category value of y axis. <br />
/// `{value}` : The value of the axis or legend. <br />
/// The following placeholder apply to `UITable` components: <br />
/// `{name}` : indicates the row name of the table. <br />
@@ -151,13 +152,14 @@ namespace XCharts.Runtime
/// 模板通配符有以下这些,部分只适用于固定的组件:<br/>
/// `{.}`:圆点标记。<br/>
/// `{a}`:系列名。<br/>
/// `{b}`:类目或数据名。<br/>
/// `{b}`X轴类目或数据名。<br/>
/// `{c}`:数据值。<br/>
/// `{d}`:百分比。<br/>
/// `{e}`:数据名。<br/>
/// `{f}`:数据和。<br/>
/// `{g}`:数据总个数。<br/>
/// `{h}`:十六进制颜色值。<br/>
/// `{y}`Y轴的类目名。<br/>
/// `{value}`:坐标轴或图例的值。<br/>
/// 以下通配符适用UITable组件<br/>
/// `{name}` 表格的行名。<br/>

View File

@@ -24,7 +24,7 @@ namespace XCharts.Runtime
}
public static string GetFormatterContent(Serie serie, SerieData serieData,
double dataValue, double dataTotal, LabelStyle serieLabel, Color color)
double dataValue, double dataTotal, LabelStyle serieLabel, Color color, BaseChart chart = null)
{
if (serieLabel == null)
{
@@ -45,7 +45,7 @@ namespace XCharts.Runtime
{
var content = serieLabel.formatter;
FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, serie.dataCount, dataValue,
dataTotal, serieName, dataName, dataName, color, serieData);
dataTotal, serieName, dataName, dataName, color, serieData, chart);
if (serieLabel.formatterFunction == null)
return content;
else
@@ -70,7 +70,5 @@ namespace XCharts.Runtime
serieData.labelObject.text.SetColor(label.textStyle.color);
}
}
}
}

View File

@@ -192,6 +192,7 @@ namespace XCharts.Runtime
/// {h} is the hexadecimal color value of serieData for the serie data item currently indicated or index 0. <br />
/// {f} is the sum of data. <br />
/// {g} indicates the total number of data. <br />
/// {y} is category value of y axis. <br />
/// {.1} represents a dot of the corresponding color with serie specified as index 1. <br />
/// The 1 in {a1}, {b1}, {c1} represents serie where index is specified as 1. <br />
/// {c1:2} represents the third data of the current indicator data item in serie with index 1 (one data item has multiple data, index 2 represents the third data). <br />
@@ -210,6 +211,7 @@ namespace XCharts.Runtime
/// {h}为当前所指示或index为0的serie的数据项serieData的十六进制颜色值。<br/>
/// {f}为数据总和。<br/>
/// {g}为数据总个数。<br/>
/// {f}为value所对应的y轴的类目值。<br/>
/// {.1}表示指定index为1的serie对应颜色的圆点。<br/>
/// {a1}、{b1}、{c1}中的1表示指定index为1的serie。<br/>
/// {c1:2}表示索引为1的serie的当前指示数据项的第3个数据一个数据项有多个数据index为2表示第3个数据。<br/>
@@ -229,6 +231,7 @@ namespace XCharts.Runtime
/// {d} is the percentage value of Y-dimensions (dimesion is 1) from serie that is currently indicated or whose index is 0, with no % sign.<br/>
/// {e} is the name of the data item serieData that is currently indicated or whose index is 0.<br/>
/// {f} is sum of data.<br/>
/// {y} is category value of y axis.<br/>
/// {.1} represents a dot from serie corresponding color that specifies index as 1.<br/>
/// 1 in {a1}, {b1}, {c1} represents a serie that specifies an index of 1.<br/>
/// {c1:2} represents the third data from serie's current indication data item indexed to 1 (a data item has multiple data, index 2 represents the third data).<br/>
@@ -248,11 +251,12 @@ namespace XCharts.Runtime
/// {f}为当前所指示的serie的默认维度的数据总和。<br/>
/// {g}为当前所指示的serie的数据总个数。<br/>
/// {h}为当前所指示的serie的十六进制颜色值。<br/>
/// {y}为当前所指示的serie的y轴的类目值。<br/>
/// {c0}表示当前数据项维度为0的数据。<br/>
/// {c1}表示当前数据项维度为1的数据。<br/>
/// {d3}表示维度3的数据的百分比。它的分母是默认维度一般是1维度数据。<br/>
/// |表示多个列的分隔。<br/>
/// 示例:"{i}", "{.}|{a}|{c}", "{.}|{b}|{c2:f2}"
/// 示例:"{i}", "{.}|{a}|{c}", "{.}|{b}|{c2:f2}", "{.}|{b}|{y}"
/// </summary>
public string itemFormatter { get { return m_ItemFormatter; } set { m_ItemFormatter = value; } }
/// <summary>

View File

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