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