mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-29 20:58:47 +00:00
增加自由锚点支持,任意对齐方式
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
* (2020.04.28) 增加`自由锚点`支持,任意对齐方式
|
||||||
* (2020.04.23) 优化`ScatterChart`的`Tooltip`显示效果
|
* (2020.04.23) 优化`ScatterChart`的`Tooltip`显示效果
|
||||||
* (2020.04.23) 增加`Tooltip`的`formatter`对`{.}`、`{c:0}`、`{c1:1}`的支持
|
* (2020.04.23) 增加`Tooltip`的`formatter`对`{.}`、`{c:0}`、`{c1:1}`的支持
|
||||||
* (2020.04.19) 优化`LineChart`折线图的区域填充渐变效果
|
* (2020.04.19) 优化`LineChart`折线图的区域填充渐变效果
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ namespace XCharts
|
|||||||
|
|
||||||
void OnTestBtn()
|
void OnTestBtn()
|
||||||
{
|
{
|
||||||
chart.ClearData();
|
//chart.ClearData();
|
||||||
|
chart.SetSize(800,400);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddData()
|
void AddData()
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* `BaseChart.chartWidth`:图表的宽。
|
* `BaseChart.chartWidth`:图表的宽。
|
||||||
* `BaseChart.chartHeight`:图表的高。
|
* `BaseChart.chartHeight`:图表的高。
|
||||||
* `BaseChart.customDrawCallback`:自定义绘制回调函数。
|
* `BaseChart.customDrawCallback`:自定义绘制回调函数。
|
||||||
* `BaseChart.SetSize(float width, float height)`:设置图表的大小。
|
* `BaseChart.SetSize(float width, float height)`: 设置图表的宽高(在非stretch pivot下才有效,其他情况需要自己调整RectTransform)。
|
||||||
* `BaseChart.ClearData()`:清除所有数据,系列列表会保留,只是移除列表中系列的数据。
|
* `BaseChart.ClearData()`:清除所有数据,系列列表会保留,只是移除列表中系列的数据。
|
||||||
* `BaseChart.RemoveData()`:清除所有系列和图例数据,系列列表也会被清除。
|
* `BaseChart.RemoveData()`:清除所有系列和图例数据,系列列表也会被清除。
|
||||||
* `BaseChart.RemoveData(string serieName)`:清除指定系列名称的数据。
|
* `BaseChart.RemoveData(string serieName)`:清除指定系列名称的数据。
|
||||||
|
|||||||
@@ -75,8 +75,8 @@ namespace XCharts
|
|||||||
protected virtual void OnStartInspectorGUI()
|
protected virtual void OnStartInspectorGUI()
|
||||||
{
|
{
|
||||||
EditorGUILayout.PropertyField(m_Script);
|
EditorGUILayout.PropertyField(m_Script);
|
||||||
EditorGUILayout.PropertyField(m_ChartWidth);
|
// EditorGUILayout.PropertyField(m_ChartWidth);
|
||||||
EditorGUILayout.PropertyField(m_ChartHeight);
|
// EditorGUILayout.PropertyField(m_ChartHeight);
|
||||||
EditorGUILayout.PropertyField(m_ThemeInfo, true);
|
EditorGUILayout.PropertyField(m_ThemeInfo, true);
|
||||||
EditorGUILayout.PropertyField(m_Title, true);
|
EditorGUILayout.PropertyField(m_Title, true);
|
||||||
EditorGUILayout.PropertyField(m_Legend, true);
|
EditorGUILayout.PropertyField(m_Legend, true);
|
||||||
|
|||||||
@@ -39,8 +39,14 @@ namespace XCharts
|
|||||||
protected override void OnStartInspectorGUI()
|
protected override void OnStartInspectorGUI()
|
||||||
{
|
{
|
||||||
base.OnStartInspectorGUI();
|
base.OnStartInspectorGUI();
|
||||||
|
if (m_Target is LineChart || m_Target is BarChart)
|
||||||
|
{
|
||||||
EditorGUILayout.PropertyField(m_DataZoom);
|
EditorGUILayout.PropertyField(m_DataZoom);
|
||||||
|
}
|
||||||
|
if (m_Target is HeatmapChart)
|
||||||
|
{
|
||||||
EditorGUILayout.PropertyField(m_VisualMap);
|
EditorGUILayout.PropertyField(m_VisualMap);
|
||||||
|
}
|
||||||
EditorGUILayout.PropertyField(m_Grid);
|
EditorGUILayout.PropertyField(m_Grid);
|
||||||
for (int i = 0; i < m_XAxises.arraySize; i++)
|
for (int i = 0; i < m_XAxises.arraySize; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ namespace XCharts
|
|||||||
|
|
||||||
protected override void OnEndInspectorGUI()
|
protected override void OnEndInspectorGUI()
|
||||||
{
|
{
|
||||||
base.OnEndInspectorGUI();
|
|
||||||
EditorGUILayout.PropertyField(m_Radars, true);
|
EditorGUILayout.PropertyField(m_Radars, true);
|
||||||
|
base.OnEndInspectorGUI();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,6 +66,10 @@ namespace XCharts
|
|||||||
chart.transform.SetParent(parent);
|
chart.transform.SetParent(parent);
|
||||||
chart.transform.localScale = Vector3.one;
|
chart.transform.localScale = Vector3.one;
|
||||||
chart.transform.localPosition = Vector3.zero;
|
chart.transform.localPosition = Vector3.zero;
|
||||||
|
var rect = chart.GetComponent<RectTransform>();
|
||||||
|
rect.anchorMin = new Vector2(0.5f, 0.5f);
|
||||||
|
rect.anchorMax = new Vector2(0.5f, 0.5f);
|
||||||
|
rect.pivot = new Vector2(0.5f, 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MenuItem("GameObject/XCharts/LineChart", priority = 44)]
|
[MenuItem("GameObject/XCharts/LineChart", priority = 44)]
|
||||||
|
|||||||
@@ -48,6 +48,16 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Settings settings { get { return m_Settings; } }
|
public Settings settings { get { return m_Settings; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// The x of chart.
|
||||||
|
/// 图表的X
|
||||||
|
/// </summary>
|
||||||
|
public float chartX { get { return m_ChartX; } }
|
||||||
|
/// <summary>
|
||||||
|
/// The y of chart.
|
||||||
|
/// 图表的Y
|
||||||
|
/// </summary>
|
||||||
|
public float chartY { get { return m_ChartY; } }
|
||||||
|
/// <summary>
|
||||||
/// The width of chart.
|
/// The width of chart.
|
||||||
/// 图表的宽
|
/// 图表的宽
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -58,6 +68,13 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public float chartHeight { get { return m_ChartHeight; } }
|
public float chartHeight { get { return m_ChartHeight; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// The position of chart.
|
||||||
|
/// 图表的左下角起始坐标。
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Vector3 chartPosition { get { return m_ChartPosition; } }
|
||||||
|
public Rect chartRect { get { return m_ChartRect; } }
|
||||||
|
/// <summary>
|
||||||
/// The postion of pointer.
|
/// The postion of pointer.
|
||||||
/// 鼠标位置
|
/// 鼠标位置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -70,21 +87,22 @@ namespace XCharts
|
|||||||
/// 警告信息。
|
/// 警告信息。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string warningInfo { get; protected set; }
|
public string warningInfo { get; protected set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the size of chart.
|
/// 设置图表的宽高(在非stretch pivot下才有效,其他情况需要自己调整RectTransform)
|
||||||
/// 设置图表的大小。
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="width">width</param>
|
/// <param name="width"></param>
|
||||||
/// <param name="height">height</param>
|
/// <param name="height"></param>
|
||||||
public virtual void SetSize(float width, float height)
|
public virtual void SetSize(float width, float height)
|
||||||
{
|
{
|
||||||
m_ChartWidth = width;
|
if (LayerHelper.IsFixedWidthHeight(rectTransform))
|
||||||
m_ChartHeight = height;
|
{
|
||||||
m_CheckWidth = width;
|
rectTransform.sizeDelta = new Vector2(width, height);
|
||||||
m_CheckHeight = height;
|
}
|
||||||
|
else
|
||||||
rectTransform.sizeDelta = new Vector2(m_ChartWidth, m_ChartHeight);
|
{
|
||||||
OnSizeChanged();
|
Debug.LogError("Can't set size on stretch pivot,you need to modify rectTransform by yourself.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -486,11 +504,7 @@ namespace XCharts
|
|||||||
m_RefreshChart = true;
|
m_RefreshChart = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete("Use BaseChart.RefreshLabel() instead.", true)]
|
|
||||||
public void ReinitChartLabel()
|
|
||||||
{
|
|
||||||
RefreshLabel();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 刷新文本标签Label,重新初始化,当有改动Label参数时手动调用改接口
|
/// 刷新文本标签Label,重新初始化,当有改动Label参数时手动调用改接口
|
||||||
@@ -541,15 +555,7 @@ namespace XCharts
|
|||||||
m_Series.AnimationEnable(flag);
|
m_Series.AnimationEnable(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete("Use BaseChart.AnimationFadeIn() instead.", true)]
|
|
||||||
public void AnimationStart()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete("Use BaseChart.AnimationFadeOut() instead.", true)]
|
|
||||||
public void MissAnimationStart()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// fadeIn animation.
|
/// fadeIn animation.
|
||||||
@@ -620,8 +626,8 @@ namespace XCharts
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsInChart(Vector2 local)
|
public bool IsInChart(Vector2 local)
|
||||||
{
|
{
|
||||||
if (local.x < 0 || local.x > chartWidth ||
|
if (local.x < m_ChartX || local.x > m_ChartX + chartWidth ||
|
||||||
local.y < 0 || local.y > chartHeight)
|
local.y < m_ChartY || local.y > m_ChartY + chartHeight)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -634,10 +640,10 @@ namespace XCharts
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var np = new Vector3(pos.x, pos.y);
|
var np = new Vector3(pos.x, pos.y);
|
||||||
if (np.x < 0) np.x = 0;
|
if (np.x < m_ChartX) np.x = m_ChartX;
|
||||||
if (np.x > chartWidth) np.x = chartWidth;
|
if (np.x > m_ChartX + chartWidth) np.x = m_ChartX + chartWidth;
|
||||||
if (np.y < 0) np.y = 0;
|
if (np.y < m_ChartY) np.y = m_ChartY;
|
||||||
if (np.y > chartHeight) np.y = chartHeight;
|
if (np.y > m_ChartY + chartHeight) np.y = m_ChartY + chartHeight;
|
||||||
return np;
|
return np;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -651,5 +657,24 @@ namespace XCharts
|
|||||||
warningInfo = CheckHelper.CheckChart(this);
|
warningInfo = CheckHelper.CheckChart(this);
|
||||||
return warningInfo;
|
return warningInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vector3 GetTitlePosition()
|
||||||
|
{
|
||||||
|
return chartPosition + m_Title.location.GetPosition(chartWidth, chartHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 GetLegendPosition()
|
||||||
|
{
|
||||||
|
return chartPosition + m_Legend.location.GetPosition(chartWidth, chartHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Obsolete("Use BaseChart.RefreshLabel() instead.", true)]
|
||||||
|
public void ReinitChartLabel() { }
|
||||||
|
|
||||||
|
[Obsolete("Use BaseChart.AnimationFadeIn() instead.", true)]
|
||||||
|
public void AnimationStart() { }
|
||||||
|
|
||||||
|
[Obsolete("Use BaseChart.AnimationFadeOut() instead.", true)]
|
||||||
|
public void MissAnimationStart() { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ namespace XCharts
|
|||||||
/// The lower left position x of coordinate system.
|
/// The lower left position x of coordinate system.
|
||||||
/// 坐标系的左下角坐标X。
|
/// 坐标系的左下角坐标X。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float coordinateX { get { return m_Grid.left; } }
|
public float coordinateX { get { return m_ChartX + m_Grid.left; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The lower left position y of coordinate system.
|
/// The lower left position y of coordinate system.
|
||||||
/// 坐标系的左下角坐标Y。
|
/// 坐标系的左下角坐标Y。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float coordinateY { get { return m_Grid.bottom; } }
|
public float coordinateY { get { return m_ChartY + m_Grid.bottom; } }
|
||||||
|
|
||||||
[Obsolete("Use CoordinateChart.coordinateWidth instead.", true)]
|
[Obsolete("Use CoordinateChart.coordinateWidth instead.", true)]
|
||||||
public float coordinateWid { get { return coordinateWidth; } }
|
public float coordinateWid { get { return coordinateWidth; } }
|
||||||
|
|||||||
@@ -321,9 +321,9 @@ namespace XCharts
|
|||||||
/// <param name="startX"></param>
|
/// <param name="startX"></param>
|
||||||
/// <param name="width"></param>
|
/// <param name="width"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsInZoom(Vector2 pos, float startX, float width)
|
public bool IsInZoom(Vector2 pos, float startX, float startY, float width)
|
||||||
{
|
{
|
||||||
Rect rect = Rect.MinMaxRect(startX, m_Bottom, startX + width, m_Bottom + m_Height);
|
Rect rect = Rect.MinMaxRect(startX, startY + m_Bottom, startX + width, startY + m_Bottom + m_Height);
|
||||||
return rect.Contains(pos);
|
return rect.Contains(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,11 +334,11 @@ namespace XCharts
|
|||||||
/// <param name="startX"></param>
|
/// <param name="startX"></param>
|
||||||
/// <param name="width"></param>
|
/// <param name="width"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsInSelectedZoom(Vector2 pos, float startX, float width)
|
public bool IsInSelectedZoom(Vector2 pos, float startX, float startY, float width)
|
||||||
{
|
{
|
||||||
var start = startX + width * m_Start / 100;
|
var start = startX + width * m_Start / 100;
|
||||||
var end = startX + width * m_End / 100;
|
var end = startX + width * m_End / 100;
|
||||||
Rect rect = Rect.MinMaxRect(start, m_Bottom, end, m_Bottom + m_Height);
|
Rect rect = Rect.MinMaxRect(start, startY + m_Bottom, end, startY + m_Bottom + m_Height);
|
||||||
return rect.Contains(pos);
|
return rect.Contains(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,10 +349,10 @@ namespace XCharts
|
|||||||
/// <param name="startX"></param>
|
/// <param name="startX"></param>
|
||||||
/// <param name="width"></param>
|
/// <param name="width"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsInStartZoom(Vector2 pos, float startX, float width)
|
public bool IsInStartZoom(Vector2 pos, float startX, float startY, float width)
|
||||||
{
|
{
|
||||||
var start = startX + width * m_Start / 100;
|
var start = startX + width * m_Start / 100;
|
||||||
Rect rect = Rect.MinMaxRect(start - 10, m_Bottom, start + 10, m_Bottom + m_Height);
|
Rect rect = Rect.MinMaxRect(start - 10, startY + m_Bottom, start + 10, startY + m_Bottom + m_Height);
|
||||||
return rect.Contains(pos);
|
return rect.Contains(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,10 +363,10 @@ namespace XCharts
|
|||||||
/// <param name="startX"></param>
|
/// <param name="startX"></param>
|
||||||
/// <param name="width"></param>
|
/// <param name="width"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsInEndZoom(Vector2 pos, float startX, float width)
|
public bool IsInEndZoom(Vector2 pos, float startX, float startY, float width)
|
||||||
{
|
{
|
||||||
var end = startX + width * m_End / 100;
|
var end = startX + width * m_End / 100;
|
||||||
Rect rect = Rect.MinMaxRect(end - 10, m_Bottom, end + 10, m_Bottom + m_Height);
|
Rect rect = Rect.MinMaxRect(end - 10, startY + m_Bottom, end + 10, startY + m_Bottom + m_Height);
|
||||||
return rect.Contains(pos);
|
return rect.Contains(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -282,12 +282,12 @@ namespace XCharts
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void UpdateRadarCenter(float chartWidth, float chartHeight)
|
internal void UpdateRadarCenter(Vector3 chartPosition, float chartWidth, float chartHeight)
|
||||||
{
|
{
|
||||||
if (center.Length < 2) return;
|
if (center.Length < 2) return;
|
||||||
var centerX = center[0] <= 1 ? chartWidth * center[0] : center[0];
|
var centerX = center[0] <= 1 ? chartWidth * center[0] : center[0];
|
||||||
var centerY = center[1] <= 1 ? chartHeight * center[1] : center[1];
|
var centerY = center[1] <= 1 ? chartHeight * center[1] : center[1];
|
||||||
runtimeCenterPos = new Vector2(centerX, centerY);
|
runtimeCenterPos = chartPosition + new Vector3(centerX, centerY);
|
||||||
if (radius <= 0)
|
if (radius <= 0)
|
||||||
{
|
{
|
||||||
runtimeRadius = 0;
|
runtimeRadius = 0;
|
||||||
|
|||||||
@@ -1572,21 +1572,7 @@ namespace XCharts
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 更新运行时中心点和半径
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="chartWidth"></param>
|
|
||||||
/// <param name="chartHeight"></param>
|
|
||||||
internal void UpdateCenter(float chartWidth, float chartHeight)
|
|
||||||
{
|
|
||||||
if (center.Length < 2) return;
|
|
||||||
var centerX = center[0] <= 1 ? chartWidth * center[0] : center[0];
|
|
||||||
var centerY = center[1] <= 1 ? chartHeight * center[1] : center[1];
|
|
||||||
runtimeCenterPos = new Vector2(centerX, centerY);
|
|
||||||
var minWidth = Mathf.Min(chartWidth, chartHeight);
|
|
||||||
runtimeInsideRadius = radius[0] <= 1 ? minWidth * radius[0] : radius[0];
|
|
||||||
runtimeOutsideRadius = radius[1] <= 1 ? minWidth * radius[1] : radius[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置指定index的数据图标的尺寸
|
/// 设置指定index的数据图标的尺寸
|
||||||
|
|||||||
@@ -381,9 +381,9 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetValue(Vector3 pos, float chartWidth, float chartHeight)
|
public float GetValue(Vector3 pos, Rect chartRect)
|
||||||
{
|
{
|
||||||
var centerPos = location.GetPosition(chartWidth, chartHeight);
|
var centerPos = new Vector3(chartRect.x, chartRect.y) + location.GetPosition(chartRect.width, chartRect.height);
|
||||||
var pos1 = centerPos + (runtimeIsVertical ? Vector3.down : Vector3.left) * itemHeight / 2;
|
var pos1 = centerPos + (runtimeIsVertical ? Vector3.down : Vector3.left) * itemHeight / 2;
|
||||||
var pos2 = centerPos + (runtimeIsVertical ? Vector3.up : Vector3.right) * itemHeight / 2;
|
var pos2 = centerPos + (runtimeIsVertical ? Vector3.up : Vector3.right) * itemHeight / 2;
|
||||||
if (runtimeIsVertical)
|
if (runtimeIsVertical)
|
||||||
@@ -400,9 +400,9 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsInRect(Vector3 local, float chartWidth, float chartHeight, float triangleLen = 20)
|
public bool IsInRect(Vector3 local, Rect chartRect, float triangleLen = 20)
|
||||||
{
|
{
|
||||||
var centerPos = location.GetPosition(chartWidth, chartHeight);
|
var centerPos = new Vector3(chartRect.x, chartRect.y) + location.GetPosition(chartRect.width, chartRect.height);
|
||||||
var diff = calculable ? triangleLen : 0;
|
var diff = calculable ? triangleLen : 0;
|
||||||
if (local.x >= centerPos.x - itemWidth / 2 - diff && local.x <= centerPos.x + itemWidth / 2 + diff &&
|
if (local.x >= centerPos.x - itemWidth / 2 - diff && local.x <= centerPos.x + itemWidth / 2 + diff &&
|
||||||
local.y >= centerPos.y - itemHeight / 2 - diff && local.y <= centerPos.y + itemHeight / 2 + diff)
|
local.y >= centerPos.y - itemHeight / 2 - diff && local.y <= centerPos.y + itemHeight / 2 + diff)
|
||||||
@@ -415,9 +415,9 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsInRangeRect(Vector3 local, float chartWidth, float chartHeight)
|
public bool IsInRangeRect(Vector3 local, Rect chartRect)
|
||||||
{
|
{
|
||||||
var centerPos = location.GetPosition(chartWidth, chartHeight);
|
var centerPos = new Vector3(chartRect.x, chartRect.y) + location.GetPosition(chartRect.width, chartRect.height);
|
||||||
if (orient == Orient.Vertical)
|
if (orient == Orient.Vertical)
|
||||||
{
|
{
|
||||||
var pos1 = centerPos + Vector3.down * itemHeight / 2;
|
var pos1 = centerPos + Vector3.down * itemHeight / 2;
|
||||||
@@ -432,9 +432,9 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsInRangeMinRect(Vector3 local, float chartWidth, float chartHeight, float triangleLen)
|
public bool IsInRangeMinRect(Vector3 local, Rect chartRect, float triangleLen)
|
||||||
{
|
{
|
||||||
var centerPos = location.GetPosition(chartWidth, chartHeight);
|
var centerPos = new Vector3(chartRect.x, chartRect.y) + location.GetPosition(chartRect.width, chartRect.height);
|
||||||
if (orient == Orient.Vertical)
|
if (orient == Orient.Vertical)
|
||||||
{
|
{
|
||||||
var radius = triangleLen / 2;
|
var radius = triangleLen / 2;
|
||||||
@@ -454,9 +454,9 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsInRangeMaxRect(Vector3 local, float chartWidth, float chartHeight, float triangleLen)
|
public bool IsInRangeMaxRect(Vector3 local, Rect chartRect, float triangleLen)
|
||||||
{
|
{
|
||||||
var centerPos = location.GetPosition(chartWidth, chartHeight);
|
var centerPos = new Vector3(chartRect.x, chartRect.y) + location.GetPosition(chartRect.width, chartRect.height);
|
||||||
if (orient == Orient.Vertical)
|
if (orient == Orient.Vertical)
|
||||||
{
|
{
|
||||||
var radius = triangleLen / 2;
|
var radius = triangleLen / 2;
|
||||||
|
|||||||
@@ -84,18 +84,17 @@ namespace XCharts
|
|||||||
|
|
||||||
private void InitAxisLabel()
|
private void InitAxisLabel()
|
||||||
{
|
{
|
||||||
var labelObject = ChartHelper.AddObject(s_AxisLabelObjectName, transform, Vector2.zero,
|
var labelObject = ChartHelper.AddObject(s_AxisLabelObjectName, transform, m_ChartMinAnchor,
|
||||||
Vector2.zero, Vector2.zero, new Vector2(chartWidth, chartHeight));
|
m_ChartMaxAnchor, m_ChartPivot, m_ChartSizeDelta);
|
||||||
SerieLabelPool.ReleaseAll(labelObject.transform);
|
SerieLabelPool.ReleaseAll(labelObject.transform);
|
||||||
for (int i = 0; i < m_Series.Count; i++)
|
for (int i = 0; i < m_Series.Count; i++)
|
||||||
{
|
{
|
||||||
var serie = m_Series.list[i];
|
var serie = m_Series.list[i];
|
||||||
|
|
||||||
var serieLabel = serie.gaugeAxis.axisLabel;
|
var serieLabel = serie.gaugeAxis.axisLabel;
|
||||||
serie.gaugeAxis.ClearLabelObject();
|
|
||||||
serie.UpdateCenter(chartWidth, chartHeight);
|
|
||||||
var count = serie.splitNumber > 36 ? 36 : (serie.splitNumber + 1);
|
var count = serie.splitNumber > 36 ? 36 : (serie.splitNumber + 1);
|
||||||
var startAngle = serie.startAngle;
|
var startAngle = serie.startAngle;
|
||||||
|
serie.gaugeAxis.ClearLabelObject();
|
||||||
|
SerieHelper.UpdateCenter(serie, chartPosition, chartWidth, chartHeight);
|
||||||
for (int j = 0; j < count; j++)
|
for (int j = 0; j < count; j++)
|
||||||
{
|
{
|
||||||
var textName = ChartCached.GetSerieLabelName(s_SerieLabelObjectName, i, j);
|
var textName = ChartCached.GetSerieLabelName(s_SerieLabelObjectName, i, j);
|
||||||
@@ -124,6 +123,12 @@ namespace XCharts
|
|||||||
base.OnThemeChanged();
|
base.OnThemeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnSizeChanged()
|
||||||
|
{
|
||||||
|
base.OnSizeChanged();
|
||||||
|
InitAxisLabel();
|
||||||
|
}
|
||||||
|
|
||||||
private void DrawData(VertexHelper vh)
|
private void DrawData(VertexHelper vh)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_Series.Count; i++)
|
for (int i = 0; i < m_Series.Count; i++)
|
||||||
@@ -136,7 +141,7 @@ namespace XCharts
|
|||||||
|
|
||||||
private void DrawGauge(VertexHelper vh, Serie serie)
|
private void DrawGauge(VertexHelper vh, Serie serie)
|
||||||
{
|
{
|
||||||
serie.UpdateCenter(chartWidth, chartHeight);
|
SerieHelper.UpdateCenter(serie, chartPosition, chartWidth, chartHeight);
|
||||||
var destAngle = GetCurrAngle(serie, true);
|
var destAngle = GetCurrAngle(serie, true);
|
||||||
serie.animation.InitProgress(0, serie.startAngle, destAngle);
|
serie.animation.InitProgress(0, serie.startAngle, destAngle);
|
||||||
var currAngle = serie.animation.IsFinish() ? GetCurrAngle(serie, false) : serie.animation.GetCurrDetail();
|
var currAngle = serie.animation.IsFinish() ? GetCurrAngle(serie, false) : serie.animation.GetCurrDetail();
|
||||||
|
|||||||
@@ -115,17 +115,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_Tooltip.UpdateContentText(sb.ToString().Trim());
|
TooltipHelper.SetContentAndPosition(tooltip,sb.ToString().Trim(),chartRect);
|
||||||
var pos = m_Tooltip.GetContentPos();
|
|
||||||
if (pos.x + m_Tooltip.runtimeWidth > chartWidth)
|
|
||||||
{
|
|
||||||
pos.x = chartWidth - m_Tooltip.runtimeWidth;
|
|
||||||
}
|
|
||||||
if (pos.y - m_Tooltip.runtimeHeight < 0)
|
|
||||||
{
|
|
||||||
pos.y = m_Tooltip.runtimeHeight;
|
|
||||||
}
|
|
||||||
m_Tooltip.UpdateContentPos(pos);
|
|
||||||
m_Tooltip.SetActive(true);
|
m_Tooltip.SetActive(true);
|
||||||
|
|
||||||
for (int i = 0; i < m_XAxises.Count; i++)
|
for (int i = 0; i < m_XAxises.Count; i++)
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ namespace XCharts
|
|||||||
if (legend.textStyle.color != Color.clear && legend.textStyle.color.a == 0)
|
if (legend.textStyle.color != Color.clear && legend.textStyle.color.a == 0)
|
||||||
sb.Append("warning:legend->textStyle->color alpha is 0\n");
|
sb.Append("warning:legend->textStyle->color alpha is 0\n");
|
||||||
var serieNameList = chart.series.GetLegalSerieNameList();
|
var serieNameList = chart.series.GetLegalSerieNameList();
|
||||||
Debug.LogError("namelist:" + serieNameList.Count);
|
|
||||||
if (serieNameList.Count == 0) sb.Append("warning:legend need serie.name or serieData.name not empty\n");
|
if (serieNameList.Count == 0) sb.Append("warning:legend need serie.name or serieData.name not empty\n");
|
||||||
foreach (var category in legend.data)
|
foreach (var category in legend.data)
|
||||||
{
|
{
|
||||||
|
|||||||
233
Assets/XCharts/Runtime/Helper/LayoutHelper.cs
Normal file
233
Assets/XCharts/Runtime/Helper/LayoutHelper.cs
Normal file
@@ -0,0 +1,233 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
public static class LayerHelper
|
||||||
|
{
|
||||||
|
private static Vector2 s_Vector0And0 = new Vector2(0, 0);
|
||||||
|
private static Vector2 s_Vector0And0Dot5 = new Vector2(0, 0.5f);
|
||||||
|
private static Vector2 s_Vector0And1 = new Vector2(0, 1f);
|
||||||
|
private static Vector2 s_Vector0Dot5And1 = new Vector2(0.5f, 1f);
|
||||||
|
private static Vector2 s_Vector0Dot5And0Dot5 = new Vector2(0.5f, 0.5f);
|
||||||
|
private static Vector2 s_Vector0Dot5And0 = new Vector2(0.5f, 0f);
|
||||||
|
private static Vector2 s_Vector1And1 = new Vector2(1f, 1f);
|
||||||
|
private static Vector2 s_Vector1And0Dot5 = new Vector2(1f, 0.5f);
|
||||||
|
private static Vector2 s_Vector1And0 = new Vector2(1f, 0);
|
||||||
|
|
||||||
|
internal static Vector2 ResetChartPositionAndPivot(Vector2 minAnchor, Vector2 maxAnchor, float width, float height, ref float chartX,
|
||||||
|
ref float chartY)
|
||||||
|
{
|
||||||
|
if (IsLeftTop(minAnchor, maxAnchor))
|
||||||
|
{
|
||||||
|
chartX = 0;
|
||||||
|
chartY = -height;
|
||||||
|
return s_Vector0And1;
|
||||||
|
}
|
||||||
|
else if (IsLeftCenter(minAnchor, maxAnchor))
|
||||||
|
{
|
||||||
|
chartX = 0;
|
||||||
|
chartY = -height / 2;
|
||||||
|
return s_Vector0And0Dot5;
|
||||||
|
}
|
||||||
|
else if (IsLeftBottom(minAnchor, maxAnchor))
|
||||||
|
{
|
||||||
|
chartX = 0;
|
||||||
|
chartY = 0;
|
||||||
|
return s_Vector0And0;
|
||||||
|
}
|
||||||
|
else if (IsCenterTop(minAnchor, maxAnchor))
|
||||||
|
{
|
||||||
|
chartX = -width / 2;
|
||||||
|
chartY = -height;
|
||||||
|
return s_Vector0Dot5And1;
|
||||||
|
}
|
||||||
|
else if (IsCenterCenter(minAnchor, maxAnchor))
|
||||||
|
{
|
||||||
|
chartX = -width / 2;
|
||||||
|
chartY = -height / 2;
|
||||||
|
return s_Vector0Dot5And0Dot5;
|
||||||
|
}
|
||||||
|
else if (IsCenterBottom(minAnchor, maxAnchor))
|
||||||
|
{
|
||||||
|
chartX = -width / 2;
|
||||||
|
chartY = 0;
|
||||||
|
return s_Vector0Dot5And0;
|
||||||
|
}
|
||||||
|
else if (IsRightTop(minAnchor, maxAnchor))
|
||||||
|
{
|
||||||
|
chartX = -width;
|
||||||
|
chartY = -height;
|
||||||
|
return s_Vector1And1;
|
||||||
|
}
|
||||||
|
else if (IsRightCenter(minAnchor, maxAnchor))
|
||||||
|
{
|
||||||
|
chartX = -width;
|
||||||
|
chartY = -height / 2;
|
||||||
|
return s_Vector1And0Dot5;
|
||||||
|
}
|
||||||
|
else if (IsRightBottom(minAnchor, maxAnchor))
|
||||||
|
{
|
||||||
|
chartX = -width;
|
||||||
|
chartY = 0;
|
||||||
|
return s_Vector1And0;
|
||||||
|
}
|
||||||
|
else if (IsStretchTop(minAnchor, maxAnchor))
|
||||||
|
{
|
||||||
|
chartX = -width / 2;
|
||||||
|
chartY = -height;
|
||||||
|
return s_Vector0Dot5And1;
|
||||||
|
}
|
||||||
|
else if (IsStretchMiddle(minAnchor, maxAnchor))
|
||||||
|
{
|
||||||
|
chartX = -width / 2;
|
||||||
|
chartY = -height / 2;
|
||||||
|
return s_Vector0Dot5And0Dot5;
|
||||||
|
}
|
||||||
|
else if (IsStretchBottom(minAnchor, maxAnchor))
|
||||||
|
{
|
||||||
|
chartX = -width / 2;
|
||||||
|
chartY = 0;
|
||||||
|
return s_Vector0Dot5And0;
|
||||||
|
}
|
||||||
|
else if (IsStretchLeft(minAnchor, maxAnchor))
|
||||||
|
{
|
||||||
|
chartX = 0;
|
||||||
|
chartY = -height / 2;
|
||||||
|
return s_Vector0And0Dot5;
|
||||||
|
}
|
||||||
|
else if (IsStretchCenter(minAnchor, maxAnchor))
|
||||||
|
{
|
||||||
|
chartX = -width / 2;
|
||||||
|
chartY = -height / 2;
|
||||||
|
return s_Vector0Dot5And0Dot5;
|
||||||
|
}
|
||||||
|
else if (IsStretchRight(minAnchor, maxAnchor))
|
||||||
|
{
|
||||||
|
chartX = -width;
|
||||||
|
chartY = -height / 2;
|
||||||
|
return s_Vector1And0Dot5;
|
||||||
|
}
|
||||||
|
else if (IsStretchStrech(minAnchor, maxAnchor))
|
||||||
|
{
|
||||||
|
chartX = -width / 2;
|
||||||
|
chartY = -height / 2;
|
||||||
|
return s_Vector0Dot5And0Dot5;
|
||||||
|
}
|
||||||
|
chartX = 0;
|
||||||
|
chartY = 0;
|
||||||
|
return Vector2.zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsLeftTop(Vector2 minAnchor, Vector2 maxAnchor)
|
||||||
|
{
|
||||||
|
return minAnchor == s_Vector0And1 && maxAnchor == s_Vector0And1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsLeftCenter(Vector2 minAnchor, Vector2 maxAnchor)
|
||||||
|
{
|
||||||
|
return minAnchor == s_Vector0And0Dot5 && maxAnchor == s_Vector0And0Dot5;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsLeftBottom(Vector2 minAnchor, Vector2 maxAnchor)
|
||||||
|
{
|
||||||
|
return minAnchor == Vector2.zero && maxAnchor == Vector2.zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsCenterTop(Vector2 minAnchor, Vector2 maxAnchor)
|
||||||
|
{
|
||||||
|
return minAnchor == s_Vector0Dot5And1 && maxAnchor == s_Vector0Dot5And1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsCenterCenter(Vector2 minAnchor, Vector2 maxAnchor)
|
||||||
|
{
|
||||||
|
return minAnchor == s_Vector0Dot5And0Dot5 && maxAnchor == s_Vector0Dot5And0Dot5;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsCenterBottom(Vector2 minAnchor, Vector2 maxAnchor)
|
||||||
|
{
|
||||||
|
return minAnchor == s_Vector0Dot5And0 && maxAnchor == s_Vector0Dot5And0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsRightTop(Vector2 minAnchor, Vector2 maxAnchor)
|
||||||
|
{
|
||||||
|
return minAnchor == s_Vector1And1 && maxAnchor == s_Vector1And1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsRightCenter(Vector2 minAnchor, Vector2 maxAnchor)
|
||||||
|
{
|
||||||
|
return minAnchor == s_Vector1And0Dot5 && maxAnchor == s_Vector1And0Dot5;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsRightBottom(Vector2 minAnchor, Vector2 maxAnchor)
|
||||||
|
{
|
||||||
|
return minAnchor == s_Vector1And0 && maxAnchor == s_Vector1And0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsStretchTop(Vector2 minAnchor, Vector2 maxAnchor)
|
||||||
|
{
|
||||||
|
return minAnchor == s_Vector0And1 && maxAnchor == s_Vector1And1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsStretchMiddle(Vector2 minAnchor, Vector2 maxAnchor)
|
||||||
|
{
|
||||||
|
return minAnchor == s_Vector0And0Dot5 && maxAnchor == s_Vector1And0Dot5;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsStretchBottom(Vector2 minAnchor, Vector2 maxAnchor)
|
||||||
|
{
|
||||||
|
return minAnchor == s_Vector0And0 && maxAnchor == s_Vector1And0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsStretchLeft(Vector2 minAnchor, Vector2 maxAnchor)
|
||||||
|
{
|
||||||
|
return minAnchor == s_Vector0And0 && maxAnchor == s_Vector0And1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsStretchCenter(Vector2 minAnchor, Vector2 maxAnchor)
|
||||||
|
{
|
||||||
|
return minAnchor == s_Vector0Dot5And0 && maxAnchor == s_Vector0Dot5And1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsStretchRight(Vector2 minAnchor, Vector2 maxAnchor)
|
||||||
|
{
|
||||||
|
return minAnchor == s_Vector1And0 && maxAnchor == s_Vector1And1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsStretchStrech(Vector2 minAnchor, Vector2 maxAnchor)
|
||||||
|
{
|
||||||
|
return minAnchor == s_Vector0And0 && maxAnchor == s_Vector1And1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsStretchPivot(RectTransform rt)
|
||||||
|
{
|
||||||
|
return IsStretchTop(rt.anchorMin, rt.anchorMax) ||
|
||||||
|
IsStretchMiddle(rt.anchorMin, rt.anchorMax) ||
|
||||||
|
IsStretchBottom(rt.anchorMin, rt.anchorMax) ||
|
||||||
|
IsStretchLeft(rt.anchorMin, rt.anchorMax) ||
|
||||||
|
IsStretchCenter(rt.anchorMin, rt.anchorMax) ||
|
||||||
|
IsStretchRight(rt.anchorMin, rt.anchorMax) ||
|
||||||
|
IsStretchStrech(rt.anchorMin, rt.anchorMax);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsFixedWidthHeight(RectTransform rt)
|
||||||
|
{
|
||||||
|
return IsLeftTop(rt.anchorMin, rt.anchorMax) ||
|
||||||
|
IsLeftCenter(rt.anchorMin, rt.anchorMax) ||
|
||||||
|
IsLeftBottom(rt.anchorMin, rt.anchorMax) ||
|
||||||
|
IsCenterTop(rt.anchorMin, rt.anchorMax) ||
|
||||||
|
IsCenterCenter(rt.anchorMin, rt.anchorMax) ||
|
||||||
|
IsCenterBottom(rt.anchorMin, rt.anchorMax) ||
|
||||||
|
IsRightTop(rt.anchorMin, rt.anchorMax) ||
|
||||||
|
IsRightCenter(rt.anchorMin, rt.anchorMax) ||
|
||||||
|
IsRightBottom(rt.anchorMin, rt.anchorMax);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/XCharts/Runtime/Helper/LayoutHelper.cs.meta
Normal file
11
Assets/XCharts/Runtime/Helper/LayoutHelper.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b0e7e693f76fc4853a01019b644b5d88
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -240,5 +240,21 @@ namespace XCharts
|
|||||||
if (itemStyle != null) return itemStyle.cornerRadius;
|
if (itemStyle != null) return itemStyle.cornerRadius;
|
||||||
else return null;
|
else return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新运行时中心点和半径
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="chartWidth"></param>
|
||||||
|
/// <param name="chartHeight"></param>
|
||||||
|
internal static void UpdateCenter(Serie serie, Vector3 chartPosition, float chartWidth, float chartHeight)
|
||||||
|
{
|
||||||
|
if (serie.center.Length < 2) return;
|
||||||
|
var centerX = serie.center[0] <= 1 ? chartWidth * serie.center[0] : serie.center[0];
|
||||||
|
var centerY = serie.center[1] <= 1 ? chartHeight * serie.center[1] : serie.center[1];
|
||||||
|
serie.runtimeCenterPos = chartPosition + new Vector3(centerX, centerY);
|
||||||
|
var minWidth = Mathf.Min(chartWidth, chartHeight);
|
||||||
|
serie.runtimeInsideRadius = serie.radius[0] <= 1 ? minWidth * serie.radius[0] : serie.radius[0];
|
||||||
|
serie.runtimeOutsideRadius = serie.radius[1] <= 1 ? minWidth * serie.radius[1] : serie.radius[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,6 +175,20 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SetContentAndPosition(Tooltip tooltip,string content,Rect chartRect){
|
||||||
|
tooltip.UpdateContentText(content);
|
||||||
|
var pos = tooltip.GetContentPos();
|
||||||
|
if (pos.x + tooltip.runtimeWidth > chartRect.x + chartRect.width)
|
||||||
|
{
|
||||||
|
pos.x = chartRect.x + chartRect.width - tooltip.runtimeWidth;
|
||||||
|
}
|
||||||
|
if (pos.y - tooltip.runtimeHeight < chartRect.y)
|
||||||
|
{
|
||||||
|
pos.y = chartRect.y + tooltip.runtimeHeight;
|
||||||
|
}
|
||||||
|
tooltip.UpdateContentPos(pos);
|
||||||
|
}
|
||||||
|
|
||||||
public static string GetFormatterContent(Tooltip tooltip, int dataIndex, Series series, ThemeInfo themeInfo,
|
public static string GetFormatterContent(Tooltip tooltip, int dataIndex, Series series, ThemeInfo themeInfo,
|
||||||
string category = null, DataZoom dataZoom = null, bool isCartesian = false)
|
string category = null, DataZoom dataZoom = null, bool isCartesian = false)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ namespace XCharts
|
|||||||
|
|
||||||
[SerializeField] protected float m_ChartWidth;
|
[SerializeField] protected float m_ChartWidth;
|
||||||
[SerializeField] protected float m_ChartHeight;
|
[SerializeField] protected float m_ChartHeight;
|
||||||
|
[SerializeField] protected float m_ChartX;
|
||||||
|
[SerializeField] protected float m_ChartY;
|
||||||
[SerializeField] protected ThemeInfo m_ThemeInfo;
|
[SerializeField] protected ThemeInfo m_ThemeInfo;
|
||||||
[SerializeField] protected Title m_Title = Title.defaultTitle;
|
[SerializeField] protected Title m_Title = Title.defaultTitle;
|
||||||
[SerializeField] protected Legend m_Legend = Legend.defaultLegend;
|
[SerializeField] protected Legend m_Legend = Legend.defaultLegend;
|
||||||
@@ -52,10 +54,12 @@ namespace XCharts
|
|||||||
[SerializeField] protected string m_DebugInfo = "";
|
[SerializeField] protected string m_DebugInfo = "";
|
||||||
|
|
||||||
[NonSerialized] private Theme m_CheckTheme = 0;
|
[NonSerialized] private Theme m_CheckTheme = 0;
|
||||||
[NonSerialized] private float m_CheckWidth = 0;
|
[NonSerialized] protected Vector3 m_ChartPosition = Vector3.zero;
|
||||||
[NonSerialized] private float m_CheckHeight = 0;
|
[NonSerialized] protected Vector2 m_ChartMinAnchor;
|
||||||
[NonSerialized] private Vector2 m_CheckMinAnchor;
|
[NonSerialized] protected Vector2 m_ChartMaxAnchor;
|
||||||
[NonSerialized] private Vector2 m_CheckMaxAnchor;
|
[NonSerialized] protected Vector2 m_ChartPivot;
|
||||||
|
[NonSerialized] protected Vector2 m_ChartSizeDelta;
|
||||||
|
[NonSerialized] protected Rect m_ChartRect = new Rect(0, 0, 0, 0);
|
||||||
|
|
||||||
[NonSerialized] protected bool m_RefreshChart = false;
|
[NonSerialized] protected bool m_RefreshChart = false;
|
||||||
[NonSerialized] protected bool m_RefreshLabel = false;
|
[NonSerialized] protected bool m_RefreshLabel = false;
|
||||||
@@ -65,9 +69,9 @@ namespace XCharts
|
|||||||
[NonSerialized] protected bool m_IsPlayingAnimation = false;
|
[NonSerialized] protected bool m_IsPlayingAnimation = false;
|
||||||
[NonSerialized] protected List<string> m_LegendRealShowName = new List<string>();
|
[NonSerialized] protected List<string> m_LegendRealShowName = new List<string>();
|
||||||
|
|
||||||
protected Vector2 chartAnchorMax { get { return rectTransform.anchorMax; } }
|
protected Vector2 chartAnchorMax { get { return m_ChartMinAnchor; } }
|
||||||
protected Vector2 chartAnchorMin { get { return rectTransform.anchorMin; } }
|
protected Vector2 chartAnchorMin { get { return m_ChartMaxAnchor; } }
|
||||||
protected Vector2 chartPivot { get { return rectTransform.pivot; } }
|
protected Vector2 chartPivot { get { return m_ChartPivot; } }
|
||||||
|
|
||||||
protected virtual void InitComponent()
|
protected virtual void InitComponent()
|
||||||
{
|
{
|
||||||
@@ -85,13 +89,10 @@ namespace XCharts
|
|||||||
m_ThemeInfo = ThemeInfo.Default;
|
m_ThemeInfo = ThemeInfo.Default;
|
||||||
}
|
}
|
||||||
raycastTarget = false;
|
raycastTarget = false;
|
||||||
rectTransform.anchorMax = Vector2.zero;
|
m_ChartX = 100;
|
||||||
rectTransform.anchorMin = Vector2.zero;
|
m_ChartY = 100;
|
||||||
rectTransform.pivot = Vector2.zero;
|
m_ChartWidth = rectTransform.rect.width;
|
||||||
m_ChartWidth = rectTransform.sizeDelta.x;
|
m_ChartHeight = rectTransform.rect.height;
|
||||||
m_ChartHeight = rectTransform.sizeDelta.y;
|
|
||||||
m_CheckWidth = m_ChartWidth;
|
|
||||||
m_CheckHeight = m_ChartHeight;
|
|
||||||
m_CheckTheme = m_ThemeInfo.theme;
|
m_CheckTheme = m_ThemeInfo.theme;
|
||||||
InitComponent();
|
InitComponent();
|
||||||
m_Series.AnimationReset();
|
m_Series.AnimationReset();
|
||||||
@@ -225,7 +226,7 @@ namespace XCharts
|
|||||||
Vector2 anchorMin = m_Title.location.runtimeAnchorMin;
|
Vector2 anchorMin = m_Title.location.runtimeAnchorMin;
|
||||||
Vector2 anchorMax = m_Title.location.runtimeAnchorMax;
|
Vector2 anchorMax = m_Title.location.runtimeAnchorMax;
|
||||||
Vector2 pivot = m_Title.location.runtimePivot;
|
Vector2 pivot = m_Title.location.runtimePivot;
|
||||||
Vector3 titlePosition = m_Title.location.GetPosition(chartWidth, chartHeight);
|
Vector3 titlePosition = GetTitlePosition();
|
||||||
Vector3 subTitlePosition = -new Vector3(0, m_Title.textStyle.fontSize + m_Title.itemGap, 0);
|
Vector3 subTitlePosition = -new Vector3(0, m_Title.textStyle.fontSize + m_Title.itemGap, 0);
|
||||||
float titleWid = chartWidth;
|
float titleWid = chartWidth;
|
||||||
|
|
||||||
@@ -269,7 +270,7 @@ namespace XCharts
|
|||||||
|
|
||||||
var legendObject = ChartHelper.AddObject(s_LegendObjectName, transform, anchorMin, anchorMax,
|
var legendObject = ChartHelper.AddObject(s_LegendObjectName, transform, anchorMin, anchorMax,
|
||||||
pivot, new Vector2(chartWidth, chartHeight));
|
pivot, new Vector2(chartWidth, chartHeight));
|
||||||
legendObject.transform.localPosition = m_Legend.location.GetPosition(chartWidth, chartHeight);
|
legendObject.transform.localPosition = GetLegendPosition();
|
||||||
|
|
||||||
m_LegendRealShowName = m_Series.GetSerieNameList();
|
m_LegendRealShowName = m_Series.GetSerieNameList();
|
||||||
List<string> datas;
|
List<string> datas;
|
||||||
@@ -363,14 +364,14 @@ namespace XCharts
|
|||||||
|
|
||||||
private void InitSerieLabel()
|
private void InitSerieLabel()
|
||||||
{
|
{
|
||||||
var labelObject = ChartHelper.AddObject(s_SerieLabelObjectName, transform, Vector2.zero,
|
var labelObject = ChartHelper.AddObject(s_SerieLabelObjectName, transform, m_ChartMinAnchor,
|
||||||
Vector2.zero, Vector2.zero, new Vector2(chartWidth, chartHeight));
|
m_ChartMaxAnchor, m_ChartPivot, m_ChartSizeDelta);
|
||||||
SerieLabelPool.ReleaseAll(labelObject.transform);
|
SerieLabelPool.ReleaseAll(labelObject.transform);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < m_Series.Count; i++)
|
for (int i = 0; i < m_Series.Count; i++)
|
||||||
{
|
{
|
||||||
var serie = m_Series.list[i];
|
var serie = m_Series.list[i];
|
||||||
serie.UpdateCenter(chartWidth, chartHeight);
|
SerieHelper.UpdateCenter(serie, chartPosition, chartWidth, chartHeight);
|
||||||
for (int j = 0; j < serie.data.Count; j++)
|
for (int j = 0; j < serie.data.Count; j++)
|
||||||
{
|
{
|
||||||
var serieData = serie.data[j];
|
var serieData = serie.data[j];
|
||||||
@@ -404,8 +405,8 @@ namespace XCharts
|
|||||||
|
|
||||||
private void InitSerieTitle()
|
private void InitSerieTitle()
|
||||||
{
|
{
|
||||||
var titleObject = ChartHelper.AddObject(s_SerieTitleObjectName, transform, Vector2.zero,
|
var titleObject = ChartHelper.AddObject(s_SerieTitleObjectName, transform, m_ChartMinAnchor,
|
||||||
Vector2.zero, Vector2.zero, new Vector2(chartWidth, chartHeight));
|
m_ChartMaxAnchor, m_ChartPivot, new Vector2(chartWidth, chartHeight));
|
||||||
ChartHelper.HideAllObject(titleObject);
|
ChartHelper.HideAllObject(titleObject);
|
||||||
for (int i = 0; i < m_Series.Count; i++)
|
for (int i = 0; i < m_Series.Count; i++)
|
||||||
{
|
{
|
||||||
@@ -436,8 +437,8 @@ namespace XCharts
|
|||||||
|
|
||||||
private void InitTooltip()
|
private void InitTooltip()
|
||||||
{
|
{
|
||||||
var tooltipObject = ChartHelper.AddObject("tooltip", transform, chartAnchorMin,
|
var tooltipObject = ChartHelper.AddObject("tooltip", transform, m_ChartMinAnchor,
|
||||||
chartAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));
|
m_ChartMaxAnchor, m_ChartPivot, m_ChartSizeDelta);
|
||||||
tooltipObject.transform.localPosition = Vector3.zero;
|
tooltipObject.transform.localPosition = Vector3.zero;
|
||||||
DestroyImmediate(tooltipObject.GetComponent<Image>());
|
DestroyImmediate(tooltipObject.GetComponent<Image>());
|
||||||
var parent = tooltipObject.transform;
|
var parent = tooltipObject.transform;
|
||||||
@@ -459,22 +460,43 @@ namespace XCharts
|
|||||||
|
|
||||||
private void CheckSize()
|
private void CheckSize()
|
||||||
{
|
{
|
||||||
var sizeDelta = rectTransform.sizeDelta;
|
var currWidth = rectTransform.rect.width;
|
||||||
if (m_CheckWidth == 0 && m_CheckHeight == 0 && (sizeDelta.x != 0 || sizeDelta.y != 0))
|
var currHeight = rectTransform.rect.height;
|
||||||
|
|
||||||
|
if (m_ChartWidth == 0 && m_ChartHeight == 0 && (currWidth != 0 || currHeight != 0))
|
||||||
{
|
{
|
||||||
Awake();
|
Awake();
|
||||||
}
|
}
|
||||||
else if (m_CheckWidth != sizeDelta.x || m_CheckHeight != sizeDelta.y)
|
|
||||||
|
if (m_ChartWidth != currWidth || m_ChartHeight != currHeight ||
|
||||||
|
m_ChartMinAnchor != rectTransform.anchorMin || m_ChartMaxAnchor != rectTransform.anchorMax)
|
||||||
{
|
{
|
||||||
SetSize(sizeDelta.x, sizeDelta.y);
|
UpdateSize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_CheckMinAnchor != rectTransform.anchorMin || m_CheckMaxAnchor != rectTransform.anchorMax)
|
private void UpdateSize()
|
||||||
{
|
{
|
||||||
m_CheckMaxAnchor = rectTransform.anchorMax;
|
m_ChartWidth = rectTransform.rect.width;
|
||||||
m_CheckMinAnchor = rectTransform.anchorMin;
|
m_ChartHeight = rectTransform.rect.height;
|
||||||
|
|
||||||
|
m_ChartMaxAnchor = rectTransform.anchorMax;
|
||||||
|
m_ChartMinAnchor = rectTransform.anchorMin;
|
||||||
|
m_ChartSizeDelta = rectTransform.sizeDelta;
|
||||||
m_ReinitLabel = true;
|
m_ReinitLabel = true;
|
||||||
}
|
|
||||||
|
rectTransform.pivot = LayerHelper.ResetChartPositionAndPivot(m_ChartMinAnchor, m_ChartMaxAnchor,
|
||||||
|
m_ChartWidth, m_ChartHeight, ref m_ChartX, ref m_ChartY);
|
||||||
|
m_ChartPivot = rectTransform.pivot;
|
||||||
|
|
||||||
|
m_ChartRect.x = m_ChartX;
|
||||||
|
m_ChartRect.y = m_ChartY;
|
||||||
|
m_ChartRect.width = m_ChartWidth;
|
||||||
|
m_ChartRect.height = m_ChartHeight;
|
||||||
|
m_ChartPosition.x = m_ChartX;
|
||||||
|
m_ChartPosition.y = m_ChartY;
|
||||||
|
|
||||||
|
OnSizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckLegend()
|
private void CheckLegend()
|
||||||
@@ -541,8 +563,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (local.x < 0 || local.x > chartWidth ||
|
if (!IsInChart(local))
|
||||||
local.y < 0 || local.y > chartHeight)
|
|
||||||
{
|
{
|
||||||
if (m_Tooltip.IsActive())
|
if (m_Tooltip.IsActive())
|
||||||
{
|
{
|
||||||
@@ -609,6 +630,7 @@ namespace XCharts
|
|||||||
m_Legend.SetAllDirty();
|
m_Legend.SetAllDirty();
|
||||||
m_Tooltip.SetAllDirty();
|
m_Tooltip.SetAllDirty();
|
||||||
m_Series.SetLabelDirty();
|
m_Series.SetLabelDirty();
|
||||||
|
RefreshChart();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnThemeChanged()
|
protected virtual void OnThemeChanged()
|
||||||
@@ -721,10 +743,10 @@ namespace XCharts
|
|||||||
|
|
||||||
protected virtual void DrawBackground(VertexHelper vh)
|
protected virtual void DrawBackground(VertexHelper vh)
|
||||||
{
|
{
|
||||||
Vector3 p1 = new Vector3(0, chartHeight);
|
Vector3 p1 = new Vector3(chartX, chartY + chartHeight);
|
||||||
Vector3 p2 = new Vector3(chartWidth, chartHeight);
|
Vector3 p2 = new Vector3(chartX + chartWidth, chartY + chartHeight);
|
||||||
Vector3 p3 = new Vector3(chartWidth, 0);
|
Vector3 p3 = new Vector3(chartX + chartWidth, chartY);
|
||||||
Vector3 p4 = new Vector3(0, 0);
|
Vector3 p4 = new Vector3(chartX, chartY);
|
||||||
ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, m_ThemeInfo.backgroundColor);
|
ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, m_ThemeInfo.backgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -858,7 +880,6 @@ namespace XCharts
|
|||||||
|
|
||||||
public virtual void OnPointerUp(PointerEventData eventData)
|
public virtual void OnPointerUp(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnPointerEnter(PointerEventData eventData)
|
public virtual void OnPointerEnter(PointerEventData eventData)
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ namespace XCharts
|
|||||||
var cp3 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, cpty);
|
var cp3 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, cpty);
|
||||||
var cp4 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, coordinateY - xLineDiff);
|
var cp4 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, coordinateY - xLineDiff);
|
||||||
ChartDrawer.DrawPolygon(vh, cp1, cp2, cp3, cp4, m_ThemeInfo.backgroundColor);
|
ChartDrawer.DrawPolygon(vh, cp1, cp2, cp3, cp4, m_ThemeInfo.backgroundColor);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -168,25 +169,25 @@ namespace XCharts
|
|||||||
var yLineDiff = yAxis0.axisLine.width;
|
var yLineDiff = yAxis0.axisLine.width;
|
||||||
var xSplitDiff = xAxis0.splitLine.lineStyle.width;
|
var xSplitDiff = xAxis0.splitLine.lineStyle.width;
|
||||||
var ySplitDiff = yAxis0.splitLine.lineStyle.width;
|
var ySplitDiff = yAxis0.splitLine.lineStyle.width;
|
||||||
var lp1 = new Vector3(0, 0);
|
var lp1 = new Vector3(m_ChartX, m_ChartY);
|
||||||
var lp2 = new Vector3(0, chartHeight);
|
var lp2 = new Vector3(m_ChartX, m_ChartY + chartHeight);
|
||||||
var lp3 = new Vector3(coordinateX - yLineDiff, chartHeight);
|
var lp3 = new Vector3(coordinateX - yLineDiff, m_ChartY + chartHeight);
|
||||||
var lp4 = new Vector3(coordinateX - yLineDiff, 0);
|
var lp4 = new Vector3(coordinateX - yLineDiff, m_ChartY);
|
||||||
ChartDrawer.DrawPolygon(vh, lp1, lp2, lp3, lp4, m_ThemeInfo.backgroundColor);
|
ChartDrawer.DrawPolygon(vh, lp1, lp2, lp3, lp4, m_ThemeInfo.backgroundColor);
|
||||||
var rp1 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, 0);
|
var rp1 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, m_ChartY);
|
||||||
var rp2 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, chartHeight);
|
var rp2 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, m_ChartY + chartHeight);
|
||||||
var rp3 = new Vector3(chartWidth, chartHeight);
|
var rp3 = new Vector3(m_ChartX + chartWidth, m_ChartY + chartHeight);
|
||||||
var rp4 = new Vector3(chartWidth, 0);
|
var rp4 = new Vector3(m_ChartX + chartWidth, m_ChartY);
|
||||||
ChartDrawer.DrawPolygon(vh, rp1, rp2, rp3, rp4, m_ThemeInfo.backgroundColor);
|
ChartDrawer.DrawPolygon(vh, rp1, rp2, rp3, rp4, m_ThemeInfo.backgroundColor);
|
||||||
var up1 = new Vector3(coordinateX - yLineDiff, coordinateY + coordinateHeight + ySplitDiff);
|
var up1 = new Vector3(coordinateX - yLineDiff, coordinateY + coordinateHeight + ySplitDiff);
|
||||||
var up2 = new Vector3(coordinateX - yLineDiff, chartHeight);
|
var up2 = new Vector3(coordinateX - yLineDiff, m_ChartY + chartHeight);
|
||||||
var up3 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, chartHeight);
|
var up3 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, m_ChartY + chartHeight);
|
||||||
var up4 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, coordinateY + coordinateHeight + ySplitDiff);
|
var up4 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, coordinateY + coordinateHeight + ySplitDiff);
|
||||||
ChartDrawer.DrawPolygon(vh, up1, up2, up3, up4, m_ThemeInfo.backgroundColor);
|
ChartDrawer.DrawPolygon(vh, up1, up2, up3, up4, m_ThemeInfo.backgroundColor);
|
||||||
var dp1 = new Vector3(coordinateX - yLineDiff, 0);
|
var dp1 = new Vector3(coordinateX - yLineDiff, m_ChartY);
|
||||||
var dp2 = new Vector3(coordinateX - yLineDiff, coordinateY - xLineDiff);
|
var dp2 = new Vector3(coordinateX - yLineDiff, coordinateY - xLineDiff);
|
||||||
var dp3 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, coordinateY - xLineDiff);
|
var dp3 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, coordinateY - xLineDiff);
|
||||||
var dp4 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, 0);
|
var dp4 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, m_ChartY);
|
||||||
ChartDrawer.DrawPolygon(vh, dp1, dp2, dp3, dp4, m_ThemeInfo.backgroundColor);
|
ChartDrawer.DrawPolygon(vh, dp1, dp2, dp3, dp4, m_ThemeInfo.backgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,17 +408,7 @@ namespace XCharts
|
|||||||
var category = tempAxis.GetData(index, m_DataZoom);
|
var category = tempAxis.GetData(index, m_DataZoom);
|
||||||
var content = TooltipHelper.GetFormatterContent(m_Tooltip, index, m_Series, m_ThemeInfo, category,
|
var content = TooltipHelper.GetFormatterContent(m_Tooltip, index, m_Series, m_ThemeInfo, category,
|
||||||
m_DataZoom, isCartesian);
|
m_DataZoom, isCartesian);
|
||||||
m_Tooltip.UpdateContentText(content);
|
TooltipHelper.SetContentAndPosition(m_Tooltip, content, chartRect);
|
||||||
var pos = m_Tooltip.GetContentPos();
|
|
||||||
if (pos.x + m_Tooltip.runtimeWidth > chartWidth)
|
|
||||||
{
|
|
||||||
pos.x = chartWidth - m_Tooltip.runtimeWidth;
|
|
||||||
}
|
|
||||||
if (pos.y - m_Tooltip.runtimeHeight < 0)
|
|
||||||
{
|
|
||||||
pos.y = m_Tooltip.runtimeHeight;
|
|
||||||
}
|
|
||||||
m_Tooltip.UpdateContentPos(pos);
|
|
||||||
m_Tooltip.SetActive(true);
|
m_Tooltip.SetActive(true);
|
||||||
|
|
||||||
for (int i = 0; i < m_XAxises.Count; i++)
|
for (int i = 0; i < m_XAxises.Count; i++)
|
||||||
@@ -800,16 +791,16 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (axis is XAxis)
|
if (axis is XAxis)
|
||||||
{
|
{
|
||||||
m_Series.GetXMinMaxValue(m_DataZoom, axisIndex, true, axis.inverse, out tempMinValue, out tempMaxValue);
|
m_Series.GetXMinMaxValue(null, axisIndex, true, axis.inverse, out tempMinValue, out tempMaxValue);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Series.GetYMinMaxValue(m_DataZoom, axisIndex, true, axis.inverse, out tempMinValue, out tempMaxValue);
|
m_Series.GetYMinMaxValue(null, axisIndex, true, axis.inverse, out tempMinValue, out tempMaxValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Series.GetYMinMaxValue(m_DataZoom, axisIndex, false, axis.inverse, out tempMinValue, out tempMaxValue);
|
m_Series.GetYMinMaxValue(null, axisIndex, false, axis.inverse, out tempMinValue, out tempMaxValue);
|
||||||
}
|
}
|
||||||
axis.AdjustMinMaxValue(ref tempMinValue, ref tempMaxValue, true);
|
axis.AdjustMinMaxValue(ref tempMinValue, ref tempMaxValue, true);
|
||||||
if (tempMinValue != axis.runtimeMinValue || tempMaxValue != axis.runtimeMaxValue)
|
if (tempMinValue != axis.runtimeMinValue || tempMaxValue != axis.runtimeMaxValue)
|
||||||
@@ -1120,10 +1111,10 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (!m_DataZoom.enable || !m_DataZoom.supportSlider) return;
|
if (!m_DataZoom.enable || !m_DataZoom.supportSlider) return;
|
||||||
var hig = m_DataZoom.GetHeight(grid.bottom);
|
var hig = m_DataZoom.GetHeight(grid.bottom);
|
||||||
var p1 = new Vector2(coordinateX, m_DataZoom.bottom);
|
var p1 = new Vector3(coordinateX, m_ChartY + m_DataZoom.bottom);
|
||||||
var p2 = new Vector2(coordinateX, m_DataZoom.bottom + hig);
|
var p2 = new Vector3(coordinateX, m_ChartY + m_DataZoom.bottom + hig);
|
||||||
var p3 = new Vector2(coordinateX + coordinateWidth, m_DataZoom.bottom + hig);
|
var p3 = new Vector3(coordinateX + coordinateWidth, m_ChartY + m_DataZoom.bottom + hig);
|
||||||
var p4 = new Vector2(coordinateX + coordinateWidth, m_DataZoom.bottom);
|
var p4 = new Vector3(coordinateX + coordinateWidth, m_ChartY + m_DataZoom.bottom);
|
||||||
var xAxis = xAxises[0];
|
var xAxis = xAxises[0];
|
||||||
ChartDrawer.DrawLine(vh, p1, p2, xAxis.axisLine.width, m_ThemeInfo.dataZoomLineColor);
|
ChartDrawer.DrawLine(vh, p1, p2, xAxis.axisLine.width, m_ThemeInfo.dataZoomLineColor);
|
||||||
ChartDrawer.DrawLine(vh, p2, p3, xAxis.axisLine.width, m_ThemeInfo.dataZoomLineColor);
|
ChartDrawer.DrawLine(vh, p2, p3, xAxis.axisLine.width, m_ThemeInfo.dataZoomLineColor);
|
||||||
@@ -1155,9 +1146,11 @@ namespace XCharts
|
|||||||
float value = SampleValue(ref showData, serie.sampleType, rate, serie.minShow, maxCount, totalAverage, i,
|
float value = SampleValue(ref showData, serie.sampleType, rate, serie.minShow, maxCount, totalAverage, i,
|
||||||
serie.animation.GetUpdateAnimationDuration(), ref dataChanging, axis.inverse);
|
serie.animation.GetUpdateAnimationDuration(), ref dataChanging, axis.inverse);
|
||||||
float pX = coordinateX + i * scaleWid;
|
float pX = coordinateX + i * scaleWid;
|
||||||
float dataHig = (axis.runtimeMaxValue - axis.runtimeMinValue) == 0 ? 0 :
|
// float dataHig = (axis.runtimeMaxValue - axis.runtimeMinValue) == 0 ? 0 :
|
||||||
(value - axis.runtimeMinValue) / (axis.runtimeMaxValue - axis.runtimeMinValue) * hig;
|
// (value - axis.runtimeMinValue) / (axis.runtimeMaxValue - axis.runtimeMinValue) * hig;
|
||||||
np = new Vector3(pX, m_DataZoom.bottom + dataHig);
|
float dataHig = (maxValue - minValue) == 0 ? 0 :
|
||||||
|
(value - minValue) / (maxValue - minValue) * hig;
|
||||||
|
np = new Vector3(pX, m_ChartY + m_DataZoom.bottom + dataHig);
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
{
|
{
|
||||||
Color color = m_ThemeInfo.dataZoomLineColor;
|
Color color = m_ThemeInfo.dataZoomLineColor;
|
||||||
@@ -1165,8 +1158,8 @@ namespace XCharts
|
|||||||
Vector3 alp = new Vector3(lp.x, lp.y - xAxis.axisLine.width);
|
Vector3 alp = new Vector3(lp.x, lp.y - xAxis.axisLine.width);
|
||||||
Vector3 anp = new Vector3(np.x, np.y - xAxis.axisLine.width);
|
Vector3 anp = new Vector3(np.x, np.y - xAxis.axisLine.width);
|
||||||
Color areaColor = new Color(color.r, color.g, color.b, color.a * 0.75f);
|
Color areaColor = new Color(color.r, color.g, color.b, color.a * 0.75f);
|
||||||
Vector3 tnp = new Vector3(np.x, m_DataZoom.bottom + xAxis.axisLine.width);
|
Vector3 tnp = new Vector3(np.x, m_ChartY + m_DataZoom.bottom + xAxis.axisLine.width);
|
||||||
Vector3 tlp = new Vector3(lp.x, m_DataZoom.bottom + xAxis.axisLine.width);
|
Vector3 tlp = new Vector3(lp.x, m_ChartY + m_DataZoom.bottom + xAxis.axisLine.width);
|
||||||
ChartDrawer.DrawPolygon(vh, alp, anp, tnp, tlp, areaColor);
|
ChartDrawer.DrawPolygon(vh, alp, anp, tnp, tlp, areaColor);
|
||||||
}
|
}
|
||||||
lp = np;
|
lp = np;
|
||||||
@@ -1181,10 +1174,10 @@ namespace XCharts
|
|||||||
case DataZoom.RangeMode.Percent:
|
case DataZoom.RangeMode.Percent:
|
||||||
var start = coordinateX + coordinateWidth * m_DataZoom.start / 100;
|
var start = coordinateX + coordinateWidth * m_DataZoom.start / 100;
|
||||||
var end = coordinateX + coordinateWidth * m_DataZoom.end / 100;
|
var end = coordinateX + coordinateWidth * m_DataZoom.end / 100;
|
||||||
p1 = new Vector2(start, m_DataZoom.bottom);
|
p1 = new Vector2(start, m_ChartY + m_DataZoom.bottom);
|
||||||
p2 = new Vector2(start, m_DataZoom.bottom + hig);
|
p2 = new Vector2(start, m_ChartY + m_DataZoom.bottom + hig);
|
||||||
p3 = new Vector2(end, m_DataZoom.bottom + hig);
|
p3 = new Vector2(end, m_ChartY + m_DataZoom.bottom + hig);
|
||||||
p4 = new Vector2(end, m_DataZoom.bottom);
|
p4 = new Vector2(end, m_ChartY + m_DataZoom.bottom);
|
||||||
ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, m_ThemeInfo.dataZoomSelectedColor);
|
ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, m_ThemeInfo.dataZoomSelectedColor);
|
||||||
ChartDrawer.DrawLine(vh, p1, p2, xAxis.axisLine.width, m_ThemeInfo.dataZoomSelectedColor);
|
ChartDrawer.DrawLine(vh, p1, p2, xAxis.axisLine.width, m_ThemeInfo.dataZoomSelectedColor);
|
||||||
ChartDrawer.DrawLine(vh, p3, p4, xAxis.axisLine.width, m_ThemeInfo.dataZoomSelectedColor);
|
ChartDrawer.DrawLine(vh, p3, p4, xAxis.axisLine.width, m_ThemeInfo.dataZoomSelectedColor);
|
||||||
@@ -1337,9 +1330,9 @@ namespace XCharts
|
|||||||
m_DataZoom.SetLabelActive(false);
|
m_DataZoom.SetLabelActive(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_DataZoom.IsInSelectedZoom(local, coordinateX, coordinateWidth)
|
if (m_DataZoom.IsInSelectedZoom(local, coordinateX, chartY, coordinateWidth)
|
||||||
|| m_DataZoom.IsInStartZoom(local, coordinateX, coordinateWidth)
|
|| m_DataZoom.IsInStartZoom(local, coordinateX, chartY, coordinateWidth)
|
||||||
|| m_DataZoom.IsInEndZoom(local, coordinateX, coordinateWidth))
|
|| m_DataZoom.IsInEndZoom(local, coordinateX, chartY, coordinateWidth))
|
||||||
{
|
{
|
||||||
m_DataZoom.SetLabelActive(true);
|
m_DataZoom.SetLabelActive(true);
|
||||||
RefreshDataZoomLabel();
|
RefreshDataZoomLabel();
|
||||||
@@ -1370,8 +1363,8 @@ namespace XCharts
|
|||||||
var start = coordinateX + coordinateWidth * m_DataZoom.start / 100;
|
var start = coordinateX + coordinateWidth * m_DataZoom.start / 100;
|
||||||
var end = coordinateX + coordinateWidth * m_DataZoom.end / 100;
|
var end = coordinateX + coordinateWidth * m_DataZoom.end / 100;
|
||||||
var hig = m_DataZoom.GetHeight(grid.bottom);
|
var hig = m_DataZoom.GetHeight(grid.bottom);
|
||||||
m_DataZoom.UpdateStartLabelPosition(new Vector3(start - 10, m_DataZoom.bottom + hig / 2));
|
m_DataZoom.UpdateStartLabelPosition(new Vector3(start - 10, chartY + m_DataZoom.bottom + hig / 2));
|
||||||
m_DataZoom.UpdateEndLabelPosition(new Vector3(end + 10, m_DataZoom.bottom + hig / 2));
|
m_DataZoom.UpdateEndLabelPosition(new Vector3(end + 10, chartY + m_DataZoom.bottom + hig / 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1523,15 +1516,15 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
if (m_DataZoom.supportSlider)
|
if (m_DataZoom.supportSlider)
|
||||||
{
|
{
|
||||||
if (m_DataZoom.IsInStartZoom(pos, coordinateX, coordinateWidth))
|
if (m_DataZoom.IsInStartZoom(pos, coordinateX, chartY, coordinateWidth))
|
||||||
{
|
{
|
||||||
m_DataZoomStartDrag = true;
|
m_DataZoomStartDrag = true;
|
||||||
}
|
}
|
||||||
else if (m_DataZoom.IsInEndZoom(pos, coordinateX, coordinateWidth))
|
else if (m_DataZoom.IsInEndZoom(pos, coordinateX, chartY, coordinateWidth))
|
||||||
{
|
{
|
||||||
m_DataZoomEndDrag = true;
|
m_DataZoomEndDrag = true;
|
||||||
}
|
}
|
||||||
else if (m_DataZoom.IsInSelectedZoom(pos, coordinateX, coordinateWidth))
|
else if (m_DataZoom.IsInSelectedZoom(pos, coordinateX, chartY, coordinateWidth))
|
||||||
{
|
{
|
||||||
m_DataZoomDrag = true;
|
m_DataZoomDrag = true;
|
||||||
}
|
}
|
||||||
@@ -1656,13 +1649,14 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_DataZoom.IsInStartZoom(localPos, coordinateX, coordinateWidth) ||
|
|
||||||
m_DataZoom.IsInEndZoom(localPos, coordinateX, coordinateWidth))
|
if (m_DataZoom.IsInStartZoom(localPos, coordinateX, chartY, coordinateWidth) ||
|
||||||
|
m_DataZoom.IsInEndZoom(localPos, coordinateX, chartY, coordinateWidth))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_DataZoom.IsInZoom(localPos, coordinateX, coordinateWidth)
|
if (m_DataZoom.IsInZoom(localPos, coordinateX, chartY, coordinateWidth)
|
||||||
&& !m_DataZoom.IsInSelectedZoom(localPos, coordinateX, coordinateWidth))
|
&& !m_DataZoom.IsInSelectedZoom(localPos, coordinateX, chartY, coordinateWidth))
|
||||||
{
|
{
|
||||||
var pointerX = localPos.x;
|
var pointerX = localPos.x;
|
||||||
var selectWidth = coordinateWidth * (m_DataZoom.end - m_DataZoom.start) / 100;
|
var selectWidth = coordinateWidth * (m_DataZoom.end - m_DataZoom.start) / 100;
|
||||||
@@ -1688,14 +1682,14 @@ namespace XCharts
|
|||||||
public override void OnScroll(PointerEventData eventData)
|
public override void OnScroll(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
if (Input.touchCount > 1) return;
|
if (Input.touchCount > 1) return;
|
||||||
if (!m_DataZoom.enable || m_DataZoom.zoomLock || !m_DataZoom.supportInside) return;
|
if (!m_DataZoom.enable || m_DataZoom.zoomLock) return;
|
||||||
Vector2 pos;
|
Vector2 pos;
|
||||||
if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform,
|
if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform,
|
||||||
eventData.position, canvas.worldCamera, out pos))
|
eventData.position, canvas.worldCamera, out pos))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!IsInCooridate(pos))
|
if (!IsInCooridate(pos) && !m_DataZoom.IsInSelectedZoom(pos, coordinateX, chartY, coordinateWidth))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (local.x < 0 || local.x > chartWidth ||
|
if (local.x < chartX || local.x > chartX + chartWidth ||
|
||||||
local.y < 0 || local.y > chartHeight ||
|
local.y < chartY || local.y > chartY + chartHeight ||
|
||||||
!m_VisualMap.IsInRangeRect(local, chartWidth, chartHeight))
|
!m_VisualMap.IsInRangeRect(local, chartRect))
|
||||||
{
|
{
|
||||||
if (m_VisualMap.runtimeSelectedIndex >= 0)
|
if (m_VisualMap.runtimeSelectedIndex >= 0)
|
||||||
{
|
{
|
||||||
@@ -45,7 +45,7 @@ namespace XCharts
|
|||||||
var pos1 = Vector3.zero;
|
var pos1 = Vector3.zero;
|
||||||
var pos2 = Vector3.zero;
|
var pos2 = Vector3.zero;
|
||||||
var halfHig = m_VisualMap.itemHeight / 2;
|
var halfHig = m_VisualMap.itemHeight / 2;
|
||||||
var centerPos = m_VisualMap.location.GetPosition(chartWidth, chartHeight);
|
var centerPos = chartPosition + m_VisualMap.location.GetPosition(chartWidth, chartHeight);
|
||||||
var selectedIndex = -1;
|
var selectedIndex = -1;
|
||||||
var value = 0f;
|
var value = 0f;
|
||||||
switch (m_VisualMap.orient)
|
switch (m_VisualMap.orient)
|
||||||
@@ -71,8 +71,8 @@ namespace XCharts
|
|||||||
protected void OnDragVisualMapStart()
|
protected void OnDragVisualMapStart()
|
||||||
{
|
{
|
||||||
if (!m_VisualMap.enable || !m_VisualMap.show || !m_VisualMap.calculable) return;
|
if (!m_VisualMap.enable || !m_VisualMap.show || !m_VisualMap.calculable) return;
|
||||||
var inMinRect = m_VisualMap.IsInRangeMinRect(pointerPos, chartWidth, chartHeight, m_Settings.visualMapTriangeLen);
|
var inMinRect = m_VisualMap.IsInRangeMinRect(pointerPos, chartRect, m_Settings.visualMapTriangeLen);
|
||||||
var inMaxRect = m_VisualMap.IsInRangeMaxRect(pointerPos, chartWidth, chartHeight, m_Settings.visualMapTriangeLen);
|
var inMaxRect = m_VisualMap.IsInRangeMaxRect(pointerPos, chartRect, m_Settings.visualMapTriangeLen);
|
||||||
if (inMinRect || inMaxRect)
|
if (inMinRect || inMaxRect)
|
||||||
{
|
{
|
||||||
if (inMinRect)
|
if (inMinRect)
|
||||||
@@ -91,7 +91,7 @@ namespace XCharts
|
|||||||
if (!m_VisualMap.enable || !m_VisualMap.show || !m_VisualMap.calculable) return;
|
if (!m_VisualMap.enable || !m_VisualMap.show || !m_VisualMap.calculable) return;
|
||||||
if (!m_VisualMapMinDrag && !m_VisualMapMaxDrag) return;
|
if (!m_VisualMapMinDrag && !m_VisualMapMaxDrag) return;
|
||||||
|
|
||||||
var value = m_VisualMap.GetValue(pointerPos, chartWidth, chartHeight);
|
var value = m_VisualMap.GetValue(pointerPos, chartRect);
|
||||||
if (m_VisualMapMinDrag)
|
if (m_VisualMapMinDrag)
|
||||||
{
|
{
|
||||||
m_VisualMap.rangeMin = value;
|
m_VisualMap.rangeMin = value;
|
||||||
@@ -202,7 +202,7 @@ namespace XCharts
|
|||||||
protected void DrawVisualMap(VertexHelper vh)
|
protected void DrawVisualMap(VertexHelper vh)
|
||||||
{
|
{
|
||||||
if (!m_VisualMap.enable || !m_VisualMap.show) return;
|
if (!m_VisualMap.enable || !m_VisualMap.show) return;
|
||||||
var centerPos = m_VisualMap.location.GetPosition(chartWidth, chartHeight);
|
var centerPos = chartPosition + m_VisualMap.location.GetPosition(chartWidth, chartHeight);
|
||||||
|
|
||||||
var pos1 = Vector3.zero;
|
var pos1 = Vector3.zero;
|
||||||
var pos2 = Vector3.zero;
|
var pos2 = Vector3.zero;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace XCharts
|
|||||||
if (serie.pieClickOffset) isClickOffset = true;
|
if (serie.pieClickOffset) isClickOffset = true;
|
||||||
serie.runtimePieDataMax = serie.yMax;
|
serie.runtimePieDataMax = serie.yMax;
|
||||||
serie.runtimePieDataTotal = serie.yTotal;
|
serie.runtimePieDataTotal = serie.yTotal;
|
||||||
serie.UpdateCenter(chartWidth, chartHeight);
|
SerieHelper.UpdateCenter(serie, chartPosition, chartWidth, chartHeight);
|
||||||
|
|
||||||
float totalDegree = 360;
|
float totalDegree = 360;
|
||||||
float startDegree = 0;
|
float startDegree = 0;
|
||||||
@@ -567,17 +567,7 @@ namespace XCharts
|
|||||||
if (index < 0) continue;
|
if (index < 0) continue;
|
||||||
showTooltip = true;
|
showTooltip = true;
|
||||||
var content = TooltipHelper.GetFormatterContent(m_Tooltip, index, m_Series, m_ThemeInfo);
|
var content = TooltipHelper.GetFormatterContent(m_Tooltip, index, m_Series, m_ThemeInfo);
|
||||||
m_Tooltip.UpdateContentText(content);
|
TooltipHelper.SetContentAndPosition(tooltip, content, chartRect);
|
||||||
var pos = m_Tooltip.GetContentPos();
|
|
||||||
if (pos.x + m_Tooltip.runtimeWidth > chartWidth)
|
|
||||||
{
|
|
||||||
pos.x = chartWidth - m_Tooltip.runtimeWidth;
|
|
||||||
}
|
|
||||||
if (pos.y - m_Tooltip.runtimeHeight < 0)
|
|
||||||
{
|
|
||||||
pos.y = m_Tooltip.runtimeHeight;
|
|
||||||
}
|
|
||||||
m_Tooltip.UpdateContentPos(pos);
|
|
||||||
}
|
}
|
||||||
m_Tooltip.SetActive(showTooltip);
|
m_Tooltip.SetActive(showTooltip);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,13 +103,19 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
protected override void OnSizeChanged()
|
||||||
|
{
|
||||||
|
base.OnSizeChanged();
|
||||||
|
m_RadarsDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
private void InitIndicator()
|
private void InitIndicator()
|
||||||
{
|
{
|
||||||
ChartHelper.HideAllObject(transform, INDICATOR_TEXT);
|
ChartHelper.HideAllObject(transform, INDICATOR_TEXT);
|
||||||
for (int n = 0; n < m_Radars.Count; n++)
|
for (int n = 0; n < m_Radars.Count; n++)
|
||||||
{
|
{
|
||||||
Radar radar = m_Radars[n];
|
Radar radar = m_Radars[n];
|
||||||
radar.UpdateRadarCenter(chartWidth, chartHeight);
|
radar.UpdateRadarCenter(chartPosition, chartWidth, chartHeight);
|
||||||
int indicatorNum = radar.indicatorList.Count;
|
int indicatorNum = radar.indicatorList.Count;
|
||||||
float txtWid = 100;
|
float txtWid = 100;
|
||||||
float txtHig = 20;
|
float txtHig = 20;
|
||||||
@@ -165,7 +171,7 @@ namespace XCharts
|
|||||||
base.DrawChart(vh);
|
base.DrawChart(vh);
|
||||||
foreach (var radar in m_Radars)
|
foreach (var radar in m_Radars)
|
||||||
{
|
{
|
||||||
radar.UpdateRadarCenter(chartWidth, chartHeight);
|
radar.UpdateRadarCenter(chartPosition, chartWidth, chartHeight);
|
||||||
if (radar.shape == Radar.Shape.Circle)
|
if (radar.shape == Radar.Shape.Circle)
|
||||||
{
|
{
|
||||||
DrawCricleRadar(vh, radar);
|
DrawCricleRadar(vh, radar);
|
||||||
@@ -712,17 +718,7 @@ namespace XCharts
|
|||||||
var radar = m_Radars[serie.radarIndex];
|
var radar = m_Radars[serie.radarIndex];
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
TooltipHelper.InitRadarTooltip(ref sb, tooltip, serie, radar, themeInfo);
|
TooltipHelper.InitRadarTooltip(ref sb, tooltip, serie, radar, themeInfo);
|
||||||
m_Tooltip.UpdateContentText(sb.ToString());
|
TooltipHelper.SetContentAndPosition(tooltip, sb.ToString(), chartRect);
|
||||||
var pos = m_Tooltip.GetContentPos();
|
|
||||||
if (pos.x + m_Tooltip.runtimeWidth > chartWidth)
|
|
||||||
{
|
|
||||||
pos.x = chartWidth - m_Tooltip.runtimeWidth;
|
|
||||||
}
|
|
||||||
if (pos.y - m_Tooltip.runtimeHeight < 0)
|
|
||||||
{
|
|
||||||
pos.y = m_Tooltip.runtimeHeight;
|
|
||||||
}
|
|
||||||
m_Tooltip.UpdateContentPos(pos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnRefreshLabel()
|
protected override void OnRefreshLabel()
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ namespace XCharts
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
serie.animation.InitProgress(data.Count, serie.startAngle, serie.startAngle + 360);
|
serie.animation.InitProgress(data.Count, serie.startAngle, serie.startAngle + 360);
|
||||||
serie.UpdateCenter(chartWidth, chartHeight);
|
SerieHelper.UpdateCenter(serie, chartPosition, chartWidth, chartHeight);
|
||||||
TitleStyleHelper.CheckTitle(serie, ref m_ReinitTitle, ref m_UpdateTitleText);
|
TitleStyleHelper.CheckTitle(serie, ref m_ReinitTitle, ref m_UpdateTitleText);
|
||||||
SerieLabelHelper.CheckLabel(serie, ref m_ReinitLabel, ref m_UpdateLabelText);
|
SerieLabelHelper.CheckLabel(serie, ref m_ReinitLabel, ref m_UpdateLabelText);
|
||||||
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||||
@@ -330,18 +330,7 @@ namespace XCharts
|
|||||||
if (index < 0) continue;
|
if (index < 0) continue;
|
||||||
showTooltip = true;
|
showTooltip = true;
|
||||||
var content = TooltipHelper.GetFormatterContent(m_Tooltip, index, m_Series, m_ThemeInfo);
|
var content = TooltipHelper.GetFormatterContent(m_Tooltip, index, m_Series, m_ThemeInfo);
|
||||||
m_Tooltip.UpdateContentText(content);
|
TooltipHelper.SetContentAndPosition(tooltip,content,chartRect);
|
||||||
|
|
||||||
var pos = m_Tooltip.GetContentPos();
|
|
||||||
if (pos.x + m_Tooltip.runtimeWidth > chartWidth)
|
|
||||||
{
|
|
||||||
pos.x = chartWidth - m_Tooltip.runtimeWidth;
|
|
||||||
}
|
|
||||||
if (pos.y - m_Tooltip.runtimeHeight < 0)
|
|
||||||
{
|
|
||||||
pos.y = m_Tooltip.runtimeHeight;
|
|
||||||
}
|
|
||||||
m_Tooltip.UpdateContentPos(pos);
|
|
||||||
}
|
}
|
||||||
m_Tooltip.SetActive(showTooltip);
|
m_Tooltip.SetActive(showTooltip);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,18 +111,7 @@ namespace XCharts
|
|||||||
if (m_Tooltip.isAnySerieDataIndex())
|
if (m_Tooltip.isAnySerieDataIndex())
|
||||||
{
|
{
|
||||||
var content = TooltipHelper.GetFormatterContent(m_Tooltip, 0, m_Series, m_ThemeInfo);
|
var content = TooltipHelper.GetFormatterContent(m_Tooltip, 0, m_Series, m_ThemeInfo);
|
||||||
m_Tooltip.UpdateContentText(content);
|
TooltipHelper.SetContentAndPosition(tooltip, content, chartRect);
|
||||||
|
|
||||||
var pos = m_Tooltip.GetContentPos();
|
|
||||||
if (pos.x + m_Tooltip.runtimeWidth > chartWidth)
|
|
||||||
{
|
|
||||||
pos.x = chartWidth - m_Tooltip.runtimeWidth;
|
|
||||||
}
|
|
||||||
if (pos.y - m_Tooltip.runtimeHeight < 0)
|
|
||||||
{
|
|
||||||
pos.y = m_Tooltip.runtimeHeight;
|
|
||||||
}
|
|
||||||
m_Tooltip.UpdateContentPos(pos);
|
|
||||||
m_Tooltip.SetActive(true);
|
m_Tooltip.SetActive(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user