mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-22 08:50:10 +00:00
增加TextStyle的lineSpacing参数配置行间距
This commit is contained in:
@@ -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`参数配置文字和边框的间距
|
||||
|
||||
@@ -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()`:开始初始动画。
|
||||
|
||||
@@ -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`
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace XCharts
|
||||
[CustomPropertyDrawer(typeof(TextStyle), true)]
|
||||
public class TextStyleDrawer : PropertyDrawer
|
||||
{
|
||||
//private Dictionary<string, bool> m_TextStyleToggle = new Dictionary<string, bool>();
|
||||
private Dictionary<string, bool> m_TextStyleToggle = new Dictionary<string, bool>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -482,6 +482,14 @@ namespace XCharts
|
||||
m_ReinitLabel = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 刷新Tooltip组件。
|
||||
/// </summary>
|
||||
public void RefreshTooltip()
|
||||
{
|
||||
InitTooltip();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update chart theme.
|
||||
/// 切换图表主题。
|
||||
|
||||
@@ -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<SerieData> m_Data = new List<SerieData>();
|
||||
|
||||
|
||||
@@ -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。
|
||||
/// </summary>
|
||||
public float minHeight { get { return m_MinHeight; } set { m_MinHeight = value; } }
|
||||
/// <summary>
|
||||
/// font size.
|
||||
/// 文字的字体大小。
|
||||
/// </summary>
|
||||
public int fontSize { get { return m_FontSize; } set { m_FontSize = value; } }
|
||||
/// <summary>
|
||||
/// font style.
|
||||
/// 文字的字体风格。
|
||||
/// </summary>
|
||||
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; }
|
||||
/// <summary>
|
||||
/// 是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。
|
||||
/// </summary>
|
||||
@@ -168,6 +164,10 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Sprite backgroundImage { get { return m_BackgroundImage; } set { m_BackgroundImage = value; SetBackground(m_BackgroundImage); } }
|
||||
/// <summary>
|
||||
/// 提示框内容文本样式。
|
||||
/// </summary>
|
||||
public TextStyle textStyle { get { return m_TextStyle; } set { if (value != null) m_TextStyle = value; } }
|
||||
/// <summary>
|
||||
/// 指示线样式。
|
||||
/// </summary>
|
||||
public LineStyle lineStyle { get { return m_LineStyle; } set { if (value != null) m_LineStyle = value; } }
|
||||
|
||||
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Rotation of text.
|
||||
@@ -52,6 +53,11 @@ namespace XCharts
|
||||
/// 文本字体的风格。
|
||||
/// </summary>
|
||||
public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } }
|
||||
/// <summary>
|
||||
/// text line spacing.
|
||||
/// 行间距。
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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<Image>());
|
||||
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()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -15,14 +15,15 @@ namespace XCharts
|
||||
{
|
||||
private static readonly Stack<GameObject> m_Stack = new Stack<GameObject>(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
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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<Text>(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<RectTransform>(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<Image>(btnObj);
|
||||
GetOrAddComponent<Button>(btnObj);
|
||||
Text txt = AddTextObject("Text", btnObj.transform, font, color, TextAnchor.MiddleCenter,
|
||||
new Vector2(0, 0), new Vector2(1, 1), new Vector2(0.5f, 0.5f),
|
||||
sizeDelta, fontSize);
|
||||
sizeDelta, fontSize, lineSpacing);
|
||||
txt.rectTransform.offsetMin = Vector2.zero;
|
||||
txt.rectTransform.offsetMax = Vector2.zero;
|
||||
return btnObj.GetComponent<Button>();
|
||||
}
|
||||
|
||||
internal static GameObject AddTooltipContent(string name, Transform parent, Font font, int fontSize, FontStyle fontStyle)
|
||||
internal static GameObject AddTooltipContent(string name, Transform parent, Font font, int fontSize,
|
||||
FontStyle fontStyle, float lineSpacing)
|
||||
{
|
||||
var anchorMax = new Vector2(0, 1);
|
||||
var anchorMin = new Vector2(0, 1);
|
||||
@@ -211,7 +213,7 @@ namespace XCharts
|
||||
var img = GetOrAddComponent<Image>(tooltipObj);
|
||||
img.color = Color.black;
|
||||
Text txt = AddTextObject("Text", tooltipObj.transform, font, Color.white, TextAnchor.UpperLeft,
|
||||
anchorMin, anchorMax, pivot, sizeDelta, fontSize, 0, fontStyle);
|
||||
anchorMin, anchorMax, pivot, sizeDelta, fontSize, 0, fontStyle, lineSpacing);
|
||||
txt.text = "Text";
|
||||
txt.transform.localPosition = new Vector2(3, -3);
|
||||
tooltipObj.transform.localPosition = Vector3.zero;
|
||||
@@ -229,8 +231,9 @@ namespace XCharts
|
||||
return iconObj;
|
||||
}
|
||||
|
||||
internal static GameObject AddSerieLabel(string name, Transform parent, Font font, Color textColor, Color backgroundColor,
|
||||
int fontSize, FontStyle fontStyle, float rotate, float width, float height)
|
||||
internal static GameObject AddSerieLabel(string name, Transform parent, Font font, Color textColor,
|
||||
Color backgroundColor, int fontSize, FontStyle fontStyle, float rotate, float width, float height,
|
||||
float lineSpacing)
|
||||
{
|
||||
var anchorMin = new Vector2(0.5f, 0.5f);
|
||||
var anchorMax = new Vector2(0.5f, 0.5f);
|
||||
@@ -241,7 +244,7 @@ namespace XCharts
|
||||
//img.color = backgroundColor;
|
||||
labelObj.transform.localEulerAngles = new Vector3(0, 0, rotate);
|
||||
Text txt = AddTextObject("Text", labelObj.transform, font, textColor, TextAnchor.MiddleCenter,
|
||||
anchorMin, anchorMax, pivot, sizeDelta, fontSize, 0, fontStyle);
|
||||
anchorMin, anchorMax, pivot, sizeDelta, fontSize, 0, fontStyle, lineSpacing);
|
||||
txt.text = "Text";
|
||||
txt.transform.localPosition = new Vector2(0, 0);
|
||||
txt.transform.localEulerAngles = Vector3.zero;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace XCharts
|
||||
public class XChartsMgr : MonoBehaviour
|
||||
{
|
||||
public const string version = "1.2.0";
|
||||
public const int date = 20200211;
|
||||
public const int date = 20200213;
|
||||
|
||||
[SerializeField] private string m_NowVersion;
|
||||
[SerializeField] private string m_NewVersion;
|
||||
|
||||
Reference in New Issue
Block a user