diff --git a/Assets/XCharts/CHANGELOG-EN.md b/Assets/XCharts/CHANGELOG-EN.md index c09828b5..6ba7db2c 100644 --- a/Assets/XCharts/CHANGELOG-EN.md +++ b/Assets/XCharts/CHANGELOG-EN.md @@ -40,6 +40,7 @@ ## master +* (2021.10.29) Added support for `{e}` in `Tooltip` #170 * (2021.09.08) Improved `RadarChart` * (2021.09.07) Fixed bug where `label` does not disappear at the end of `PieChart` fade animation #168 * (2021.09.06) Fixed bug where `GaugeChart` changing `splitNumber` with code does not refresh `label` #167 diff --git a/Assets/XCharts/CHANGELOG.md b/Assets/XCharts/CHANGELOG.md index 323f1d57..c64878c1 100644 --- a/Assets/XCharts/CHANGELOG.md +++ b/Assets/XCharts/CHANGELOG.md @@ -40,6 +40,7 @@ ## master +* (2021.10.29) 增加`Tooltip`对通配符`{e}`的支持 #170 * (2021.09.08) 完善`RadarChart` * (2021.09.07) 修复`PieChart`渐出动画结束时`label`没有消失的问题 #168 * (2021.09.06) 修复`GaugeChart`用代码改变`splitNumber`不会刷新`label`的问题 #167 diff --git a/Assets/XCharts/Documentation/XCharts配置项手册.md b/Assets/XCharts/Documentation/XCharts配置项手册.md index 151d84c2..42c93bf6 100644 --- a/Assets/XCharts/Documentation/XCharts配置项手册.md +++ b/Assets/XCharts/Documentation/XCharts配置项手册.md @@ -233,6 +233,7 @@ * `{b}`为当前所指示或`index`为`0`的`serie`的数据项`serieData`的`name`,或者类目值(如折线图的`X`轴)。 * `{c}`为当前所指示或`index`为`0`的`serie`的`y`维(`dimesion`为`1`)的数值。 * `{d}`为当前所指示或`index`为`0`的`serie`的`y`维(`dimesion`为`1`)百分比值,注意不带`%`号。 + * `{e}`为当前所指示或`index`为`0`的`serie`的数据项`serieData`的`name`。 * `{.1}`表示指定`index`为`1`的`serie`对应颜色的圆点。 * `{a1}`、`{b1}`、`{c1}`中的`1`表示指定`index`为`1`的`serie`。 * `{c1:2}`表示索引为`1`的`serie`的当前指示数据项的第`3`个数据(一个数据项有多个数据,index为`2`表示第`3`个数据)。 diff --git a/Assets/XCharts/Documentation/xcharts-configuration-EN.md b/Assets/XCharts/Documentation/xcharts-configuration-EN.md index 7a6f6d70..17bd85c8 100644 --- a/Assets/XCharts/Documentation/xcharts-configuration-EN.md +++ b/Assets/XCharts/Documentation/xcharts-configuration-EN.md @@ -237,6 +237,7 @@ Tooltip component. * `{b}` is the `name` of the `serieData` that is currently indicated or whose `index` is `0`, or a `category` value (such as the X-axis of a line chart). * `{c}` is the value of a Y-dimension (`dimesion` is 1) from the `serie` that is currently indicated or whose `index` is `0`. * `{d}` is the percentage value of Y-dimensions (`dimesion` is 1) from the `serie` that is currently indicated or whose `index` is `0`, with no `%` sign. + * `{e}` is the `name` of the `serieData` that is currently indicated or whose `index` is `0`. * `{.1}` represents a dot from serie corresponding color that specifies `index` as `1`. * `1` in `{a1}`, `{b1}`, `{c1}` represents a `serie` that specifies an `index` of `1`. * `{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). diff --git a/Assets/XCharts/Runtime/Component/Main/Tooltip.cs b/Assets/XCharts/Runtime/Component/Main/Tooltip.cs index 0cc12152..97f7bdae 100644 --- a/Assets/XCharts/Runtime/Component/Main/Tooltip.cs +++ b/Assets/XCharts/Runtime/Component/Main/Tooltip.cs @@ -101,6 +101,7 @@ namespace XCharts /// {b} is the name of the data item serieData that is currently indicated or whose index is 0, or a category value (such as the X-axis of a line chart). /// {c} is the value of a Y-dimension (dimesion is 1) from a Serie that is currently indicated or whose index is 0. /// {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. + /// {e} is the name of the data item serieData that is currently indicated or whose index is 0. /// {.1} represents a dot from serie corresponding color that specifies index as 1. /// 1 in {a1}, {b1}, {c1} represents a serie that specifies an index of 1. /// {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). @@ -115,6 +116,7 @@ namespace XCharts /// {b}为当前所指示或index为0的serie的数据项serieData的name,或者类目值(如折线图的X轴)。 /// {c}为当前所指示或index为0的serie的y维(dimesion为1)的数值。 /// {d}为当前所指示或index为0的serie的y维(dimesion为1)百分比值,注意不带%号。 + /// {e}为当前所指示或index为0的serie的数据项serieData的name。 /// {.1}表示指定index为1的serie对应颜色的圆点。 /// {a1}、{b1}、{c1}中的1表示指定index为1的serie。 /// {c1:2}表示索引为1的serie的当前指示数据项的第3个数据(一个数据项有多个数据,index为2表示第3个数据)。 diff --git a/Assets/XCharts/Runtime/Helper/FormatterHelper.cs b/Assets/XCharts/Runtime/Helper/FormatterHelper.cs index 30a59ccf..90b87552 100644 --- a/Assets/XCharts/Runtime/Helper/FormatterHelper.cs +++ b/Assets/XCharts/Runtime/Helper/FormatterHelper.cs @@ -15,7 +15,7 @@ namespace XCharts public static class FormatterHelper { public const string PH_NN = "\n"; - private static Regex s_Regex = new Regex(@"{([a-d|.]\d*)(:\d+(-\d+)?)?(:[c-g|x|p|r]\d*|:0\.#*)?}", RegexOptions.IgnoreCase); + private static Regex s_Regex = new Regex(@"{([a-e|.]\d*)(:\d+(-\d+)?)?(:[c-g|x|p|r]\d*|:0\.#*)?}", RegexOptions.IgnoreCase); private static Regex s_RegexSub = new Regex(@"(0\.#*)|(\d+-\d+)|(\w+)|(\.)", RegexOptions.IgnoreCase); private static Regex s_RegexN = new Regex(@"^\d+", RegexOptions.IgnoreCase); private static Regex s_RegexN_N = new Regex(@"\d+-\d+", RegexOptions.IgnoreCase); @@ -23,11 +23,11 @@ namespace XCharts private static Regex s_RegexNewLine = new Regex(@"[\\|/]+n|
|
|
", RegexOptions.IgnoreCase); private static Regex s_RegexForAxisLabel = new Regex(@"{value(:[c-g|x|p|r]\d*)?}", RegexOptions.IgnoreCase); private static Regex s_RegexSubForAxisLabel = new Regex(@"(value)|([c-g|x|p|r]\d*)", RegexOptions.IgnoreCase); - private static Regex s_RegexForSerieLabel = new Regex(@"{[a-d|\.](:[c-g|x|p|r]\d*)?}", RegexOptions.IgnoreCase); - private static Regex s_RegexSubForSerieLabel = new Regex(@"(\.)|([a-d])|([c-g|x|p|r]\d*)", RegexOptions.IgnoreCase); + private static Regex s_RegexForSerieLabel = new Regex(@"{[a-e|\.](:[c-g|x|p|r]\d*)?}", RegexOptions.IgnoreCase); + private static Regex s_RegexSubForSerieLabel = new Regex(@"(\.)|([a-e])|([c-g|x|p|r]\d*)", RegexOptions.IgnoreCase); /// - /// 替换字符串中的通配符,支持的通配符有{.}、{a}、{b}、{c}、{d}。 + /// 替换字符串中的通配符,支持的通配符有{.}、{a}、{b}、{c}、{d}、{e}。 /// /// 要替换的字符串 /// 选中的数据项serieData索引 @@ -84,15 +84,16 @@ namespace XCharts content = content.Replace(old, serie.name); } } - else if (p == 'b' || p == 'B') + else if (p == 'b' || p == 'B' || p == 'e' || p == 'E') { var bIndex = dataIndex; if (argsCount >= 2) { var args1Str = args[1].ToString(); - if (s_RegexN.IsMatch(args1Str)) bIndex = int.Parse(args1Str); + if (s_RegexN.IsMatch(args1Str)) + bIndex = int.Parse(args1Str); } - var needCategory = serie.type == SerieType.Line || serie.type == SerieType.Bar; + var needCategory = (p != 'e' && p != 'E') && (serie.type == SerieType.Line || serie.type == SerieType.Bar); if (needCategory) { var category = (chart as CoordinateChart).GetTooltipCategory(dataIndex, serie, dataZoom); @@ -236,7 +237,7 @@ namespace XCharts { content = content.Replace(old, serieName); } - else if (p == 'b' || p == 'B') + else if (p == 'b' || p == 'B' || p == 'c' || p == 'E') { content = content.Replace(old, dataName); }