mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-18 14:30:10 +00:00
增加SerieSymbol关于显示间隔的相关配置
This commit is contained in:
@@ -21,7 +21,7 @@ public class Demo_Dynamic : MonoBehaviour
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponentInChildren<CoordinateChart>();
|
||||
//chart.RemoveData();
|
||||
chart.RemoveData();
|
||||
var serie = chart.AddSerie(SerieType.Line);
|
||||
serie.symbol.type = SerieSymbolType.None;
|
||||
serie.maxCache = maxCacheDataNumber;
|
||||
|
||||
@@ -22,6 +22,9 @@ namespace XCharts
|
||||
SerializedProperty m_SelectedDataScale = prop.FindPropertyRelative("m_SelectedDataScale");
|
||||
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
|
||||
SerializedProperty m_Opacity = prop.FindPropertyRelative("m_Opacity");
|
||||
SerializedProperty m_StartIndex = prop.FindPropertyRelative("m_StartIndex");
|
||||
SerializedProperty m_Interval = prop.FindPropertyRelative("m_Interval");
|
||||
SerializedProperty m_ForceShowLast = prop.FindPropertyRelative("m_ForceShowLast");
|
||||
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_SerieSymbolToggle, prop, null, m_Type, false);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
@@ -55,6 +58,12 @@ namespace XCharts
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Opacity);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_StartIndex);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Interval);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_ForceShowLast);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
@@ -68,13 +77,13 @@ namespace XCharts
|
||||
switch (sizeType)
|
||||
{
|
||||
case SerieSymbolSizeType.Custom:
|
||||
return 6 * EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing;
|
||||
return 9 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
|
||||
case SerieSymbolSizeType.FromData:
|
||||
return 7 * EditorGUIUtility.singleLineHeight + 7 * EditorGUIUtility.standardVerticalSpacing;
|
||||
return 10 * EditorGUIUtility.singleLineHeight + 10 * EditorGUIUtility.standardVerticalSpacing;
|
||||
case SerieSymbolSizeType.Callback:
|
||||
return 6 * EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing;
|
||||
return 9 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
return 6 * EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing;
|
||||
return 9 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -80,8 +80,16 @@ namespace XCharts
|
||||
{
|
||||
for (int i = 0; i < m_Series.Count; i++)
|
||||
{
|
||||
if ((string.IsNullOrEmpty(name) && string.IsNullOrEmpty(m_Series[i].name))
|
||||
|| name.Equals(m_Series[i].name))
|
||||
bool match = false;
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
if (string.IsNullOrEmpty(m_Series[i].name)) match = true;
|
||||
}
|
||||
else if (name.Equals(m_Series[i].name))
|
||||
{
|
||||
match = true;
|
||||
}
|
||||
if (match)
|
||||
{
|
||||
m_Series[i].index = i;
|
||||
return m_Series[i];
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace XCharts
|
||||
var count = serie.dataPoints.Count;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (!serie.symbol.ShowSymbol(i, count)) continue;
|
||||
if (serie.lineArrow.show)
|
||||
{
|
||||
if (serie.lineArrow.position == LineArrow.Position.Start && i == 0) continue;
|
||||
|
||||
@@ -82,79 +82,85 @@ namespace XCharts
|
||||
[SerializeField] private SymbolSizeCallback m_SelectedSizeCallback;
|
||||
[SerializeField] private Color m_Color;
|
||||
[SerializeField] [Range(0, 1)] private float m_Opacity = 1;
|
||||
[SerializeField] private int m_StartIndex;
|
||||
[SerializeField] private int m_Interval;
|
||||
[SerializeField] private bool m_ForceShowLast = false;
|
||||
|
||||
/// <summary>
|
||||
/// the type of symbol.
|
||||
/// 标记类型。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public SerieSymbolType type { get { return m_Type; } set { m_Type = value; } }
|
||||
/// <summary>
|
||||
/// the type of symbol size.
|
||||
/// 标记图形的大小获取方式。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public SerieSymbolSizeType sizeType { get { return m_SizeType; } set { m_SizeType = value; } }
|
||||
/// <summary>
|
||||
/// the size of symbol.
|
||||
/// 标记的大小。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public float size { get { return m_Size; } set { m_Size = value; } }
|
||||
/// <summary>
|
||||
/// the size of selected symbol.
|
||||
/// 被选中的标记的大小。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public float selectedSize { get { return m_SelectedSize; } set { m_SelectedSize = value; } }
|
||||
/// <summary>
|
||||
/// whitch data index is when the sizeType assined as FromData.
|
||||
/// 当sizeType指定为FromData时,指定的数据源索引。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public int dataIndex { get { return m_DataIndex; } set { m_DataIndex = value; } }
|
||||
/// <summary>
|
||||
/// the scale of data when sizeType assined as FromData.
|
||||
/// 当sizeType指定为FromData时,指定的倍数系数。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public float dataScale { get { return m_DataScale; } set { m_DataScale = value; } }
|
||||
/// <summary>
|
||||
/// the scale of selected data when sizeType assined as FromData.
|
||||
/// 当sizeType指定为FromData时,指定的高亮倍数系数。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public float selectedDataScale { get { return m_SelectedDataScale; } set { m_SelectedDataScale = value; } }
|
||||
/// <summary>
|
||||
/// the callback of size when sizeType assined as Callback.
|
||||
/// 当sizeType指定为Callback时,指定的回调函数。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public SymbolSizeCallback sizeCallback { get { return m_SizeCallback; } set { m_SizeCallback = value; } }
|
||||
/// <summary>
|
||||
/// the callback of size when sizeType assined as Callback.
|
||||
/// 当sizeType指定为Callback时,指定的高亮回调函数。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public SymbolSizeCallback selectedSizeCallback { get { return m_SelectedSizeCallback; } set { m_SelectedSizeCallback = value; } }
|
||||
/// <summary>
|
||||
/// the color of symbol,default from serie.
|
||||
/// 标记图形的颜色,默认和系列一致。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public Color color { get { return m_Color; } set { m_Color = value; } }
|
||||
/// <summary>
|
||||
/// the opacity of color.
|
||||
/// 图形标记的透明度。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public float opacity { get { return m_Opacity; } set { m_Opacity = value; } }
|
||||
/// <summary>
|
||||
/// the index start to show symbol.
|
||||
/// 开始显示图形标记的索引。
|
||||
/// </summary>
|
||||
public int startIndex { get { return m_StartIndex; } set { m_StartIndex = value; } }
|
||||
/// <summary>
|
||||
/// the interval of show symbol.
|
||||
/// 显示图形标记的间隔。0表示显示所有标签,1表示隔一个隔显示一个标签,以此类推。
|
||||
/// </summary>
|
||||
public int interval { get { return m_Interval; } set { m_Interval = value; } }
|
||||
/// <summary>
|
||||
/// whether to show the last symbol.
|
||||
/// 是否强制显示最后一个图形标记。
|
||||
/// </summary>
|
||||
public bool forceShowLast { get { return m_ForceShowLast; } set { m_ForceShowLast = value; } }
|
||||
private List<float> m_AnimationSize = new List<float>() { 0, 5, 10 };
|
||||
/// <summary>
|
||||
/// the setting for effect scatter.
|
||||
/// 带有涟漪特效动画的散点图的动画参数。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public List<float> animationSize { get { return m_AnimationSize; } }
|
||||
|
||||
/// <summary>
|
||||
@@ -212,5 +218,14 @@ namespace XCharts
|
||||
default: return selectedSize;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowSymbol(int dataIndex, int dataCount)
|
||||
{
|
||||
if (type == SerieSymbolType.None) return false;
|
||||
if (dataIndex < startIndex) return false;
|
||||
if (m_Interval <= 0) return true;
|
||||
if (m_ForceShowLast && dataIndex == dataCount - 1) return true;
|
||||
return (dataIndex - startIndex) % (m_Interval + 1) == 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,7 +293,7 @@ namespace XCharts
|
||||
{
|
||||
ChartHelper.DrawLine(vh, startPoint, firstPoint, serie.lineStyle.width, lineColor);
|
||||
}
|
||||
if (serie.symbol.type != SerieSymbolType.None)
|
||||
if (serie.symbol.type != SerieSymbolType.None )
|
||||
{
|
||||
var symbolSize = (isHighlight ? serie.symbol.selectedSize : serie.symbol.size);
|
||||
float symbolRadius = symbolSize - serie.lineStyle.width * 2;
|
||||
|
||||
@@ -4,6 +4,16 @@
|
||||
[XChartsAPI接口](XChartsAPI.md)
|
||||
[XCharts问答](XCharts问答.md)
|
||||
|
||||
* [Theme](#Theme)
|
||||
* [Title](#Title)
|
||||
* [Legend](#Legend)
|
||||
* [Tooltip](#Tooltip)
|
||||
* [DataZoom](#DataZoom)
|
||||
* [Grid](#Grid)
|
||||
* [XAxis](#XAxis)
|
||||
* [Series](#Series)
|
||||
* [Settings](#Settings)
|
||||
|
||||
## `Theme`
|
||||
|
||||
---
|
||||
@@ -315,6 +325,9 @@
|
||||
* `selectedSizeCallback`:当 `sizeType` 指定为 `Callback` 时,指定的高亮回调函数。
|
||||
* `color`:标记图形的颜色,默认和系列一致。
|
||||
* `opacity`:图形标记的透明度。
|
||||
* `startIndex`:开始显示图形标记的索引。
|
||||
* `interval`:显示图形标记的间隔。0表示显示所有标签,1表示隔一个隔显示一个标签,以此类推。
|
||||
* `forceShowLast`:是否强制显示最后一个图形标记。默认为 `false`。
|
||||
* `lineType`:折线图样式类型。支持以下九种类型:
|
||||
* `Normal`:普通折线图。
|
||||
* `Smooth`:平滑曲线。
|
||||
|
||||
Reference in New Issue
Block a user