mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-20 15:30:09 +00:00
重构minShowDataNumber、maxShowDataNumber、maxCacheDataNumber到Serie的minShow、maxShow、maxCache
This commit is contained in:
@@ -32,7 +32,8 @@ public class Demo11_AddSinCurve : MonoBehaviour
|
||||
chart.yAxises[0].type = Axis.AxisType.Value;
|
||||
|
||||
chart.xAxises[0].boundaryGap = false;
|
||||
chart.maxCacheDataNumber = 0;
|
||||
chart.xAxises[0].maxCache = 0;
|
||||
chart.series.series[0].maxCache = 0;
|
||||
|
||||
chart.RemoveData();
|
||||
|
||||
|
||||
@@ -24,7 +24,8 @@ public class Demo_Dynamic : MonoBehaviour
|
||||
//chart.RemoveData();
|
||||
var serie = chart.AddSerie("data", SerieType.Line);
|
||||
serie.symbol.type = SerieSymbolType.None;
|
||||
chart.maxCacheDataNumber = maxCacheDataNumber;
|
||||
serie.maxCache = maxCacheDataNumber;
|
||||
chart.xAxises[0].maxCache = maxCacheDataNumber;
|
||||
timeNow = DateTime.Now;
|
||||
timeNow = timeNow.AddSeconds(-maxCacheDataNumber);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ public class Demo_LargeData : MonoBehaviour
|
||||
timeNow = System.DateTime.Now;
|
||||
chart.ClearAxisData();
|
||||
chart.series.ClearData();
|
||||
chart.maxCacheDataNumber = 0;
|
||||
chart.series.series[0].maxCache = maxCacheDataNumber;
|
||||
chart.xAxises[0].maxCache = maxCacheDataNumber;
|
||||
chart.title.text = maxCacheDataNumber + "数据";
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,6 @@ namespace XCharts
|
||||
protected SerializedProperty m_Series;
|
||||
|
||||
protected SerializedProperty m_Large;
|
||||
protected SerializedProperty m_MinShowDataNumber;
|
||||
protected SerializedProperty m_MaxShowDataNumber;
|
||||
protected SerializedProperty m_MaxCacheDataNumber;
|
||||
protected SerializedProperty m_LineSmoothStyle;
|
||||
|
||||
protected float m_DefaultLabelWidth;
|
||||
@@ -46,9 +43,6 @@ namespace XCharts
|
||||
m_Series = serializedObject.FindProperty("m_Series");
|
||||
|
||||
m_Large = serializedObject.FindProperty("m_Large");
|
||||
m_MinShowDataNumber = serializedObject.FindProperty("m_MinShowDataNumber");
|
||||
m_MaxShowDataNumber = serializedObject.FindProperty("m_MaxShowDataNumber");
|
||||
m_MaxCacheDataNumber = serializedObject.FindProperty("m_MaxCacheDataNumber");
|
||||
m_LineSmoothStyle = serializedObject.FindProperty("m_LineSmoothStyle");
|
||||
}
|
||||
|
||||
@@ -92,13 +86,7 @@ namespace XCharts
|
||||
EditorGUI.indentLevel++;
|
||||
var largeTip = "Whether to enable the optimization of large-scale graph. \n是否启用大规模线图的优化,在数据图形特别多的时候(>=5k)可以开启。";
|
||||
EditorGUILayout.PropertyField(m_Large, new GUIContent("Large", largeTip));
|
||||
EditorGUILayout.PropertyField(m_MinShowDataNumber, true);
|
||||
EditorGUILayout.PropertyField(m_MaxShowDataNumber, true);
|
||||
EditorGUILayout.PropertyField(m_MaxCacheDataNumber, true);
|
||||
EditorGUILayout.PropertyField(m_LineSmoothStyle,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;
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,10 @@ namespace XCharts
|
||||
SerializedProperty stack = prop.FindPropertyRelative("m_Stack");
|
||||
SerializedProperty m_AxisIndex = prop.FindPropertyRelative("m_AxisIndex");
|
||||
SerializedProperty m_RadarIndex = prop.FindPropertyRelative("m_RadarIndex");
|
||||
SerializedProperty m_MinShow = prop.FindPropertyRelative("m_MinShow");
|
||||
SerializedProperty m_MaxShow = prop.FindPropertyRelative("m_MaxShow");
|
||||
SerializedProperty m_MaxCache = prop.FindPropertyRelative("m_MaxCache");
|
||||
|
||||
SerializedProperty m_LineStyle = prop.FindPropertyRelative("m_LineStyle");
|
||||
SerializedProperty m_LineArrow = prop.FindPropertyRelative("m_LineArrow");
|
||||
SerializedProperty m_LineType = prop.FindPropertyRelative("m_LineType");
|
||||
@@ -79,6 +83,15 @@ namespace XCharts
|
||||
EditorGUI.PropertyField(drawRect, m_AxisIndex);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
EditorGUI.PropertyField(drawRect, m_MinShow);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_MaxShow);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_MaxCache);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_MinShow.intValue < 0) m_MinShow.intValue = 0;
|
||||
if (m_MinShow.intValue < 0) m_MinShow.intValue = 0;
|
||||
if (m_MaxCache.intValue < 0) m_MaxCache.intValue = 0;
|
||||
if (serieType == SerieType.Line)
|
||||
{
|
||||
EditorGUI.PropertyField(drawRect, m_LineType);
|
||||
@@ -325,7 +338,7 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
height += 6 * EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += 9 * EditorGUIUtility.singleLineHeight + 8 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_AreaStyle"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
|
||||
|
||||
@@ -96,6 +96,7 @@ namespace XCharts
|
||||
[SerializeField] protected bool m_ShowSplitLine = false;
|
||||
[SerializeField] protected SplitLineType m_SplitLineType = SplitLineType.Dashed;
|
||||
[SerializeField] protected bool m_BoundaryGap = true;
|
||||
[SerializeField] protected int m_MaxCache = 0;
|
||||
[SerializeField] protected List<string> m_Data = new List<string>();
|
||||
[SerializeField] protected AxisLine m_AxisLine = AxisLine.defaultAxisLine;
|
||||
[SerializeField] protected AxisName m_AxisName = AxisName.defaultAxisName;
|
||||
@@ -156,6 +157,12 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public bool boundaryGap { get { return m_BoundaryGap; } set { m_BoundaryGap = value; } }
|
||||
/// <summary>
|
||||
/// The max number of axis data cache.
|
||||
/// The first data will be remove when the size of axis data is larger then maxCache.
|
||||
/// 可缓存的最大数据量。默认为0没有限制,大于0时超过指定值会移除旧数据再插入新数据。
|
||||
/// </summary>
|
||||
public int maxCache { get { return m_MaxCache; } set { m_MaxCache = value < 0 ? 0 : value; } }
|
||||
/// <summary>
|
||||
/// Category data, available in type: 'Category' axis.
|
||||
/// 类目数据,在类目轴(type: 'category')中有效。
|
||||
/// </summary>
|
||||
@@ -268,12 +275,11 @@ namespace XCharts
|
||||
/// 添加一个类目到类目数据列表
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
public void AddData(string category, int maxDataNumber)
|
||||
public void AddData(string category)
|
||||
{
|
||||
if (maxDataNumber > 0)
|
||||
if (maxCache > 0)
|
||||
{
|
||||
while (m_Data.Count > maxDataNumber) m_Data.RemoveAt(0);
|
||||
while (m_Data.Count > maxCache) m_Data.RemoveAt(0);
|
||||
}
|
||||
m_Data.Add(category);
|
||||
}
|
||||
|
||||
@@ -123,6 +123,9 @@ namespace XCharts
|
||||
[SerializeField] private string m_Stack;
|
||||
[SerializeField] [Range(0, 1)] private int m_AxisIndex = 0;
|
||||
[SerializeField] private int m_RadarIndex = 0;
|
||||
[SerializeField] protected int m_MinShow;
|
||||
[SerializeField] protected int m_MaxShow;
|
||||
[SerializeField] protected int m_MaxCache;
|
||||
[SerializeField] private AreaStyle m_AreaStyle = AreaStyle.defaultAreaStyle;
|
||||
[SerializeField] private SerieSymbol m_Symbol = new SerieSymbol();
|
||||
[SerializeField] private LineType m_LineType = LineType.Normal;
|
||||
@@ -187,6 +190,35 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public int radarIndex { get { return m_RadarIndex; } set { m_RadarIndex = value; } }
|
||||
/// <summary>
|
||||
/// The min number of data to show in chart.
|
||||
/// 系列所显示数据的最小索引
|
||||
/// </summary>
|
||||
public int minShow
|
||||
{
|
||||
get { return m_MinShow; }
|
||||
set { m_MinShow = value; if (m_MinShow < 0) m_MinShow = 0; }
|
||||
}
|
||||
/// <summary>
|
||||
/// The max number of data to show in chart.
|
||||
/// 系列所显示数据的最大索引
|
||||
/// </summary>
|
||||
public int maxShow
|
||||
{
|
||||
get { return m_MaxShow; }
|
||||
set { m_MaxShow = value; if (m_MaxShow < 0) m_MaxShow = 0; }
|
||||
}
|
||||
/// <summary>
|
||||
/// The max number of serie data cache.
|
||||
/// The first data will be remove when the size of serie data is larger then maxCache.
|
||||
/// default:0,unlimited.
|
||||
/// 系列中可缓存的最大数据量。默认为0没有限制,大于0时超过指定值会移除旧数据再插入新数据。
|
||||
/// </summary>
|
||||
public int maxCache
|
||||
{
|
||||
get { return m_MaxCache; }
|
||||
set { m_MaxCache = value; if (m_MaxCache < 0) m_MaxCache = 0; }
|
||||
}
|
||||
/// <summary>
|
||||
/// The style of area.
|
||||
/// 区域填充样式。
|
||||
/// </summary>
|
||||
@@ -484,12 +516,11 @@ namespace XCharts
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
public void AddYData(float value, string dataName = null, int maxDataNumber = 0)
|
||||
public void AddYData(float value, string dataName = null)
|
||||
{
|
||||
if (maxDataNumber > 0)
|
||||
if (m_MaxCache > 0)
|
||||
{
|
||||
while (m_Data.Count > maxDataNumber) m_Data.RemoveAt(0);
|
||||
while (m_Data.Count > m_MaxCache) m_Data.RemoveAt(0);
|
||||
}
|
||||
int xValue = m_Data.Count;
|
||||
m_Data.Add(new SerieData() { data = new List<float>() { xValue, value }, name = dataName });
|
||||
@@ -502,11 +533,11 @@ namespace XCharts
|
||||
/// <param name="yValue"></param>
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
public void AddXYData(float xValue, float yValue, string dataName = null, int maxDataNumber = 0)
|
||||
public void AddXYData(float xValue, float yValue, string dataName = null)
|
||||
{
|
||||
if (maxDataNumber > 0)
|
||||
if (m_MaxCache > 0)
|
||||
{
|
||||
while (m_Data.Count > maxDataNumber) m_Data.RemoveAt(0);
|
||||
while (m_Data.Count > m_MaxCache) m_Data.RemoveAt(0);
|
||||
}
|
||||
m_Data.Add(new SerieData() { data = new List<float>() { xValue, yValue }, name = dataName });
|
||||
}
|
||||
@@ -518,22 +549,22 @@ namespace XCharts
|
||||
/// <param name="valueList"></param>
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
public void AddData(List<float> valueList, string dataName = null, int maxDataNumber = 0)
|
||||
public void AddData(List<float> valueList, string dataName = null)
|
||||
{
|
||||
if (valueList == null || valueList.Count == 0) return;
|
||||
if (valueList.Count == 1)
|
||||
{
|
||||
AddYData(valueList[0], dataName, maxDataNumber);
|
||||
AddYData(valueList[0], dataName);
|
||||
}
|
||||
else if (valueList.Count == 2)
|
||||
{
|
||||
AddXYData(valueList[0], valueList[1], dataName, maxDataNumber);
|
||||
AddXYData(valueList[0], valueList[1], dataName);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (maxDataNumber > 0)
|
||||
if (m_MaxCache > 0)
|
||||
{
|
||||
while (m_Data.Count > maxDataNumber) m_Data.RemoveAt(0);
|
||||
while (m_Data.Count > m_MaxCache) m_Data.RemoveAt(0);
|
||||
}
|
||||
var serieData = new SerieData();
|
||||
serieData.name = dataName;
|
||||
|
||||
@@ -256,12 +256,12 @@ namespace XCharts
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
/// <returns></returns>
|
||||
public bool AddData(string serieName, float value, string dataName = null, int maxDataNumber = 0)
|
||||
public bool AddData(string serieName, float value, string dataName = null)
|
||||
{
|
||||
var serie = GetSerie(serieName);
|
||||
if (serie != null)
|
||||
{
|
||||
serie.AddYData(value, dataName, maxDataNumber);
|
||||
serie.AddYData(value, dataName);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -275,12 +275,12 @@ namespace XCharts
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
/// <returns></returns>
|
||||
public bool AddData(int index, float value, string dataName = null, int maxDataNumber = 0)
|
||||
public bool AddData(int index, float value, string dataName = null)
|
||||
{
|
||||
var serie = GetSerie(index);
|
||||
if (serie != null)
|
||||
{
|
||||
serie.AddYData(value, dataName, maxDataNumber);
|
||||
serie.AddYData(value, dataName);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -294,12 +294,12 @@ namespace XCharts
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
/// <returns></returns>
|
||||
public bool AddData(string serieName, List<float> multidimensionalData, string dataName = null, int maxDataNumber = 0)
|
||||
public bool AddData(string serieName, List<float> multidimensionalData, string dataName = null)
|
||||
{
|
||||
var serie = GetSerie(serieName);
|
||||
if (serie != null)
|
||||
{
|
||||
serie.AddData(multidimensionalData, dataName, maxDataNumber);
|
||||
serie.AddData(multidimensionalData, dataName);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -313,12 +313,12 @@ namespace XCharts
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
/// <returns></returns>
|
||||
public bool AddData(int serieIndex, List<float> multidimensionalData, string dataName = null, int maxDataNumber = 0)
|
||||
public bool AddData(int serieIndex, List<float> multidimensionalData, string dataName = null)
|
||||
{
|
||||
var serie = GetSerie(serieIndex);
|
||||
if (serie != null)
|
||||
{
|
||||
serie.AddData(multidimensionalData, dataName, maxDataNumber);
|
||||
serie.AddData(multidimensionalData, dataName);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -333,12 +333,12 @@ namespace XCharts
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
/// <returns></returns>
|
||||
public bool AddXYData(string serieName, float xValue, float yValue, string dataName = null, int maxDataNumber = 0)
|
||||
public bool AddXYData(string serieName, float xValue, float yValue, string dataName = null)
|
||||
{
|
||||
var serie = GetSerie(serieName);
|
||||
if (serie != null)
|
||||
{
|
||||
serie.AddXYData(xValue, yValue, dataName, maxDataNumber);
|
||||
serie.AddXYData(xValue, yValue, dataName);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -353,12 +353,12 @@ namespace XCharts
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
/// <returns></returns>
|
||||
public bool AddXYData(int index, float xValue, float yValue, string dataName = null, int maxDataNumber = 0)
|
||||
public bool AddXYData(int index, float xValue, float yValue, string dataName = null)
|
||||
{
|
||||
var serie = GetSerie(index);
|
||||
if (serie != null)
|
||||
{
|
||||
serie.AddXYData(xValue, yValue, dataName, maxDataNumber);
|
||||
serie.AddXYData(xValue, yValue, dataName);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -39,9 +39,6 @@ namespace XCharts
|
||||
[SerializeField] protected Tooltip m_Tooltip = Tooltip.defaultTooltip;
|
||||
[SerializeField] protected Series m_Series = Series.defaultSeries;
|
||||
[SerializeField] protected float m_Large = 1;
|
||||
[SerializeField] protected int m_MinShowDataNumber;
|
||||
[SerializeField] protected int m_MaxShowDataNumber;
|
||||
[SerializeField] protected int m_MaxCacheDataNumber;
|
||||
[SerializeField] [Range(1, 8)] private float m_LineSmoothStyle = 2f;
|
||||
|
||||
[NonSerialized] private Theme m_CheckTheme = 0;
|
||||
|
||||
@@ -41,38 +41,6 @@ namespace XCharts
|
||||
/// <value></value>
|
||||
public float chartHeight { get { return m_ChartHeight; } }
|
||||
|
||||
/// <summary>
|
||||
/// The min number of data to show in chart.
|
||||
/// 图表所显示数据的最小索引
|
||||
/// </summary>
|
||||
public int minShowDataNumber
|
||||
{
|
||||
get { return m_MinShowDataNumber; }
|
||||
set { m_MinShowDataNumber = value; if (m_MinShowDataNumber < 0) m_MinShowDataNumber = 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The max number of data to show in chart.
|
||||
/// 图表所显示数据的最大索引
|
||||
/// </summary>
|
||||
public int maxShowDataNumber
|
||||
{
|
||||
get { return m_MaxShowDataNumber; }
|
||||
set { m_MaxShowDataNumber = value; if (m_MaxShowDataNumber < 0) m_MaxShowDataNumber = 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The max number of serie and axis data cache.
|
||||
/// The first data will be remove when the size of serie and axis data is larger then maxCacheDataNumber.
|
||||
/// default:0,unlimited.
|
||||
/// 图表每个系列中可缓存的最大数据量。默认为0没有限制,大于0时超过指定值会移除旧数据再插入新数据。
|
||||
/// </summary>
|
||||
public int maxCacheDataNumber
|
||||
{
|
||||
get { return m_MaxCacheDataNumber; }
|
||||
set { m_MaxCacheDataNumber = value; if (m_MaxCacheDataNumber < 0) m_MaxCacheDataNumber = 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the smooth line chart style.
|
||||
/// 平滑折线图的平滑系数。
|
||||
@@ -159,7 +127,7 @@ namespace XCharts
|
||||
/// <returns>Returns True on success</returns>
|
||||
public virtual bool AddData(string serieName, float data, string dataName = null)
|
||||
{
|
||||
var success = m_Series.AddData(serieName, data, dataName, m_MaxCacheDataNumber);
|
||||
var success = m_Series.AddData(serieName, data, dataName);
|
||||
if (success) RefreshChart();
|
||||
return success;
|
||||
}
|
||||
@@ -174,7 +142,7 @@ namespace XCharts
|
||||
/// <returns>Returns True on success</returns>
|
||||
public virtual bool AddData(int serieIndex, float data, string dataName = null)
|
||||
{
|
||||
var success = m_Series.AddData(serieIndex, data, dataName, m_MaxCacheDataNumber);
|
||||
var success = m_Series.AddData(serieIndex, data, dataName);
|
||||
if (success)
|
||||
{
|
||||
RefreshChart();
|
||||
@@ -193,7 +161,7 @@ namespace XCharts
|
||||
/// <returns>Returns True on success</returns>
|
||||
public virtual bool AddData(string serieName, List<float> multidimensionalData, string dataName = null)
|
||||
{
|
||||
var success = m_Series.AddData(serieName, multidimensionalData, dataName, m_MaxCacheDataNumber);
|
||||
var success = m_Series.AddData(serieName, multidimensionalData, dataName);
|
||||
if (success)
|
||||
{
|
||||
RefreshChart();
|
||||
@@ -212,7 +180,7 @@ namespace XCharts
|
||||
/// <returns>Returns True on success</returns>
|
||||
public virtual bool AddData(int serieIndex, List<float> multidimensionalData, string dataName = null)
|
||||
{
|
||||
var success = m_Series.AddData(serieIndex, multidimensionalData, dataName, m_MaxCacheDataNumber);
|
||||
var success = m_Series.AddData(serieIndex, multidimensionalData, dataName);
|
||||
if (success)
|
||||
{
|
||||
RefreshChart();
|
||||
@@ -232,7 +200,7 @@ namespace XCharts
|
||||
/// <returns>Returns True on success</returns>
|
||||
public virtual bool AddData(string serieName, float xValue, float yValue, string dataName)
|
||||
{
|
||||
var success = m_Series.AddXYData(serieName, xValue, yValue, dataName, m_MaxCacheDataNumber);
|
||||
var success = m_Series.AddXYData(serieName, xValue, yValue, dataName);
|
||||
if (success)
|
||||
{
|
||||
RefreshChart();
|
||||
@@ -252,7 +220,7 @@ namespace XCharts
|
||||
/// <returns>Returns True on success</returns>
|
||||
public virtual bool AddData(int serieIndex, float xValue, float yValue, string dataName = null)
|
||||
{
|
||||
var success = m_Series.AddXYData(serieIndex, xValue, yValue, dataName, m_MaxCacheDataNumber);
|
||||
var success = m_Series.AddXYData(serieIndex, xValue, yValue, dataName);
|
||||
if (success)
|
||||
{
|
||||
RefreshChart();
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace XCharts
|
||||
/// <param name="xAxisIndex">which xAxis should category add to</param>
|
||||
public void AddXAxisData(string category, int xAxisIndex = 0)
|
||||
{
|
||||
m_XAxises[xAxisIndex].AddData(category, m_MaxCacheDataNumber);
|
||||
m_XAxises[xAxisIndex].AddData(category);
|
||||
m_XAxisChanged = true;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace XCharts
|
||||
/// <param name="yAxisIndex">which yAxis should category add to</param>
|
||||
public void AddYAxisData(string category, int yAxisIndex = 0)
|
||||
{
|
||||
m_YAxises[yAxisIndex].AddData(category, m_MaxCacheDataNumber);
|
||||
m_YAxises[yAxisIndex].AddData(category);
|
||||
m_YAxisChanged = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,17 +26,17 @@ namespace XCharts
|
||||
float space = serie.barGap == -1 ? offset : offset + m_BarLastOffset;
|
||||
|
||||
var showData = serie.GetDataList(m_DataZoom);
|
||||
int maxCount = maxShowDataNumber > 0 ?
|
||||
(maxShowDataNumber > showData.Count ? showData.Count : maxShowDataNumber)
|
||||
int maxCount = serie.maxShow > 0 ?
|
||||
(serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||
: showData.Count;
|
||||
if (seriesHig.Count < minShowDataNumber)
|
||||
if (seriesHig.Count < serie.minShow)
|
||||
{
|
||||
for (int i = 0; i < minShowDataNumber; i++)
|
||||
for (int i = 0; i < serie.minShow; i++)
|
||||
{
|
||||
seriesHig.Add(0);
|
||||
}
|
||||
}
|
||||
for (int i = minShowDataNumber; i < maxCount; i++)
|
||||
for (int i = serie.minShow; i < maxCount; i++)
|
||||
{
|
||||
if (i >= seriesHig.Count)
|
||||
{
|
||||
@@ -110,18 +110,18 @@ namespace XCharts
|
||||
float offset = (categoryWidth - totalBarWidth) / 2;
|
||||
float barGapWidth = barWidth + barWidth * barGap;
|
||||
float space = serie.barGap == -1 ? offset : offset + m_BarLastOffset;
|
||||
int maxCount = maxShowDataNumber > 0 ?
|
||||
(maxShowDataNumber > showData.Count ? showData.Count : maxShowDataNumber)
|
||||
int maxCount = serie.maxShow > 0 ?
|
||||
(serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||
: showData.Count;
|
||||
|
||||
if (seriesHig.Count < minShowDataNumber)
|
||||
if (seriesHig.Count < serie.minShow)
|
||||
{
|
||||
for (int i = 0; i < minShowDataNumber; i++)
|
||||
for (int i = 0; i < serie.minShow; i++)
|
||||
{
|
||||
seriesHig.Add(0);
|
||||
}
|
||||
}
|
||||
for (int i = minShowDataNumber; i < maxCount; i++)
|
||||
for (int i = serie.minShow; i < maxCount; i++)
|
||||
{
|
||||
if (i >= seriesHig.Count)
|
||||
{
|
||||
|
||||
@@ -84,22 +84,22 @@ namespace XCharts
|
||||
if (!xAxis.show) xAxis = m_XAxises[(serie.axisIndex + 1) % m_XAxises.Count];
|
||||
float scaleWid = xAxis.GetDataWidth(coordinateWid, m_DataZoom);
|
||||
float startX = coordinateX + (xAxis.boundaryGap ? scaleWid / 2 : 0);
|
||||
int maxCount = maxShowDataNumber > 0 ?
|
||||
(maxShowDataNumber > showData.Count ? showData.Count : maxShowDataNumber)
|
||||
int maxCount = serie.maxShow > 0 ?
|
||||
(serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||
: showData.Count;
|
||||
int i;
|
||||
if (seriesHig.Count < minShowDataNumber)
|
||||
if (seriesHig.Count < serie.minShow)
|
||||
{
|
||||
for (i = 0; i < minShowDataNumber; i++)
|
||||
for (i = 0; i < serie.minShow; i++)
|
||||
{
|
||||
seriesHig.Add(0);
|
||||
}
|
||||
}
|
||||
int rate = 1;
|
||||
var sampleDist = serie.lineSampleDist;
|
||||
if (sampleDist > 0) rate = (int)((maxCount - minShowDataNumber) / (coordinateWid / sampleDist));
|
||||
if (sampleDist > 0) rate = (int)((maxCount - serie.minShow) / (coordinateWid / sampleDist));
|
||||
if (rate < 1) rate = 1;
|
||||
for (i = minShowDataNumber; i < maxCount; i += rate)
|
||||
for (i = serie.minShow; i < maxCount; i += rate)
|
||||
{
|
||||
if (i >= seriesHig.Count)
|
||||
{
|
||||
@@ -269,13 +269,13 @@ namespace XCharts
|
||||
if (!yAxis.show) yAxis = m_YAxises[(serie.axisIndex + 1) % m_YAxises.Count];
|
||||
float scaleWid = yAxis.GetDataWidth(coordinateHig, m_DataZoom);
|
||||
float startY = coordinateY + (yAxis.boundaryGap ? scaleWid / 2 : 0);
|
||||
int maxCount = maxShowDataNumber > 0 ?
|
||||
(maxShowDataNumber > showData.Count ? showData.Count : maxShowDataNumber)
|
||||
int maxCount = serie.maxShow > 0 ?
|
||||
(serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||
: showData.Count;
|
||||
int i = 0;
|
||||
if (seriesHig.Count < minShowDataNumber)
|
||||
if (seriesHig.Count < serie.minShow)
|
||||
{
|
||||
for (i = 0; i < minShowDataNumber; i++)
|
||||
for (i = 0; i < serie.minShow; i++)
|
||||
{
|
||||
seriesHig.Add(0);
|
||||
}
|
||||
@@ -284,9 +284,9 @@ namespace XCharts
|
||||
|
||||
int rate = 1;
|
||||
var sampleDist = serie.lineSampleDist;
|
||||
if (sampleDist > 0) rate = (int)((maxCount - minShowDataNumber) / (coordinateWid / sampleDist));
|
||||
if (sampleDist > 0) rate = (int)((maxCount - serie.minShow) / (coordinateWid / sampleDist));
|
||||
if (rate < 1) rate = 1;
|
||||
for (i = minShowDataNumber; i < maxCount; i += rate)
|
||||
for (i = serie.minShow; i < maxCount; i += rate)
|
||||
{
|
||||
if (i >= seriesHig.Count)
|
||||
{
|
||||
|
||||
@@ -81,10 +81,10 @@ namespace XCharts
|
||||
}
|
||||
var color = serie.symbol.color != Color.clear ? serie.symbol.color : (Color)m_ThemeInfo.GetColor(serieNameCount);
|
||||
color.a *= serie.symbol.opacity;
|
||||
int maxCount = maxShowDataNumber > 0 ?
|
||||
(maxShowDataNumber > serie.dataCount ? serie.dataCount : maxShowDataNumber)
|
||||
int maxCount = serie.maxShow > 0 ?
|
||||
(serie.maxShow > serie.dataCount ? serie.dataCount : serie.maxShow)
|
||||
: serie.dataCount;
|
||||
for (int n = minShowDataNumber; n < maxCount; n++)
|
||||
for (int n = serie.minShow; n < maxCount; n++)
|
||||
{
|
||||
var serieData = serie.GetDataList(m_DataZoom)[n];
|
||||
float xValue = serieData.data[0];
|
||||
|
||||
Reference in New Issue
Block a user