diff --git a/CHANGELOG.md b/CHANGELOG.md
index 30dd12fa..61265d75 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
# 更新日志
+* (2020.07.07) 增加`Tooltip`的`offset`参数配置偏移
* (2020.07.06) 增加`LiquidChart`水位图
* (2020.07.01) 增加`PolarChart`极坐标图表
* (2020.06.25) 发布`v1.5.2`版本
diff --git a/Documentation/XCharts配置项手册.md b/Documentation/XCharts配置项手册.md
index decdcfc8..46ef056a 100644
--- a/Documentation/XCharts配置项手册.md
+++ b/Documentation/XCharts配置项手册.md
@@ -232,6 +232,8 @@
* `backgroundImage`:提示框的背景图。
* `ignoreDataDefaultContent`:被忽略数据的默认显示字符信息。
* `alwayShow`:是否触发后一直显示。
+* `offset`:`(since v1.5.3)`提示框相对于鼠标位置的偏移。
+
* `lineStyle`:指示器线条样式 [LineStyle](#LineStyle)。
* `textStyle`:显示内容文本样式 [TextStyle](#TextStyle)。
diff --git a/Editor/PropertyDrawers/TooltipDrawer.cs b/Editor/PropertyDrawers/TooltipDrawer.cs
index f3409ee7..3b440467 100644
--- a/Editor/PropertyDrawers/TooltipDrawer.cs
+++ b/Editor/PropertyDrawers/TooltipDrawer.cs
@@ -35,6 +35,7 @@ namespace XCharts
SerializedProperty m_IgnoreDataDefaultContent = prop.FindPropertyRelative("m_IgnoreDataDefaultContent");
SerializedProperty m_LineStyle = prop.FindPropertyRelative("m_LineStyle");
SerializedProperty m_TextStyle = prop.FindPropertyRelative("m_TextStyle");
+ SerializedProperty m_Offset = prop.FindPropertyRelative("m_Offset");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TooltipModuleToggle, "Tooltip", show);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
@@ -67,6 +68,8 @@ namespace XCharts
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_IgnoreDataDefaultContent);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
+ EditorGUI.PropertyField(drawRect, m_Offset);
+ drawRect.y += EditorGUI.GetPropertyHeight(m_Offset);
EditorGUI.PropertyField(drawRect, m_LineStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle);
EditorGUI.PropertyField(drawRect, m_TextStyle);
@@ -79,6 +82,7 @@ namespace XCharts
{
if (m_TooltipModuleToggle)
return 14 * EditorGUIUtility.singleLineHeight + 13 * EditorGUIUtility.standardVerticalSpacing +
+ EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Offset")) +
EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle")) +
EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TextStyle"));
else
diff --git a/Runtime/Component/Main/Tooltip.cs b/Runtime/Component/Main/Tooltip.cs
index 1600e566..29772472 100644
--- a/Runtime/Component/Main/Tooltip.cs
+++ b/Runtime/Component/Main/Tooltip.cs
@@ -64,6 +64,7 @@ namespace XCharts
[SerializeField] private float m_PaddingTopBottom = 5f;
[SerializeField] private string m_IgnoreDataDefaultContent = "-";
[SerializeField] private bool m_AlwayShow = false;
+ [SerializeField] private Vector2 m_Offset = new Vector2(18f, -25f);
[SerializeField] private Sprite m_BackgroundImage;
[SerializeField] private TextStyle m_TextStyle = new TextStyle(18, FontStyle.Normal);
[SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.Solid, 0.7f);
@@ -175,6 +176,10 @@ namespace XCharts
///
public bool alwayShow { get { return m_AlwayShow; } set { m_AlwayShow = value; } }
///
+ /// 提示框相对于鼠标位置的偏移。
+ ///
+ public Vector2 offset { get { return m_Offset; } set { m_Offset = value; } }
+ ///
/// 提示框内容文本样式。
///
public TextStyle textStyle
diff --git a/Runtime/Internal/CoordinateChart.cs b/Runtime/Internal/CoordinateChart.cs
index c003d114..14f7dfbb 100644
--- a/Runtime/Internal/CoordinateChart.cs
+++ b/Runtime/Internal/CoordinateChart.cs
@@ -358,7 +358,7 @@ namespace XCharts
}
if (m_Tooltip.IsSelected())
{
- m_Tooltip.UpdateContentPos(new Vector2(local.x + 18, local.y - 25));
+ m_Tooltip.UpdateContentPos(local + m_Tooltip.offset);
UpdateTooltip();
if (m_Tooltip.IsDataIndexChanged() || m_Tooltip.type == Tooltip.Type.Corss)
{
diff --git a/Runtime/Internal/Helper/SerieDataHelper.cs.meta b/Runtime/Internal/Helper/SerieDataHelper.cs.meta
deleted file mode 100644
index b497cb52..00000000
--- a/Runtime/Internal/Helper/SerieDataHelper.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: e78d1b28fc61d4b1b995a1eca16cf3b6
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/Internal/Helper/VisualMapHelper.cs.meta b/Runtime/Internal/Helper/VisualMapHelper.cs.meta
deleted file mode 100644
index 2183dfde..00000000
--- a/Runtime/Internal/Helper/VisualMapHelper.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 15e5106bd46f5484596429d512f6af5d
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Runtime/PieChart.cs b/Runtime/PieChart.cs
index 9b60b692..633c30ce 100644
--- a/Runtime/PieChart.cs
+++ b/Runtime/PieChart.cs
@@ -457,7 +457,7 @@ namespace XCharts
}
if (selected)
{
- m_Tooltip.UpdateContentPos(new Vector2(local.x + 18, local.y - 25));
+ m_Tooltip.UpdateContentPos(local + m_Tooltip.offset);
UpdateTooltip();
}
else if (m_Tooltip.IsActive())
diff --git a/Runtime/PolarChart.cs b/Runtime/PolarChart.cs
index 4c404d12..83683177 100644
--- a/Runtime/PolarChart.cs
+++ b/Runtime/PolarChart.cs
@@ -576,7 +576,7 @@ namespace XCharts
break;
}
}
- m_Tooltip.UpdateContentPos(new Vector2(local.x + 18, local.y - 25));
+ m_Tooltip.UpdateContentPos(local + m_Tooltip.offset);
UpdateTooltip();
if (m_Tooltip.type == Tooltip.Type.Corss)
{
diff --git a/Runtime/RadarChart.cs b/Runtime/RadarChart.cs
index fd399957..e806f457 100644
--- a/Runtime/RadarChart.cs
+++ b/Runtime/RadarChart.cs
@@ -678,7 +678,7 @@ namespace XCharts
}
else
{
- m_Tooltip.UpdateContentPos(new Vector2(local.x + 18, local.y - 25));
+ m_Tooltip.UpdateContentPos(local + m_Tooltip.offset);
UpdateTooltip();
RefreshChart();
}
diff --git a/Runtime/RingChart.cs b/Runtime/RingChart.cs
index 6442d92f..f6382b19 100644
--- a/Runtime/RingChart.cs
+++ b/Runtime/RingChart.cs
@@ -279,7 +279,7 @@ namespace XCharts
}
if (selected)
{
- m_Tooltip.UpdateContentPos(new Vector2(local.x + 18, local.y - 25));
+ m_Tooltip.UpdateContentPos(local + m_Tooltip.offset);
UpdateTooltip();
}
else if (m_Tooltip.IsActive())
diff --git a/Runtime/ScatterChart.cs b/Runtime/ScatterChart.cs
index bca81f8b..d014a386 100644
--- a/Runtime/ScatterChart.cs
+++ b/Runtime/ScatterChart.cs
@@ -99,7 +99,7 @@ namespace XCharts
}
if (selected)
{
- m_Tooltip.UpdateContentPos(new Vector2(local.x + 18, local.y - 25));
+ m_Tooltip.UpdateContentPos(local + m_Tooltip.offset);
UpdateTooltip();
}
else if (m_Tooltip.IsActive())