mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-19 23:10:06 +00:00
优化性能,优化折线图和柱状图的大数据绘制,重构代码
This commit is contained in:
@@ -28,8 +28,7 @@ namespace XCharts
|
||||
timeNow = System.DateTime.Now;
|
||||
chart.ClearAxisData();
|
||||
chart.series.ClearData();
|
||||
chart.series.list[0].maxCache = maxCacheDataNumber;
|
||||
chart.xAxises[0].maxCache = maxCacheDataNumber;
|
||||
chart.SetMaxCache(maxCacheDataNumber);
|
||||
chart.title.text = maxCacheDataNumber + "数据";
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace XCharts
|
||||
protected SerializedProperty m_Series;
|
||||
protected SerializedProperty m_Settings;
|
||||
protected SerializedProperty m_Large;
|
||||
protected SerializedProperty m_ChartName;
|
||||
protected SerializedProperty m_ChartUUID;
|
||||
|
||||
protected float m_DefaultLabelWidth;
|
||||
protected float m_DefaultFieldWidth;
|
||||
@@ -40,6 +42,8 @@ namespace XCharts
|
||||
{
|
||||
m_Target = (BaseChart)target;
|
||||
m_Script = serializedObject.FindProperty("m_Script");
|
||||
m_ChartName = serializedObject.FindProperty("m_ChartName");
|
||||
m_ChartUUID = serializedObject.FindProperty("m_ChartUUID");
|
||||
m_ChartWidth = serializedObject.FindProperty("m_ChartWidth");
|
||||
m_ChartHeight = serializedObject.FindProperty("m_ChartHeight");
|
||||
m_Theme = serializedObject.FindProperty("m_Theme");
|
||||
@@ -75,8 +79,21 @@ namespace XCharts
|
||||
protected virtual void OnStartInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.PropertyField(m_Script);
|
||||
// EditorGUILayout.PropertyField(m_ChartWidth);
|
||||
// EditorGUILayout.PropertyField(m_ChartHeight);
|
||||
// EditorGUI.BeginChangeCheck();
|
||||
// EditorGUILayout.PropertyField(m_ChartName);
|
||||
// if (EditorGUI.EndChangeCheck())
|
||||
// {
|
||||
// if (XChartsMgr.Instance.ContainsChart(m_ChartName.stringValue))
|
||||
// {
|
||||
// m_ChartName.stringValue = "";
|
||||
// serializedObject.ApplyModifiedProperties();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// m_ChartUUID.stringValue = m_ChartName.stringValue;
|
||||
// }
|
||||
// }
|
||||
// EditorGUILayout.PropertyField(m_ChartUUID);
|
||||
EditorGUILayout.PropertyField(m_ThemeInfo, true);
|
||||
EditorGUILayout.PropertyField(m_Title, true);
|
||||
EditorGUILayout.PropertyField(m_Legend, true);
|
||||
|
||||
@@ -75,6 +75,8 @@ namespace XCharts
|
||||
SerializedProperty m_Ignore = prop.FindPropertyRelative("m_Ignore");
|
||||
SerializedProperty m_IgnoreValue = prop.FindPropertyRelative("m_IgnoreValue");
|
||||
SerializedProperty m_ShowAsPositiveNumber = prop.FindPropertyRelative("m_ShowAsPositiveNumber");
|
||||
SerializedProperty m_Large = prop.FindPropertyRelative("m_Large");
|
||||
SerializedProperty m_LargeThreshold = prop.FindPropertyRelative("m_LargeThreshold");
|
||||
SerializedProperty m_Datas = prop.FindPropertyRelative("m_Data");
|
||||
|
||||
int index = InitToggle(prop);
|
||||
@@ -134,6 +136,10 @@ namespace XCharts
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_ShowAsPositiveNumber);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Large);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_LargeThreshold);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Symbol);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol);
|
||||
EditorGUI.PropertyField(drawRect, m_LineStyle);
|
||||
@@ -183,6 +189,10 @@ namespace XCharts
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_ShowAsPositiveNumber);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Large);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_LargeThreshold);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_ItemStyle);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
|
||||
EditorGUI.PropertyField(drawRect, m_Label);
|
||||
@@ -495,7 +505,7 @@ namespace XCharts
|
||||
switch (serieType)
|
||||
{
|
||||
case SerieType.Line:
|
||||
height += 17 * EditorGUIUtility.singleLineHeight + 16 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += 19 * EditorGUIUtility.singleLineHeight + 18 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineArrow"));
|
||||
@@ -506,7 +516,7 @@ namespace XCharts
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
||||
break;
|
||||
case SerieType.Bar:
|
||||
height += 19 * EditorGUIUtility.singleLineHeight + 18 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += 21 * EditorGUIUtility.singleLineHeight + 20 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
|
||||
|
||||
@@ -323,7 +323,7 @@ namespace XCharts
|
||||
m_CustomColorPalette.InsertArrayElementAtIndex(m_CustomColorPalette.arraySize);
|
||||
}
|
||||
var customElement = m_CustomColorPalette.GetArrayElementAtIndex(i);
|
||||
color = customElement.colorValue != Color.clear ?
|
||||
color = !ChartHelper.IsClearColor(customElement.colorValue) ?
|
||||
customElement :
|
||||
m_ColorPalette.GetArrayElementAtIndex(i);
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
@@ -149,6 +149,7 @@ namespace XCharts
|
||||
m_Tooltip.ClearValue();
|
||||
m_CheckAnimation = false;
|
||||
m_ReinitLabel = true;
|
||||
m_SerieLabelRoot = null;
|
||||
RefreshChart();
|
||||
}
|
||||
|
||||
@@ -161,6 +162,7 @@ namespace XCharts
|
||||
{
|
||||
m_Series.Remove(serieName);
|
||||
m_Legend.RemoveData(serieName);
|
||||
m_SerieLabelRoot = null;
|
||||
RefreshChart();
|
||||
}
|
||||
|
||||
@@ -191,8 +193,9 @@ namespace XCharts
|
||||
var serieData = m_Series.AddData(serieName, data, dataName);
|
||||
if (serieData != null)
|
||||
{
|
||||
var serie = m_Series.GetSerie(serieName);
|
||||
AddSerieLabel(serie, serieData);
|
||||
RefreshChart();
|
||||
RefreshLabel();
|
||||
}
|
||||
return serieData;
|
||||
}
|
||||
@@ -210,8 +213,9 @@ namespace XCharts
|
||||
var serieData = m_Series.AddData(serieIndex, data, dataName);
|
||||
if (serieData != null)
|
||||
{
|
||||
var serie = m_Series.GetSerie(serieIndex);
|
||||
AddSerieLabel(serie, serieData);
|
||||
RefreshChart();
|
||||
RefreshLabel();
|
||||
}
|
||||
return serieData;
|
||||
}
|
||||
@@ -229,8 +233,9 @@ namespace XCharts
|
||||
var serieData = m_Series.AddData(serieName, multidimensionalData, dataName);
|
||||
if (serieData != null)
|
||||
{
|
||||
var serie = m_Series.GetSerie(serieName);
|
||||
AddSerieLabel(serie, serieData);
|
||||
RefreshChart();
|
||||
RefreshLabel();
|
||||
}
|
||||
return serieData;
|
||||
}
|
||||
@@ -248,8 +253,9 @@ namespace XCharts
|
||||
var serieData = m_Series.AddData(serieIndex, multidimensionalData, dataName);
|
||||
if (serieData != null)
|
||||
{
|
||||
var serie = m_Series.GetSerie(serieIndex);
|
||||
AddSerieLabel(serie, serieData);
|
||||
RefreshChart();
|
||||
RefreshLabel();
|
||||
}
|
||||
return serieData;
|
||||
}
|
||||
@@ -268,8 +274,9 @@ namespace XCharts
|
||||
var serieData = m_Series.AddXYData(serieName, xValue, yValue, dataName);
|
||||
if (serieData != null)
|
||||
{
|
||||
var serie = m_Series.GetSerie(serieName);
|
||||
AddSerieLabel(serie, serieData);
|
||||
RefreshChart();
|
||||
RefreshLabel();
|
||||
}
|
||||
return serieData;
|
||||
}
|
||||
@@ -288,8 +295,9 @@ namespace XCharts
|
||||
var serieData = m_Series.AddXYData(serieIndex, xValue, yValue, dataName);
|
||||
if (serieData != null)
|
||||
{
|
||||
var serie = m_Series.GetSerie(serieIndex);
|
||||
AddSerieLabel(serie, serieData);
|
||||
RefreshChart();
|
||||
RefreshLabel();
|
||||
}
|
||||
return serieData;
|
||||
}
|
||||
@@ -529,6 +537,7 @@ namespace XCharts
|
||||
public void RefreshLabel()
|
||||
{
|
||||
m_ReinitLabel = true;
|
||||
m_SerieLabelRoot = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -643,25 +652,27 @@ namespace XCharts
|
||||
/// <returns></returns>
|
||||
public bool IsInChart(Vector2 local)
|
||||
{
|
||||
if (local.x < m_ChartX || local.x > m_ChartX + m_ChartWidth ||
|
||||
local.y < m_ChartY || local.y > m_ChartY + m_ChartHeight)
|
||||
return IsInChart(local.x, local.y);
|
||||
}
|
||||
|
||||
public bool IsInChart(float x, float y)
|
||||
{
|
||||
if (x < m_ChartX || x > m_ChartX + m_ChartWidth ||
|
||||
y < m_ChartY || y > m_ChartY + m_ChartHeight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Vector3 ClampInChart(Vector3 pos)
|
||||
public void ClampInChart(ref Vector3 pos)
|
||||
{
|
||||
if (IsInChart(pos)) return pos;
|
||||
else
|
||||
if (!IsInChart(pos.x, pos.y))
|
||||
{
|
||||
var np = new Vector3(pos.x, pos.y);
|
||||
if (np.x < m_ChartX) np.x = m_ChartX;
|
||||
if (np.x > m_ChartX + chartWidth) np.x = m_ChartX + chartWidth;
|
||||
if (np.y < m_ChartY) np.y = m_ChartY;
|
||||
if (np.y > m_ChartY + chartHeight) np.y = m_ChartY + chartHeight;
|
||||
return np;
|
||||
if (pos.x < m_ChartX) pos.x = m_ChartX;
|
||||
if (pos.x > m_ChartX + m_ChartWidth) pos.x = m_ChartX + m_ChartWidth;
|
||||
if (pos.y < m_ChartY) pos.y = m_ChartY;
|
||||
if (pos.y > m_ChartY + m_ChartHeight) pos.y = m_ChartY + m_ChartHeight;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,29 +22,23 @@ namespace XCharts
|
||||
/// The lower left position x of coordinate system.
|
||||
/// 坐标系的左下角坐标X。
|
||||
/// </summary>
|
||||
public float coordinateX { get { return m_ChartX + m_Grid.left; } }
|
||||
public float coordinateX { get { return m_CoordinateX; } }
|
||||
/// <summary>
|
||||
/// The lower left position y of coordinate system.
|
||||
/// 坐标系的左下角坐标Y。
|
||||
/// </summary>
|
||||
public float coordinateY { get { return m_ChartY + m_Grid.bottom; } }
|
||||
|
||||
[Obsolete("Use CoordinateChart.coordinateWidth instead.", true)]
|
||||
public float coordinateWid { get { return coordinateWidth; } }
|
||||
|
||||
[Obsolete("Use CoordinateChart.coordinateHeight instead.", true)]
|
||||
public float coordinateHig { get { return coordinateHeight; } }
|
||||
public float coordinateY { get { return m_CoordinateY; } }
|
||||
|
||||
/// <summary>
|
||||
/// the width of coordinate system。
|
||||
/// 坐标系的宽。
|
||||
/// </summary>
|
||||
public float coordinateWidth { get { return chartWidth - m_Grid.left - m_Grid.right; } }
|
||||
public float coordinateWidth { get { return m_CoordinateWidth; } }
|
||||
/// <summary>
|
||||
/// the height of coordinate system。
|
||||
/// 坐标系的高。
|
||||
/// </summary>
|
||||
public float coordinateHeight { get { return chartHeight - m_Grid.top - m_Grid.bottom; } }
|
||||
public float coordinateHeight { get { return m_CoordinateHeight; } }
|
||||
/// <summary>
|
||||
/// grid component.
|
||||
/// 网格组件。
|
||||
@@ -175,8 +169,18 @@ namespace XCharts
|
||||
|
||||
public bool IsInCooridate(Vector2 local)
|
||||
{
|
||||
if (local.x < coordinateX - 1 || local.x > coordinateX + coordinateWidth + 1 ||
|
||||
local.y < coordinateY - 1 || local.y > coordinateY + coordinateHeight + 1)
|
||||
return IsInCooridate(local.x, local.y);
|
||||
}
|
||||
|
||||
public bool IsInCooridate(Vector3 local)
|
||||
{
|
||||
return IsInCooridate(local.x, local.y);
|
||||
}
|
||||
|
||||
public bool IsInCooridate(float x, float y)
|
||||
{
|
||||
if (x < m_CoordinateX - 1 || x > m_CoordinateX + m_CoordinateWidth + 1 ||
|
||||
y < m_CoordinateY - 1 || y > m_CoordinateY + m_CoordinateHeight + 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -204,12 +208,12 @@ namespace XCharts
|
||||
if (IsInCooridate(pos)) return pos;
|
||||
else
|
||||
{
|
||||
var np = new Vector3(pos.x, pos.y);
|
||||
if (np.x < coordinateX) np.x = coordinateX;
|
||||
if (np.x > coordinateX + coordinateWidth) np.x = coordinateX + coordinateWidth;
|
||||
if (np.y < coordinateY) np.y = coordinateY;
|
||||
if (np.y > coordinateY + coordinateHeight) np.y = coordinateY + coordinateHeight;
|
||||
return np;
|
||||
// var pos = new Vector3(pos.x, pos.y);
|
||||
if (pos.x < m_CoordinateX) pos.x = m_CoordinateX;
|
||||
if (pos.x > m_CoordinateX + m_CoordinateWidth) pos.x = m_CoordinateX + m_CoordinateWidth;
|
||||
if (pos.y < m_CoordinateY) pos.y = m_CoordinateY;
|
||||
if (pos.y > m_CoordinateY + m_CoordinateHeight) pos.y = m_CoordinateY + m_CoordinateHeight;
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,6 +240,27 @@ namespace XCharts
|
||||
yAxis.runtimeMaxValue = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新坐标系原点和宽高
|
||||
/// </summary>
|
||||
public void UpdateCoordinate()
|
||||
{
|
||||
m_CoordinateX = m_ChartX + m_Grid.left;
|
||||
m_CoordinateY = m_ChartY + m_Grid.bottom;
|
||||
m_CoordinateWidth = m_ChartWidth - m_Grid.left - m_Grid.right;
|
||||
m_CoordinateHeight = m_ChartHeight - m_Grid.top - m_Grid.bottom;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置可缓存的最大数据量。
|
||||
/// </summary>
|
||||
public void SetMaxCache(int maxCache)
|
||||
{
|
||||
foreach (var serie in m_Series.list) serie.maxCache = maxCache;
|
||||
foreach (var axis in m_XAxises) axis.maxCache = maxCache;
|
||||
foreach (var axis in m_YAxises) axis.maxCache = maxCache;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -271,6 +271,8 @@ namespace XCharts
|
||||
[SerializeField] private bool m_Ignore = false;
|
||||
[SerializeField] private float m_IgnoreValue = 0;
|
||||
[SerializeField] private bool m_ShowAsPositiveNumber = false;
|
||||
[SerializeField] private bool m_Large = true;
|
||||
[SerializeField] private int m_LargeThreshold = 200;
|
||||
[SerializeField] private RadarType m_RadarType = RadarType.Multiple;
|
||||
|
||||
[SerializeField] private List<SerieData> m_Data = new List<SerieData>();
|
||||
@@ -753,6 +755,38 @@ namespace XCharts
|
||||
set { if (PropertyUtility.SetStruct(ref m_ShowAsPositiveNumber, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否开启大数据量优化,在数据图形特别多而出现卡顿时候可以开启。
|
||||
/// 开启后配合 largeThreshold 在数据量大于指定阈值的时候对绘制进行优化。
|
||||
/// 缺点:优化后不能自定义设置单个数据项的样式,不能显示Label。
|
||||
/// </summary>
|
||||
public bool large
|
||||
{
|
||||
get { return m_Large; }
|
||||
set
|
||||
{
|
||||
if (PropertyUtility.SetStruct(ref m_Large, value))
|
||||
{
|
||||
SetAllDirty();
|
||||
label.SetComponentDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 开启大数量优化的阈值。
|
||||
/// </summary>
|
||||
public int largeThreshold
|
||||
{
|
||||
get { return m_LargeThreshold; }
|
||||
set
|
||||
{
|
||||
if (PropertyUtility.SetStruct(ref m_LargeThreshold, value))
|
||||
{
|
||||
SetAllDirty();
|
||||
label.SetComponentDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 系列中的数据内容数组。SerieData可以设置1到n维数据。
|
||||
/// </summary>
|
||||
public List<SerieData> data { get { return m_Data; } }
|
||||
@@ -869,7 +903,7 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
var list = new List<Vector3>(size);
|
||||
var list = ListPool<Vector3>.Get();
|
||||
m_UpSmoothPoints[dataIndex] = list;
|
||||
return list;
|
||||
}
|
||||
@@ -883,7 +917,7 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
var list = new List<Vector3>(size);
|
||||
var list = ListPool<Vector3>.Get();
|
||||
m_DownSmoothPoints[dataIndex] = list;
|
||||
return list;
|
||||
}
|
||||
@@ -1016,9 +1050,9 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public void ClearData()
|
||||
{
|
||||
foreach (var serieData in m_Data)
|
||||
while (m_Data.Count > 0)
|
||||
{
|
||||
SerieDataPool.Release(serieData);
|
||||
RemoveData(0);
|
||||
}
|
||||
m_Data.Clear();
|
||||
SetVerticesDirty();
|
||||
@@ -1037,6 +1071,22 @@ namespace XCharts
|
||||
SetNameDirty();
|
||||
}
|
||||
SetVerticesDirty();
|
||||
var serieData = m_Data[index];
|
||||
SerieDataPool.Release(serieData);
|
||||
if (serieData.labelObject != null)
|
||||
{
|
||||
SerieLabelPool.Release(serieData.labelObject.gameObject);
|
||||
}
|
||||
if (m_UpSmoothPoints.ContainsKey(serieData.index))
|
||||
{
|
||||
ListPool<Vector3>.Release(m_UpSmoothPoints[serieData.index]);
|
||||
m_UpSmoothPoints.Remove(serieData.index);
|
||||
}
|
||||
if (m_DownSmoothPoints.ContainsKey(serieData.index))
|
||||
{
|
||||
ListPool<Vector3>.Release(m_DownSmoothPoints[serieData.index]);
|
||||
m_DownSmoothPoints.Remove(serieData.index);
|
||||
}
|
||||
m_Data.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
@@ -1048,15 +1098,7 @@ namespace XCharts
|
||||
/// <param name="dataName"></param>
|
||||
public SerieData AddYData(float value, string dataName = null)
|
||||
{
|
||||
if (m_MaxCache > 0)
|
||||
{
|
||||
while (m_Data.Count > m_MaxCache)
|
||||
{
|
||||
m_NeedUpdateFilterData = true;
|
||||
SerieDataPool.Release(m_Data[0]);
|
||||
m_Data.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
CheckMaxCache();
|
||||
int xValue = m_Data.Count;
|
||||
var serieData = SerieDataPool.Get();
|
||||
serieData.data.Add(xValue);
|
||||
@@ -1146,8 +1188,7 @@ namespace XCharts
|
||||
while (m_Data.Count > m_MaxCache)
|
||||
{
|
||||
m_NeedUpdateFilterData = true;
|
||||
SerieDataPool.Release(m_Data[0]);
|
||||
m_Data.RemoveAt(0);
|
||||
RemoveData(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1431,9 +1472,9 @@ namespace XCharts
|
||||
var serieData = m_Data[index];
|
||||
serieData.name = name;
|
||||
SetNameDirty();
|
||||
if (serieData.labelText != null)
|
||||
if (serieData.labelObject != null)
|
||||
{
|
||||
serieData.labelText.text = name == null ? "" : name;
|
||||
serieData.labelObject.SetText(name == null ? "" : name);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1572,7 +1613,16 @@ namespace XCharts
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否为性能模式。只有折线图和柱状图才有性能模式。性能模式下不绘制Symbol,不刷新Label,不单独设置数据项配置。
|
||||
/// </summary>
|
||||
public bool IsPerformanceMode()
|
||||
{
|
||||
if (m_Type == SerieType.Line || m_Type == SerieType.Bar)
|
||||
return m_Large && m_Data.Count > m_LargeThreshold;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置指定index的数据图标的尺寸
|
||||
|
||||
@@ -120,6 +120,12 @@ namespace XCharts
|
||||
SetLabelDirty();
|
||||
}
|
||||
|
||||
public override void ClearDirty()
|
||||
{
|
||||
base.ClearDirty();
|
||||
ClearLabelDirty();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空所有系列的数据
|
||||
/// </summary>
|
||||
@@ -242,7 +248,9 @@ namespace XCharts
|
||||
{
|
||||
if (serie.show && serie.areaStyle.show && stack.Equals(serie.stack))
|
||||
{
|
||||
if (serie.areaStyle.color != serie.areaStyle.toColor && serie.areaStyle.toColor != Color.clear) return true;
|
||||
if (serie.areaStyle.color != serie.areaStyle.toColor
|
||||
&& !ChartHelper.IsClearColor(serie.areaStyle.toColor))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Color32 backgroundColor
|
||||
{
|
||||
get { return m_CustomBackgroundColor != Color.clear ? m_CustomBackgroundColor : m_BackgroundColor; }
|
||||
get { return !ChartHelper.IsClearColor(m_CustomBackgroundColor) ? m_CustomBackgroundColor : m_BackgroundColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomBackgroundColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
@@ -116,7 +116,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Color32 titleTextColor
|
||||
{
|
||||
get { return m_CustomTitleTextColor != Color.clear ? m_CustomTitleTextColor : m_TitleTextColor; }
|
||||
get { return !ChartHelper.IsClearColor(m_CustomTitleTextColor) ? m_CustomTitleTextColor : m_TitleTextColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomTitleTextColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
@@ -125,7 +125,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Color32 titleSubTextColor
|
||||
{
|
||||
get { return m_CustomTitleSubTextColor != Color.clear ? m_CustomTitleSubTextColor : m_TitleSubTextColor; }
|
||||
get { return !ChartHelper.IsClearColor(m_CustomTitleSubTextColor) ? m_CustomTitleSubTextColor : m_TitleSubTextColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomTitleSubTextColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
@@ -134,7 +134,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Color32 legendTextColor
|
||||
{
|
||||
get { return m_CustomLegendTextColor != Color.clear ? m_CustomLegendTextColor : m_LegendTextColor; }
|
||||
get { return !ChartHelper.IsClearColor(m_CustomLegendTextColor) ? m_CustomLegendTextColor : m_LegendTextColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomLegendTextColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
@@ -143,7 +143,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Color32 legendUnableColor
|
||||
{
|
||||
get { return m_CustomLegendUnableColor != Color.clear ? m_CustomLegendUnableColor : m_LegendUnableColor; }
|
||||
get { return !ChartHelper.IsClearColor(m_CustomLegendUnableColor) ? m_CustomLegendUnableColor : m_LegendUnableColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomLegendUnableColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
@@ -152,7 +152,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Color32 axisTextColor
|
||||
{
|
||||
get { return m_CustomAxisTextColor != Color.clear ? m_CustomAxisTextColor : m_AxisTextColor; }
|
||||
get { return !ChartHelper.IsClearColor(m_CustomAxisTextColor) ? m_CustomAxisTextColor : m_AxisTextColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomAxisTextColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
@@ -161,7 +161,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Color32 axisLineColor
|
||||
{
|
||||
get { return m_CustomAxisLineColor != Color.clear ? m_CustomAxisLineColor : m_AxisLineColor; }
|
||||
get { return !ChartHelper.IsClearColor(m_CustomAxisLineColor) ? m_CustomAxisLineColor : m_AxisLineColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomAxisLineColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
@@ -170,7 +170,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Color32 axisSplitLineColor
|
||||
{
|
||||
get { return m_CustomAxisSplitLineColor != Color.clear ? m_CustomAxisSplitLineColor : m_AxisSplitLineColor; }
|
||||
get { return !ChartHelper.IsClearColor(m_CustomAxisSplitLineColor) ? m_CustomAxisSplitLineColor : m_AxisSplitLineColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomAxisSplitLineColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
@@ -179,7 +179,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Color32 tooltipBackgroundColor
|
||||
{
|
||||
get { return m_CustomTooltipBackgroundColor != Color.clear ? m_CustomTooltipBackgroundColor : m_TooltipBackgroundColor; }
|
||||
get { return !ChartHelper.IsClearColor(m_CustomTooltipBackgroundColor) ? m_CustomTooltipBackgroundColor : m_TooltipBackgroundColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomTooltipBackgroundColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
@@ -188,7 +188,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Color32 tooltipFlagAreaColor
|
||||
{
|
||||
get { return m_CustomTooltipFlagAreaColor != Color.clear ? m_CustomTooltipFlagAreaColor : m_TooltipFlagAreaColor; }
|
||||
get { return !ChartHelper.IsClearColor(m_CustomTooltipFlagAreaColor) ? m_CustomTooltipFlagAreaColor : m_TooltipFlagAreaColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomTooltipFlagAreaColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
@@ -197,7 +197,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Color32 tooltipTextColor
|
||||
{
|
||||
get { return m_CustomTooltipTextColor != Color.clear ? m_CustomTooltipTextColor : m_TooltipTextColor; }
|
||||
get { return !ChartHelper.IsClearColor(m_CustomTooltipTextColor) ? m_CustomTooltipTextColor : m_TooltipTextColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomTooltipTextColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
@@ -206,7 +206,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Color32 tooltipLabelColor
|
||||
{
|
||||
get { return m_CustomTooltipLabelColor != Color.clear ? m_CustomTooltipLabelColor : m_TooltipLabelColor; }
|
||||
get { return !ChartHelper.IsClearColor(m_CustomTooltipLabelColor) ? m_CustomTooltipLabelColor : m_TooltipLabelColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomTooltipLabelColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
@@ -215,7 +215,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Color32 tooltipLineColor
|
||||
{
|
||||
get { return m_CustomTooltipLineColor != Color.clear ? m_CustomTooltipLineColor : m_TooltipLineColor; }
|
||||
get { return !ChartHelper.IsClearColor(m_CustomTooltipLineColor) ? m_CustomTooltipLineColor : m_TooltipLineColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomTooltipLineColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
@@ -224,7 +224,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Color32 dataZoomTextColor
|
||||
{
|
||||
get { return m_CustomDataZoomTextColor != Color.clear ? m_CustomDataZoomTextColor : m_DataZoomTextColor; }
|
||||
get { return !ChartHelper.IsClearColor(m_CustomDataZoomTextColor) ? m_CustomDataZoomTextColor : m_DataZoomTextColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomDataZoomTextColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
@@ -233,7 +233,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Color32 dataZoomLineColor
|
||||
{
|
||||
get { return m_CustomDataZoomLineColor != Color.clear ? m_CustomDataZoomLineColor : m_DataZoomLineColor; }
|
||||
get { return !ChartHelper.IsClearColor(m_CustomDataZoomLineColor) ? m_CustomDataZoomLineColor : m_DataZoomLineColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomDataZoomLineColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
@@ -242,7 +242,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Color32 dataZoomSelectedColor
|
||||
{
|
||||
get { return m_CustomDataZoomSelectedColor != Color.clear ? m_CustomDataZoomSelectedColor : m_DataZoomSelectedColor; }
|
||||
get { return !ChartHelper.IsClearColor(m_CustomDataZoomSelectedColor) ? m_CustomDataZoomSelectedColor : m_DataZoomSelectedColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomDataZoomSelectedColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Color32 visualMapBackgroundColor
|
||||
{
|
||||
get { return m_CustomVisualMapBackgroundColor != Color.clear ? m_CustomVisualMapBackgroundColor : m_VisualMapBackgroundColor; }
|
||||
get { return !ChartHelper.IsClearColor(m_CustomVisualMapBackgroundColor) ? m_CustomVisualMapBackgroundColor : m_VisualMapBackgroundColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomVisualMapBackgroundColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Color32 visualMapBorderColor
|
||||
{
|
||||
get { return m_CustomVisualMapBorderColor != Color.clear ? m_CustomVisualMapBorderColor : m_VisualMapBorderColor; }
|
||||
get { return !ChartHelper.IsClearColor(m_CustomVisualMapBorderColor) ? m_CustomVisualMapBorderColor : m_VisualMapBorderColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomVisualMapBorderColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
@@ -282,7 +282,8 @@ namespace XCharts
|
||||
if (m_CustomColorPalette.Count > 0)
|
||||
{
|
||||
var customIndex = index < m_CustomColorPalette.Count ? index : index % m_CustomColorPalette.Count;
|
||||
if (customIndex < m_CustomColorPalette.Count && m_CustomColorPalette[customIndex] != Color.clear)
|
||||
if (customIndex < m_CustomColorPalette.Count
|
||||
&& !ChartHelper.IsClearColor(m_CustomColorPalette[customIndex]))
|
||||
{
|
||||
return m_CustomColorPalette[customIndex];
|
||||
}
|
||||
@@ -305,12 +306,12 @@ namespace XCharts
|
||||
}
|
||||
for (int i = 0; i < m_ColorPalette.Length; i++)
|
||||
{
|
||||
if (m_ColorPalette[i] != Color.clear && m_ColorPalette[i].a == 0)
|
||||
if (!ChartHelper.IsClearColor(m_ColorPalette[i]) && m_ColorPalette[i].a == 0)
|
||||
sb.AppendFormat("warning:theme->colorPalette[{0}] alpha = 0\n", i);
|
||||
}
|
||||
for (int i = 0; i < m_CustomColorPalette.Count; i++)
|
||||
{
|
||||
if (m_CustomColorPalette[i] != Color.clear && m_CustomColorPalette[i].a == 0)
|
||||
if (!ChartHelper.IsClearColor(m_CustomColorPalette[i]) && m_CustomColorPalette[i].a == 0)
|
||||
sb.AppendFormat("warning:theme->colorPalette[{0}] alpha = 0\n", i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace XCharts
|
||||
|
||||
internal Color GetColor(ThemeInfo theme)
|
||||
{
|
||||
if (lineStyle.color != Color.clear)
|
||||
if (!ChartHelper.IsClearColor(lineStyle.color))
|
||||
{
|
||||
var color = lineStyle.color;
|
||||
color.a *= lineStyle.opacity;
|
||||
|
||||
@@ -177,14 +177,14 @@ namespace XCharts
|
||||
|
||||
internal Color GetAxisLineColor(ThemeInfo theme, int index)
|
||||
{
|
||||
var color = axisLine.barColor != Color.clear ? axisLine.barColor : (Color)theme.GetColor(index);
|
||||
var color = !ChartHelper.IsClearColor(axisLine.barColor) ? axisLine.barColor : (Color)theme.GetColor(index);
|
||||
color.a *= axisLine.opacity;
|
||||
return color;
|
||||
}
|
||||
|
||||
internal Color GetAxisLineBackgroundColor(ThemeInfo theme, int index)
|
||||
{
|
||||
var color = axisLine.barBackgroundColor != Color.clear ? axisLine.barBackgroundColor : Color.grey;
|
||||
var color = !ChartHelper.IsClearColor(axisLine.barBackgroundColor) ? axisLine.barBackgroundColor : Color.grey;
|
||||
color.a *= axisLine.opacity;
|
||||
return color;
|
||||
}
|
||||
@@ -192,7 +192,7 @@ namespace XCharts
|
||||
internal Color GetSplitLineColor(ThemeInfo theme, int serieIndex, float angle)
|
||||
{
|
||||
Color color;
|
||||
if (splitLine.lineStyle.color != Color.clear)
|
||||
if (!ChartHelper.IsClearColor(splitLine.lineStyle.color))
|
||||
{
|
||||
color = splitLine.lineStyle.color;
|
||||
color.a *= splitLine.lineStyle.opacity;
|
||||
@@ -215,7 +215,7 @@ namespace XCharts
|
||||
internal Color GetAxisTickColor(ThemeInfo theme, int serieIndex, float angle)
|
||||
{
|
||||
Color color;
|
||||
if (axisTick.lineStyle.color != Color.clear)
|
||||
if (!ChartHelper.IsClearColor(axisTick.lineStyle.color))
|
||||
{
|
||||
color = axisTick.lineStyle.color;
|
||||
color.a *= axisTick.lineStyle.opacity;
|
||||
@@ -238,7 +238,7 @@ namespace XCharts
|
||||
internal Color GetPointerColor(ThemeInfo theme, int serieIndex, float angle, ItemStyle itemStyle)
|
||||
{
|
||||
Color color;
|
||||
if (itemStyle.color != Color.clear)
|
||||
if (!ChartHelper.IsClearColor(itemStyle.color))
|
||||
{
|
||||
color = itemStyle.color;
|
||||
color.a *= itemStyle.opacity;
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace XCharts
|
||||
/// Whether the data icon is show.
|
||||
/// 是否显示图标。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; UpdateIcon(); } }
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// 显示在上层还是在下层。
|
||||
/// </summary>
|
||||
@@ -59,47 +59,5 @@ namespace XCharts
|
||||
/// 图标偏移。
|
||||
/// </summary>
|
||||
public Vector3 offset { get { return m_Offset; } set { m_Offset = value; } }
|
||||
|
||||
public Image image { get; private set; }
|
||||
public RectTransform rect { get; private set; }
|
||||
|
||||
public void SetImage(Image image)
|
||||
{
|
||||
this.image = image;
|
||||
if (image)
|
||||
{
|
||||
rect = image.GetComponent<RectTransform>();
|
||||
if (m_Layer == Layer.UnderLabel)
|
||||
rect.SetSiblingIndex(0);
|
||||
else
|
||||
rect.SetSiblingIndex(image.transform.childCount - 1);
|
||||
UpdateIcon();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetActive(bool flag)
|
||||
{
|
||||
if (image)
|
||||
{
|
||||
ChartHelper.SetActive(image.gameObject, flag);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateIcon()
|
||||
{
|
||||
if (image == null) return;
|
||||
if (show)
|
||||
{
|
||||
ChartHelper.SetActive(image.gameObject, true);
|
||||
image.sprite = m_Sprite;
|
||||
image.color = m_Color;
|
||||
rect.sizeDelta = new Vector2(m_Width, m_Height);
|
||||
image.transform.localPosition = m_Offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
ChartHelper.SetActive(image.gameObject, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,11 +178,12 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public bool NeedShowBorder()
|
||||
{
|
||||
return borderWidth != 0 && borderColor != Color.clear;
|
||||
return borderWidth != 0 && !ChartHelper.IsClearColor(borderColor);
|
||||
}
|
||||
|
||||
public Color GetColor()
|
||||
{
|
||||
if (m_Opacity == 1) return m_Color;
|
||||
var color = m_Color;
|
||||
color.a *= m_Opacity;
|
||||
return color;
|
||||
|
||||
@@ -32,10 +32,9 @@ namespace XCharts
|
||||
[SerializeField] private Emphasis m_Emphasis = new Emphasis();
|
||||
[SerializeField] private List<float> m_Data = new List<float>();
|
||||
|
||||
public LabelObject labelObject { get; set; }
|
||||
|
||||
private bool m_Show = true;
|
||||
private bool m_LabelAutoSize;
|
||||
private float m_LabelPaddingLeftRight;
|
||||
private float m_LabelPaddingTopBottom;
|
||||
private float m_RtPieOutsideRadius;
|
||||
|
||||
public int index { get; set; }
|
||||
@@ -102,15 +101,6 @@ namespace XCharts
|
||||
/// 该数据项是否被高亮,一般由鼠标悬停或图例悬停触发高亮。
|
||||
/// </summary>
|
||||
public bool highlighted { get; set; }
|
||||
/// <summary>
|
||||
/// the label of data item.
|
||||
/// 该数据项的文本标签。
|
||||
/// </summary>
|
||||
public Text labelText { get; private set; }
|
||||
public RectTransform labelRect { get; private set; }
|
||||
/// <summary>
|
||||
/// 标志位置。
|
||||
/// </summary>
|
||||
public Vector3 labelPosition { get; set; }
|
||||
private bool m_CanShowLabel = true;
|
||||
/// <summary>
|
||||
@@ -127,11 +117,6 @@ namespace XCharts
|
||||
/// 最小值。
|
||||
/// </summary>
|
||||
public float min { get { return m_Data.Min(); } }
|
||||
|
||||
/// <summary>
|
||||
/// 关联的gameObject
|
||||
/// </summary>
|
||||
public GameObject gameObject { get; private set; }
|
||||
/// <summary>
|
||||
/// 饼图数据项的开始角度(运行时自动计算)
|
||||
/// </summary>
|
||||
@@ -279,93 +264,21 @@ namespace XCharts
|
||||
return false;
|
||||
}
|
||||
|
||||
public void InitLabel(GameObject labelObj, bool autoSize, float paddingLeftRight, float paddingTopBottom)
|
||||
{
|
||||
gameObject = labelObj;
|
||||
m_LabelAutoSize = autoSize;
|
||||
m_LabelPaddingLeftRight = paddingLeftRight;
|
||||
m_LabelPaddingTopBottom = paddingTopBottom;
|
||||
labelText = labelObj.GetComponentInChildren<Text>();
|
||||
labelRect = labelText.GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
public void SetLabelActive(bool active)
|
||||
{
|
||||
if (labelRect)
|
||||
{
|
||||
ChartHelper.SetActive(labelRect, active);
|
||||
}
|
||||
}
|
||||
|
||||
public bool SetLabelText(string text)
|
||||
{
|
||||
if (labelText && !labelText.text.Equals(text))
|
||||
{
|
||||
labelText.text = text;
|
||||
if (m_LabelAutoSize)
|
||||
{
|
||||
var newSize = string.IsNullOrEmpty(text) ? Vector2.zero :
|
||||
new Vector2(labelText.preferredWidth + m_LabelPaddingLeftRight * 2,
|
||||
labelText.preferredHeight + m_LabelPaddingTopBottom * 2);
|
||||
var sizeChange = newSize.x != labelRect.sizeDelta.x || newSize.y != labelRect.sizeDelta.y;
|
||||
if (sizeChange) labelRect.sizeDelta = newSize;
|
||||
return sizeChange;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetLabelColor(Color color)
|
||||
{
|
||||
if (labelText)
|
||||
{
|
||||
labelText.color = color;
|
||||
}
|
||||
}
|
||||
|
||||
public float GetLabelWidth()
|
||||
{
|
||||
if (labelRect) return labelRect.sizeDelta.x;
|
||||
if (labelObject != null) return labelObject.GetLabelWidth();
|
||||
else return 0;
|
||||
}
|
||||
|
||||
public float GetLabelHeight()
|
||||
{
|
||||
if (labelRect) return labelRect.sizeDelta.y;
|
||||
if (labelObject != null) return labelObject.GetLabelHeight();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void SetGameObjectPosition(Vector3 position)
|
||||
public void SetLabelActive(bool flag)
|
||||
{
|
||||
if (gameObject)
|
||||
{
|
||||
gameObject.transform.localPosition = position;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLabelPosition(Vector3 position)
|
||||
{
|
||||
if (labelRect) labelRect.localPosition = position;
|
||||
}
|
||||
|
||||
[Obsolete("Use SerieData.SetIconImage() instead.", true)]
|
||||
public void SetIconObj(GameObject iconObj) { }
|
||||
|
||||
public void SetIconImage(Image image)
|
||||
{
|
||||
if (iconStyle == null) return;
|
||||
iconStyle.SetImage(image);
|
||||
}
|
||||
|
||||
public void UpdateIcon()
|
||||
{
|
||||
if (iconStyle == null) return;
|
||||
iconStyle.UpdateIcon();
|
||||
}
|
||||
|
||||
public bool IsInitLabel()
|
||||
{
|
||||
return labelText != null;
|
||||
if (labelObject != null) labelObject.SetLabelActive(flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace XCharts
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The position of label.
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace XCharts
|
||||
{
|
||||
if (runtimeText && !runtimeText.text.Equals(text))
|
||||
{
|
||||
if (textStyle.color != Color.clear) runtimeText.color = textStyle.color;
|
||||
if (!ChartHelper.IsClearColor(textStyle.color)) runtimeText.color = textStyle.color;
|
||||
runtimeText.text = text;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ namespace XCharts
|
||||
{
|
||||
if (!serie.gaugePointer.show) return;
|
||||
var pointerColor = serie.gaugeAxis.GetPointerColor(m_ThemeInfo, serie.index, currAngle, serie.itemStyle);
|
||||
var pointerToColor = serie.itemStyle.toColor != Color.clear ? serie.itemStyle.toColor : pointerColor;
|
||||
var pointerToColor = !ChartHelper.IsClearColor(serie.itemStyle.toColor) ? serie.itemStyle.toColor : pointerColor;
|
||||
var len = serie.gaugePointer.length < 1 && serie.gaugePointer.length > -1 ?
|
||||
serie.runtimeInsideRadius * serie.gaugePointer.length :
|
||||
serie.gaugePointer.length;
|
||||
|
||||
@@ -36,8 +36,8 @@ namespace XCharts
|
||||
RemoveData();
|
||||
var serie = AddSerie(SerieType.Heatmap, "serie1");
|
||||
var heatmapGridWid = 10f;
|
||||
int xSplitNumber = (int)(coordinateWidth / heatmapGridWid);
|
||||
int ySplitNumber = (int)(coordinateHeight / heatmapGridWid);
|
||||
int xSplitNumber = (int)(m_CoordinateWidth / heatmapGridWid);
|
||||
int ySplitNumber = (int)(m_CoordinateHeight / heatmapGridWid);
|
||||
serie.itemStyle.show = true;
|
||||
serie.itemStyle.borderWidth = 1;
|
||||
serie.itemStyle.borderColor = Color.clear;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace XCharts
|
||||
{
|
||||
private static bool IsColorAlphaZero(Color color)
|
||||
{
|
||||
return color != Color.clear && color.a == 0;
|
||||
return !ChartHelper.IsClearColor(color) && color.a == 0;
|
||||
}
|
||||
public static string CheckChart(BaseChart chart)
|
||||
{
|
||||
@@ -48,9 +48,9 @@ namespace XCharts
|
||||
var title = chart.title;
|
||||
if (!title.show) return;
|
||||
if (string.IsNullOrEmpty(title.text)) sb.Append("warning:title->text is null\n");
|
||||
if (title.textStyle.color != Color.clear && title.textStyle.color.a == 0)
|
||||
if(IsColorAlphaZero(title.textStyle.color))
|
||||
sb.Append("warning:title->textStyle->color alpha is 0\n");
|
||||
if (title.subTextStyle.color != Color.clear && title.subTextStyle.color.a == 0)
|
||||
if(IsColorAlphaZero(title.subTextStyle.color))
|
||||
sb.Append("warning:title->subTextStyle->color alpha is 0\n");
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace XCharts
|
||||
{
|
||||
var legend = chart.legend;
|
||||
if (!legend.show) return;
|
||||
if (legend.textStyle.color != Color.clear && legend.textStyle.color.a == 0)
|
||||
if(IsColorAlphaZero(legend.textStyle.color))
|
||||
sb.Append("warning:legend->textStyle->color alpha is 0\n");
|
||||
var serieNameList = chart.series.GetLegalSerieNameList();
|
||||
if (serieNameList.Count == 0) sb.Append("warning:legend need serie.name or serieData.name not empty\n");
|
||||
@@ -106,7 +106,7 @@ namespace XCharts
|
||||
sb.AppendFormat("warning:serie {0} lineStyle->width is 0\n", serie.index);
|
||||
if (serie.lineStyle.opacity == 0)
|
||||
sb.AppendFormat("warning:serie {0} lineStyle->opacity is 0\n", serie.index);
|
||||
if (serie.lineStyle.color != Color.clear && serie.lineStyle.color.a == 0)
|
||||
if(IsColorAlphaZero(serie.lineStyle.color))
|
||||
sb.AppendFormat("warning:serie {0} lineStyle->color alpha is 0\n", serie.index);
|
||||
break;
|
||||
case SerieType.Bar:
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace XCharts
|
||||
public static Color GetContentColor(Legend legend, ThemeInfo themeInfo, bool active)
|
||||
{
|
||||
var textStyle = legend.textStyle;
|
||||
if (active) return textStyle.color != Color.clear ? textStyle.color : (Color)themeInfo.legendTextColor;
|
||||
if (active) return !ChartHelper.IsClearColor(textStyle.color) ? textStyle.color : (Color)themeInfo.legendTextColor;
|
||||
else return (Color)themeInfo.legendUnableColor;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,19 +13,19 @@ namespace XCharts
|
||||
{
|
||||
internal static Color GetItemBackgroundColor(Serie serie, SerieData serieData, ThemeInfo theme, int index, bool highlight, bool useDefault = true)
|
||||
{
|
||||
var itemStyle = GetItemStyle(serie, serieData);
|
||||
var color = Color.clear;
|
||||
if (highlight)
|
||||
{
|
||||
var itemStyleEmphasis = GetItemStyleEmphasis(serie, serieData);
|
||||
if (itemStyleEmphasis != null && itemStyleEmphasis.backgroundColor != Color.clear)
|
||||
if (itemStyleEmphasis != null && !ChartHelper.IsClearColor(itemStyleEmphasis.backgroundColor))
|
||||
{
|
||||
color = itemStyleEmphasis.backgroundColor;
|
||||
color.a *= itemStyleEmphasis.opacity;
|
||||
return color;
|
||||
}
|
||||
}
|
||||
if (itemStyle.backgroundColor != Color.clear)
|
||||
var itemStyle = GetItemStyle(serie, serieData);
|
||||
if (!ChartHelper.IsClearColor(itemStyle.backgroundColor))
|
||||
{
|
||||
color = itemStyle.backgroundColor;
|
||||
if (highlight) color *= color;
|
||||
@@ -39,23 +39,23 @@ namespace XCharts
|
||||
color.a = 0.2f;
|
||||
return color;
|
||||
}
|
||||
return Color.clear;
|
||||
return color;
|
||||
}
|
||||
|
||||
internal static Color GetItemColor(Serie serie, SerieData serieData, ThemeInfo theme, int index, bool highlight)
|
||||
{
|
||||
var itemStyle = GetItemStyle(serie, serieData);
|
||||
if (highlight)
|
||||
{
|
||||
var itemStyleEmphasis = GetItemStyleEmphasis(serie, serieData);
|
||||
if (itemStyleEmphasis != null && itemStyleEmphasis.color != Color.clear)
|
||||
if (itemStyleEmphasis != null && !ChartHelper.IsClearColor(itemStyleEmphasis.color))
|
||||
{
|
||||
var color = itemStyleEmphasis.color;
|
||||
color.a *= itemStyleEmphasis.opacity;
|
||||
return color;
|
||||
}
|
||||
}
|
||||
if (itemStyle.color != Color.clear)
|
||||
var itemStyle = GetItemStyle(serie, serieData);
|
||||
if (!ChartHelper.IsClearColor(itemStyle.color))
|
||||
{
|
||||
var color = itemStyle.color;
|
||||
if (highlight) color *= color;
|
||||
@@ -73,26 +73,26 @@ namespace XCharts
|
||||
|
||||
internal static Color GetItemToColor(Serie serie, SerieData serieData, ThemeInfo theme, int index, bool highlight)
|
||||
{
|
||||
var itemStyle = GetItemStyle(serie, serieData, highlight);
|
||||
if (highlight)
|
||||
{
|
||||
var itemStyleEmphasis = GetItemStyleEmphasis(serie, serieData);
|
||||
if (itemStyleEmphasis != null && itemStyleEmphasis.toColor != Color.clear)
|
||||
if (itemStyleEmphasis != null && !ChartHelper.IsClearColor(itemStyleEmphasis.toColor))
|
||||
{
|
||||
var color = itemStyleEmphasis.toColor;
|
||||
color.a *= itemStyleEmphasis.opacity;
|
||||
return color;
|
||||
}
|
||||
}
|
||||
var itemStyle = GetItemStyle(serie, serieData, highlight);
|
||||
if (itemStyle == null) itemStyle = serieData.itemStyle;
|
||||
if (itemStyle.toColor != Color.clear)
|
||||
if (!ChartHelper.IsClearColor(itemStyle.toColor))
|
||||
{
|
||||
var color = itemStyle.toColor;
|
||||
if (highlight) color *= color;
|
||||
color.a *= itemStyle.opacity;
|
||||
return color;
|
||||
}
|
||||
if (itemStyle.color != Color.clear)
|
||||
if (!ChartHelper.IsClearColor(itemStyle.color))
|
||||
{
|
||||
var color = itemStyle.color;
|
||||
if (highlight) color *= color;
|
||||
@@ -142,13 +142,14 @@ namespace XCharts
|
||||
if (style == null) return GetItemStyle(serie, serieData, false);
|
||||
else return style;
|
||||
}
|
||||
else if (serie.IsPerformanceMode()) return serie.itemStyle;
|
||||
else if (serieData != null && serieData.enableItemStyle) return serieData.itemStyle;
|
||||
else return serie.itemStyle;
|
||||
}
|
||||
|
||||
public static ItemStyle GetItemStyleEmphasis(Serie serie, SerieData serieData)
|
||||
{
|
||||
if (serieData != null && serieData.enableEmphasis && serieData.emphasis.show)
|
||||
if (!serie.IsPerformanceMode() && serieData != null && serieData.enableEmphasis && serieData.emphasis.show)
|
||||
return serieData.emphasis.itemStyle;
|
||||
else if (serie.emphasis.show) return serie.emphasis.itemStyle;
|
||||
else return null;
|
||||
@@ -158,13 +159,14 @@ namespace XCharts
|
||||
{
|
||||
if (highlight)
|
||||
{
|
||||
if (serieData.enableEmphasis && serieData.emphasis.show) return serieData.emphasis.label;
|
||||
if (!serie.IsPerformanceMode() && serieData.enableEmphasis && serieData.emphasis.show)
|
||||
return serieData.emphasis.label;
|
||||
else if (serie.emphasis.show) return serie.emphasis.label;
|
||||
else return serie.label;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (serieData.enableLabel) return serieData.label;
|
||||
if (!serie.IsPerformanceMode() && serieData.enableLabel) return serieData.label;
|
||||
else return serie.label;
|
||||
}
|
||||
}
|
||||
@@ -172,10 +174,10 @@ namespace XCharts
|
||||
public static Color GetAreaColor(Serie serie, ThemeInfo theme, int index, bool highlight)
|
||||
{
|
||||
var areaStyle = serie.areaStyle;
|
||||
var color = areaStyle.color != Color.clear ? areaStyle.color : (Color)theme.GetColor(index);
|
||||
var color = !ChartHelper.IsClearColor(areaStyle.color) ? areaStyle.color : (Color)theme.GetColor(index);
|
||||
if (highlight)
|
||||
{
|
||||
if (areaStyle.highlightColor != Color.clear) color = areaStyle.highlightColor;
|
||||
if (!ChartHelper.IsClearColor(areaStyle.highlightColor)) color = areaStyle.highlightColor;
|
||||
else color *= color;
|
||||
}
|
||||
color.a *= areaStyle.opacity;
|
||||
@@ -185,12 +187,12 @@ namespace XCharts
|
||||
public static Color GetAreaToColor(Serie serie, ThemeInfo theme, int index, bool highlight)
|
||||
{
|
||||
var areaStyle = serie.areaStyle;
|
||||
if (areaStyle.toColor != Color.clear)
|
||||
if (!ChartHelper.IsClearColor(areaStyle.toColor))
|
||||
{
|
||||
var color = areaStyle.toColor;
|
||||
if (highlight)
|
||||
{
|
||||
if (areaStyle.highlightToColor != Color.clear) color = areaStyle.highlightToColor;
|
||||
if (!ChartHelper.IsClearColor(areaStyle.highlightToColor)) color = areaStyle.highlightToColor;
|
||||
else color *= color;
|
||||
}
|
||||
color.a *= areaStyle.opacity;
|
||||
@@ -208,16 +210,16 @@ namespace XCharts
|
||||
if (highlight)
|
||||
{
|
||||
var itemStyleEmphasis = GetItemStyleEmphasis(serie, null);
|
||||
if (itemStyleEmphasis != null && itemStyleEmphasis.color != Color.clear)
|
||||
if (itemStyleEmphasis != null && !ChartHelper.IsClearColor(itemStyleEmphasis.color))
|
||||
{
|
||||
color = itemStyleEmphasis.color;
|
||||
color.a *= itemStyleEmphasis.opacity;
|
||||
return color;
|
||||
}
|
||||
}
|
||||
if (serie.lineStyle.color != Color.clear) color = serie.lineStyle.GetColor();
|
||||
else if (serie.itemStyle.color != Color.clear) color = serie.itemStyle.GetColor();
|
||||
if (color == Color.clear)
|
||||
if (!ChartHelper.IsClearColor(serie.lineStyle.color)) color = serie.lineStyle.GetColor();
|
||||
else if (!ChartHelper.IsClearColor(serie.itemStyle.color)) color = serie.itemStyle.GetColor();
|
||||
if (ChartHelper.IsClearColor(color))
|
||||
{
|
||||
color = (Color)theme.GetColor(index);
|
||||
color.a = serie.lineStyle.opacity;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace XCharts
|
||||
{
|
||||
if (serie.label.show && serie.show)
|
||||
{
|
||||
if (serieData.IsInitLabel())
|
||||
if (serieData.labelObject != null)
|
||||
{
|
||||
serieData.SetLabelActive(true);
|
||||
m_UpdateLabelText = true;
|
||||
@@ -32,7 +32,7 @@ namespace XCharts
|
||||
m_ReinitLabel = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (serieData.labelObject != null)
|
||||
{
|
||||
serieData.SetLabelActive(false);
|
||||
}
|
||||
@@ -60,7 +60,7 @@ namespace XCharts
|
||||
|
||||
public static Color GetLabelColor(Serie serie, ThemeInfo themeInfo, int index)
|
||||
{
|
||||
if (serie.label.color != Color.clear)
|
||||
if (!ChartHelper.IsClearColor(serie.label.color))
|
||||
{
|
||||
return serie.label.color;
|
||||
}
|
||||
@@ -72,13 +72,12 @@ namespace XCharts
|
||||
|
||||
public static void ResetLabel(SerieData serieData, SerieLabel label, ThemeInfo themeInfo, int colorIndex)
|
||||
{
|
||||
if (serieData.labelText)
|
||||
{
|
||||
serieData.labelText.color = label.color != Color.clear ? label.color :
|
||||
(Color)themeInfo.GetColor(colorIndex);
|
||||
serieData.labelText.fontSize = label.fontSize;
|
||||
serieData.labelText.fontStyle = label.fontStyle;
|
||||
}
|
||||
if (serieData.labelObject == null) return;
|
||||
if (serieData.labelObject.label == null) return;
|
||||
serieData.labelObject.label.color = !ChartHelper.IsClearColor(label.color) ? label.color :
|
||||
(Color)themeInfo.GetColor(colorIndex);
|
||||
serieData.labelObject.label.fontSize = label.fontSize;
|
||||
serieData.labelObject.label.fontStyle = label.fontStyle;
|
||||
}
|
||||
|
||||
public static string GetFormatterContent(Serie serie, SerieData serieData,
|
||||
@@ -126,20 +125,16 @@ namespace XCharts
|
||||
private static void SetGaugeLabelText(Serie serie)
|
||||
{
|
||||
var serieData = serie.GetSerieData(0);
|
||||
if (serieData != null)
|
||||
if (serieData == null) return;
|
||||
if (serieData.labelObject == null) return;
|
||||
var value = serieData.GetData(1);
|
||||
var total = serie.max;
|
||||
var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, total);
|
||||
serieData.labelObject.SetText(content);
|
||||
serieData.labelObject.SetLabelPosition(serie.runtimeCenterPos + serie.label.offset);
|
||||
if (!ChartHelper.IsClearColor(serie.label.color))
|
||||
{
|
||||
if (serieData.IsInitLabel())
|
||||
{
|
||||
var value = serieData.GetData(1);
|
||||
var total = serie.max;
|
||||
var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, total);
|
||||
serieData.SetLabelText(content);
|
||||
serieData.SetLabelPosition(serie.runtimeCenterPos + serie.label.offset);
|
||||
if (serie.label.color != Color.clear)
|
||||
{
|
||||
serieData.SetLabelColor(serie.label.color);
|
||||
}
|
||||
}
|
||||
serieData.labelObject.label.color = serie.label.color;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +144,7 @@ namespace XCharts
|
||||
{
|
||||
var serieData = serie.data[i];
|
||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData, serieData.highlighted);
|
||||
if (serieLabel.show && serieData.IsInitLabel())
|
||||
if (serieLabel.show && serieData.labelObject != null)
|
||||
{
|
||||
if (!serie.show || !serieData.show)
|
||||
{
|
||||
@@ -160,20 +155,20 @@ namespace XCharts
|
||||
var total = serieData.GetData(1);
|
||||
var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, total);
|
||||
serieData.SetLabelActive(true);
|
||||
serieData.SetLabelText(content);
|
||||
serieData.SetLabelColor(GetLabelColor(serie, themeInfo, i));
|
||||
serieData.labelObject.SetText(content);
|
||||
serieData.labelObject.SetLabelColor(GetLabelColor(serie, themeInfo, i));
|
||||
|
||||
if (serie.label.position == SerieLabel.Position.Bottom)
|
||||
{
|
||||
var labelWidth = serieData.GetLabelWidth();
|
||||
if (serie.clockwise)
|
||||
serieData.SetLabelPosition(serieData.labelPosition - new Vector3(labelWidth / 2, 0));
|
||||
serieData.labelObject.SetLabelPosition(serieData.labelPosition - new Vector3(labelWidth / 2, 0));
|
||||
else
|
||||
serieData.SetLabelPosition(serieData.labelPosition + new Vector3(labelWidth / 2, 0));
|
||||
serieData.labelObject.SetLabelPosition(serieData.labelPosition + new Vector3(labelWidth / 2, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
serieData.SetLabelPosition(serieData.labelPosition);
|
||||
serieData.labelObject.SetLabelPosition(serieData.labelPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace XCharts
|
||||
|
||||
public static Color GetTextColor(Title title, ThemeInfo themeInfo)
|
||||
{
|
||||
return title.textStyle.color != Color.clear ? title.textStyle.color : (Color)themeInfo.titleTextColor;
|
||||
return !ChartHelper.IsClearColor(title.textStyle.color) ? title.textStyle.color : (Color)themeInfo.titleTextColor;
|
||||
}
|
||||
|
||||
public static Font GetSubTextFont(Title title, ThemeInfo themeInfo)
|
||||
@@ -28,7 +28,7 @@ namespace XCharts
|
||||
|
||||
public static Color GetSubTextColor(Title title, ThemeInfo themeInfo)
|
||||
{
|
||||
return title.subTextStyle.color != Color.clear ? title.subTextStyle.color : (Color)themeInfo.titleSubTextColor;
|
||||
return !ChartHelper.IsClearColor(title.subTextStyle.color) ? title.subTextStyle.color : (Color)themeInfo.titleSubTextColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -421,7 +421,7 @@ namespace XCharts
|
||||
public static Color GetLineColor(Tooltip tooltip, ThemeInfo theme)
|
||||
{
|
||||
var lineStyle = tooltip.lineStyle;
|
||||
if (lineStyle.color != Color.clear)
|
||||
if (!ChartHelper.IsClearColor(lineStyle.color))
|
||||
{
|
||||
var color = lineStyle.color;
|
||||
color.a *= lineStyle.opacity;
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace XCharts
|
||||
IDragHandler, IEndDragHandler, IScrollHandler
|
||||
{
|
||||
protected static readonly string s_TitleObjectName = "title";
|
||||
protected static readonly string s_SubTitleObjectName = "title_sub";
|
||||
protected static readonly string s_LegendObjectName = "legend";
|
||||
protected static readonly string s_SerieLabelObjectName = "label";
|
||||
protected static readonly string s_SerieTitleObjectName = "serie";
|
||||
@@ -70,6 +71,7 @@ namespace XCharts
|
||||
[NonSerialized] protected bool m_CheckAnimation = false;
|
||||
[NonSerialized] protected bool m_IsPlayingAnimation = false;
|
||||
[NonSerialized] protected List<string> m_LegendRealShowName = new List<string>();
|
||||
[NonSerialized] protected GameObject m_SerieLabelRoot;
|
||||
|
||||
protected Vector2 chartAnchorMax { get { return m_ChartMinAnchor; } }
|
||||
protected Vector2 chartAnchorMin { get { return m_ChartMaxAnchor; } }
|
||||
@@ -249,7 +251,7 @@ namespace XCharts
|
||||
|
||||
var subTextFont = TitleHelper.GetSubTextFont(title, themeInfo);
|
||||
var subTextColor = TitleHelper.GetSubTextColor(title, themeInfo);
|
||||
Text subText = ChartHelper.AddTextObject(s_TitleObjectName + "_sub", titleObject.transform,
|
||||
Text subText = ChartHelper.AddTextObject(s_SubTitleObjectName, titleObject.transform,
|
||||
subTextFont, subTextColor, 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.lineSpacing);
|
||||
@@ -364,9 +366,9 @@ namespace XCharts
|
||||
|
||||
private void InitSerieLabel()
|
||||
{
|
||||
var labelObject = ChartHelper.AddObject(s_SerieLabelObjectName, transform, m_ChartMinAnchor,
|
||||
m_SerieLabelRoot = ChartHelper.AddObject(s_SerieLabelObjectName, transform, m_ChartMinAnchor,
|
||||
m_ChartMaxAnchor, m_ChartPivot, m_ChartSizeDelta);
|
||||
SerieLabelPool.ReleaseAll(labelObject.transform);
|
||||
SerieLabelPool.ReleaseAll(m_SerieLabelRoot.transform);
|
||||
int count = 0;
|
||||
for (int i = 0; i < m_Series.Count; i++)
|
||||
{
|
||||
@@ -375,34 +377,44 @@ namespace XCharts
|
||||
for (int j = 0; j < serie.data.Count; j++)
|
||||
{
|
||||
var serieData = serie.data[j];
|
||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
||||
if (!serieLabel.show && j > 100) continue;
|
||||
var textName = ChartCached.GetSerieLabelName(s_SerieLabelObjectName, i, j);
|
||||
var color = Color.grey;
|
||||
if (serie.type == SerieType.Pie)
|
||||
{
|
||||
color = (serieLabel.position == SerieLabel.Position.Inside) ? Color.white :
|
||||
(Color)m_ThemeInfo.GetColor(count);
|
||||
}
|
||||
else
|
||||
{
|
||||
color = serieLabel.color != Color.clear ? serieLabel.color :
|
||||
(Color)m_ThemeInfo.GetColor(i);
|
||||
}
|
||||
var labelObj = SerieLabelPool.Get(textName, labelObject.transform, serieLabel, m_ThemeInfo.font, color,
|
||||
serieData.iconStyle.width, serieData.iconStyle.height);
|
||||
var iconImage = labelObj.transform.Find("Icon").GetComponent<Image>();
|
||||
serieData.SetIconImage(iconImage);
|
||||
|
||||
var isAutoSize = serieLabel.backgroundWidth == 0 || serieLabel.backgroundHeight == 0;
|
||||
serieData.InitLabel(labelObj, isAutoSize, serieLabel.paddingLeftRight, serieLabel.paddingTopBottom);
|
||||
serieData.SetLabelActive(false);
|
||||
serieData.index = j;
|
||||
AddSerieLabel(serie, serieData, count);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
SerieLabelHelper.UpdateLabelText(m_Series, m_ThemeInfo);
|
||||
}
|
||||
|
||||
protected void AddSerieLabel(Serie serie, SerieData serieData, int count = -1)
|
||||
{
|
||||
if (m_SerieLabelRoot == null) return;
|
||||
if (count == -1) count = serie.dataCount;
|
||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
||||
if (serie.IsPerformanceMode()) return;
|
||||
if (!serieLabel.show) return;
|
||||
var textName = ChartCached.GetSerieLabelName(s_SerieLabelObjectName, serie.index, serieData.index);
|
||||
var color = Color.grey;
|
||||
if (serie.type == SerieType.Pie)
|
||||
{
|
||||
color = (serieLabel.position == SerieLabel.Position.Inside) ? Color.white :
|
||||
(Color)m_ThemeInfo.GetColor(count);
|
||||
}
|
||||
else
|
||||
{
|
||||
color = !ChartHelper.IsClearColor(serieLabel.color) ? serieLabel.color :
|
||||
(Color)m_ThemeInfo.GetColor(serie.index);
|
||||
}
|
||||
var labelObj = SerieLabelPool.Get(textName, m_SerieLabelRoot.transform, serieLabel, m_ThemeInfo.font, color,
|
||||
serieData.iconStyle.width, serieData.iconStyle.height);
|
||||
var iconImage = labelObj.transform.Find("Icon").GetComponent<Image>();
|
||||
var isAutoSize = serieLabel.backgroundWidth == 0 || serieLabel.backgroundHeight == 0;
|
||||
var item = new LabelObject();
|
||||
item.SetLabel(labelObj, isAutoSize, serieLabel.paddingLeftRight, serieLabel.paddingTopBottom);
|
||||
item.SetIcon(iconImage);
|
||||
item.SetIconActive(false);
|
||||
serieData.labelObject = item;
|
||||
}
|
||||
|
||||
private void InitSerieTitle()
|
||||
{
|
||||
var titleObject = ChartHelper.AddObject(s_SerieTitleObjectName, transform, m_ChartMinAnchor,
|
||||
@@ -412,7 +424,7 @@ namespace XCharts
|
||||
{
|
||||
var serie = m_Series.list[i];
|
||||
var textStyle = serie.titleStyle.textStyle;
|
||||
var color = textStyle.color == Color.clear ? m_ThemeInfo.GetColor(i) : (Color32)textStyle.color;
|
||||
var color = ChartHelper.IsClearColor(textStyle.color) ? m_ThemeInfo.GetColor(i) : (Color32)textStyle.color;
|
||||
var anchorMin = new Vector2(0.5f, 0.5f);
|
||||
var anchorMax = new Vector2(0.5f, 0.5f);
|
||||
var pivot = new Vector2(0.5f, 0.5f);
|
||||
@@ -850,7 +862,7 @@ namespace XCharts
|
||||
&& SerieHelper.IsDownPoint(serie, serieData.index)
|
||||
&& !serie.areaStyle.show;
|
||||
var centerPos = serieData.labelPosition + serieLabel.offset * (invert ? -1 : 1);
|
||||
var labelHalfWid = serieData.GetLabelWidth() / 2;
|
||||
var labelHalfWid = serieData.labelObject.GetLabelWidth() / 2;
|
||||
var labelHalfHig = serieData.GetLabelHeight() / 2;
|
||||
var p1 = new Vector3(centerPos.x - labelHalfWid, centerPos.y + labelHalfHig);
|
||||
var p2 = new Vector3(centerPos.x + labelHalfWid, centerPos.y + labelHalfHig);
|
||||
|
||||
@@ -24,6 +24,10 @@ namespace XCharts
|
||||
[SerializeField] protected DataZoom m_DataZoom = DataZoom.defaultDataZoom;
|
||||
[SerializeField] protected VisualMap m_VisualMap = new VisualMap();
|
||||
|
||||
protected float m_CoordinateX;
|
||||
protected float m_CoordinateY;
|
||||
protected float m_CoordinateWidth;
|
||||
protected float m_CoordinateHeight;
|
||||
private bool m_DataZoomDrag;
|
||||
private bool m_DataZoomCoordinateDrag;
|
||||
private bool m_DataZoomStartDrag;
|
||||
@@ -147,11 +151,11 @@ namespace XCharts
|
||||
var xSplitDiff = xAxis0.splitLine.lineStyle.width;
|
||||
var ySplitDiff = yAxis0.splitLine.lineStyle.width;
|
||||
|
||||
var cpty = coordinateY + coordinateHeight + ySplitDiff;
|
||||
var cp1 = new Vector3(coordinateX - yLineDiff, coordinateY - xLineDiff);
|
||||
var cp2 = new Vector3(coordinateX - yLineDiff, cpty);
|
||||
var cp3 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, cpty);
|
||||
var cp4 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, coordinateY - xLineDiff);
|
||||
var cpty = m_CoordinateY + m_CoordinateHeight + ySplitDiff;
|
||||
var cp1 = new Vector3(m_CoordinateX - yLineDiff, m_CoordinateY - xLineDiff);
|
||||
var cp2 = new Vector3(m_CoordinateX - yLineDiff, cpty);
|
||||
var cp3 = new Vector3(m_CoordinateX + m_CoordinateWidth + xSplitDiff, cpty);
|
||||
var cp4 = new Vector3(m_CoordinateX + m_CoordinateWidth + xSplitDiff, m_CoordinateY - xLineDiff);
|
||||
ChartDrawer.DrawPolygon(vh, cp1, cp2, cp3, cp4, m_ThemeInfo.backgroundColor);
|
||||
|
||||
}
|
||||
@@ -170,23 +174,23 @@ namespace XCharts
|
||||
var ySplitDiff = yAxis0.splitLine.lineStyle.width;
|
||||
var lp1 = new Vector3(m_ChartX, m_ChartY);
|
||||
var lp2 = new Vector3(m_ChartX, m_ChartY + chartHeight);
|
||||
var lp3 = new Vector3(coordinateX - yLineDiff, m_ChartY + chartHeight);
|
||||
var lp4 = new Vector3(coordinateX - yLineDiff, m_ChartY);
|
||||
var lp3 = new Vector3(m_CoordinateX - yLineDiff, m_ChartY + chartHeight);
|
||||
var lp4 = new Vector3(m_CoordinateX - yLineDiff, m_ChartY);
|
||||
ChartDrawer.DrawPolygon(vh, lp1, lp2, lp3, lp4, m_ThemeInfo.backgroundColor);
|
||||
var rp1 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, m_ChartY);
|
||||
var rp2 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, m_ChartY + chartHeight);
|
||||
var rp1 = new Vector3(m_CoordinateX + m_CoordinateWidth + xSplitDiff, m_ChartY);
|
||||
var rp2 = new Vector3(m_CoordinateX + m_CoordinateWidth + xSplitDiff, m_ChartY + chartHeight);
|
||||
var rp3 = new Vector3(m_ChartX + chartWidth, m_ChartY + chartHeight);
|
||||
var rp4 = new Vector3(m_ChartX + chartWidth, m_ChartY);
|
||||
ChartDrawer.DrawPolygon(vh, rp1, rp2, rp3, rp4, m_ThemeInfo.backgroundColor);
|
||||
var up1 = new Vector3(coordinateX - yLineDiff, coordinateY + coordinateHeight + ySplitDiff);
|
||||
var up2 = new Vector3(coordinateX - yLineDiff, m_ChartY + chartHeight);
|
||||
var up3 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, m_ChartY + chartHeight);
|
||||
var up4 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, coordinateY + coordinateHeight + ySplitDiff);
|
||||
var up1 = new Vector3(m_CoordinateX - yLineDiff, m_CoordinateY + m_CoordinateHeight + ySplitDiff);
|
||||
var up2 = new Vector3(m_CoordinateX - yLineDiff, m_ChartY + chartHeight);
|
||||
var up3 = new Vector3(m_CoordinateX + m_CoordinateWidth + xSplitDiff, m_ChartY + chartHeight);
|
||||
var up4 = new Vector3(m_CoordinateX + m_CoordinateWidth + xSplitDiff, m_CoordinateY + m_CoordinateHeight + ySplitDiff);
|
||||
ChartDrawer.DrawPolygon(vh, up1, up2, up3, up4, m_ThemeInfo.backgroundColor);
|
||||
var dp1 = new Vector3(coordinateX - yLineDiff, m_ChartY);
|
||||
var dp2 = new Vector3(coordinateX - yLineDiff, coordinateY - xLineDiff);
|
||||
var dp3 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, coordinateY - xLineDiff);
|
||||
var dp4 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, m_ChartY);
|
||||
var dp1 = new Vector3(m_CoordinateX - yLineDiff, m_ChartY);
|
||||
var dp2 = new Vector3(m_CoordinateX - yLineDiff, m_CoordinateY - xLineDiff);
|
||||
var dp3 = new Vector3(m_CoordinateX + m_CoordinateWidth + xSplitDiff, m_CoordinateY - xLineDiff);
|
||||
var dp4 = new Vector3(m_CoordinateX + m_CoordinateWidth + xSplitDiff, m_ChartY);
|
||||
ChartDrawer.DrawPolygon(vh, dp1, dp2, dp3, dp4, m_ThemeInfo.backgroundColor);
|
||||
}
|
||||
|
||||
@@ -260,12 +264,12 @@ namespace XCharts
|
||||
if (!xAxis.show && !yAxis.show) continue;
|
||||
if (isCartesian && xAxis.show && yAxis.show)
|
||||
{
|
||||
var yRate = (yAxis.runtimeMaxValue - yAxis.runtimeMinValue) / coordinateHeight;
|
||||
var xRate = (xAxis.runtimeMaxValue - xAxis.runtimeMinValue) / coordinateWidth;
|
||||
var yValue = yRate * (local.y - coordinateY - yAxis.runtimeZeroYOffset);
|
||||
var yRate = (yAxis.runtimeMaxValue - yAxis.runtimeMinValue) / m_CoordinateHeight;
|
||||
var xRate = (xAxis.runtimeMaxValue - xAxis.runtimeMinValue) / m_CoordinateWidth;
|
||||
var yValue = yRate * (local.y - m_CoordinateY - yAxis.runtimeZeroYOffset);
|
||||
if (yAxis.runtimeMinValue > 0) yValue += yAxis.runtimeMinValue;
|
||||
m_Tooltip.runtimeYValues[i] = yValue;
|
||||
var xValue = xRate * (local.x - coordinateX - xAxis.runtimeZeroXOffset);
|
||||
var xValue = xRate * (local.x - m_CoordinateX - xAxis.runtimeZeroXOffset);
|
||||
if (xAxis.runtimeMinValue > 0) xValue += xAxis.runtimeMinValue;
|
||||
m_Tooltip.runtimeXValues[i] = xValue;
|
||||
|
||||
@@ -296,8 +300,8 @@ namespace XCharts
|
||||
|
||||
for (int j = 0; j < xAxis.GetDataNumber(m_DataZoom); j++)
|
||||
{
|
||||
float splitWid = xAxis.GetDataWidth(coordinateWidth, dataCount, m_DataZoom);
|
||||
float pX = coordinateX + j * splitWid;
|
||||
float splitWid = xAxis.GetDataWidth(m_CoordinateWidth, dataCount, m_DataZoom);
|
||||
float pX = m_CoordinateX + j * splitWid;
|
||||
if ((xAxis.boundaryGap && (local.x > pX && local.x <= pX + splitWid)) ||
|
||||
(!xAxis.boundaryGap && (local.x > pX - splitWid / 2 && local.x <= pX + splitWid / 2)))
|
||||
{
|
||||
@@ -308,8 +312,8 @@ namespace XCharts
|
||||
}
|
||||
for (int j = 0; j < yAxis.GetDataNumber(m_DataZoom); j++)
|
||||
{
|
||||
float splitWid = yAxis.GetDataWidth(coordinateHeight, dataCount, m_DataZoom);
|
||||
float pY = coordinateY + j * splitWid;
|
||||
float splitWid = yAxis.GetDataWidth(m_CoordinateHeight, dataCount, m_DataZoom);
|
||||
float pY = m_CoordinateY + j * splitWid;
|
||||
if ((yAxis.boundaryGap && (local.y > pY && local.y <= pY + splitWid)) ||
|
||||
(!yAxis.boundaryGap && (local.y > pY - splitWid / 2 && local.y <= pY + splitWid / 2)))
|
||||
{
|
||||
@@ -320,13 +324,13 @@ namespace XCharts
|
||||
}
|
||||
else if (xAxis.IsCategory())
|
||||
{
|
||||
var value = (yAxis.runtimeMaxValue - yAxis.runtimeMinValue) * (local.y - coordinateY - yAxis.runtimeZeroYOffset) / coordinateHeight;
|
||||
var value = (yAxis.runtimeMaxValue - yAxis.runtimeMinValue) * (local.y - m_CoordinateY - yAxis.runtimeZeroYOffset) / m_CoordinateHeight;
|
||||
if (yAxis.runtimeMinValue > 0) value += yAxis.runtimeMinValue;
|
||||
m_Tooltip.runtimeYValues[i] = value;
|
||||
for (int j = 0; j < xAxis.GetDataNumber(m_DataZoom); j++)
|
||||
{
|
||||
float splitWid = xAxis.GetDataWidth(coordinateWidth, dataCount, m_DataZoom);
|
||||
float pX = coordinateX + j * splitWid;
|
||||
float splitWid = xAxis.GetDataWidth(m_CoordinateWidth, dataCount, m_DataZoom);
|
||||
float pX = m_CoordinateX + j * splitWid;
|
||||
if ((xAxis.boundaryGap && (local.x > pX && local.x <= pX + splitWid)) ||
|
||||
(!xAxis.boundaryGap && (local.x > pX - splitWid / 2 && local.x <= pX + splitWid / 2)))
|
||||
{
|
||||
@@ -338,13 +342,13 @@ namespace XCharts
|
||||
}
|
||||
else if (yAxis.IsCategory())
|
||||
{
|
||||
var value = (xAxis.runtimeMaxValue - xAxis.runtimeMinValue) * (local.x - coordinateX - xAxis.runtimeZeroXOffset) / coordinateWidth;
|
||||
var value = (xAxis.runtimeMaxValue - xAxis.runtimeMinValue) * (local.x - m_CoordinateX - xAxis.runtimeZeroXOffset) / m_CoordinateWidth;
|
||||
if (xAxis.runtimeMinValue > 0) value += xAxis.runtimeMinValue;
|
||||
m_Tooltip.runtimeXValues[i] = value;
|
||||
for (int j = 0; j < yAxis.GetDataNumber(m_DataZoom); j++)
|
||||
{
|
||||
float splitWid = yAxis.GetDataWidth(coordinateHeight, dataCount, m_DataZoom);
|
||||
float pY = coordinateY + j * splitWid;
|
||||
float splitWid = yAxis.GetDataWidth(m_CoordinateHeight, dataCount, m_DataZoom);
|
||||
float pY = m_CoordinateY + j * splitWid;
|
||||
if ((yAxis.boundaryGap && (local.y > pY && local.y <= pY + splitWid)) ||
|
||||
(!yAxis.boundaryGap && (local.y > pY - splitWid / 2 && local.y <= pY + splitWid / 2)))
|
||||
{
|
||||
@@ -429,7 +433,7 @@ namespace XCharts
|
||||
Vector2 labelPos = Vector2.zero;
|
||||
if (axis is XAxis)
|
||||
{
|
||||
var posY = axisIndex > 0 ? coordinateY + coordinateHeight : coordinateY;
|
||||
var posY = axisIndex > 0 ? m_CoordinateY + m_CoordinateHeight : m_CoordinateY;
|
||||
var diff = axisIndex > 0 ? -axis.axisLabel.fontSize - axis.axisLabel.margin - 3.5f : axis.axisLabel.margin / 2 + 1;
|
||||
if (axis.IsValue())
|
||||
{
|
||||
@@ -439,15 +443,15 @@ namespace XCharts
|
||||
else
|
||||
{
|
||||
labelText = axis.GetData((int)m_Tooltip.runtimeXValues[axisIndex], m_DataZoom);
|
||||
float splitWidth = axis.GetSplitWidth(coordinateWidth, m_DataZoom);
|
||||
float splitWidth = axis.GetSplitWidth(m_CoordinateWidth, m_DataZoom);
|
||||
int index = (int)m_Tooltip.runtimeXValues[axisIndex];
|
||||
float px = coordinateX + index * splitWidth + (axis.boundaryGap ? splitWidth / 2 : 0) + 0.5f;
|
||||
float px = m_CoordinateX + index * splitWidth + (axis.boundaryGap ? splitWidth / 2 : 0) + 0.5f;
|
||||
labelPos = new Vector2(px, posY - diff);
|
||||
}
|
||||
}
|
||||
else if (axis is YAxis)
|
||||
{
|
||||
var posX = axisIndex > 0 ? coordinateX + coordinateWidth : coordinateX;
|
||||
var posX = axisIndex > 0 ? m_CoordinateX + m_CoordinateWidth : m_CoordinateX;
|
||||
var diff = axisIndex > 0 ? -axis.axisLabel.margin + 3 : axis.axisLabel.margin - 3;
|
||||
if (axis.IsValue())
|
||||
{
|
||||
@@ -457,9 +461,9 @@ namespace XCharts
|
||||
else
|
||||
{
|
||||
labelText = axis.GetData((int)m_Tooltip.runtimeYValues[axisIndex], m_DataZoom);
|
||||
float splitWidth = axis.GetSplitWidth(coordinateHeight, m_DataZoom);
|
||||
float splitWidth = axis.GetSplitWidth(m_CoordinateHeight, m_DataZoom);
|
||||
int index = (int)m_Tooltip.runtimeYValues[axisIndex];
|
||||
float py = coordinateY + index * splitWidth + (axis.boundaryGap ? splitWidth / 2 : 0);
|
||||
float py = m_CoordinateY + index * splitWidth + (axis.boundaryGap ? splitWidth / 2 : 0);
|
||||
labelPos = new Vector2(posX - diff, py);
|
||||
}
|
||||
}
|
||||
@@ -518,10 +522,10 @@ namespace XCharts
|
||||
axisObj.transform.localPosition = Vector3.zero;
|
||||
axisObj.SetActive(yAxis.show && yAxis.axisLabel.show);
|
||||
ChartHelper.HideAllObject(axisObj);
|
||||
var labelColor = yAxis.axisLabel.color == Color.clear ?
|
||||
var labelColor = ChartHelper.IsClearColor(yAxis.axisLabel.color) ?
|
||||
(Color)m_ThemeInfo.axisTextColor :
|
||||
yAxis.axisLabel.color;
|
||||
int splitNumber = yAxis.GetSplitNumber(coordinateHeight, m_DataZoom);
|
||||
int splitNumber = yAxis.GetSplitNumber(m_CoordinateHeight, m_DataZoom);
|
||||
float totalWidth = 0;
|
||||
for (int i = 0; i < splitNumber; i++)
|
||||
{
|
||||
@@ -542,12 +546,12 @@ namespace XCharts
|
||||
yAxis.axisLabel.fontSize, yAxis.axisLabel.rotate, yAxis.axisLabel.fontStyle);
|
||||
}
|
||||
|
||||
float labelWidth = yAxis.GetScaleWidth(coordinateHeight, i, m_DataZoom);
|
||||
float labelWidth = yAxis.GetScaleWidth(m_CoordinateHeight, i, m_DataZoom);
|
||||
if (i == 0) yAxis.axisLabel.SetRelatedText(txt, labelWidth);
|
||||
txt.transform.localPosition = GetLabelYPosition(totalWidth + (yAxis.boundaryGap ? labelWidth / 2 : 0), i, yAxisIndex, yAxis);
|
||||
|
||||
var isPercentStack = m_Series.IsPercentStack(SerieType.Bar);
|
||||
txt.text = yAxis.GetLabelName(coordinateHeight, i, yAxis.runtimeMinValue, yAxis.runtimeMaxValue, m_DataZoom, isPercentStack);
|
||||
txt.text = yAxis.GetLabelName(m_CoordinateHeight, i, yAxis.runtimeMinValue, yAxis.runtimeMaxValue, m_DataZoom, isPercentStack);
|
||||
txt.gameObject.SetActive(yAxis.show &&
|
||||
(yAxis.axisLabel.interval == 0 || i % (yAxis.axisLabel.interval + 1) == 0));
|
||||
yAxis.axisLabelTextList.Add(txt);
|
||||
@@ -555,12 +559,12 @@ namespace XCharts
|
||||
}
|
||||
if (yAxis.axisName.show)
|
||||
{
|
||||
var color = yAxis.axisName.color == Color.clear ? (Color)m_ThemeInfo.axisTextColor :
|
||||
var color = ChartHelper.IsClearColor(yAxis.axisName.color) ? (Color)m_ThemeInfo.axisTextColor :
|
||||
yAxis.axisName.color;
|
||||
var fontSize = yAxis.axisName.fontSize;
|
||||
var offset = yAxis.axisName.offset;
|
||||
Text axisName = null;
|
||||
var zeroPos = new Vector3(coordinateX + m_XAxises[yAxisIndex].runtimeZeroXOffset, coordinateY);
|
||||
var zeroPos = new Vector3(m_CoordinateX + m_XAxises[yAxisIndex].runtimeZeroXOffset, m_CoordinateY);
|
||||
switch (yAxis.axisName.location)
|
||||
{
|
||||
case AxisName.Location.Start:
|
||||
@@ -569,8 +573,8 @@ namespace XCharts
|
||||
new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(100, 20), fontSize,
|
||||
yAxis.axisName.rotate, yAxis.axisName.fontStyle);
|
||||
axisName.transform.localPosition = yAxisIndex > 0 ?
|
||||
new Vector2(coordinateX + coordinateWidth + offset.x, coordinateY - offset.y) :
|
||||
new Vector2(zeroPos.x + offset.x, coordinateY - offset.y);
|
||||
new Vector2(m_CoordinateX + m_CoordinateWidth + offset.x, m_CoordinateY - offset.y) :
|
||||
new Vector2(zeroPos.x + offset.x, m_CoordinateY - offset.y);
|
||||
break;
|
||||
case AxisName.Location.Middle:
|
||||
axisName = ChartHelper.AddTextObject(s_DefaultAxisName, axisObj.transform,
|
||||
@@ -578,8 +582,8 @@ namespace XCharts
|
||||
new Vector2(1, 0.5f), new Vector2(1, 0.5f), new Vector2(100, 20), fontSize,
|
||||
yAxis.axisName.rotate, yAxis.axisName.fontStyle);
|
||||
axisName.transform.localPosition = yAxisIndex > 0 ?
|
||||
new Vector2(coordinateX + coordinateWidth - offset.x, coordinateY + coordinateHeight / 2 + offset.y) :
|
||||
new Vector2(coordinateX - offset.x, coordinateY + coordinateHeight / 2 + offset.y);
|
||||
new Vector2(m_CoordinateX + m_CoordinateWidth - offset.x, m_CoordinateY + m_CoordinateHeight / 2 + offset.y) :
|
||||
new Vector2(m_CoordinateX - offset.x, m_CoordinateY + m_CoordinateHeight / 2 + offset.y);
|
||||
break;
|
||||
case AxisName.Location.End:
|
||||
axisName = ChartHelper.AddTextObject(s_DefaultAxisName, axisObj.transform,
|
||||
@@ -587,8 +591,8 @@ namespace XCharts
|
||||
new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(100, 20), fontSize,
|
||||
yAxis.axisName.rotate, yAxis.axisName.fontStyle);
|
||||
axisName.transform.localPosition = yAxisIndex > 0 ?
|
||||
new Vector2(coordinateX + coordinateWidth + offset.x, coordinateY + coordinateHeight + offset.y) :
|
||||
new Vector2(zeroPos.x + offset.x, coordinateY + coordinateHeight + offset.y);
|
||||
new Vector2(m_CoordinateX + m_CoordinateWidth + offset.x, m_CoordinateY + m_CoordinateHeight + offset.y) :
|
||||
new Vector2(zeroPos.x + offset.x, m_CoordinateY + m_CoordinateHeight + offset.y);
|
||||
break;
|
||||
}
|
||||
axisName.text = yAxis.axisName.name;
|
||||
@@ -623,14 +627,14 @@ namespace XCharts
|
||||
axisObj.transform.localPosition = Vector3.zero;
|
||||
axisObj.SetActive(xAxis.show && xAxis.axisLabel.show);
|
||||
ChartHelper.HideAllObject(axisObj);
|
||||
var labelColor = xAxis.axisLabel.color == Color.clear ?
|
||||
var labelColor = ChartHelper.IsClearColor(xAxis.axisLabel.color) ?
|
||||
(Color)m_ThemeInfo.axisTextColor :
|
||||
xAxis.axisLabel.color;
|
||||
int splitNumber = xAxis.GetSplitNumber(coordinateWidth, m_DataZoom);
|
||||
int splitNumber = xAxis.GetSplitNumber(m_CoordinateWidth, m_DataZoom);
|
||||
float totalWidth = 0;
|
||||
for (int i = 0; i < splitNumber; i++)
|
||||
{
|
||||
float labelWidth = xAxis.GetScaleWidth(coordinateWidth, i, m_DataZoom);
|
||||
float labelWidth = xAxis.GetScaleWidth(m_CoordinateWidth, i, m_DataZoom);
|
||||
bool inside = xAxis.axisLabel.inside;
|
||||
Text txt = ChartHelper.AddTextObject(ChartCached.GetXAxisName(xAxisIndex, i), axisObj.transform,
|
||||
m_ThemeInfo.font, labelColor, TextAnchor.MiddleCenter, new Vector2(0, 1),
|
||||
@@ -641,7 +645,7 @@ namespace XCharts
|
||||
i, xAxisIndex, xAxis);
|
||||
totalWidth += labelWidth;
|
||||
var isPercentStack = m_Series.IsPercentStack(SerieType.Bar);
|
||||
txt.text = xAxis.GetLabelName(coordinateWidth, i, xAxis.runtimeMinValue, xAxis.runtimeMaxValue, m_DataZoom,
|
||||
txt.text = xAxis.GetLabelName(m_CoordinateWidth, i, xAxis.runtimeMinValue, xAxis.runtimeMaxValue, m_DataZoom,
|
||||
isPercentStack);
|
||||
txt.gameObject.SetActive(xAxis.show &&
|
||||
(xAxis.axisLabel.interval == 0 || i % (xAxis.axisLabel.interval + 1) == 0));
|
||||
@@ -649,12 +653,12 @@ namespace XCharts
|
||||
}
|
||||
if (xAxis.axisName.show)
|
||||
{
|
||||
var color = xAxis.axisName.color == Color.clear ? (Color)m_ThemeInfo.axisTextColor :
|
||||
var color = ChartHelper.IsClearColor(xAxis.axisName.color) ? (Color)m_ThemeInfo.axisTextColor :
|
||||
xAxis.axisName.color;
|
||||
var fontSize = xAxis.axisName.fontSize;
|
||||
var offset = xAxis.axisName.offset;
|
||||
Text axisName = null;
|
||||
var zeroPos = new Vector3(coordinateX, coordinateY + m_YAxises[xAxisIndex].runtimeZeroYOffset);
|
||||
var zeroPos = new Vector3(m_CoordinateX, m_CoordinateY + m_YAxises[xAxisIndex].runtimeZeroYOffset);
|
||||
switch (xAxis.axisName.location)
|
||||
{
|
||||
case AxisName.Location.Start:
|
||||
@@ -663,7 +667,7 @@ namespace XCharts
|
||||
new Vector2(1, 0.5f), new Vector2(1, 0.5f), new Vector2(100, 20), fontSize,
|
||||
xAxis.axisName.rotate, xAxis.axisName.fontStyle);
|
||||
axisName.transform.localPosition = xAxisIndex > 0 ?
|
||||
new Vector2(zeroPos.x - offset.x, coordinateY + coordinateHeight + offset.y) :
|
||||
new Vector2(zeroPos.x - offset.x, m_CoordinateY + m_CoordinateHeight + offset.y) :
|
||||
new Vector2(zeroPos.x - offset.x, zeroPos.y + offset.y);
|
||||
break;
|
||||
case AxisName.Location.Middle:
|
||||
@@ -672,8 +676,8 @@ namespace XCharts
|
||||
new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(100, 20), fontSize,
|
||||
xAxis.axisName.rotate, xAxis.axisName.fontStyle);
|
||||
axisName.transform.localPosition = xAxisIndex > 0 ?
|
||||
new Vector2(coordinateX + coordinateWidth / 2 + offset.x, coordinateY + coordinateHeight - offset.y) :
|
||||
new Vector2(coordinateX + coordinateWidth / 2 + offset.x, coordinateY - offset.y);
|
||||
new Vector2(m_CoordinateX + m_CoordinateWidth / 2 + offset.x, m_CoordinateY + m_CoordinateHeight - offset.y) :
|
||||
new Vector2(m_CoordinateX + m_CoordinateWidth / 2 + offset.x, m_CoordinateY - offset.y);
|
||||
break;
|
||||
case AxisName.Location.End:
|
||||
axisName = ChartHelper.AddTextObject(s_DefaultAxisName, axisObj.transform,
|
||||
@@ -681,8 +685,8 @@ namespace XCharts
|
||||
new Vector2(0, 0.5f), new Vector2(0, 0.5f), new Vector2(100, 20), fontSize,
|
||||
xAxis.axisName.rotate, xAxis.axisName.fontStyle);
|
||||
axisName.transform.localPosition = xAxisIndex > 0 ?
|
||||
new Vector2(coordinateX + coordinateWidth + offset.x, coordinateY + coordinateHeight + offset.y) :
|
||||
new Vector2(coordinateX + coordinateWidth + offset.x, zeroPos.y + offset.y);
|
||||
new Vector2(m_CoordinateX + m_CoordinateWidth + offset.x, m_CoordinateY + m_CoordinateHeight + offset.y) :
|
||||
new Vector2(m_CoordinateX + m_CoordinateWidth + offset.x, zeroPos.y + offset.y);
|
||||
break;
|
||||
}
|
||||
axisName.text = xAxis.axisName.name;
|
||||
@@ -727,7 +731,7 @@ namespace XCharts
|
||||
|
||||
private Vector3 GetLabelYPosition(float scaleWid, int i, int yAxisIndex, YAxis yAxis)
|
||||
{
|
||||
var startX = yAxisIndex == 0 ? coordinateX : coordinateX + coordinateWidth;
|
||||
var startX = yAxisIndex == 0 ? m_CoordinateX : m_CoordinateX + m_CoordinateWidth;
|
||||
var posX = 0f;
|
||||
var inside = yAxis.axisLabel.inside;
|
||||
if ((inside && yAxisIndex == 0) || (!inside && yAxisIndex == 1))
|
||||
@@ -738,13 +742,13 @@ namespace XCharts
|
||||
{
|
||||
posX = startX - yAxis.axisLabel.margin;
|
||||
}
|
||||
return new Vector3(posX, coordinateY + scaleWid, 0);
|
||||
return new Vector3(posX, m_CoordinateY + scaleWid, 0);
|
||||
}
|
||||
|
||||
private Vector3 GetLabelXPosition(float scaleWid, int i, int xAxisIndex, XAxis xAxis)
|
||||
{
|
||||
var startY = coordinateY + (xAxis.axisLabel.onZero ? m_YAxises[xAxisIndex].runtimeZeroYOffset : 0);
|
||||
if (xAxisIndex > 0) startY += coordinateHeight;
|
||||
var startY = m_CoordinateY + (xAxis.axisLabel.onZero ? m_YAxises[xAxisIndex].runtimeZeroYOffset : 0);
|
||||
if (xAxisIndex > 0) startY += m_CoordinateHeight;
|
||||
var posY = 0f;
|
||||
var inside = xAxis.axisLabel.inside;
|
||||
if ((inside && xAxisIndex == 0) || (!inside && xAxisIndex == 1))
|
||||
@@ -755,7 +759,7 @@ namespace XCharts
|
||||
{
|
||||
posY = startY - xAxis.axisLabel.margin - xAxis.axisLabel.fontSize / 2;
|
||||
}
|
||||
return new Vector3(coordinateX + scaleWid, posY);
|
||||
return new Vector3(m_CoordinateX + scaleWid, posY);
|
||||
}
|
||||
|
||||
private void CheckMinMaxValue()
|
||||
@@ -813,14 +817,14 @@ namespace XCharts
|
||||
if (axis is XAxis && axis.IsValue())
|
||||
{
|
||||
axis.runtimeZeroXOffset = axis.runtimeMinValue > 0 ? 0 :
|
||||
axis.runtimeMaxValue < 0 ? this.coordinateWidth :
|
||||
Mathf.Abs(axis.runtimeMinValue) * (this.coordinateWidth / (Mathf.Abs(axis.runtimeMinValue) + Mathf.Abs(axis.runtimeMaxValue)));
|
||||
axis.runtimeMaxValue < 0 ? this.m_CoordinateWidth :
|
||||
Mathf.Abs(axis.runtimeMinValue) * (this.m_CoordinateWidth / (Mathf.Abs(axis.runtimeMinValue) + Mathf.Abs(axis.runtimeMaxValue)));
|
||||
}
|
||||
if (axis is YAxis && axis.IsValue())
|
||||
{
|
||||
axis.runtimeZeroYOffset = axis.runtimeMinValue > 0 ? 0 :
|
||||
axis.runtimeMaxValue < 0 ? coordinateHeight :
|
||||
Mathf.Abs(axis.runtimeMinValue) * (coordinateHeight / (Mathf.Abs(axis.runtimeMinValue) + Mathf.Abs(axis.runtimeMaxValue)));
|
||||
axis.runtimeMaxValue < 0 ? m_CoordinateHeight :
|
||||
Mathf.Abs(axis.runtimeMinValue) * (m_CoordinateHeight / (Mathf.Abs(axis.runtimeMinValue) + Mathf.Abs(axis.runtimeMaxValue)));
|
||||
}
|
||||
}
|
||||
if (updateChart)
|
||||
@@ -838,13 +842,14 @@ namespace XCharts
|
||||
|
||||
protected void UpdateAxisLabelText(Axis axis)
|
||||
{
|
||||
float coordinateWidth = axis is XAxis ? this.coordinateWidth : coordinateHeight;
|
||||
float m_CoordinateWidth = axis is XAxis ? this.m_CoordinateWidth : m_CoordinateHeight;
|
||||
var isPercentStack = m_Series.IsPercentStack(SerieType.Bar);
|
||||
axis.UpdateLabelText(coordinateWidth, m_DataZoom, isPercentStack, 500);
|
||||
axis.UpdateLabelText(m_CoordinateWidth, m_DataZoom, isPercentStack, 500);
|
||||
}
|
||||
|
||||
protected virtual void OnCoordinateChanged()
|
||||
{
|
||||
UpdateCoordinate();
|
||||
m_XAxisesDirty = true;
|
||||
m_YAxisesDirty = true;
|
||||
}
|
||||
@@ -852,8 +857,7 @@ namespace XCharts
|
||||
protected override void OnSizeChanged()
|
||||
{
|
||||
base.OnSizeChanged();
|
||||
m_XAxisesDirty = true;
|
||||
m_YAxisesDirty = true;
|
||||
OnCoordinateChanged();
|
||||
}
|
||||
|
||||
private void DrawCoordinate(VertexHelper vh)
|
||||
@@ -891,12 +895,12 @@ namespace XCharts
|
||||
|
||||
private void DrawGrid(VertexHelper vh)
|
||||
{
|
||||
if (m_Grid.show && m_Grid.backgroundColor != Color.clear)
|
||||
if (m_Grid.show && !ChartHelper.IsClearColor(m_Grid.backgroundColor))
|
||||
{
|
||||
var p1 = new Vector2(coordinateX, coordinateY);
|
||||
var p2 = new Vector2(coordinateX, coordinateY + coordinateHeight);
|
||||
var p3 = new Vector2(coordinateX + coordinateWidth, coordinateY + coordinateHeight);
|
||||
var p4 = new Vector2(coordinateX + coordinateWidth, coordinateY);
|
||||
var p1 = new Vector2(m_CoordinateX, m_CoordinateY);
|
||||
var p2 = new Vector2(m_CoordinateX, m_CoordinateY + m_CoordinateHeight);
|
||||
var p3 = new Vector2(m_CoordinateX + m_CoordinateWidth, m_CoordinateY + m_CoordinateHeight);
|
||||
var p4 = new Vector2(m_CoordinateX + m_CoordinateWidth, m_CoordinateY);
|
||||
ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, m_Grid.backgroundColor);
|
||||
}
|
||||
}
|
||||
@@ -905,13 +909,13 @@ namespace XCharts
|
||||
{
|
||||
if (yAxis.NeedShowSplit())
|
||||
{
|
||||
var size = yAxis.GetScaleNumber(coordinateWidth, m_DataZoom);
|
||||
var totalWidth = coordinateY;
|
||||
var size = yAxis.GetScaleNumber(m_CoordinateWidth, m_DataZoom);
|
||||
var totalWidth = m_CoordinateY;
|
||||
var xAxis = m_XAxises[yAxisIndex];
|
||||
var zeroPos = new Vector3(coordinateX + xAxis.runtimeZeroXOffset, coordinateY + yAxis.runtimeZeroYOffset);
|
||||
var zeroPos = new Vector3(m_CoordinateX + xAxis.runtimeZeroXOffset, m_CoordinateY + yAxis.runtimeZeroYOffset);
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
var scaleWidth = yAxis.GetScaleWidth(coordinateHeight, i, m_DataZoom);
|
||||
var scaleWidth = yAxis.GetScaleWidth(m_CoordinateHeight, i, m_DataZoom);
|
||||
float pY = totalWidth;
|
||||
if (yAxis.boundaryGap && yAxis.axisTick.alignWithLabel)
|
||||
{
|
||||
@@ -919,10 +923,10 @@ namespace XCharts
|
||||
}
|
||||
if (yAxis.splitArea.show && i < size - 1)
|
||||
{
|
||||
ChartDrawer.DrawPolygon(vh, new Vector2(coordinateX, pY),
|
||||
new Vector2(coordinateX + coordinateWidth, pY),
|
||||
new Vector2(coordinateX + coordinateWidth, pY + scaleWidth),
|
||||
new Vector2(coordinateX, pY + scaleWidth),
|
||||
ChartDrawer.DrawPolygon(vh, new Vector2(m_CoordinateX, pY),
|
||||
new Vector2(m_CoordinateX + m_CoordinateWidth, pY),
|
||||
new Vector2(m_CoordinateX + m_CoordinateWidth, pY + scaleWidth),
|
||||
new Vector2(m_CoordinateX, pY + scaleWidth),
|
||||
yAxis.splitArea.getColor(i));
|
||||
}
|
||||
if (yAxis.splitLine.show)
|
||||
@@ -931,8 +935,8 @@ namespace XCharts
|
||||
{
|
||||
if (yAxis.splitLine.NeedShow(i))
|
||||
{
|
||||
DrawLineStyle(vh, yAxis.splitLine.lineStyle, new Vector3(coordinateX, pY),
|
||||
new Vector3(coordinateX + coordinateWidth, pY), yAxis.splitLine.GetColor(m_ThemeInfo));
|
||||
DrawLineStyle(vh, yAxis.splitLine.lineStyle, new Vector3(m_CoordinateX, pY),
|
||||
new Vector3(m_CoordinateX + m_CoordinateWidth, pY), yAxis.splitLine.GetColor(m_ThemeInfo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -945,12 +949,12 @@ namespace XCharts
|
||||
{
|
||||
if (yAxis.NeedShowSplit())
|
||||
{
|
||||
var size = yAxis.GetScaleNumber(coordinateWidth, m_DataZoom);
|
||||
var totalWidth = coordinateY;
|
||||
var size = yAxis.GetScaleNumber(m_CoordinateWidth, m_DataZoom);
|
||||
var totalWidth = m_CoordinateY;
|
||||
var xAxis = m_XAxises[yAxisIndex];
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
var scaleWidth = yAxis.GetScaleWidth(coordinateHeight, i, m_DataZoom);
|
||||
var scaleWidth = yAxis.GetScaleWidth(m_CoordinateHeight, i, m_DataZoom);
|
||||
float pX = 0;
|
||||
float pY = totalWidth;
|
||||
if (yAxis.boundaryGap && yAxis.axisTick.alignWithLabel)
|
||||
@@ -959,9 +963,9 @@ namespace XCharts
|
||||
}
|
||||
if (yAxis.axisTick.show)
|
||||
{
|
||||
var startX = coordinateX + (yAxis.axisLine.onZero ? m_XAxises[yAxisIndex].runtimeZeroXOffset : 0);
|
||||
var startX = m_CoordinateX + (yAxis.axisLine.onZero ? m_XAxises[yAxisIndex].runtimeZeroXOffset : 0);
|
||||
startX -= yAxis.axisLine.width;
|
||||
if (yAxis.IsValue() && yAxisIndex > 0) startX += coordinateWidth;
|
||||
if (yAxis.IsValue() && yAxisIndex > 0) startX += m_CoordinateWidth;
|
||||
bool inside = yAxis.axisTick.inside;
|
||||
if ((inside && yAxisIndex == 0) || (!inside && yAxisIndex == 1))
|
||||
{
|
||||
@@ -979,13 +983,13 @@ namespace XCharts
|
||||
}
|
||||
if (yAxis.show && yAxis.axisLine.show)
|
||||
{
|
||||
var lineX = coordinateX + (yAxis.axisLine.onZero ? m_XAxises[yAxisIndex].runtimeZeroXOffset : 0);
|
||||
if (yAxis.IsValue() && yAxisIndex > 0) lineX += coordinateWidth;
|
||||
var top = new Vector3(lineX, coordinateY + coordinateHeight + yAxis.axisLine.width);
|
||||
var lineX = m_CoordinateX + (yAxis.axisLine.onZero ? m_XAxises[yAxisIndex].runtimeZeroXOffset : 0);
|
||||
if (yAxis.IsValue() && yAxisIndex > 0) lineX += m_CoordinateWidth;
|
||||
var top = new Vector3(lineX, m_CoordinateY + m_CoordinateHeight + yAxis.axisLine.width);
|
||||
if (yAxis.axisLine.symbol)
|
||||
{
|
||||
var axisLine = yAxis.axisLine;
|
||||
ChartDrawer.DrawArrow(vh, new Vector3(lineX, coordinateX), top, axisLine.symbolWidth, axisLine.symbolHeight,
|
||||
ChartDrawer.DrawArrow(vh, new Vector3(lineX, m_CoordinateX), top, axisLine.symbolWidth, axisLine.symbolHeight,
|
||||
axisLine.symbolOffset, axisLine.symbolDent, m_ThemeInfo.axisLineColor);
|
||||
}
|
||||
}
|
||||
@@ -995,13 +999,13 @@ namespace XCharts
|
||||
{
|
||||
if (xAxis.NeedShowSplit())
|
||||
{
|
||||
var size = xAxis.GetScaleNumber(coordinateWidth, m_DataZoom);
|
||||
var totalWidth = coordinateX;
|
||||
var size = xAxis.GetScaleNumber(m_CoordinateWidth, m_DataZoom);
|
||||
var totalWidth = m_CoordinateX;
|
||||
var yAxis = m_YAxises[xAxisIndex];
|
||||
var zeroPos = new Vector3(coordinateX, coordinateY + yAxis.runtimeZeroYOffset);
|
||||
var zeroPos = new Vector3(m_CoordinateX, m_CoordinateY + yAxis.runtimeZeroYOffset);
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
var scaleWidth = xAxis.GetScaleWidth(coordinateWidth, i, m_DataZoom);
|
||||
var scaleWidth = xAxis.GetScaleWidth(m_CoordinateWidth, i, m_DataZoom);
|
||||
float pX = totalWidth;
|
||||
if (xAxis.boundaryGap && xAxis.axisTick.alignWithLabel)
|
||||
{
|
||||
@@ -1009,10 +1013,10 @@ namespace XCharts
|
||||
}
|
||||
if (xAxis.splitArea.show && i < size - 1)
|
||||
{
|
||||
ChartDrawer.DrawPolygon(vh, new Vector2(pX, coordinateY),
|
||||
new Vector2(pX, coordinateY + coordinateHeight),
|
||||
new Vector2(pX + scaleWidth, coordinateY + coordinateHeight),
|
||||
new Vector2(pX + scaleWidth, coordinateY),
|
||||
ChartDrawer.DrawPolygon(vh, new Vector2(pX, m_CoordinateY),
|
||||
new Vector2(pX, m_CoordinateY + m_CoordinateHeight),
|
||||
new Vector2(pX + scaleWidth, m_CoordinateY + m_CoordinateHeight),
|
||||
new Vector2(pX + scaleWidth, m_CoordinateY),
|
||||
xAxis.splitArea.getColor(i));
|
||||
}
|
||||
if (xAxis.splitLine.show)
|
||||
@@ -1021,8 +1025,8 @@ namespace XCharts
|
||||
{
|
||||
if (xAxis.splitLine.NeedShow(i))
|
||||
{
|
||||
DrawLineStyle(vh, xAxis.splitLine.lineStyle, new Vector3(pX, coordinateY),
|
||||
new Vector3(pX, coordinateY + coordinateHeight), xAxis.splitLine.GetColor(m_ThemeInfo));
|
||||
DrawLineStyle(vh, xAxis.splitLine.lineStyle, new Vector3(pX, m_CoordinateY),
|
||||
new Vector3(pX, m_CoordinateY + m_CoordinateHeight), xAxis.splitLine.GetColor(m_ThemeInfo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1035,12 +1039,12 @@ namespace XCharts
|
||||
{
|
||||
if (xAxis.NeedShowSplit())
|
||||
{
|
||||
var size = xAxis.GetScaleNumber(coordinateWidth, m_DataZoom);
|
||||
var totalWidth = coordinateX;
|
||||
var size = xAxis.GetScaleNumber(m_CoordinateWidth, m_DataZoom);
|
||||
var totalWidth = m_CoordinateX;
|
||||
var yAxis = m_YAxises[xAxisIndex];
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
var scaleWidth = xAxis.GetScaleWidth(coordinateWidth, i, m_DataZoom);
|
||||
var scaleWidth = xAxis.GetScaleWidth(m_CoordinateWidth, i, m_DataZoom);
|
||||
float pX = totalWidth;
|
||||
float pY = 0;
|
||||
if (xAxis.boundaryGap && xAxis.axisTick.alignWithLabel)
|
||||
@@ -1049,9 +1053,9 @@ namespace XCharts
|
||||
}
|
||||
if (xAxis.axisTick.show)
|
||||
{
|
||||
var startY = coordinateY + (xAxis.axisLine.onZero ? m_YAxises[xAxisIndex].runtimeZeroYOffset : 0);
|
||||
var startY = m_CoordinateY + (xAxis.axisLine.onZero ? m_YAxises[xAxisIndex].runtimeZeroYOffset : 0);
|
||||
startY -= xAxis.axisLine.width;
|
||||
if (xAxis.IsValue() && xAxisIndex > 0) startY += coordinateHeight;
|
||||
if (xAxis.IsValue() && xAxisIndex > 0) startY += m_CoordinateHeight;
|
||||
bool inside = xAxis.axisTick.inside;
|
||||
if ((inside && xAxisIndex == 0) || (!inside && xAxisIndex == 1))
|
||||
{
|
||||
@@ -1069,13 +1073,13 @@ namespace XCharts
|
||||
}
|
||||
if (xAxis.show && xAxis.axisLine.show)
|
||||
{
|
||||
var lineY = coordinateY + (xAxis.axisLine.onZero ? m_YAxises[xAxisIndex].runtimeZeroYOffset : 0);
|
||||
if (xAxis.IsValue() && xAxisIndex > 0) lineY += coordinateHeight;
|
||||
var top = new Vector3(coordinateX + coordinateWidth + xAxis.axisLine.width, lineY);
|
||||
var lineY = m_CoordinateY + (xAxis.axisLine.onZero ? m_YAxises[xAxisIndex].runtimeZeroYOffset : 0);
|
||||
if (xAxis.IsValue() && xAxisIndex > 0) lineY += m_CoordinateHeight;
|
||||
var top = new Vector3(m_CoordinateX + m_CoordinateWidth + xAxis.axisLine.width, lineY);
|
||||
if (xAxis.axisLine.symbol)
|
||||
{
|
||||
var axisLine = xAxis.axisLine;
|
||||
ChartDrawer.DrawArrow(vh, new Vector3(coordinateX, lineY), top, axisLine.symbolWidth, axisLine.symbolHeight,
|
||||
ChartDrawer.DrawArrow(vh, new Vector3(m_CoordinateX, lineY), top, axisLine.symbolWidth, axisLine.symbolHeight,
|
||||
axisLine.symbolOffset, axisLine.symbolDent, m_ThemeInfo.axisLineColor);
|
||||
}
|
||||
}
|
||||
@@ -1085,10 +1089,10 @@ namespace XCharts
|
||||
{
|
||||
if (xAxis.show && xAxis.axisLine.show)
|
||||
{
|
||||
var lineY = coordinateY + (xAxis.axisLine.onZero ? m_YAxises[xAxisIndex].runtimeZeroYOffset : 0);
|
||||
if (xAxis.IsValue() && xAxisIndex > 0) lineY += coordinateHeight;
|
||||
var left = new Vector3(coordinateX - xAxis.axisLine.width, lineY);
|
||||
var top = new Vector3(coordinateX + coordinateWidth + xAxis.axisLine.width, lineY);
|
||||
var lineY = m_CoordinateY + (xAxis.axisLine.onZero ? m_YAxises[xAxisIndex].runtimeZeroYOffset : 0);
|
||||
if (xAxis.IsValue() && xAxisIndex > 0) lineY += m_CoordinateHeight;
|
||||
var left = new Vector3(m_CoordinateX - xAxis.axisLine.width, lineY);
|
||||
var top = new Vector3(m_CoordinateX + m_CoordinateWidth + xAxis.axisLine.width, lineY);
|
||||
ChartDrawer.DrawLine(vh, left, top, xAxis.axisLine.width, m_ThemeInfo.axisLineColor);
|
||||
}
|
||||
}
|
||||
@@ -1097,10 +1101,10 @@ namespace XCharts
|
||||
{
|
||||
if (yAxis.show && yAxis.axisLine.show)
|
||||
{
|
||||
var lineX = coordinateX + (yAxis.axisLine.onZero ? m_XAxises[yAxisIndex].runtimeZeroXOffset : 0);
|
||||
if (yAxis.IsValue() && yAxisIndex > 0) lineX += coordinateWidth;
|
||||
var top = new Vector3(lineX, coordinateY + coordinateHeight + yAxis.axisLine.width);
|
||||
ChartDrawer.DrawLine(vh, new Vector3(lineX, coordinateY - yAxis.axisLine.width),
|
||||
var lineX = m_CoordinateX + (yAxis.axisLine.onZero ? m_XAxises[yAxisIndex].runtimeZeroXOffset : 0);
|
||||
if (yAxis.IsValue() && yAxisIndex > 0) lineX += m_CoordinateWidth;
|
||||
var top = new Vector3(lineX, m_CoordinateY + m_CoordinateHeight + yAxis.axisLine.width);
|
||||
ChartDrawer.DrawLine(vh, new Vector3(lineX, m_CoordinateY - yAxis.axisLine.width),
|
||||
top, yAxis.axisLine.width, m_ThemeInfo.axisLineColor);
|
||||
}
|
||||
}
|
||||
@@ -1109,10 +1113,10 @@ namespace XCharts
|
||||
{
|
||||
if (!m_DataZoom.enable || !m_DataZoom.supportSlider) return;
|
||||
var hig = m_DataZoom.GetHeight(grid.bottom);
|
||||
var p1 = new Vector3(coordinateX, m_ChartY + m_DataZoom.bottom);
|
||||
var p2 = new Vector3(coordinateX, m_ChartY + m_DataZoom.bottom + hig);
|
||||
var p3 = new Vector3(coordinateX + coordinateWidth, m_ChartY + m_DataZoom.bottom + hig);
|
||||
var p4 = new Vector3(coordinateX + coordinateWidth, m_ChartY + m_DataZoom.bottom);
|
||||
var p1 = new Vector3(m_CoordinateX, m_ChartY + m_DataZoom.bottom);
|
||||
var p2 = new Vector3(m_CoordinateX, m_ChartY + m_DataZoom.bottom + hig);
|
||||
var p3 = new Vector3(m_CoordinateX + m_CoordinateWidth, m_ChartY + m_DataZoom.bottom + hig);
|
||||
var p4 = new Vector3(m_CoordinateX + m_CoordinateWidth, m_ChartY + m_DataZoom.bottom);
|
||||
var xAxis = xAxises[0];
|
||||
ChartDrawer.DrawLine(vh, p1, p2, xAxis.axisLine.width, m_ThemeInfo.dataZoomLineColor);
|
||||
ChartDrawer.DrawLine(vh, p2, p3, xAxis.axisLine.width, m_ThemeInfo.dataZoomLineColor);
|
||||
@@ -1123,7 +1127,7 @@ namespace XCharts
|
||||
Serie serie = m_Series.list[0];
|
||||
Axis axis = yAxises[0];
|
||||
var showData = serie.GetDataList(null);
|
||||
float scaleWid = coordinateWidth / (showData.Count - 1);
|
||||
float scaleWid = m_CoordinateWidth / (showData.Count - 1);
|
||||
Vector3 lp = Vector3.zero;
|
||||
Vector3 np = Vector3.zero;
|
||||
float minValue = 0;
|
||||
@@ -1134,7 +1138,7 @@ namespace XCharts
|
||||
int rate = 1;
|
||||
var sampleDist = serie.sampleDist < 2 ? 2 : serie.sampleDist;
|
||||
var maxCount = showData.Count;
|
||||
if (sampleDist > 0) rate = (int)((maxCount - serie.minShow) / (coordinateWidth / sampleDist));
|
||||
if (sampleDist > 0) rate = (int)((maxCount - serie.minShow) / (m_CoordinateWidth / sampleDist));
|
||||
if (rate < 1) rate = 1;
|
||||
var totalAverage = serie.sampleAverage > 0 ? serie.sampleAverage :
|
||||
DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
|
||||
@@ -1143,7 +1147,7 @@ namespace XCharts
|
||||
{
|
||||
float value = SampleValue(ref showData, serie.sampleType, rate, serie.minShow, maxCount, totalAverage, i,
|
||||
serie.animation.GetUpdateAnimationDuration(), ref dataChanging, axis.inverse);
|
||||
float pX = coordinateX + i * scaleWid;
|
||||
float pX = m_CoordinateX + i * scaleWid;
|
||||
// float dataHig = (axis.runtimeMaxValue - axis.runtimeMinValue) == 0 ? 0 :
|
||||
// (value - axis.runtimeMinValue) / (axis.runtimeMaxValue - axis.runtimeMinValue) * hig;
|
||||
float dataHig = (maxValue - minValue) == 0 ? 0 :
|
||||
@@ -1170,8 +1174,8 @@ namespace XCharts
|
||||
switch (m_DataZoom.rangeMode)
|
||||
{
|
||||
case DataZoom.RangeMode.Percent:
|
||||
var start = coordinateX + coordinateWidth * m_DataZoom.start / 100;
|
||||
var end = coordinateX + coordinateWidth * m_DataZoom.end / 100;
|
||||
var start = m_CoordinateX + m_CoordinateWidth * m_DataZoom.start / 100;
|
||||
var end = m_CoordinateX + m_CoordinateWidth * m_DataZoom.end / 100;
|
||||
p1 = new Vector2(start, m_ChartY + m_DataZoom.bottom);
|
||||
p2 = new Vector2(start, m_ChartY + m_DataZoom.bottom + hig);
|
||||
p3 = new Vector2(end, m_ChartY + m_DataZoom.bottom + hig);
|
||||
@@ -1193,35 +1197,35 @@ namespace XCharts
|
||||
var xAxis = m_XAxises[i];
|
||||
var yAxis = m_YAxises[i];
|
||||
if (!xAxis.show) continue;
|
||||
float splitWidth = xAxis.GetDataWidth(coordinateWidth, dataCount, m_DataZoom);
|
||||
float splitWidth = xAxis.GetDataWidth(m_CoordinateWidth, dataCount, m_DataZoom);
|
||||
switch (m_Tooltip.type)
|
||||
{
|
||||
case Tooltip.Type.Corss:
|
||||
case Tooltip.Type.Line:
|
||||
float pX = coordinateX + m_Tooltip.runtimeXValues[i] * splitWidth
|
||||
float pX = m_CoordinateX + m_Tooltip.runtimeXValues[i] * splitWidth
|
||||
+ (xAxis.boundaryGap ? splitWidth / 2 : 0);
|
||||
if (xAxis.IsValue()) pX = m_Tooltip.runtimePointerPos.x;
|
||||
Vector2 sp = new Vector2(pX, coordinateY);
|
||||
Vector2 ep = new Vector2(pX, coordinateY + coordinateHeight);
|
||||
Vector2 sp = new Vector2(pX, m_CoordinateY);
|
||||
Vector2 ep = new Vector2(pX, m_CoordinateY + m_CoordinateHeight);
|
||||
var lineColor = TooltipHelper.GetLineColor(tooltip, m_ThemeInfo);
|
||||
DrawLineStyle(vh, m_Tooltip.lineStyle, sp, ep, lineColor);
|
||||
if (m_Tooltip.type == Tooltip.Type.Corss)
|
||||
{
|
||||
sp = new Vector2(coordinateX, m_Tooltip.runtimePointerPos.y);
|
||||
ep = new Vector2(coordinateX + coordinateWidth, m_Tooltip.runtimePointerPos.y);
|
||||
sp = new Vector2(m_CoordinateX, m_Tooltip.runtimePointerPos.y);
|
||||
ep = new Vector2(m_CoordinateX + m_CoordinateWidth, m_Tooltip.runtimePointerPos.y);
|
||||
DrawLineStyle(vh, m_Tooltip.lineStyle, sp, ep, lineColor);
|
||||
}
|
||||
break;
|
||||
case Tooltip.Type.Shadow:
|
||||
float tooltipSplitWid = splitWidth < 1 ? 1 : splitWidth;
|
||||
pX = coordinateX + splitWidth * m_Tooltip.runtimeXValues[i] -
|
||||
pX = m_CoordinateX + splitWidth * m_Tooltip.runtimeXValues[i] -
|
||||
(xAxis.boundaryGap ? 0 : splitWidth / 2);
|
||||
if (xAxis.IsValue()) pX = m_Tooltip.runtimeXValues[i];
|
||||
float pY = coordinateY + coordinateHeight;
|
||||
Vector3 p1 = new Vector3(pX, coordinateY);
|
||||
float pY = m_CoordinateY + m_CoordinateHeight;
|
||||
Vector3 p1 = new Vector3(pX, m_CoordinateY);
|
||||
Vector3 p2 = new Vector3(pX, pY);
|
||||
Vector3 p3 = new Vector3(pX + tooltipSplitWid, pY);
|
||||
Vector3 p4 = new Vector3(pX + tooltipSplitWid, coordinateY);
|
||||
Vector3 p4 = new Vector3(pX + tooltipSplitWid, m_CoordinateY);
|
||||
ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, m_ThemeInfo.tooltipFlagAreaColor);
|
||||
break;
|
||||
}
|
||||
@@ -1238,30 +1242,30 @@ namespace XCharts
|
||||
var yAxis = m_YAxises[i];
|
||||
var xAxis = m_XAxises[i];
|
||||
if (!yAxis.show) continue;
|
||||
float splitWidth = yAxis.GetDataWidth(coordinateHeight, dataCount, m_DataZoom);
|
||||
float splitWidth = yAxis.GetDataWidth(m_CoordinateHeight, dataCount, m_DataZoom);
|
||||
switch (m_Tooltip.type)
|
||||
{
|
||||
case Tooltip.Type.Corss:
|
||||
case Tooltip.Type.Line:
|
||||
float pY = coordinateY + m_Tooltip.runtimeYValues[i] * splitWidth + (yAxis.boundaryGap ? splitWidth / 2 : 0);
|
||||
Vector2 sp = new Vector2(coordinateX, pY);
|
||||
Vector2 ep = new Vector2(coordinateX + coordinateWidth, pY);
|
||||
float pY = m_CoordinateY + m_Tooltip.runtimeYValues[i] * splitWidth + (yAxis.boundaryGap ? splitWidth / 2 : 0);
|
||||
Vector2 sp = new Vector2(m_CoordinateX, pY);
|
||||
Vector2 ep = new Vector2(m_CoordinateX + m_CoordinateWidth, pY);
|
||||
var lineColor = TooltipHelper.GetLineColor(tooltip, m_ThemeInfo);
|
||||
DrawLineStyle(vh, m_Tooltip.lineStyle, sp, ep, lineColor);
|
||||
if (m_Tooltip.type == Tooltip.Type.Corss)
|
||||
{
|
||||
sp = new Vector2(coordinateX, m_Tooltip.runtimePointerPos.y);
|
||||
ep = new Vector2(coordinateX + coordinateWidth, m_Tooltip.runtimePointerPos.y);
|
||||
sp = new Vector2(m_CoordinateX, m_Tooltip.runtimePointerPos.y);
|
||||
ep = new Vector2(m_CoordinateX + m_CoordinateWidth, m_Tooltip.runtimePointerPos.y);
|
||||
DrawLineStyle(vh, m_Tooltip.lineStyle, sp, ep, lineColor);
|
||||
}
|
||||
break;
|
||||
case Tooltip.Type.Shadow:
|
||||
float tooltipSplitWid = splitWidth < 1 ? 1 : splitWidth;
|
||||
float pX = coordinateX + coordinateWidth;
|
||||
pY = coordinateY + splitWidth * m_Tooltip.runtimeYValues[i] -
|
||||
float pX = m_CoordinateX + m_CoordinateWidth;
|
||||
pY = m_CoordinateY + splitWidth * m_Tooltip.runtimeYValues[i] -
|
||||
(yAxis.boundaryGap ? 0 : splitWidth / 2);
|
||||
Vector3 p1 = new Vector3(coordinateX, pY);
|
||||
Vector3 p2 = new Vector3(coordinateX, pY + tooltipSplitWid);
|
||||
Vector3 p1 = new Vector3(m_CoordinateX, pY);
|
||||
Vector3 p2 = new Vector3(m_CoordinateX, pY + tooltipSplitWid);
|
||||
Vector3 p3 = new Vector3(pX, pY + tooltipSplitWid);
|
||||
Vector3 p4 = new Vector3(pX, pY);
|
||||
ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, m_ThemeInfo.tooltipFlagAreaColor);
|
||||
@@ -1328,9 +1332,9 @@ namespace XCharts
|
||||
m_DataZoom.SetLabelActive(false);
|
||||
return;
|
||||
}
|
||||
if (m_DataZoom.IsInSelectedZoom(local, coordinateX, chartY, coordinateWidth)
|
||||
|| m_DataZoom.IsInStartZoom(local, coordinateX, chartY, coordinateWidth)
|
||||
|| m_DataZoom.IsInEndZoom(local, coordinateX, chartY, coordinateWidth))
|
||||
if (m_DataZoom.IsInSelectedZoom(local, m_CoordinateX, chartY, m_CoordinateWidth)
|
||||
|| m_DataZoom.IsInStartZoom(local, m_CoordinateX, chartY, m_CoordinateWidth)
|
||||
|| m_DataZoom.IsInEndZoom(local, m_CoordinateX, chartY, m_CoordinateWidth))
|
||||
{
|
||||
m_DataZoom.SetLabelActive(true);
|
||||
RefreshDataZoomLabel();
|
||||
@@ -1358,8 +1362,8 @@ namespace XCharts
|
||||
}
|
||||
InitAxisX();
|
||||
}
|
||||
var start = coordinateX + coordinateWidth * m_DataZoom.start / 100;
|
||||
var end = coordinateX + coordinateWidth * m_DataZoom.end / 100;
|
||||
var start = m_CoordinateX + m_CoordinateWidth * m_DataZoom.start / 100;
|
||||
var end = m_CoordinateX + m_CoordinateWidth * m_DataZoom.end / 100;
|
||||
var hig = m_DataZoom.GetHeight(grid.bottom);
|
||||
m_DataZoom.UpdateStartLabelPosition(new Vector3(start - 10, chartY + m_DataZoom.bottom + hig / 2));
|
||||
m_DataZoom.UpdateEndLabelPosition(new Vector3(end + 10, chartY + m_DataZoom.bottom + hig / 2));
|
||||
@@ -1378,6 +1382,7 @@ namespace XCharts
|
||||
for (int j = 0; j < serie.data.Count; j++)
|
||||
{
|
||||
var serieData = serie.data[j];
|
||||
if (serieData.labelObject == null) continue;
|
||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData, serieData.highlighted);
|
||||
serieData.index = j;
|
||||
if ((serieLabel.show || serieData.iconStyle.show))
|
||||
@@ -1406,12 +1411,12 @@ namespace XCharts
|
||||
if (isYAxis)
|
||||
{
|
||||
var xAxis = m_XAxises[serie.axisIndex];
|
||||
zeroPos = new Vector3(coordinateX + xAxis.runtimeZeroXOffset, coordinateY);
|
||||
zeroPos = new Vector3(m_CoordinateX + xAxis.runtimeZeroXOffset, m_CoordinateY);
|
||||
}
|
||||
else
|
||||
{
|
||||
var yAxis = m_YAxises[serie.axisIndex];
|
||||
zeroPos = new Vector3(coordinateX, coordinateY + yAxis.runtimeZeroYOffset);
|
||||
zeroPos = new Vector3(m_CoordinateX, m_CoordinateY + yAxis.runtimeZeroYOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1448,18 +1453,20 @@ namespace XCharts
|
||||
for (int i = 0; i < m_Series.Count; i++)
|
||||
{
|
||||
var serie = m_Series.GetSerie(i);
|
||||
if (serie.IsPerformanceMode()) continue;
|
||||
var total = serie.yTotal;
|
||||
var isPercentStack = m_Series.IsPercentStack(serie.stack, SerieType.Bar);
|
||||
for (int j = 0; j < serie.data.Count; j++)
|
||||
{
|
||||
if (j >= serie.dataPoints.Count) break;
|
||||
var serieData = serie.data[j];
|
||||
if (serieData.labelObject == null) continue;
|
||||
var pos = serie.dataPoints[j];
|
||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
||||
var dimension = 1;
|
||||
var isIgnore = serie.IsIgnoreIndex(j, 1);
|
||||
serieData.SetGameObjectPosition(serieData.labelPosition);
|
||||
serieData.UpdateIcon();
|
||||
serieData.labelObject.SetPosition(serieData.labelPosition);
|
||||
serieData.labelObject.UpdateIcon(serieData.iconStyle);
|
||||
if (serie.show && serieLabel.show && serieData.canShowLabel && !isIgnore)
|
||||
{
|
||||
float value = 0f;
|
||||
@@ -1485,8 +1492,8 @@ namespace XCharts
|
||||
}
|
||||
serieData.SetLabelActive(value != 0 && serieData.labelPosition != Vector3.zero);
|
||||
var invert = serie.type == SerieType.Line && SerieHelper.IsDownPoint(serie, j) && !serie.areaStyle.show;
|
||||
serieData.SetLabelPosition(invert ? -serieLabel.offset : serieLabel.offset);
|
||||
if (serieData.SetLabelText(content)) RefreshChart();
|
||||
serieData.labelObject.SetLabelPosition(invert ? -serieLabel.offset : serieLabel.offset);
|
||||
if (serieData.labelObject.SetText(content)) RefreshChart();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1514,15 +1521,15 @@ namespace XCharts
|
||||
}
|
||||
if (m_DataZoom.supportSlider)
|
||||
{
|
||||
if (m_DataZoom.IsInStartZoom(pos, coordinateX, chartY, coordinateWidth))
|
||||
if (m_DataZoom.IsInStartZoom(pos, m_CoordinateX, chartY, m_CoordinateWidth))
|
||||
{
|
||||
m_DataZoomStartDrag = true;
|
||||
}
|
||||
else if (m_DataZoom.IsInEndZoom(pos, coordinateX, chartY, coordinateWidth))
|
||||
else if (m_DataZoom.IsInEndZoom(pos, m_CoordinateX, chartY, m_CoordinateWidth))
|
||||
{
|
||||
m_DataZoomEndDrag = true;
|
||||
}
|
||||
else if (m_DataZoom.IsInSelectedZoom(pos, coordinateX, chartY, coordinateWidth))
|
||||
else if (m_DataZoom.IsInSelectedZoom(pos, m_CoordinateX, chartY, m_CoordinateWidth))
|
||||
{
|
||||
m_DataZoomDrag = true;
|
||||
}
|
||||
@@ -1534,7 +1541,7 @@ namespace XCharts
|
||||
{
|
||||
if (Input.touchCount > 1) return;
|
||||
float deltaX = eventData.delta.x;
|
||||
float deltaPercent = deltaX / coordinateWidth * 100;
|
||||
float deltaPercent = deltaX / m_CoordinateWidth * 100;
|
||||
OnDragInside(deltaPercent);
|
||||
OnDragSlider(deltaPercent);
|
||||
OnDragVisualMap();
|
||||
@@ -1648,30 +1655,30 @@ namespace XCharts
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_DataZoom.IsInStartZoom(localPos, coordinateX, chartY, coordinateWidth) ||
|
||||
m_DataZoom.IsInEndZoom(localPos, coordinateX, chartY, coordinateWidth))
|
||||
if (m_DataZoom.IsInStartZoom(localPos, m_CoordinateX, chartY, m_CoordinateWidth) ||
|
||||
m_DataZoom.IsInEndZoom(localPos, m_CoordinateX, chartY, m_CoordinateWidth))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_DataZoom.IsInZoom(localPos, coordinateX, chartY, coordinateWidth)
|
||||
&& !m_DataZoom.IsInSelectedZoom(localPos, coordinateX, chartY, coordinateWidth))
|
||||
if (m_DataZoom.IsInZoom(localPos, m_CoordinateX, chartY, m_CoordinateWidth)
|
||||
&& !m_DataZoom.IsInSelectedZoom(localPos, m_CoordinateX, chartY, m_CoordinateWidth))
|
||||
{
|
||||
var pointerX = localPos.x;
|
||||
var selectWidth = coordinateWidth * (m_DataZoom.end - m_DataZoom.start) / 100;
|
||||
var selectWidth = m_CoordinateWidth * (m_DataZoom.end - m_DataZoom.start) / 100;
|
||||
var startX = pointerX - selectWidth / 2;
|
||||
var endX = pointerX + selectWidth / 2;
|
||||
if (startX < coordinateX)
|
||||
if (startX < m_CoordinateX)
|
||||
{
|
||||
startX = coordinateX;
|
||||
endX = coordinateX + selectWidth;
|
||||
startX = m_CoordinateX;
|
||||
endX = m_CoordinateX + selectWidth;
|
||||
}
|
||||
else if (endX > coordinateX + coordinateWidth)
|
||||
else if (endX > m_CoordinateX + m_CoordinateWidth)
|
||||
{
|
||||
endX = coordinateX + coordinateWidth;
|
||||
startX = coordinateX + coordinateWidth - selectWidth;
|
||||
endX = m_CoordinateX + m_CoordinateWidth;
|
||||
startX = m_CoordinateX + m_CoordinateWidth - selectWidth;
|
||||
}
|
||||
m_DataZoom.start = (startX - coordinateX) / coordinateWidth * 100;
|
||||
m_DataZoom.end = (endX - coordinateX) / coordinateWidth * 100;
|
||||
m_DataZoom.start = (startX - m_CoordinateX) / m_CoordinateWidth * 100;
|
||||
m_DataZoom.end = (endX - m_CoordinateX) / m_CoordinateWidth * 100;
|
||||
RefreshDataZoomLabel();
|
||||
RefreshChart();
|
||||
}
|
||||
@@ -1687,7 +1694,7 @@ namespace XCharts
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!IsInCooridate(pos) && !m_DataZoom.IsInSelectedZoom(pos, coordinateX, chartY, coordinateWidth))
|
||||
if (!IsInCooridate(pos) && !m_DataZoom.IsInSelectedZoom(pos, m_CoordinateX, chartY, m_CoordinateWidth))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1696,7 +1703,7 @@ namespace XCharts
|
||||
|
||||
private void ScaleDataZoom(float delta)
|
||||
{
|
||||
float deltaPercent = Mathf.Abs(delta / coordinateWidth * 100);
|
||||
float deltaPercent = Mathf.Abs(delta / m_CoordinateWidth * 100);
|
||||
if (delta > 0)
|
||||
{
|
||||
if (m_DataZoom.end <= m_DataZoom.start) return;
|
||||
@@ -1735,10 +1742,10 @@ namespace XCharts
|
||||
protected void CheckClipAndDrawPolygon(VertexHelper vh, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4,
|
||||
Color32 startColor, Color32 toColor, bool clip)
|
||||
{
|
||||
p1 = ClampInChart(p1);
|
||||
p2 = ClampInChart(p2);
|
||||
p3 = ClampInChart(p3);
|
||||
p4 = ClampInChart(p4);
|
||||
ClampInChart(ref p1);
|
||||
ClampInChart(ref p2);
|
||||
ClampInChart(ref p3);
|
||||
ClampInChart(ref p4);
|
||||
if (clip)
|
||||
{
|
||||
p1 = ClampInCoordinate(p1);
|
||||
@@ -1753,10 +1760,10 @@ namespace XCharts
|
||||
protected void CheckClipAndDrawPolygon(VertexHelper vh, ref Vector3 p1, ref Vector3 p2, ref Vector3 p3, ref Vector3 p4,
|
||||
Color32 startColor, Color32 toColor, bool clip)
|
||||
{
|
||||
p1 = ClampInChart(p1);
|
||||
p2 = ClampInChart(p2);
|
||||
p3 = ClampInChart(p3);
|
||||
p4 = ClampInChart(p4);
|
||||
ClampInChart(ref p1);
|
||||
ClampInChart(ref p2);
|
||||
ClampInChart(ref p3);
|
||||
ClampInChart(ref p4);
|
||||
if (clip)
|
||||
{
|
||||
p1 = ClampInCoordinate(p1);
|
||||
@@ -1801,21 +1808,21 @@ namespace XCharts
|
||||
protected void CheckClipAndDrawZebraLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size,
|
||||
float zebraWidth, float zebraGap, Color32 color, bool clip)
|
||||
{
|
||||
p1 = ClampInChart(p1);
|
||||
p2 = ClampInChart(p2);
|
||||
ClampInChart(ref p1);
|
||||
ClampInChart(ref p2);
|
||||
ChartDrawer.DrawZebraLine(vh, p1, p2, size, zebraWidth, zebraGap, color);
|
||||
}
|
||||
|
||||
protected Color GetXLerpColor(Color areaColor, Color areaToColor, Vector3 pos)
|
||||
{
|
||||
if (areaColor == areaToColor) return areaColor;
|
||||
return Color.Lerp(areaToColor, areaColor, (pos.y - coordinateY) / coordinateHeight);
|
||||
return Color.Lerp(areaToColor, areaColor, (pos.y - m_CoordinateY) / m_CoordinateHeight);
|
||||
}
|
||||
|
||||
protected Color GetYLerpColor(Color areaColor, Color areaToColor, Vector3 pos)
|
||||
{
|
||||
if (areaColor == areaToColor) return areaColor;
|
||||
return Color.Lerp(areaToColor, areaColor, (pos.x - coordinateX) / coordinateWidth);
|
||||
return Color.Lerp(areaToColor, areaColor, (pos.x - m_CoordinateX) / m_CoordinateWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace XCharts
|
||||
if (!yAxis.show) yAxis = m_YAxises[(serie.axisIndex + 1) % m_YAxises.Count];
|
||||
|
||||
var showData = serie.GetDataList(m_DataZoom);
|
||||
float categoryWidth = yAxis.GetDataWidth(coordinateHeight, showData.Count, m_DataZoom);
|
||||
float categoryWidth = yAxis.GetDataWidth(m_CoordinateHeight, showData.Count, m_DataZoom);
|
||||
float barGap = GetBarGap();
|
||||
float totalBarWidth = GetBarTotalWidth(categoryWidth, barGap);
|
||||
float barWidth = serie.GetBarWidth(categoryWidth);
|
||||
@@ -71,8 +71,8 @@ namespace XCharts
|
||||
float borderWidth = value == 0 ? 0 : itemStyle.runtimeBorderWidth;
|
||||
if (showData[i].IsDataChanged()) dataChanging = true;
|
||||
float axisLineWidth = (value < 0 ? -1 : 1) * yAxis.axisLine.width;
|
||||
float pX = seriesHig[i] + coordinateX + xAxis.runtimeZeroXOffset + axisLineWidth;
|
||||
float pY = coordinateY + i * categoryWidth;
|
||||
float pX = seriesHig[i] + m_CoordinateX + xAxis.runtimeZeroXOffset + axisLineWidth;
|
||||
float pY = m_CoordinateY + i * categoryWidth;
|
||||
if (!yAxis.boundaryGap) pY -= categoryWidth / 2;
|
||||
|
||||
var barHig = 0f;
|
||||
@@ -80,7 +80,7 @@ namespace XCharts
|
||||
if (isPercentStack)
|
||||
{
|
||||
valueTotal = GetSameStackTotalValue(serie.stack, i);
|
||||
barHig = valueTotal != 0 ? (value / valueTotal * coordinateWidth) : 0;
|
||||
barHig = valueTotal != 0 ? (value / valueTotal * m_CoordinateWidth) : 0;
|
||||
seriesHig[i] += barHig;
|
||||
}
|
||||
else
|
||||
@@ -88,7 +88,7 @@ namespace XCharts
|
||||
valueTotal = xMaxValue - xMinValue;
|
||||
if (valueTotal != 0)
|
||||
barHig = (xMinValue > 0 ? value - xMinValue : value)
|
||||
/ valueTotal * coordinateWidth;
|
||||
/ valueTotal * m_CoordinateWidth;
|
||||
seriesHig[i] += barHig;
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace XCharts
|
||||
var xAxis = m_XAxises[serie.axisIndex];
|
||||
if (!xAxis.show) xAxis = m_XAxises[(serie.axisIndex + 1) % m_XAxises.Count];
|
||||
|
||||
float categoryWidth = xAxis.GetDataWidth(coordinateWidth, showData.Count, m_DataZoom);
|
||||
float categoryWidth = xAxis.GetDataWidth(m_CoordinateWidth, showData.Count, m_DataZoom);
|
||||
float barGap = GetBarGap();
|
||||
float totalBarWidth = GetBarTotalWidth(categoryWidth, barGap);
|
||||
float barWidth = serie.GetBarWidth(categoryWidth);
|
||||
@@ -208,8 +208,8 @@ namespace XCharts
|
||||
float value = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse);
|
||||
float borderWidth = value == 0 ? 0 : itemStyle.runtimeBorderWidth;
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
float pX = coordinateX + i * categoryWidth;
|
||||
float zeroY = coordinateY + yAxis.runtimeZeroYOffset;
|
||||
float pX = m_CoordinateX + i * categoryWidth;
|
||||
float zeroY = m_CoordinateY + yAxis.runtimeZeroYOffset;
|
||||
if (!xAxis.boundaryGap) pX -= categoryWidth / 2;
|
||||
float axisLineWidth = (value < 0 ? -1 : 1) * xAxis.axisLine.width;
|
||||
float pY = seriesHig[i] + zeroY + axisLineWidth;
|
||||
@@ -219,7 +219,7 @@ namespace XCharts
|
||||
if (isPercentStack)
|
||||
{
|
||||
valueTotal = GetSameStackTotalValue(serie.stack, i);
|
||||
barHig = valueTotal != 0 ? (value / valueTotal * coordinateHeight) : 0;
|
||||
barHig = valueTotal != 0 ? (value / valueTotal * m_CoordinateHeight) : 0;
|
||||
seriesHig[i] += barHig;
|
||||
}
|
||||
else
|
||||
@@ -227,7 +227,7 @@ namespace XCharts
|
||||
valueTotal = yMaxValue - yMinValue;
|
||||
if (valueTotal != 0)
|
||||
barHig = (yMinValue > 0 ? value - yMinValue : value)
|
||||
/ valueTotal * coordinateHeight;
|
||||
/ valueTotal * m_CoordinateHeight;
|
||||
seriesHig[i] += barHig;
|
||||
}
|
||||
float currHig = CheckAnimation(serie, i, barHig);
|
||||
@@ -436,15 +436,15 @@ namespace XCharts
|
||||
bool highlight, float pX, float pY, float space, float barWidth, bool isYAxis)
|
||||
{
|
||||
Color color = SerieHelper.GetItemBackgroundColor(serie, serieData, m_ThemeInfo, colorIndex, highlight, false);
|
||||
if (color == Color.clear) return;
|
||||
if (ChartHelper.IsClearColor(color)) return;
|
||||
if (isYAxis)
|
||||
{
|
||||
var axis = m_YAxises[serie.axisIndex];
|
||||
var axisWidth = axis.axisLine.width;
|
||||
Vector3 plt = new Vector3(coordinateX + axisWidth, pY + space + barWidth);
|
||||
Vector3 prt = new Vector3(coordinateX + axisWidth + coordinateWidth, pY + space + barWidth);
|
||||
Vector3 prb = new Vector3(coordinateX + axisWidth + coordinateWidth, pY + space);
|
||||
Vector3 plb = new Vector3(coordinateX + axisWidth, pY + space);
|
||||
Vector3 plt = new Vector3(m_CoordinateX + axisWidth, pY + space + barWidth);
|
||||
Vector3 prt = new Vector3(m_CoordinateX + axisWidth + m_CoordinateWidth, pY + space + barWidth);
|
||||
Vector3 prb = new Vector3(m_CoordinateX + axisWidth + m_CoordinateWidth, pY + space);
|
||||
Vector3 plb = new Vector3(m_CoordinateX + axisWidth, pY + space);
|
||||
if (serie.barType == BarType.Capsule)
|
||||
{
|
||||
var radius = barWidth / 2;
|
||||
@@ -480,10 +480,10 @@ namespace XCharts
|
||||
{
|
||||
var axis = m_XAxises[serie.axisIndex];
|
||||
var axisWidth = axis.axisLine.width;
|
||||
Vector3 plb = new Vector3(pX + space, coordinateY + axisWidth);
|
||||
Vector3 plt = new Vector3(pX + space, coordinateY + coordinateHeight + axisWidth);
|
||||
Vector3 prt = new Vector3(pX + space + barWidth, coordinateY + coordinateHeight + axisWidth);
|
||||
Vector3 prb = new Vector3(pX + space + barWidth, coordinateY + axisWidth);
|
||||
Vector3 plb = new Vector3(pX + space, m_CoordinateY + axisWidth);
|
||||
Vector3 plt = new Vector3(pX + space, m_CoordinateY + m_CoordinateHeight + axisWidth);
|
||||
Vector3 prt = new Vector3(pX + space + barWidth, m_CoordinateY + m_CoordinateHeight + axisWidth);
|
||||
Vector3 prb = new Vector3(pX + space + barWidth, m_CoordinateY + axisWidth);
|
||||
if (serie.barType == BarType.Capsule)
|
||||
{
|
||||
var radius = barWidth / 2;
|
||||
|
||||
@@ -121,11 +121,11 @@ namespace XCharts
|
||||
var xAxis = m_XAxises[serie.axisIndex];
|
||||
var xCount = xAxis.data.Count;
|
||||
var yCount = yAxis.data.Count;
|
||||
var xWidth = coordinateWidth / xCount;
|
||||
var yWidth = coordinateHeight / yCount;
|
||||
var xWidth = m_CoordinateWidth / xCount;
|
||||
var yWidth = m_CoordinateHeight / yCount;
|
||||
|
||||
var zeroX = coordinateX;
|
||||
var zeroY = coordinateY;
|
||||
var zeroX = m_CoordinateX;
|
||||
var zeroY = m_CoordinateY;
|
||||
var dataList = serie.GetDataList();
|
||||
var rangeMin = m_VisualMap.rangeMin;
|
||||
var rangeMax = m_VisualMap.rangeMax;
|
||||
@@ -175,7 +175,7 @@ namespace XCharts
|
||||
var rectWid = xWidth - 2 * borderWidth;
|
||||
var rectHig = yWidth - 2 * borderWidth;
|
||||
ChartDrawer.DrawPolygon(vh, pos, rectWid / 2, rectHig / 2, color);
|
||||
if (borderWidth > 0 && borderColor != Color.clear)
|
||||
if (borderWidth > 0 && !ChartHelper.IsClearColor(borderColor))
|
||||
{
|
||||
ChartDrawer.DrawBorder(vh, pos, rectWid, rectHig, borderWidth, borderColor);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace XCharts
|
||||
for (int n = 0; n < m_Series.Count; n++)
|
||||
{
|
||||
var serie = m_Series.GetSerie(n);
|
||||
if (serie.IsPerformanceMode()) continue;
|
||||
if (serie.type != SerieType.Line) continue;
|
||||
if (!serie.show || serie.symbol.type == SerieSymbolType.None) continue;
|
||||
var count = serie.dataPoints.Count;
|
||||
@@ -96,11 +97,11 @@ namespace XCharts
|
||||
Vector3 lp = Vector3.zero, np = Vector3.zero, llp = Vector3.zero, nnp = Vector3.zero;
|
||||
var yAxis = m_YAxises[serie.axisIndex];
|
||||
var xAxis = m_XAxises[serie.axisIndex];
|
||||
var zeroPos = new Vector3(coordinateX, coordinateY + yAxis.runtimeZeroYOffset);
|
||||
var zeroPos = new Vector3(m_CoordinateX, m_CoordinateY + yAxis.runtimeZeroYOffset);
|
||||
var isStack = m_Series.IsStack(serie.stack, SerieType.Line);
|
||||
if (!xAxis.show) xAxis = m_XAxises[(serie.axisIndex + 1) % m_XAxises.Count];
|
||||
float scaleWid = xAxis.GetDataWidth(coordinateWidth, showData.Count, m_DataZoom);
|
||||
float startX = coordinateX + (xAxis.boundaryGap ? scaleWid / 2 : 0);
|
||||
float scaleWid = xAxis.GetDataWidth(m_CoordinateWidth, showData.Count, m_DataZoom);
|
||||
float startX = m_CoordinateX + (xAxis.boundaryGap ? scaleWid / 2 : 0);
|
||||
int maxCount = serie.maxShow > 0 ?
|
||||
(serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||
: showData.Count;
|
||||
@@ -114,7 +115,7 @@ namespace XCharts
|
||||
}
|
||||
int rate = 1;
|
||||
var sampleDist = serie.sampleDist;
|
||||
if (sampleDist > 0) rate = (int)((maxCount - serie.minShow) / (coordinateWidth / sampleDist));
|
||||
if (sampleDist > 0) rate = (int)((maxCount - serie.minShow) / (m_CoordinateWidth / sampleDist));
|
||||
if (rate < 1) rate = 1;
|
||||
var includeLastData = false;
|
||||
var totalAverage = serie.sampleAverage > 0 ? serie.sampleAverage :
|
||||
@@ -421,46 +422,46 @@ namespace XCharts
|
||||
if (xAxis.IsValue() || xAxis.IsLog())
|
||||
{
|
||||
float xValue = i > showData.Count - 1 ? 0 : showData[i].GetData(0, xAxis.inverse);
|
||||
float pX = coordinateX + xAxis.axisLine.width;
|
||||
float pY = serieHig + coordinateY + xAxis.axisLine.width;
|
||||
float pX = m_CoordinateX + xAxis.axisLine.width;
|
||||
float pY = serieHig + m_CoordinateY + xAxis.axisLine.width;
|
||||
if (xAxis.IsLog())
|
||||
{
|
||||
int minIndex = xAxis.runtimeMinLogIndex;
|
||||
float nowIndex = xAxis.GetLogValue(xValue);
|
||||
xDataHig = (nowIndex - minIndex) / (xAxis.splitNumber - 1) * coordinateWidth;
|
||||
xDataHig = (nowIndex - minIndex) / (xAxis.splitNumber - 1) * m_CoordinateWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((xMaxValue - xMinValue) <= 0) xDataHig = 0;
|
||||
else xDataHig = (xValue - xMinValue) / (xMaxValue - xMinValue) * coordinateWidth;
|
||||
else xDataHig = (xValue - xMinValue) / (xMaxValue - xMinValue) * m_CoordinateWidth;
|
||||
}
|
||||
if (yAxis.IsLog())
|
||||
{
|
||||
int minIndex = yAxis.runtimeMinLogIndex;
|
||||
float nowIndex = yAxis.GetLogValue(yValue);
|
||||
yDataHig = (nowIndex - minIndex) / (yAxis.splitNumber - 1) * coordinateHeight;
|
||||
yDataHig = (nowIndex - minIndex) / (yAxis.splitNumber - 1) * m_CoordinateHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((yMaxValue - yMinValue) <= 0) yDataHig = 0;
|
||||
else yDataHig = (yValue - yMinValue) / (yMaxValue - yMinValue) * coordinateHeight;
|
||||
else yDataHig = (yValue - yMinValue) / (yMaxValue - yMinValue) * m_CoordinateHeight;
|
||||
}
|
||||
np = new Vector3(pX + xDataHig, pY + yDataHig);
|
||||
}
|
||||
else
|
||||
{
|
||||
float pX = startX + i * scaleWid;
|
||||
float pY = serieHig + coordinateY + yAxis.axisLine.width;
|
||||
float pY = serieHig + m_CoordinateY + yAxis.axisLine.width;
|
||||
if (yAxis.IsLog())
|
||||
{
|
||||
int minIndex = yAxis.runtimeMinLogIndex;
|
||||
float nowIndex = yAxis.GetLogValue(yValue);
|
||||
yDataHig = (nowIndex - minIndex) / (yAxis.splitNumber - 1) * coordinateHeight;
|
||||
yDataHig = (nowIndex - minIndex) / (yAxis.splitNumber - 1) * m_CoordinateHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((yMaxValue - yMinValue) <= 0) yDataHig = 0;
|
||||
else yDataHig = (yValue - yMinValue) / (yMaxValue - yMinValue) * coordinateHeight;
|
||||
else yDataHig = (yValue - yMinValue) / (yMaxValue - yMinValue) * m_CoordinateHeight;
|
||||
}
|
||||
np = new Vector3(pX, pY + yDataHig);
|
||||
}
|
||||
@@ -484,11 +485,11 @@ namespace XCharts
|
||||
Color areaColor, areaToColor;
|
||||
var xAxis = m_XAxises[serie.axisIndex];
|
||||
var yAxis = m_YAxises[serie.axisIndex];
|
||||
var zeroPos = new Vector3(coordinateX + xAxis.runtimeZeroXOffset, coordinateY);
|
||||
var zeroPos = new Vector3(m_CoordinateX + xAxis.runtimeZeroXOffset, m_CoordinateY);
|
||||
var isStack = m_Series.IsStack(serie.stack, SerieType.Line);
|
||||
if (!yAxis.show) yAxis = m_YAxises[(serie.axisIndex + 1) % m_YAxises.Count];
|
||||
float scaleWid = yAxis.GetDataWidth(coordinateHeight, showData.Count, m_DataZoom);
|
||||
float startY = coordinateY + (yAxis.boundaryGap ? scaleWid / 2 : 0);
|
||||
float scaleWid = yAxis.GetDataWidth(m_CoordinateHeight, showData.Count, m_DataZoom);
|
||||
float startY = m_CoordinateY + (yAxis.boundaryGap ? scaleWid / 2 : 0);
|
||||
int maxCount = serie.maxShow > 0 ?
|
||||
(serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||
: showData.Count;
|
||||
@@ -502,7 +503,7 @@ namespace XCharts
|
||||
}
|
||||
int rate = 1;
|
||||
var sampleDist = serie.sampleDist;
|
||||
if (sampleDist > 0) rate = (int)((maxCount - serie.minShow) / (coordinateWidth / sampleDist));
|
||||
if (sampleDist > 0) rate = (int)((maxCount - serie.minShow) / (m_CoordinateWidth / sampleDist));
|
||||
if (rate < 1) rate = 1;
|
||||
var dataChanging = false;
|
||||
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
@@ -516,17 +517,17 @@ namespace XCharts
|
||||
}
|
||||
float value = showData[i].GetCurrData(1, dataChangeDuration, xAxis.inverse);
|
||||
float pY = startY + i * scaleWid;
|
||||
float pX = seriesHig[i] + coordinateX + yAxis.axisLine.width;
|
||||
float pX = seriesHig[i] + m_CoordinateX + yAxis.axisLine.width;
|
||||
float dataHig = 0;
|
||||
if (xAxis.IsLog())
|
||||
{
|
||||
int minIndex = xAxis.runtimeMinLogIndex;
|
||||
float nowIndex = xAxis.GetLogValue(value);
|
||||
dataHig = (nowIndex - minIndex) / (xAxis.splitNumber - 1) * coordinateWidth;
|
||||
dataHig = (nowIndex - minIndex) / (xAxis.splitNumber - 1) * m_CoordinateWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
dataHig = (value - xMinValue) / (xMaxValue - xMinValue) * coordinateWidth;
|
||||
dataHig = (value - xMinValue) / (xMaxValue - xMinValue) * m_CoordinateWidth;
|
||||
}
|
||||
np = new Vector3(pX + dataHig, pY);
|
||||
serie.dataPoints.Add(np);
|
||||
@@ -543,17 +544,17 @@ namespace XCharts
|
||||
seriesHig.Add(0);
|
||||
float value = showData[i].GetCurrData(1, dataChangeDuration, xAxis.inverse);
|
||||
float pY = startY + i * scaleWid;
|
||||
float pX = seriesHig[i] + coordinateX + yAxis.axisLine.width;
|
||||
float pX = seriesHig[i] + m_CoordinateX + yAxis.axisLine.width;
|
||||
float dataHig = 0;
|
||||
if (xAxis.IsLog())
|
||||
{
|
||||
int minIndex = xAxis.runtimeMinLogIndex;
|
||||
float nowIndex = xAxis.GetLogValue(value);
|
||||
dataHig = (nowIndex - minIndex) / (xAxis.splitNumber - 1) * coordinateWidth;
|
||||
dataHig = (nowIndex - minIndex) / (xAxis.splitNumber - 1) * m_CoordinateWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
dataHig = (value - xMinValue) / (xMaxValue - xMinValue) * coordinateWidth;
|
||||
dataHig = (value - xMinValue) / (xMaxValue - xMinValue) * m_CoordinateWidth;
|
||||
}
|
||||
np = new Vector3(pX + dataHig, pY);
|
||||
serie.dataPoints.Add(np);
|
||||
@@ -848,7 +849,7 @@ namespace XCharts
|
||||
else
|
||||
{
|
||||
var points = ((isYAxis && lp.x < zeroPos.x) || (!isYAxis && lp.y < zeroPos.y)) ? smoothPoints : smoothDownPoints;
|
||||
Vector3 aep = isYAxis ? new Vector3(zeroPos.x, zeroPos.y + coordinateHeight) : new Vector3(zeroPos.x + coordinateWidth, zeroPos.y);
|
||||
Vector3 aep = isYAxis ? new Vector3(zeroPos.x, zeroPos.y + m_CoordinateHeight) : new Vector3(zeroPos.x + m_CoordinateWidth, zeroPos.y);
|
||||
var sindex = 0;
|
||||
var eindex = 0;
|
||||
var sp = GetStartPos(points, ref sindex);
|
||||
@@ -870,9 +871,9 @@ namespace XCharts
|
||||
var sp1 = smoothDownPoints[1];
|
||||
var ep1 = smoothDownPoints[smoothDownPoints.Count - 2];
|
||||
var axisUpStart = zeroPos + (isYAxis ? Vector3.right : Vector3.up) * axis.axisLine.width;
|
||||
var axisUpEnd = axisUpStart + (isYAxis ? Vector3.up * coordinateHeight : Vector3.right * coordinateWidth);
|
||||
var axisUpEnd = axisUpStart + (isYAxis ? Vector3.up * m_CoordinateHeight : Vector3.right * m_CoordinateWidth);
|
||||
var axisDownStart = zeroPos - (isYAxis ? Vector3.right : Vector3.up) * axis.axisLine.width;
|
||||
var axisDownEnd = axisDownStart + (isYAxis ? Vector3.up * coordinateHeight : Vector3.right * coordinateWidth);
|
||||
var axisDownEnd = axisDownStart + (isYAxis ? Vector3.up * m_CoordinateHeight : Vector3.right * m_CoordinateWidth);
|
||||
var luPos = ChartHelper.GetIntersection(sp1, ep1, axisUpStart, axisUpEnd);
|
||||
var ldPos = ChartHelper.GetIntersection(sp1, ep1, axisDownStart, axisDownEnd);
|
||||
sp1 = smoothPoints[1];
|
||||
|
||||
@@ -36,10 +36,10 @@ namespace XCharts
|
||||
float xValue = serieData.GetCurrData(0, dataChangeDuration, xAxis.inverse);
|
||||
float yValue = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse);
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
float pX = coordinateX + xAxis.axisLine.width;
|
||||
float pY = coordinateY + yAxis.axisLine.width;
|
||||
float xDataHig = (xValue - xAxis.runtimeMinValue) / (xAxis.runtimeMaxValue - xAxis.runtimeMinValue) * coordinateWidth;
|
||||
float yDataHig = (yValue - yAxis.runtimeMinValue) / (yAxis.runtimeMaxValue - yAxis.runtimeMinValue) * coordinateHeight;
|
||||
float pX = m_CoordinateX + xAxis.axisLine.width;
|
||||
float pY = m_CoordinateY + yAxis.axisLine.width;
|
||||
float xDataHig = (xValue - xAxis.runtimeMinValue) / (xAxis.runtimeMaxValue - xAxis.runtimeMinValue) * m_CoordinateWidth;
|
||||
float yDataHig = (yValue - yAxis.runtimeMinValue) / (yAxis.runtimeMaxValue - yAxis.runtimeMinValue) * m_CoordinateHeight;
|
||||
var pos = new Vector3(pX + xDataHig, pY + yDataHig);
|
||||
serie.dataPoints.Add(pos);
|
||||
serieData.runtimePosition = pos;
|
||||
|
||||
@@ -6,13 +6,24 @@
|
||||
/******************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
internal static class ListPool<T>
|
||||
{
|
||||
private static readonly ObjectPool<List<T>> s_ListPool = new ObjectPool<List<T>>(null, Clear);
|
||||
static void Clear(List<T> l) { l.Clear(); }
|
||||
private static readonly ObjectPool<List<T>> s_ListPool = new ObjectPool<List<T>>(OnGet, OnClear);
|
||||
static void OnGet(List<T> l)
|
||||
{
|
||||
if (l.Capacity < 50)
|
||||
{
|
||||
l.Capacity = 50;
|
||||
}
|
||||
}
|
||||
static void OnClear(List<T> l)
|
||||
{
|
||||
l.Clear();
|
||||
}
|
||||
|
||||
public static List<T> Get()
|
||||
{
|
||||
@@ -23,5 +34,10 @@ namespace XCharts
|
||||
{
|
||||
s_ListPool.Release(toRelease);
|
||||
}
|
||||
|
||||
public static void ClearAll()
|
||||
{
|
||||
s_ListPool.ClearAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,5 +52,10 @@ namespace XCharts
|
||||
m_ActionOnRelease(element);
|
||||
m_Stack.Push(element);
|
||||
}
|
||||
|
||||
public void ClearAll()
|
||||
{
|
||||
m_Stack.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
internal static class SerieDataPool
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace XCharts
|
||||
|
||||
public static void Release(GameObject element)
|
||||
{
|
||||
if (element == null) return;
|
||||
ChartHelper.SetActive(element, false);
|
||||
if (!Application.isPlaying) return;
|
||||
if (!m_ReleaseDic.ContainsKey(element.GetInstanceID()))
|
||||
|
||||
8
Runtime/Object.meta
Normal file
8
Runtime/Object.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05690857746244b0ebec49f0b58b0f23
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
22
Runtime/Object/ChartObject.cs
Normal file
22
Runtime/Object/ChartObject.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public class ChartObject
|
||||
{
|
||||
protected GameObject m_GameObject;
|
||||
|
||||
public virtual void Destroy()
|
||||
{
|
||||
GameObject.Destroy(m_GameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Object/ChartObject.cs.meta
Normal file
11
Runtime/Object/ChartObject.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0fe3102b0eea042938d30af910ca86d6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -10,17 +10,17 @@ using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public class LabelObject
|
||||
public class LabelObject : ChartObject
|
||||
{
|
||||
private GameObject m_GameObject;
|
||||
private bool m_LabelAutoSize = true;
|
||||
private float m_LabelPaddingLeftRight = 3f;
|
||||
private float m_LabelPaddingTopBottom = 3f;
|
||||
private Text m_LabelText;
|
||||
private RectTransform m_LabelRect;
|
||||
private RectTransform m_IconRect;
|
||||
private Image m_IconImage;
|
||||
// private RectTransform m_IconRect;
|
||||
|
||||
public GameObject gameObject { get { return m_GameObject; } }
|
||||
public Image icon { get { return m_IconImage; } }
|
||||
public Text label { get { return m_LabelText; } }
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace XCharts
|
||||
m_IconImage = image;
|
||||
if (image != null)
|
||||
{
|
||||
// m_IconRect = m_IconImage.GetComponent<RectTransform>();
|
||||
m_IconRect = m_IconImage.GetComponent<RectTransform>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,12 +54,50 @@ namespace XCharts
|
||||
|
||||
public void SetIconSize(float width, float height)
|
||||
{
|
||||
if (m_LabelRect != null) m_LabelRect.sizeDelta = new Vector3(width, height);
|
||||
if (m_IconRect != null) m_IconRect.sizeDelta = new Vector3(width, height);
|
||||
}
|
||||
|
||||
public void SetIconActive(bool flag)
|
||||
public void UpdateIcon(IconStyle iconStyle)
|
||||
{
|
||||
ChartHelper.SetActive(m_IconImage, flag);
|
||||
if (m_IconImage == null) return;
|
||||
if (iconStyle.show)
|
||||
{
|
||||
ChartHelper.SetActive(m_IconImage.gameObject, true);
|
||||
m_IconImage.sprite = iconStyle.sprite;
|
||||
m_IconImage.color = iconStyle.color;
|
||||
m_IconRect.sizeDelta = new Vector2(iconStyle.width, iconStyle.height);
|
||||
m_IconImage.transform.localPosition = iconStyle.offset;
|
||||
if (iconStyle.layer == IconStyle.Layer.UnderLabel)
|
||||
m_IconRect.SetSiblingIndex(0);
|
||||
else
|
||||
m_IconRect.SetSiblingIndex(m_GameObject.transform.childCount - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChartHelper.SetActive(m_IconImage.gameObject, false);
|
||||
}
|
||||
}
|
||||
|
||||
public float GetLabelWidth()
|
||||
{
|
||||
if (m_LabelRect) return m_LabelRect.sizeDelta.x;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
public float GetLabelHeight()
|
||||
{
|
||||
if (m_LabelRect) return m_LabelRect.sizeDelta.y;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void SetLabelColor(Color color)
|
||||
{
|
||||
if (m_LabelText) m_LabelText.color = color;
|
||||
}
|
||||
|
||||
public void SetLabelRotate(float rotate)
|
||||
{
|
||||
if (m_LabelText) m_LabelText.transform.localEulerAngles = new Vector3(0, 0, rotate);
|
||||
}
|
||||
|
||||
public void SetPosition(Vector3 position)
|
||||
@@ -70,9 +108,22 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLabelPosition(Vector3 position)
|
||||
{
|
||||
if (m_LabelRect) m_LabelRect.localPosition = position;
|
||||
}
|
||||
|
||||
public void SetActive(bool flag)
|
||||
{
|
||||
ChartHelper.SetActive(m_GameObject, flag);
|
||||
if (m_GameObject) ChartHelper.SetActive(m_GameObject, flag);
|
||||
}
|
||||
public void SetLabelActive(bool flag)
|
||||
{
|
||||
if (m_LabelText) ChartHelper.SetActive(m_LabelText, flag);
|
||||
}
|
||||
public void SetIconActive(bool flag)
|
||||
{
|
||||
if (m_IconImage) ChartHelper.SetActive(m_IconImage, flag);
|
||||
}
|
||||
|
||||
public bool SetText(string text)
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4e7ef04b9a0e4526b49bf63967cfef4
|
||||
guid: 1277b7528331b42cfb61da7a2c762bee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -185,7 +185,7 @@ namespace XCharts
|
||||
|
||||
private void DrawCenter(VertexHelper vh, Serie serie, ItemStyle itemStyle, float insideRadius)
|
||||
{
|
||||
if (itemStyle.centerColor != Color.clear)
|
||||
if (!ChartHelper.IsClearColor(itemStyle.centerColor))
|
||||
{
|
||||
var radius = insideRadius - itemStyle.centerGap;
|
||||
ChartDrawer.DrawCricle(vh, serie.runtimeCenterPos, radius, itemStyle.centerColor, m_Settings.cicleSmoothness);
|
||||
@@ -242,7 +242,7 @@ namespace XCharts
|
||||
var outSideRadius = serieData.runtimePieOutsideRadius;
|
||||
var center = serie.runtimeCenterPos;
|
||||
var currAngle = serieData.runtimePieHalfAngle;
|
||||
if (serieLabel.lineColor != Color.clear) color = serieLabel.lineColor;
|
||||
if (!ChartHelper.IsClearColor(serieLabel.lineColor)) color = serieLabel.lineColor;
|
||||
else if (serieLabel.lineType == SerieLabel.LineType.HorizontalLine) color *= color;
|
||||
float currSin = Mathf.Sin(currAngle * Mathf.Deg2Rad);
|
||||
float currCos = Mathf.Cos(currAngle * Mathf.Deg2Rad);
|
||||
@@ -358,7 +358,7 @@ namespace XCharts
|
||||
|
||||
private void DrawLabel(Serie serie, int dataIndex, SerieData serieData, Color serieColor)
|
||||
{
|
||||
if (serieData.labelText == null) return;
|
||||
if (serieData.labelObject == null) return;
|
||||
var currAngle = serieData.runtimePieHalfAngle;
|
||||
var isHighlight = (serieData.highlighted && serie.emphasis.label.show);
|
||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
||||
@@ -376,9 +376,9 @@ namespace XCharts
|
||||
Color color = serieColor;
|
||||
if (isHighlight)
|
||||
{
|
||||
if (serie.emphasis.label.color != Color.clear) color = serie.emphasis.label.color;
|
||||
if (!ChartHelper.IsClearColor(serie.emphasis.label.color)) color = serie.emphasis.label.color;
|
||||
}
|
||||
else if (serieLabel.color != Color.clear)
|
||||
else if (!ChartHelper.IsClearColor(serieLabel.color))
|
||||
{
|
||||
color = serieLabel.color;
|
||||
}
|
||||
@@ -389,38 +389,37 @@ namespace XCharts
|
||||
var fontSize = isHighlight ? serie.emphasis.label.fontSize : serieLabel.fontSize;
|
||||
var fontStyle = isHighlight ? serie.emphasis.label.fontStyle : serieLabel.fontStyle;
|
||||
|
||||
serieData.labelText.color = color;
|
||||
serieData.labelText.fontSize = fontSize;
|
||||
serieData.labelText.fontStyle = fontStyle;
|
||||
|
||||
serieData.labelRect.transform.localEulerAngles = new Vector3(0, 0, rotate);
|
||||
serieData.labelObject.label.color = color;
|
||||
serieData.labelObject.label.fontSize = fontSize;
|
||||
serieData.labelObject.label.fontStyle = fontStyle;
|
||||
serieData.labelObject.SetLabelRotate(rotate);
|
||||
|
||||
UpdateLabelPostion(serie, serieData);
|
||||
if (!string.IsNullOrEmpty(serieLabel.formatter))
|
||||
{
|
||||
var value = serieData.data[1];
|
||||
var total = serie.yTotal;
|
||||
var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, total, serieLabel);
|
||||
if (serieData.SetLabelText(content)) RefreshChart();
|
||||
var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, total, serieLabel);
|
||||
if (serieData.labelObject.SetText(content)) RefreshChart();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (serieData.SetLabelText(serieData.name)) RefreshChart();
|
||||
if (serieData.labelObject.SetText(serieData.name)) RefreshChart();
|
||||
}
|
||||
serieData.SetGameObjectPosition(serieData.labelPosition);
|
||||
if (showLabel) serieData.SetLabelPosition(serieLabel.offset);
|
||||
serieData.labelObject.SetPosition(serieData.labelPosition);
|
||||
if (showLabel) serieData.labelObject.SetLabelPosition(serieLabel.offset);
|
||||
else serieData.SetLabelActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
serieData.SetLabelActive(false);
|
||||
}
|
||||
serieData.UpdateIcon();
|
||||
serieData.labelObject.UpdateIcon(serieData.iconStyle);
|
||||
}
|
||||
|
||||
protected void UpdateLabelPostion(Serie serie, SerieData serieData)
|
||||
{
|
||||
if (serieData.labelText == null) return;
|
||||
if (serieData.labelObject == null) return;
|
||||
var currAngle = serieData.runtimePieHalfAngle;
|
||||
var currRad = currAngle * Mathf.Deg2Rad;
|
||||
var offsetRadius = serieData.runtimePieOffsetRadius;
|
||||
@@ -453,7 +452,7 @@ namespace XCharts
|
||||
}
|
||||
var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos * radius3, 2)) - currSin * radius3;
|
||||
r4 += serieLabel.lineLength1 + serieLabel.lineWidth * 4;
|
||||
r4 += serieData.labelText.preferredWidth / 2;
|
||||
r4 += serieData.labelObject.label.preferredWidth / 2;
|
||||
serieData.labelPosition = pos0 + (currAngle > 180 ? Vector3.left : Vector3.right) * r4;
|
||||
}
|
||||
else
|
||||
@@ -461,7 +460,7 @@ namespace XCharts
|
||||
labelRadius = serie.runtimeOutsideRadius + serieLabel.lineLength1;
|
||||
labelCenter = new Vector2(serie.runtimeCenterPos.x + labelRadius * Mathf.Sin(currRad),
|
||||
serie.runtimeCenterPos.y + labelRadius * Mathf.Cos(currRad));
|
||||
float labelWidth = serieData.labelText.preferredWidth;
|
||||
float labelWidth = serieData.labelObject.label.preferredWidth;
|
||||
if (currAngle > 180)
|
||||
{
|
||||
serieData.labelPosition = new Vector2(labelCenter.x - serieLabel.lineLength2 - 5 - labelWidth / 2, labelCenter.y);
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace XCharts
|
||||
var pos = radar.GetIndicatorPosition(i);
|
||||
TextAnchor anchor = TextAnchor.MiddleCenter;
|
||||
var textStyle = indicator.textStyle;
|
||||
var textColor = textStyle.color == Color.clear ? (Color)m_ThemeInfo.axisTextColor : textStyle.color;
|
||||
var textColor = ChartHelper.IsClearColor(textStyle.color) ? (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, textStyle.lineSpacing);
|
||||
@@ -732,23 +732,24 @@ namespace XCharts
|
||||
for (int n = 0; n < serie.dataCount; n++)
|
||||
{
|
||||
var serieData = serie.data[n];
|
||||
if (serieData.labelObject == null) continue;
|
||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
||||
var labelPos = serieData.labelPosition;
|
||||
if (serieLabel.margin != 0)
|
||||
{
|
||||
labelPos += serieLabel.margin * (labelPos - center).normalized;
|
||||
}
|
||||
serieData.SetGameObjectPosition(labelPos);
|
||||
serieData.UpdateIcon();
|
||||
serieData.labelObject.SetPosition(labelPos);
|
||||
serieData.labelObject.UpdateIcon(serieData.iconStyle);
|
||||
if (serie.show && serieLabel.show && serieData.canShowLabel)
|
||||
{
|
||||
var value = serieData.GetCurrData(1);
|
||||
var max = radar.GetIndicatorMax(n);
|
||||
SerieLabelHelper.ResetLabel(serieData, serieLabel, themeInfo, i);
|
||||
serieData.SetLabelActive(serieData.labelPosition != Vector3.zero);
|
||||
serieData.SetLabelPosition(serieLabel.offset);
|
||||
serieData.labelObject.SetLabelPosition(serieLabel.offset);
|
||||
var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, max, serieLabel);
|
||||
if (serieData.SetLabelText(content)) RefreshChart();
|
||||
if (serieData.labelObject.SetText(content)) RefreshChart();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace XCharts
|
||||
private void DrawCenter(VertexHelper vh, Serie serie, SerieData serieData, float insideRadius, bool last)
|
||||
{
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData);
|
||||
if (itemStyle.centerColor != Color.clear && last)
|
||||
if (!ChartHelper.IsClearColor(itemStyle.centerColor) && last)
|
||||
{
|
||||
var radius = insideRadius - itemStyle.centerGap;
|
||||
var smoothness = m_Settings.cicleSmoothness;
|
||||
@@ -163,6 +163,7 @@ namespace XCharts
|
||||
float toAngle, float centerRadius)
|
||||
{
|
||||
if (!serie.label.show) return;
|
||||
if (serieData.labelObject == null) return;
|
||||
switch (serie.label.position)
|
||||
{
|
||||
case SerieLabel.Position.Center:
|
||||
@@ -182,7 +183,7 @@ namespace XCharts
|
||||
serieData.labelPosition = serie.runtimeCenterPos + new Vector3(px2, py2);
|
||||
break;
|
||||
}
|
||||
serieData.SetLabelPosition(serieData.labelPosition);
|
||||
serieData.labelObject.SetLabelPosition(serieData.labelPosition);
|
||||
}
|
||||
|
||||
private void DrawBackground(VertexHelper vh, Serie serie, SerieData serieData, int index, float insideRadius, float outsideRadius)
|
||||
@@ -207,7 +208,7 @@ namespace XCharts
|
||||
private void DrawBorder(VertexHelper vh, Serie serie, SerieData serieData, float insideRadius, float outsideRadius)
|
||||
{
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData);
|
||||
if (itemStyle.show && itemStyle.borderWidth > 0 && itemStyle.borderColor != Color.clear)
|
||||
if (itemStyle.show && itemStyle.borderWidth > 0 && !ChartHelper.IsClearColor(itemStyle.borderColor))
|
||||
{
|
||||
ChartDrawer.DrawDoughnut(vh, serie.runtimeCenterPos, outsideRadius,
|
||||
outsideRadius + itemStyle.borderWidth, itemStyle.borderColor,
|
||||
|
||||
@@ -407,7 +407,7 @@ namespace XCharts
|
||||
public static void DrawBorder(VertexHelper vh, Vector3 center, float rectWidth, float rectHeight,
|
||||
float borderWidth, Color32 color, float rotate = 0, float[] cornerRadius = null)
|
||||
{
|
||||
if (borderWidth == 0 || color == Color.clear) return;
|
||||
if (borderWidth == 0 || ChartHelper.IsClearColor(color)) return;
|
||||
var halfWid = rectWidth / 2;
|
||||
var halfHig = rectHeight / 2;
|
||||
var lbIn = new Vector3(center.x - halfWid, center.y - halfHig);
|
||||
@@ -954,7 +954,7 @@ namespace XCharts
|
||||
p.y + outsideRadius * Mathf.Cos(currAngle));
|
||||
p4 = new Vector3(p.x + insideRadius * Mathf.Sin(currAngle),
|
||||
p.y + insideRadius * Mathf.Cos(currAngle));
|
||||
if (emptyColor != Color.clear) DrawTriangle(vh, p, p1, p4, emptyColor);
|
||||
if (!ChartHelper.IsClearColor(emptyColor)) DrawTriangle(vh, p, p1, p4, emptyColor);
|
||||
DrawPolygon(vh, p2, p3, p4, p1, color, toColor);
|
||||
p1 = p4;
|
||||
p2 = p3;
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace XCharts
|
||||
if (parent.Find(name))
|
||||
{
|
||||
obj = parent.Find(name).gameObject;
|
||||
obj.SetActive(true);
|
||||
SetActive(obj, true);
|
||||
obj.transform.localPosition = Vector3.zero;
|
||||
obj.transform.localScale = Vector3.one;
|
||||
}
|
||||
@@ -423,6 +423,16 @@ namespace XCharts
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool IsClearColor(Color32 color)
|
||||
{
|
||||
return color.a == 0 && color.b == 0 && color.g == 0 && color.r == 0;
|
||||
}
|
||||
|
||||
public static bool IsClearColor(Color color)
|
||||
{
|
||||
return color.a == 0 && color.b == 0 && color.g == 0 && color.r == 0;
|
||||
}
|
||||
|
||||
public static bool CopyList<T>(List<T> toList, List<T> fromList)
|
||||
{
|
||||
if (toList == null || fromList == null) return false;
|
||||
|
||||
Reference in New Issue
Block a user