diff --git a/CHANGELOG.md b/CHANGELOG.md index d5fa1199..a6c7891f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # 更新日志 +* (2020.02.13) 增加`BaseChart.RefreshTooltip()`接口立即重新初始化`Tooltip`组件 +* (2020.02.13) 增加`Tooltip`的`textStyle`参数配置内容文本样式,去掉`fontSize`和`fontStyle`参数 +* (2020.02.13) 增加`TextStyle`的`lineSpacing`参数配置行间距 * (2020.02.11) 增加`Radar`的`splitLine`参数配置分割线,去掉`lineStyle`参数 * (2020.02.11) 增加`Tooltip`的`backgroundImage`参数配置背景图 * (2020.02.11) 增加`Tooltip`的`paddingLeftRight`和`paddingTopBottom`参数配置文字和边框的间距 diff --git a/Documentation/XChartsAPI.md b/Documentation/XChartsAPI.md index 2d0a464b..c8361dc0 100644 --- a/Documentation/XChartsAPI.md +++ b/Documentation/XChartsAPI.md @@ -40,6 +40,7 @@ * `BaseChart.IsActiveByLegend(string legendName)`:获得指定图例名字的系列是否显示。 * `BaseChart.RefreshChart()`:在下一帧刷新图表。 * `BaseChart.RefreshLabel()`:在下一帧刷新文本标签。 +* `BaseChart.RefreshTooltip()`:立即刷新`Tooltip`组件。 * `BaseChart.UpdateTheme(Theme theme)`:切换图表主题。 * `BaseChart.AnimationEnable(bool flag)`:启用或关闭起始动画。 * `BaseChart.AnimationStart()`:开始初始动画。 diff --git a/Documentation/XCharts配置项手册.md b/Documentation/XCharts配置项手册.md index bfd30455..427b6177 100644 --- a/Documentation/XCharts配置项手册.md +++ b/Documentation/XCharts配置项手册.md @@ -171,6 +171,7 @@ * `color`:颜色。 * `fontSize`:字体大小。 * `fontStyle`:字体风格。 +* `lineSpacing`:行间距。 ## `Tooltip` @@ -197,11 +198,10 @@ * `minHeight`:最小高度。当同时设置 f`ixedHeight` 和 `minHeight` 时,`fixedHeight` 比 `minHeight` 优先级高。 * `paddingLeftRight`:文字和边框的左右边距。 * `paddingTopBottom`:文字和边框的上下边距。 -* `fontSize`:文字的字体大小。 -* `fontStyle`:文字的字体风格。 * `backgroundImage`:提示框的背景图。 * `forceENotation`:是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。 * `lineStyle`:指示器线条样式 [LineStyle](#LineStyle)。 +* `textStyle`:显示内容文本样式 [TextStyle](#TextStyle)。 ## `DataZoom` diff --git a/Editor/PropertyDrawers/TextStyleDrawer.cs b/Editor/PropertyDrawers/TextStyleDrawer.cs index 38f9713e..3af4bb76 100644 --- a/Editor/PropertyDrawers/TextStyleDrawer.cs +++ b/Editor/PropertyDrawers/TextStyleDrawer.cs @@ -14,7 +14,7 @@ namespace XCharts [CustomPropertyDrawer(typeof(TextStyle), true)] public class TextStyleDrawer : PropertyDrawer { - //private Dictionary m_TextStyleToggle = new Dictionary(); + private Dictionary m_TextStyleToggle = new Dictionary(); public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label) { @@ -25,38 +25,40 @@ namespace XCharts SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize"); SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle"); SerializedProperty m_Offset = prop.FindPropertyRelative("m_Offset"); - // ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TextStyleToggle, prop, "Text Style"); - // drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - // if (ChartEditorHelper.IsToggle(m_TextStyleToggle, prop)) - // { - // ++EditorGUI.indentLevel; - EditorGUI.PropertyField(drawRect, m_Rotate); + SerializedProperty m_LineSpacing = prop.FindPropertyRelative("m_LineSpacing"); + ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TextStyleToggle, prop, null,null,false); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - EditorGUI.PropertyField(drawRect, m_Offset); - drawRect.y += EditorGUI.GetPropertyHeight(m_Offset); - EditorGUI.PropertyField(drawRect, m_Color); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - EditorGUI.PropertyField(drawRect, m_FontSize); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - EditorGUI.PropertyField(drawRect, m_FontStyle); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - // --EditorGUI.indentLevel; - // } + if (ChartEditorHelper.IsToggle(m_TextStyleToggle, prop)) + { + ++EditorGUI.indentLevel; + EditorGUI.PropertyField(drawRect, m_Rotate); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, m_Offset); + drawRect.y += EditorGUI.GetPropertyHeight(m_Offset); + EditorGUI.PropertyField(drawRect, m_Color); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, m_FontSize); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, m_FontStyle); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, m_LineSpacing); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + --EditorGUI.indentLevel; + } } public override float GetPropertyHeight(SerializedProperty prop, GUIContent label) { - // float height = 0; - // if (ChartEditorHelper.IsToggle(m_TextStyleToggle, prop)) - // { - // height += 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing; - // } - // else - // { - // height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing; - // } - float height = 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing; - height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Offset")); + float height = 0; + if (ChartEditorHelper.IsToggle(m_TextStyleToggle, prop)) + { + height += 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing; + height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Offset")); + } + else + { + height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing; + } return height; } } diff --git a/Editor/PropertyDrawers/TitleDrawer.cs b/Editor/PropertyDrawers/TitleDrawer.cs index 7e7cb324..0b774860 100644 --- a/Editor/PropertyDrawers/TitleDrawer.cs +++ b/Editor/PropertyDrawers/TitleDrawer.cs @@ -34,19 +34,16 @@ namespace XCharts { EditorGUI.PropertyField(drawRect, text); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - ++EditorGUI.indentLevel; - EditorGUI.PropertyField(drawRect, m_TextStyle); - drawRect.y += EditorGUI.GetPropertyHeight(m_TextStyle); - --EditorGUI.indentLevel; EditorGUI.PropertyField(drawRect, subText); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - ++EditorGUI.indentLevel; - EditorGUI.PropertyField(drawRect, m_SubTextStyle); - drawRect.y += EditorGUI.GetPropertyHeight(m_SubTextStyle); - --EditorGUI.indentLevel; EditorGUI.PropertyField(drawRect, m_ItemGap, new GUIContent("Item Gap")); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, location); + drawRect.y += EditorGUI.GetPropertyHeight(location); + EditorGUI.PropertyField(drawRect, m_TextStyle); + drawRect.y += EditorGUI.GetPropertyHeight(m_TextStyle); + EditorGUI.PropertyField(drawRect, m_SubTextStyle); + drawRect.y += EditorGUI.GetPropertyHeight(m_SubTextStyle); } --EditorGUI.indentLevel; } diff --git a/Editor/PropertyDrawers/TooltipDrawer.cs b/Editor/PropertyDrawers/TooltipDrawer.cs index 50fe7255..77edf907 100644 --- a/Editor/PropertyDrawers/TooltipDrawer.cs +++ b/Editor/PropertyDrawers/TooltipDrawer.cs @@ -28,13 +28,12 @@ namespace XCharts SerializedProperty m_FixedHeight = prop.FindPropertyRelative("m_FixedHeight"); SerializedProperty m_MinWidth = prop.FindPropertyRelative("m_MinWidth"); SerializedProperty m_MinHeight = prop.FindPropertyRelative("m_MinHeight"); - SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize"); - SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle"); SerializedProperty m_ForceENotation = prop.FindPropertyRelative("m_ForceENotation"); SerializedProperty m_PaddingLeftRight = prop.FindPropertyRelative("m_PaddingLeftRight"); SerializedProperty m_PaddingTopBottom = prop.FindPropertyRelative("m_PaddingTopBottom"); SerializedProperty m_BackgroundImage = prop.FindPropertyRelative("m_BackgroundImage"); SerializedProperty m_LineStyle = prop.FindPropertyRelative("m_LineStyle"); + SerializedProperty m_TextStyle = prop.FindPropertyRelative("m_TextStyle"); ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TooltipModuleToggle, "Tooltip", show); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; @@ -61,16 +60,14 @@ namespace XCharts drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, m_PaddingTopBottom); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - EditorGUI.PropertyField(drawRect, m_FontSize); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - EditorGUI.PropertyField(drawRect, m_FontStyle); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, m_BackgroundImage); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, m_ForceENotation); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, m_LineStyle); drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle); + EditorGUI.PropertyField(drawRect, m_TextStyle); + drawRect.y += EditorGUI.GetPropertyHeight(m_TextStyle); EditorGUI.indentLevel--; } } @@ -78,8 +75,9 @@ namespace XCharts public override float GetPropertyHeight(SerializedProperty prop, GUIContent label) { if (m_TooltipModuleToggle) - return 15 * EditorGUIUtility.singleLineHeight + 14 * EditorGUIUtility.standardVerticalSpacing + - EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle")); + return 13 * EditorGUIUtility.singleLineHeight + 12 * EditorGUIUtility.standardVerticalSpacing + + EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle")) + + EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TextStyle")); else return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; } diff --git a/Runtime/API/BaseChart_API.cs b/Runtime/API/BaseChart_API.cs index faf23efd..9c78b82c 100644 --- a/Runtime/API/BaseChart_API.cs +++ b/Runtime/API/BaseChart_API.cs @@ -482,6 +482,14 @@ namespace XCharts m_ReinitLabel = true; } + /// + /// 刷新Tooltip组件。 + /// + public void RefreshTooltip() + { + InitTooltip(); + } + /// /// Update chart theme. /// 切换图表主题。 diff --git a/Runtime/Component/Main/Serie.cs b/Runtime/Component/Main/Serie.cs index 737983f7..57b3b28c 100644 --- a/Runtime/Component/Main/Serie.cs +++ b/Runtime/Component/Main/Serie.cs @@ -194,7 +194,7 @@ namespace XCharts [System.Serializable] public class Serie : MainComponent { - [SerializeField] [DefaultValue("true")] private bool m_Show = true; + [SerializeField] private bool m_Show = true; [SerializeField] private SerieType m_Type; [SerializeField] private string m_Name; [SerializeField] private string m_Stack; @@ -246,7 +246,7 @@ namespace XCharts [SerializeField] [Range(1, 10)] private int m_ShowDataDimension; [SerializeField] private bool m_ShowDataName; [SerializeField] private bool m_ShowDataIcon; - [SerializeField] private bool m_Clip = false; + [SerializeField] private bool m_Clip = true; [SerializeField] private List m_Data = new List(); diff --git a/Runtime/Component/Main/Tooltip.cs b/Runtime/Component/Main/Tooltip.cs index e7b081ed..6661c454 100644 --- a/Runtime/Component/Main/Tooltip.cs +++ b/Runtime/Component/Main/Tooltip.cs @@ -1,4 +1,5 @@ -/******************************************/ +using System.Collections.ObjectModel; +/******************************************/ /* */ /* Copyright (c) 2018 monitor1394 */ /* https://github.com/monitor1394 */ @@ -8,6 +9,8 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; +using System; +using UnityEngine.EventSystems; namespace XCharts { @@ -55,12 +58,11 @@ namespace XCharts [SerializeField] private float m_FixedHeight = 0; [SerializeField] private float m_MinWidth = 0; [SerializeField] private float m_MinHeight = 0; - [SerializeField] private int m_FontSize = 18; - [SerializeField] private FontStyle m_FontStyle = FontStyle.Normal; [SerializeField] private bool m_ForceENotation = false; [SerializeField] private float m_PaddingLeftRight = 5f; [SerializeField] private float m_PaddingTopBottom = 5f; [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); private GameObject m_GameObject; @@ -138,16 +140,10 @@ namespace XCharts /// 最小高度。如若 fixedHeight 设有值,优先取 fixedHeight。 /// public float minHeight { get { return m_MinHeight; } set { m_MinHeight = value; } } - /// - /// font size. - /// 文字的字体大小。 - /// - public int fontSize { get { return m_FontSize; } set { m_FontSize = value; } } - /// - /// font style. - /// 文字的字体风格。 - /// - public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } } + [Obsolete("Use Tooltip.textStyle.fontSize instead.", true)] + public int fontSize { get; set; } + [Obsolete("Use Tooltip.textStyle.fontStyle instead.", true)] + public FontStyle fontStyle { get; set; } /// /// 是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。 /// @@ -168,6 +164,10 @@ namespace XCharts /// public Sprite backgroundImage { get { return m_BackgroundImage; } set { m_BackgroundImage = value; SetBackground(m_BackgroundImage); } } /// + /// 提示框内容文本样式。 + /// + public TextStyle textStyle { get { return m_TextStyle; } set { if (value != null) m_TextStyle = value; } } + /// /// 指示线样式。 /// public LineStyle lineStyle { get { return m_LineStyle; } set { if (value != null) m_LineStyle = value; } } diff --git a/Runtime/Component/Sub/TextStyle.cs b/Runtime/Component/Sub/TextStyle.cs index 79518a4a..787f0803 100644 --- a/Runtime/Component/Sub/TextStyle.cs +++ b/Runtime/Component/Sub/TextStyle.cs @@ -23,6 +23,7 @@ namespace XCharts [SerializeField] private Color m_Color = Color.clear; [SerializeField] private int m_FontSize = 18; [SerializeField] private FontStyle m_FontStyle = FontStyle.Normal; + [SerializeField] private float m_LineSpacing = 1; /// /// Rotation of text. @@ -52,6 +53,11 @@ namespace XCharts /// 文本字体的风格。 /// public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } } + /// + /// text line spacing. + /// 行间距。 + /// + public float lineSpacing { get { return m_LineSpacing; } set { m_LineSpacing = value; } } public TextStyle() { @@ -90,6 +96,7 @@ namespace XCharts this.color = style.color; this.rotate = style.rotate; this.offset = style.offset; + this.lineSpacing = style.lineSpacing; } public TextStyle Clone() @@ -100,6 +107,7 @@ namespace XCharts textStyle.fontSize = fontSize; textStyle.fontStyle = fontStyle; textStyle.offset = offset; + textStyle.lineSpacing = lineSpacing; return textStyle; } @@ -129,6 +137,7 @@ namespace XCharts fontSize == other.fontSize && fontStyle == other.fontStyle && offset == other.offset && + lineSpacing == other.lineSpacing && ChartHelper.IsValueEqualsColor(m_Color, other.color); } diff --git a/Runtime/HeatmapChart.cs b/Runtime/HeatmapChart.cs index a38c40ae..edb1fd21 100644 --- a/Runtime/HeatmapChart.cs +++ b/Runtime/HeatmapChart.cs @@ -85,7 +85,7 @@ namespace XCharts } #endif - protected override void RefreshTooltip() + protected override void UpdateTooltip() { var xData = m_Tooltip.runtimeXValues[0]; var yData = m_Tooltip.runtimeYValues[0]; diff --git a/Runtime/Internal/BaseChart.cs b/Runtime/Internal/BaseChart.cs index a1e101a4..37bb7ec3 100644 --- a/Runtime/Internal/BaseChart.cs +++ b/Runtime/Internal/BaseChart.cs @@ -142,6 +142,11 @@ namespace XCharts m_Series = Series.defaultSeries; Awake(); } + + protected override void OnValidate() + { + //TODO: + } #endif protected override void OnDestroy() @@ -170,8 +175,8 @@ namespace XCharts Text titleText = ChartHelper.AddTextObject(s_TitleObjectName, titleObject.transform, m_ThemeInfo.font, m_ThemeInfo.titleTextColor, anchor, anchorMin, anchorMax, pivot, - new Vector2(titleWid, m_Title.textStyle.fontSize), m_Title.textStyle.fontSize, m_Title.textStyle.rotate, - m_Title.textStyle.fontStyle); + new Vector2(titleWid, m_Title.textStyle.fontSize), m_Title.textStyle.fontSize, + m_Title.textStyle.rotate, m_Title.textStyle.fontStyle, m_Title.textStyle.lineSpacing); titleText.alignment = anchor; titleText.gameObject.SetActive(m_Title.show); @@ -181,7 +186,7 @@ namespace XCharts Text subText = ChartHelper.AddTextObject(s_TitleObjectName + "_sub", titleObject.transform, m_ThemeInfo.font, m_ThemeInfo.titleSubTextColor, anchor, anchorMin, anchorMax, pivot, new Vector2(titleWid, m_Title.subTextStyle.fontSize), m_Title.subTextStyle.fontSize, - m_Title.subTextStyle.rotate, m_Title.subTextStyle.fontStyle); + m_Title.subTextStyle.rotate, m_Title.subTextStyle.fontStyle, m_Title.subTextStyle.lineSpacing); subText.alignment = anchor; subText.gameObject.SetActive(m_Title.show && !string.IsNullOrEmpty(m_Title.subText)); @@ -232,7 +237,7 @@ namespace XCharts var objName = s_LegendObjectName + "_" + i + "_" + datas[i]; Button btn = ChartHelper.AddButtonObject(objName, legendObject.transform, m_ThemeInfo.font, m_Legend.itemFontSize, m_ThemeInfo.legendTextColor, anchor, - anchorMin, anchorMax, pivot, new Vector2(m_Legend.itemWidth, m_Legend.itemHeight)); + anchorMin, anchorMax, pivot, new Vector2(m_Legend.itemWidth, m_Legend.itemHeight), 1); var bgColor = IsActiveByLegend(datas[i]) ? m_ThemeInfo.GetColor(readIndex) : m_ThemeInfo.legendUnableColor; m_Legend.SetButton(legendName, btn, totalLegend); @@ -349,8 +354,9 @@ namespace XCharts var pivot = new Vector2(0.5f, 0.5f); var fontSize = 10; var sizeDelta = new Vector2(50, fontSize + 2); - var txt = ChartHelper.AddTextObject("title_" + i, titleObject.transform, m_ThemeInfo.font, color, TextAnchor.MiddleCenter, - anchorMin, anchorMax, pivot, sizeDelta, textStyle.fontSize, textStyle.rotate, textStyle.fontStyle); + var txt = ChartHelper.AddTextObject("title_" + i, titleObject.transform, m_ThemeInfo.font, color, + TextAnchor.MiddleCenter, anchorMin, anchorMax, pivot, sizeDelta, textStyle.fontSize, textStyle.rotate, + textStyle.fontStyle, textStyle.lineSpacing); txt.text = ""; txt.transform.localPosition = new Vector2(0, 0); txt.transform.localEulerAngles = Vector2.zero; @@ -372,9 +378,10 @@ namespace XCharts tooltipObject.transform.localPosition = Vector3.zero; DestroyImmediate(tooltipObject.GetComponent()); var parent = tooltipObject.transform; + var textStyle = m_Tooltip.textStyle; ChartHelper.HideAllObject(tooltipObject.transform); GameObject content = ChartHelper.AddTooltipContent("content", parent, m_ThemeInfo.font, - m_Tooltip.fontSize, m_Tooltip.fontStyle); + textStyle.fontSize, textStyle.fontStyle, textStyle.lineSpacing); m_Tooltip.SetObj(tooltipObject); m_Tooltip.SetContentObj(content); m_Tooltip.SetContentBackgroundColor(m_ThemeInfo.tooltipBackgroundColor); @@ -687,7 +694,7 @@ namespace XCharts return show; } - protected virtual void RefreshTooltip() + protected virtual void UpdateTooltip() { } diff --git a/Runtime/Internal/CoordinateChart.cs b/Runtime/Internal/CoordinateChart.cs index 1668f5f0..675f91ec 100644 --- a/Runtime/Internal/CoordinateChart.cs +++ b/Runtime/Internal/CoordinateChart.cs @@ -194,7 +194,7 @@ namespace XCharts if (!IsInCooridate(local)) { m_Tooltip.ClearValue(); - RefreshTooltip(); + UpdateTooltip(); } else { @@ -306,7 +306,7 @@ namespace XCharts if (m_Tooltip.IsSelected()) { m_Tooltip.UpdateContentPos(new Vector2(local.x + 18, local.y - 25)); - RefreshTooltip(); + UpdateTooltip(); if (m_Tooltip.IsDataIndexChanged() || m_Tooltip.type == Tooltip.Type.Corss) { m_Tooltip.UpdateLastDataIndex(); @@ -321,9 +321,9 @@ namespace XCharts } protected StringBuilder sb = new StringBuilder(100); - protected override void RefreshTooltip() + protected override void UpdateTooltip() { - base.RefreshTooltip(); + base.UpdateTooltip(); int index; Axis tempAxis; bool isCartesian = IsValue(); diff --git a/Runtime/Internal/SerieLabelPool.cs b/Runtime/Internal/SerieLabelPool.cs index 041e3e83..155a4702 100644 --- a/Runtime/Internal/SerieLabelPool.cs +++ b/Runtime/Internal/SerieLabelPool.cs @@ -15,14 +15,15 @@ namespace XCharts { private static readonly Stack m_Stack = new Stack(200); - public static GameObject Get(string name, Transform parent, SerieLabel label, Font font, Color color, float iconWidth, float iconHeight) + public static GameObject Get(string name, Transform parent, SerieLabel label, Font font, Color color, + float iconWidth, float iconHeight) { GameObject element; if (m_Stack.Count == 0 || !Application.isPlaying) { element = ChartHelper.AddSerieLabel(name, parent, font, color, label.backgroundColor, label.fontSize, label.fontStyle, label.rotate, - label.backgroundWidth, label.backgroundHeight); + label.backgroundWidth, label.backgroundHeight, 1); ChartHelper.AddIcon("Icon", element.transform, iconWidth, iconHeight); } else diff --git a/Runtime/PieChart.cs b/Runtime/PieChart.cs index 3e67ee9f..a99de3eb 100644 --- a/Runtime/PieChart.cs +++ b/Runtime/PieChart.cs @@ -531,7 +531,7 @@ namespace XCharts if (selected) { m_Tooltip.UpdateContentPos(new Vector2(local.x + 18, local.y - 25)); - RefreshTooltip(); + UpdateTooltip(); } else if (m_Tooltip.IsActive()) { @@ -570,9 +570,9 @@ namespace XCharts } StringBuilder sb = new StringBuilder(); - protected override void RefreshTooltip() + protected override void UpdateTooltip() { - base.RefreshTooltip(); + base.UpdateTooltip(); bool showTooltip = false; foreach (var serie in m_Series.list) { diff --git a/Runtime/RadarChart.cs b/Runtime/RadarChart.cs index 6d2525fb..948a125a 100644 --- a/Runtime/RadarChart.cs +++ b/Runtime/RadarChart.cs @@ -97,7 +97,7 @@ namespace XCharts var textColor = textStyle.color == Color.clear ? (Color)m_ThemeInfo.axisTextColor : textStyle.color; var txt = ChartHelper.AddTextObject(INDICATOR_TEXT + "_" + n + "_" + i, transform, m_ThemeInfo.font, textColor, anchor, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), - new Vector2(txtWid, txtHig), textStyle.fontSize, textStyle.rotate, textStyle.fontStyle); + new Vector2(txtWid, txtHig), textStyle.fontSize, textStyle.rotate, textStyle.fontStyle, textStyle.lineSpacing); txt.text = radar.indicatorList[i].name; txt.gameObject.SetActive(radar.indicator); var txtWidth = txt.preferredWidth; @@ -459,14 +459,14 @@ namespace XCharts else { m_Tooltip.UpdateContentPos(new Vector2(local.x + 18, local.y - 25)); - RefreshTooltip(); + UpdateTooltip(); RefreshChart(); } } - protected override void RefreshTooltip() + protected override void UpdateTooltip() { - base.RefreshTooltip(); + base.UpdateTooltip(); int serieIndex = m_Tooltip.runtimeDataIndex[0]; if (serieIndex < 0) { diff --git a/Runtime/Utility/ChartHelper.cs b/Runtime/Utility/ChartHelper.cs index c123814a..f8e8e288 100644 --- a/Runtime/Utility/ChartHelper.cs +++ b/Runtime/Utility/ChartHelper.cs @@ -163,7 +163,7 @@ namespace XCharts public static Text AddTextObject(string name, Transform parent, Font font, Color color, TextAnchor anchor, Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot, Vector2 sizeDelta, - int fontSize = 14, float rotate = 0, FontStyle fontStyle = FontStyle.Normal) + int fontSize = 14, float rotate = 0, FontStyle fontStyle = FontStyle.Normal, float lineSpacing = 1) { GameObject txtObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta); Text txt = GetOrAddComponent(txtObj); @@ -175,6 +175,7 @@ namespace XCharts txt.horizontalOverflow = HorizontalWrapMode.Overflow; txt.verticalOverflow = VerticalWrapMode.Overflow; txt.color = color; + txt.lineSpacing = lineSpacing; txtObj.transform.localEulerAngles = new Vector3(0, 0, rotate); RectTransform rect = GetOrAddComponent(txtObj); @@ -188,20 +189,21 @@ namespace XCharts public static Button AddButtonObject(string name, Transform parent, Font font, int fontSize, Color color, TextAnchor anchor, Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot, - Vector2 sizeDelta) + Vector2 sizeDelta, float lineSpacing) { GameObject btnObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta); GetOrAddComponent(btnObj); GetOrAddComponent