diff --git a/Documentation/XCharts配置项手册.md b/Documentation/XCharts配置项手册.md
index ec3d384e..752d8ad4 100644
--- a/Documentation/XCharts配置项手册.md
+++ b/Documentation/XCharts配置项手册.md
@@ -195,13 +195,13 @@
* `Corss`:十字准星指示器。坐标轴显示`Label`和交叉线。
* `formatter`:提示框内容字符串模版格式器。支持用 `\n` 换行。当`formatter`不为空时,优先使用`formatter`,否则使用`itemFormatter`。
* 模板变量有`{.}`、`{a}`、`{b}`、`{c}`、`{d}`。
- * `{.}`表示带动态颜色的圆点。
- * `{a}`为系列名`serie`的`name`。
- * `{b}`为数据项名`serieData`的`name`,或者类目值(如折线图的`X`轴)。
- * `{c}`为数值。
- * `{d}`为百分比值,注意不带`%`号。
+ * `{.}`为当前所指示或`index`为`0`的`serie`的对应颜色的圆点。
+ * `{a}`为当前所指示或`index`为`0`的`serie`的系列名`name`。
+ * `{b}`为当前所指示或`index`为`0`的`serie`的数据项`serieData`的`name`,或者类目值(如折线图的`X`轴)。
+ * `{c}`为当前所指示或`index`为`0`的`serie`的`y`维(`dimesion`为`1`)的数值。
+ * `{d}`为当前所指示或`index`为`0`的`serie`的`y`维(`dimesion`为`1`)百分比值,注意不带`%`号。
* `{.1}`表示指定`index`为`1`的`serie`对应颜色的圆点。
- * `{a1}`、`{b1}`、`{c1}`中的`1`表示指定`index`为`1`的`serie`,`{a}`默认`index`为`0`的`serie`。
+ * `{a1}`、`{b1}`、`{c1}`中的`1`表示指定`index`为`1`的`serie`。
* `{c1:2}`表示索引为`1`的`serie`的当前指示数据项的第`3`个数据(一个数据项有多个数据,index为`2`表示第`3`个数据)。
* `{c1:2-2}`表示索引为`1`的`serie`的第`3`个数据项的第`3`个数据(也就是要指定第几个数据项时必须要指定第几个数据)。
* `{d1:2:f2}`表示单独指定了数值的格式化字符串为`f2`(不指定时用`numericFormatter`)。
diff --git a/Editor/PropertyDrawers/RadarDrawer.cs b/Editor/PropertyDrawers/RadarDrawer.cs
index 74277b8a..ea6a18b3 100644
--- a/Editor/PropertyDrawers/RadarDrawer.cs
+++ b/Editor/PropertyDrawers/RadarDrawer.cs
@@ -74,10 +74,7 @@ namespace XCharts
var tempWidth = (pos.width - startX + 35) / 2;
var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height);
var centerYRect = new Rect(centerXRect.x + tempWidth - 20, drawRect.y, tempWidth, drawRect.height);
- while (m_Center.arraySize < 2)
- {
- m_Center.InsertArrayElementAtIndex(m_Center.arraySize);
- }
+ while (m_Center.arraySize < 2) m_Center.arraySize++;
EditorGUI.PropertyField(centerXRect, m_Center.GetArrayElementAtIndex(0), GUIContent.none);
EditorGUI.PropertyField(centerYRect, m_Center.GetArrayElementAtIndex(1), GUIContent.none);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
diff --git a/Editor/PropertyDrawers/SerieDrawer.cs b/Editor/PropertyDrawers/SerieDrawer.cs
index fb6d305d..417995f8 100644
--- a/Editor/PropertyDrawers/SerieDrawer.cs
+++ b/Editor/PropertyDrawers/SerieDrawer.cs
@@ -363,10 +363,8 @@ namespace XCharts
bool showSelected = (serieType == SerieType.Pie);
if (listSize != m_Datas.arraySize)
{
- while (listSize > m_Datas.arraySize)
- m_Datas.InsertArrayElementAtIndex(m_Datas.arraySize);
- while (listSize < m_Datas.arraySize)
- m_Datas.DeleteArrayElementAtIndex(m_Datas.arraySize - 1);
+ while (listSize > m_Datas.arraySize) m_Datas.arraySize++;
+ while (listSize < m_Datas.arraySize) m_Datas.arraySize--;
}
if (listSize > 30)
{
@@ -414,8 +412,9 @@ namespace XCharts
{
while (2 > data.arraySize)
{
- data.InsertArrayElementAtIndex(data.arraySize);
- data.GetArrayElementAtIndex(data.arraySize - 1).floatValue = 0;
+ var value = data.arraySize == 0 ? index : 0;
+ data.arraySize++;
+ data.GetArrayElementAtIndex(data.arraySize - 1).floatValue = value;
}
SerializedProperty element = data.GetArrayElementAtIndex(1);
if (showSelected)
@@ -452,8 +451,9 @@ namespace XCharts
var dataCount = i < 1 ? 2 : i + 1;
while (dataCount > data.arraySize)
{
- data.InsertArrayElementAtIndex(data.arraySize);
- data.GetArrayElementAtIndex(data.arraySize - 1).floatValue = 0;
+ var value = data.arraySize == 0 ? index : 0;
+ data.arraySize++;
+ data.GetArrayElementAtIndex(data.arraySize - 1).floatValue = value;
}
drawRect.x = startX + i * xWid;
drawRect.width = dataWid + 40;
diff --git a/Editor/PropertyDrawers/ThemeInfoDrawer.cs b/Editor/PropertyDrawers/ThemeInfoDrawer.cs
index c187ceaa..a96a69b9 100644
--- a/Editor/PropertyDrawers/ThemeInfoDrawer.cs
+++ b/Editor/PropertyDrawers/ThemeInfoDrawer.cs
@@ -320,7 +320,7 @@ namespace XCharts
{
while (i > m_CustomColorPalette.arraySize - 1)
{
- m_CustomColorPalette.InsertArrayElementAtIndex(m_CustomColorPalette.arraySize);
+ m_CustomColorPalette.arraySize++;
}
var customElement = m_CustomColorPalette.GetArrayElementAtIndex(i);
color = !ChartHelper.IsClearColor(customElement.colorValue) ?
diff --git a/Editor/Utility/ChartEditorHelper.cs b/Editor/Utility/ChartEditorHelper.cs
index 55edbbd8..13b2822a 100644
--- a/Editor/Utility/ChartEditorHelper.cs
+++ b/Editor/Utility/ChartEditorHelper.cs
@@ -32,19 +32,13 @@ public class ChartEditorHelper
public static void MakeTwoField(ref Rect drawRect, float rectWidth, SerializedProperty arrayProp, string name)
{
- while (arrayProp.arraySize < 2)
- {
- arrayProp.InsertArrayElementAtIndex(arrayProp.arraySize);
- }
+ while (arrayProp.arraySize < 2) arrayProp.arraySize++;
MakeTwoField(ref drawRect, rectWidth, arrayProp.GetArrayElementAtIndex(0), arrayProp.GetArrayElementAtIndex(1), name);
}
public static void MakeDivideList(ref Rect drawRect, float rectWidth, SerializedProperty arrayProp, string name, int showNum)
{
- while (arrayProp.arraySize < showNum)
- {
- arrayProp.InsertArrayElementAtIndex(arrayProp.arraySize);
- }
+ while (arrayProp.arraySize < showNum) arrayProp.arraySize++;
EditorGUI.LabelField(drawRect, name);
#if UNITY_2019_3_OR_NEWER
var gap = 2;
@@ -214,7 +208,7 @@ public class ChartEditorHelper
var iconRect = new Rect(drawRect.width - nameWid + temp, drawRect.y, nameWid, drawRect.height);
if (GUI.Button(iconRect, new GUIContent("+", "add")))
{
- listProp.InsertArrayElementAtIndex(listProp.arraySize);
+ listProp.arraySize++;
}
listSize = listProp.arraySize;
listSize = EditorGUI.IntField(elementRect, "Size", listSize);
@@ -228,10 +222,8 @@ public class ChartEditorHelper
if (listSize != listProp.arraySize)
{
- while (listSize > listProp.arraySize)
- listProp.InsertArrayElementAtIndex(listProp.arraySize);
- while (listSize < listProp.arraySize)
- listProp.DeleteArrayElementAtIndex(listProp.arraySize - 1);
+ while (listSize > listProp.arraySize) listProp.arraySize++;
+ while (listSize < listProp.arraySize) listProp.arraySize--;
}
}
if (listSize > 30)
diff --git a/Runtime/Component/Main/Theme.cs b/Runtime/Component/Main/Theme.cs
index 40ed0eaa..20591f68 100644
--- a/Runtime/Component/Main/Theme.cs
+++ b/Runtime/Component/Main/Theme.cs
@@ -298,11 +298,11 @@ namespace XCharts
{
if (m_Font == null && m_CustomFont == null)
{
- sb.AppendFormat("warning:theme->font is null");
+ sb.AppendFormat("warning:theme->font is null\n");
}
if (m_ColorPalette.Length == 0 && m_CustomColorPalette.Count == 0)
{
- sb.AppendFormat("warning:theme->colorPalette is empty");
+ sb.AppendFormat("warning:theme->colorPalette is empty\n");
}
for (int i = 0; i < m_ColorPalette.Length; i++)
{
diff --git a/Runtime/Component/Main/Tooltip.cs b/Runtime/Component/Main/Tooltip.cs
index fb624604..a62a8273 100644
--- a/Runtime/Component/Main/Tooltip.cs
+++ b/Runtime/Component/Main/Tooltip.cs
@@ -97,17 +97,17 @@ namespace XCharts
///
/// 提示框总内容的字符串模版格式器。支持用 \n 换行。当formatter不为空时,优先使用formatter,否则使用itemFormatter。
/// 模板变量有{.}、{a}、{b}、{c}、{d}。
- /// {.}表示带动态颜色的圆点。
- /// {a}为系列名serie的name。
- /// {b}为数据项名serieData的name,或者类目值(如折线图的X轴)。
- /// {c}为数值。
- /// {d}为百分比值,注意不带%号。
+ /// {.}为当前所指示或index为0的serie的对应颜色的圆点。
+ /// {a}为当前所指示或index为0的serie的系列名name。
+ /// {b}为当前所指示或index为0的serie的数据项serieData的name,或者类目值(如折线图的X轴)。
+ /// {c}为当前所指示或index为0的serie的y维(dimesion为1)的数值。
+ /// {d}为当前所指示或index为0的serie的y维(dimesion为1)百分比值,注意不带%号。
/// {.1}表示指定index为1的serie对应颜色的圆点。
- /// {a1}、{b1}、{c1}中的1表示指定index为1的serie,{a}默认index为0的serie。
+ /// {a1}、{b1}、{c1}中的1表示指定index为1的serie。
/// {c1:2}表示索引为1的serie的当前指示数据项的第3个数据(一个数据项有多个数据,index为2表示第3个数据)。
/// {c1:2-2}表示索引为1的serie的第3个数据项的第3个数据(也就是要指定第几个数据项时必须要指定第几个数据)。
/// {d1:2:f2}表示单独指定了数值的格式化字符串为f2(不指定时用numericFormatter)。
- /// 示例:"{a}:{c}"、"{a1}:{c1:f1}"、"{a1}:{c1:1f1}"
+ /// 示例:"{a}:{c}"、"{a1}:{c1:f1}"、"{a1}:{c1:0:f1}"、"{a1}:{c1:1-1:f1}"、
///
public string formatter { get { return m_Formatter; } set { m_Formatter = value; } }
///
diff --git a/Runtime/Component/Sub/ItemStyle.cs b/Runtime/Component/Sub/ItemStyle.cs
index f2bd51ce..8c2cad56 100644
--- a/Runtime/Component/Sub/ItemStyle.cs
+++ b/Runtime/Component/Sub/ItemStyle.cs
@@ -65,10 +65,15 @@ namespace XCharts
m_Opacity = 1;
m_TooltipFormatter = null;
m_NumericFormatter = "";
- m_CornerRadius[0] = 0;
- m_CornerRadius[1] = 0;
- m_CornerRadius[2] = 0;
- m_CornerRadius[3] = 0;
+ if (m_CornerRadius == null)
+ {
+ m_CornerRadius = new float[] { 0, 0, 0, 0 };
+ }
+ else
+ {
+ for (int i = 0; i < m_CornerRadius.Length; i++)
+ m_CornerRadius[i] = 0;
+ }
}
///
diff --git a/Runtime/Helper/CheckHelper.cs b/Runtime/Helper/CheckHelper.cs
index 789adf20..e504e8bc 100644
--- a/Runtime/Helper/CheckHelper.cs
+++ b/Runtime/Helper/CheckHelper.cs
@@ -117,7 +117,7 @@ namespace XCharts
if (serie.dataCount > 0)
{
allDataIsEmpty = false;
- for (int i = 1; i < serie.dataCount; i++)
+ for (int i = 0; i < serie.dataCount; i++)
{
var serieData = serie.GetSerieData(i);
for (int j = 1; j < serieData.data.Count; j++)
diff --git a/Runtime/Helper/FormatterHelper.cs b/Runtime/Helper/FormatterHelper.cs
index a62e7cfa..5fca6245 100644
--- a/Runtime/Helper/FormatterHelper.cs
+++ b/Runtime/Helper/FormatterHelper.cs
@@ -47,13 +47,12 @@ namespace XCharts
if (argsCount <= 0) continue;
int targetIndex = 0;
char p = GetSerieIndex(args[0].ToString(), ref targetIndex);
- if (serie == null)
+ if (targetIndex >= 0)
{
- if (targetIndex == -1) continue;
serie = series.GetSerie(targetIndex);
if (serie == null) continue;
}
- else
+ else if (serie != null)
{
targetIndex = serie.index;
}
@@ -150,7 +149,7 @@ namespace XCharts
private static char GetSerieIndex(string strType, ref int index)
{
- index = 0;
+ index = -1;
if (strType.Length > 1)
{
if (!int.TryParse(strType.Substring(1), out index))
diff --git a/Runtime/Internal/Helper/TooltipHelper.cs b/Runtime/Internal/Helper/TooltipHelper.cs
index 350a5d72..feb762a9 100644
--- a/Runtime/Internal/Helper/TooltipHelper.cs
+++ b/Runtime/Internal/Helper/TooltipHelper.cs
@@ -218,14 +218,14 @@ namespace XCharts
var itemTitle = title;
if (!string.IsNullOrEmpty(itemTitle))
{
- FormatterHelper.ReplaceContent(ref itemTitle, dataIndex, tooltip.numericFormatter, serie, null, themeInfo, category, dataZoom);
+ FormatterHelper.ReplaceContent(ref itemTitle, dataIndex, tooltip.numericFormatter, serie, series, themeInfo, category, dataZoom);
sb.Append(itemTitle).Append(FormatterHelper.PH_NN);
}
var dataIndexList = tooltip.runtimeSerieDataIndex[serie.index];
foreach (var tempIndex in dataIndexList)
{
string content = itemFormatter;
- var foundDot = FormatterHelper.ReplaceContent(ref content, tempIndex, tooltip.numericFormatter, serie, null, themeInfo, category, dataZoom);
+ var foundDot = FormatterHelper.ReplaceContent(ref content, tempIndex, tooltip.numericFormatter, serie, series, themeInfo, category, dataZoom);
if (!foundDot)
{
sb.Append(ChartCached.ColorToDotStr(themeInfo.GetColor(serie.index)));
@@ -242,7 +242,7 @@ namespace XCharts
needCategory = needCategory || (serie.type == SerieType.Line || serie.type == SerieType.Bar);
if (formatTitle)
{
- FormatterHelper.ReplaceContent(ref title, dataIndex, tooltip.numericFormatter, null, series, themeInfo, category, dataZoom);
+ FormatterHelper.ReplaceContent(ref title, dataIndex, tooltip.numericFormatter, serie, series, themeInfo, category, dataZoom);
}
if (serie.show)
{
@@ -254,7 +254,7 @@ namespace XCharts
continue;
}
string content = itemFormatter;
- FormatterHelper.ReplaceContent(ref content, dataIndex, tooltip.numericFormatter, serie, null, themeInfo, category, dataZoom);
+ FormatterHelper.ReplaceContent(ref content, dataIndex, tooltip.numericFormatter, serie, series, themeInfo, category, dataZoom);
if (!first) sb.Append(FormatterHelper.PH_NN);
sb.Append(ChartCached.ColorToDotStr(themeInfo.GetColor(i)));
sb.Append(content);