mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-18 14:30:10 +00:00
重构sampleDist到Serie的lineSampleDist
This commit is contained in:
@@ -26,7 +26,6 @@ namespace XCharts
|
||||
protected SerializedProperty m_MaxShowDataNumber;
|
||||
protected SerializedProperty m_MaxCacheDataNumber;
|
||||
protected SerializedProperty m_LineSmoothStyle;
|
||||
protected SerializedProperty m_SampleDist;
|
||||
|
||||
protected float m_DefaultLabelWidth;
|
||||
protected float m_DefaultFieldWidth;
|
||||
@@ -51,7 +50,6 @@ namespace XCharts
|
||||
m_MaxShowDataNumber = serializedObject.FindProperty("m_MaxShowDataNumber");
|
||||
m_MaxCacheDataNumber = serializedObject.FindProperty("m_MaxCacheDataNumber");
|
||||
m_LineSmoothStyle = serializedObject.FindProperty("m_LineSmoothStyle");
|
||||
m_SampleDist = serializedObject.FindProperty("m_SampleDist");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
@@ -98,11 +96,9 @@ namespace XCharts
|
||||
EditorGUILayout.PropertyField(m_MaxShowDataNumber, true);
|
||||
EditorGUILayout.PropertyField(m_MaxCacheDataNumber, true);
|
||||
EditorGUILayout.PropertyField(m_LineSmoothStyle,true);
|
||||
EditorGUILayout.PropertyField(m_SampleDist,true);
|
||||
if (m_MinShowDataNumber.intValue < 0) m_MinShowDataNumber.intValue = 0;
|
||||
if (m_MaxShowDataNumber.intValue < 0) m_MaxShowDataNumber.intValue = 0;
|
||||
if (m_MaxCacheDataNumber.intValue < 0) m_MaxCacheDataNumber.intValue = 0;
|
||||
if (m_SampleDist.floatValue < 0) m_SampleDist.floatValue = 0;
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace XCharts
|
||||
SerializedProperty m_LineStyle = prop.FindPropertyRelative("m_LineStyle");
|
||||
SerializedProperty m_LineArrow = prop.FindPropertyRelative("m_LineArrow");
|
||||
SerializedProperty m_LineType = prop.FindPropertyRelative("m_LineType");
|
||||
SerializedProperty m_LineSampleDist = prop.FindPropertyRelative("m_LineSampleDist");
|
||||
SerializedProperty m_BarWidth = prop.FindPropertyRelative("m_BarWidth");
|
||||
SerializedProperty m_BarGap = prop.FindPropertyRelative("m_BarGap");
|
||||
SerializedProperty m_BarCategoryGap = prop.FindPropertyRelative("m_BarCategoryGap");
|
||||
@@ -82,6 +83,8 @@ namespace XCharts
|
||||
{
|
||||
EditorGUI.PropertyField(drawRect, m_LineType);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_LineSampleDist);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
if (serieType == SerieType.Line
|
||||
|| serieType == SerieType.Scatter
|
||||
@@ -345,7 +348,7 @@ namespace XCharts
|
||||
if (serieType == SerieType.Line)
|
||||
{
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineArrow"));
|
||||
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += 2 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
if (serieType == SerieType.Bar)
|
||||
{
|
||||
|
||||
@@ -126,6 +126,7 @@ namespace XCharts
|
||||
[SerializeField] private AreaStyle m_AreaStyle = AreaStyle.defaultAreaStyle;
|
||||
[SerializeField] private SerieSymbol m_Symbol = new SerieSymbol();
|
||||
[SerializeField] private LineType m_LineType = LineType.Normal;
|
||||
[SerializeField] private float m_LineSampleDist = 0;
|
||||
[SerializeField] private LineStyle m_LineStyle = new LineStyle();
|
||||
[SerializeField] private float m_BarWidth = 0.6f;
|
||||
[SerializeField] private float m_BarGap = 0.3f; // 30%
|
||||
@@ -203,6 +204,12 @@ namespace XCharts
|
||||
/// <value></value>
|
||||
public LineType lineType { get { return m_LineType; } set { m_LineType = value; } }
|
||||
/// <summary>
|
||||
/// the min pixel dist of sample.
|
||||
/// 折线图采样的最小像素距离,默认为0时不采样。当两个数据点间的水平距离小于改值时,开启采样,保证两点间的水平距离不小于改值。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public float lineSampleDist { get { return m_LineSampleDist; } set { m_LineSampleDist = value < 0 ? 0 : value; } }
|
||||
/// <summary>
|
||||
/// The style of line.
|
||||
/// 线条样式。
|
||||
/// </summary>
|
||||
|
||||
@@ -43,7 +43,6 @@ namespace XCharts
|
||||
[SerializeField] protected int m_MaxShowDataNumber;
|
||||
[SerializeField] protected int m_MaxCacheDataNumber;
|
||||
[SerializeField] [Range(1, 8)] private float m_LineSmoothStyle = 2f;
|
||||
[SerializeField] protected float m_SampleDist;
|
||||
|
||||
[NonSerialized] private Theme m_CheckTheme = 0;
|
||||
[NonSerialized] private Title m_CheckTitle = Title.defaultTitle;
|
||||
|
||||
@@ -80,13 +80,6 @@ namespace XCharts
|
||||
/// <value></value>
|
||||
public float lineSmoothStyle { get { return m_LineSmoothStyle; } set { m_LineSmoothStyle = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// the min pixel dist of sample.
|
||||
/// 采样的最小像素距离,默认为0时不采样。当两个数据点间的像素距离小于改值时,开启采样,保证两点间的像素距离不小于改值。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public float sampleDist { get { return m_SampleDist; } set { m_SampleDist = value < 0 ? 0 : value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Set the size of chart.
|
||||
/// 设置图表的大小。
|
||||
|
||||
@@ -96,7 +96,8 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
int rate = 1;
|
||||
if (m_SampleDist > 0) rate = (int)((maxCount - minShowDataNumber) / (coordinateWid / m_SampleDist));
|
||||
var sampleDist = serie.lineSampleDist;
|
||||
if (sampleDist > 0) rate = (int)((maxCount - minShowDataNumber) / (coordinateWid / sampleDist));
|
||||
if (rate < 1) rate = 1;
|
||||
for (i = minShowDataNumber; i < maxCount; i += rate)
|
||||
{
|
||||
@@ -282,7 +283,8 @@ namespace XCharts
|
||||
var fine = isStack && m_Series.IsAnyGradientSerie(serie.stack);
|
||||
|
||||
int rate = 1;
|
||||
if (m_SampleDist > 0) rate = (int)((maxCount - minShowDataNumber) / (coordinateWid / m_SampleDist));
|
||||
var sampleDist = serie.lineSampleDist;
|
||||
if (sampleDist > 0) rate = (int)((maxCount - minShowDataNumber) / (coordinateWid / sampleDist));
|
||||
if (rate < 1) rate = 1;
|
||||
for (i = minShowDataNumber; i < maxCount; i += rate)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user