This commit is contained in:
monitor1394
2022-03-18 08:23:17 +08:00
parent 407b3625d7
commit 4e24ba7922
16 changed files with 166 additions and 114 deletions

View File

@@ -19,12 +19,14 @@ namespace XCharts.Editor
internal List<HeaderMenuInfo> menus = new List<HeaderMenuInfo>(); internal List<HeaderMenuInfo> menus = new List<HeaderMenuInfo>();
protected Dictionary<string, Type> m_CoordOptionsDic; protected Dictionary<string, Type> m_CoordOptionsDic;
protected List<string> m_CoordOptionsNames; protected List<string> m_CoordOptionsNames;
private string m_DisplayName;
internal void Init(BaseChart chart, Serie target, SerializedProperty property, UnityEditor.Editor inspector) internal void Init(BaseChart chart, Serie target, SerializedProperty property, UnityEditor.Editor inspector)
{ {
this.chart = chart; this.chart = chart;
this.serie = target; this.serie = target;
this.baseProperty = property; this.baseProperty = property;
m_DisplayName = string.Format("serie {0}: {1}", serie.index, serie.GetType().Name);
//m_Inspector = inspector; //m_Inspector = inspector;
showProperty = baseProperty.FindPropertyRelative("m_Show"); showProperty = baseProperty.FindPropertyRelative("m_Show");
if (showProperty == null) if (showProperty == null)
@@ -83,8 +85,9 @@ namespace XCharts.Editor
public virtual string GetDisplayTitle() public virtual string GetDisplayTitle()
{ {
var title = string.Format("serie {0}: {1}", serie.index, serie.GetType().Name); // var title = string.Format("serie {0}: {1}", serie.index, serie.GetType().Name);
return ObjectNames.NicifyVariableName(title); // return ObjectNames.NicifyVariableName(title);
return m_DisplayName;
} }
internal SerializedProperty FindProperty(string path) internal SerializedProperty FindProperty(string path)

View File

@@ -98,7 +98,7 @@ namespace XCharts.Editor
title, title,
editor.baseProperty, editor.baseProperty,
editor.showProperty, editor.showProperty,
editor.menus.ToArray()); editor.menus);
if (displayContent) if (displayContent)
{ {
editor.OnInternalInspectorGUI(); editor.OnInternalInspectorGUI();

View File

@@ -540,7 +540,54 @@ namespace XCharts.Editor
Action<Rect> drawCallback, params HeaderMenuInfo[] menus) Action<Rect> drawCallback, params HeaderMenuInfo[] menus)
{ {
var rect = GUILayoutUtility.GetRect(1f, HEADER_HEIGHT); var rect = GUILayoutUtility.GetRect(1f, HEADER_HEIGHT);
var labelRect = DrawHeaderInternal(rect, title, state, drawBackground, activeField);
DrawMenu(rect, menus);
if (drawCallback != null)
{
drawCallback(rect);
}
var e = Event.current;
if (e.type == EventType.MouseDown)
{
if (labelRect.Contains(e.mousePosition))
{
if (e.button == 0)
{
state = !state;
e.Use();
}
}
}
return state;
}
internal static bool DrawHeader(string title, bool state, bool drawBackground, SerializedProperty activeField,
Action<Rect> drawCallback, List<HeaderMenuInfo> menus)
{
var rect = GUILayoutUtility.GetRect(1f, HEADER_HEIGHT);
var labelRect = DrawHeaderInternal(rect, title, state, drawBackground, activeField);
DrawMenu(rect, menus);
if (drawCallback != null)
{
drawCallback(rect);
}
var e = Event.current;
if (e.type == EventType.MouseDown)
{
if (labelRect.Contains(e.mousePosition))
{
if (e.button == 0)
{
state = !state;
e.Use();
}
}
}
return state;
}
private static Rect DrawHeaderInternal(Rect rect, string title, bool state, bool drawBackground, SerializedProperty activeField)
{
var splitRect = rect; var splitRect = rect;
splitRect.x = EditorGUI.indentLevel * INDENT_WIDTH + 4; splitRect.x = EditorGUI.indentLevel * INDENT_WIDTH + 4;
splitRect.xMax = rect.xMax; splitRect.xMax = rect.xMax;
@@ -576,24 +623,7 @@ namespace XCharts.Editor
toggleRect.height = 13f; toggleRect.height = 13f;
activeField.boolValue = GUI.Toggle(toggleRect, activeField.boolValue, GUIContent.none); activeField.boolValue = GUI.Toggle(toggleRect, activeField.boolValue, GUIContent.none);
} }
DrawMenu(rect, menus); return labelRect;
if (drawCallback != null)
{
drawCallback(rect);
}
var e = Event.current;
if (e.type == EventType.MouseDown)
{
if (labelRect.Contains(e.mousePosition))
{
if (e.button == 0)
{
state = !state;
e.Use();
}
}
}
return state;
} }
internal static bool DrawHeader(string title, SerializedProperty group, SerializedProperty activeField, internal static bool DrawHeader(string title, SerializedProperty group, SerializedProperty activeField,
@@ -612,6 +642,13 @@ namespace XCharts.Editor
return group.isExpanded; return group.isExpanded;
} }
internal static bool DrawHeader(string title, SerializedProperty group, SerializedProperty activeField,
List<HeaderMenuInfo> menus)
{
group.isExpanded = DrawHeader(title, group.isExpanded, false, activeField, null, menus);
return group.isExpanded;
}
internal static void DrawMenu(Rect parentRect, params HeaderMenuInfo[] menus) internal static void DrawMenu(Rect parentRect, params HeaderMenuInfo[] menus)
{ {
if (menus == null || menus.Length <= 0) return; if (menus == null || menus.Length <= 0) return;
@@ -638,6 +675,32 @@ namespace XCharts.Editor
} }
} }
internal static void DrawMenu(Rect parentRect, List<HeaderMenuInfo> menus)
{
if (menus == null || menus.Count <= 0) return;
var menuIcon = EditorCustomStyles.paneOptionsIcon;
var menuRect = new Rect(parentRect.xMax - menuIcon.width, parentRect.y + 2f,
menuIcon.width, menuIcon.height);
GUI.DrawTexture(menuRect, menuIcon);
var e = Event.current;
if (e.type == EventType.MouseDown)
{
if (menuRect.Contains(e.mousePosition))
{
ShowHeaderContextMenu(new Vector2(menuRect.x, menuRect.yMax), menus);
e.Use();
}
else if (parentRect.Contains(e.mousePosition))
{
if (e.button != 0)
{
ShowHeaderContextMenu(e.mousePosition, menus);
e.Use();
}
}
}
}
static void ShowHeaderContextMenu(Vector2 position, params HeaderMenuInfo[] menus) static void ShowHeaderContextMenu(Vector2 position, params HeaderMenuInfo[] menus)
{ {
if (menus == null || menus.Length <= 0) return; if (menus == null || menus.Length <= 0) return;
@@ -651,5 +714,18 @@ namespace XCharts.Editor
} }
menu.DropDown(new Rect(position, Vector2.zero)); menu.DropDown(new Rect(position, Vector2.zero));
} }
static void ShowHeaderContextMenu(Vector2 position, List<HeaderMenuInfo> menus)
{
if (menus == null || menus.Count <= 0) return;
var menu = new GenericMenu();
foreach (var info in menus)
{
if (info.enable)
menu.AddItem(GetContent(info.name), false, () => info.action());
else
menu.AddDisabledItem(GetContent(info.name));
}
menu.DropDown(new Rect(position, Vector2.zero));
}
} }
} }

View File

@@ -553,8 +553,7 @@ namespace XCharts.Runtime
{ {
while (m_Data.Count >= maxCache) while (m_Data.Count >= maxCache)
{ {
context.isNeedUpdateFilterData = true; RemoveData(m_InsertDataToHead ? m_Data.Count - 1 : 0);
m_Data.RemoveAt(m_InsertDataToHead ? m_Data.Count - 1 : 0);
} }
} }
@@ -566,6 +565,12 @@ namespace XCharts.Runtime
SetAllDirty(); SetAllDirty();
} }
public void RemoveData(int dataIndex)
{
context.isNeedUpdateFilterData = true;
m_Data.RemoveAt(dataIndex);
}
/// <summary> /// <summary>
/// 更新类目数据 /// 更新类目数据
/// </summary> /// </summary>

View File

@@ -34,7 +34,7 @@ namespace XCharts
return; return;
if (!grid.context.isPointerEnter) if (!grid.context.isPointerEnter)
{ {
axis.context.pointerValue = double.PositiveInfinity; axis.context.pointerValue = 0;
} }
else else
{ {
@@ -44,11 +44,11 @@ namespace XCharts
var dataZoom = chart.GetDataZoomOfAxis(axis); var dataZoom = chart.GetDataZoomOfAxis(axis);
var dataCount = chart.series.Count > 0 ? chart.series[0].GetDataList(dataZoom).Count : 0; var dataCount = chart.series.Count > 0 ? chart.series[0].GetDataList(dataZoom).Count : 0;
var local = chart.pointerPos; var local = chart.pointerPos;
for (int j = 0; j < axis.GetDataCount(dataZoom); j++) if (axis is YAxis)
{ {
if (axis is YAxis) float splitWid = AxisHelper.GetDataWidth(axis, grid.context.height, dataCount, dataZoom);
for (int j = 0; j < axis.GetDataCount(dataZoom); j++)
{ {
float splitWid = AxisHelper.GetDataWidth(axis, grid.context.height, dataCount, dataZoom);
float pY = grid.context.y + j * splitWid; float pY = grid.context.y + j * splitWid;
if ((axis.boundaryGap && (local.y > pY && local.y <= pY + splitWid)) if ((axis.boundaryGap && (local.y > pY && local.y <= pY + splitWid))
|| (!axis.boundaryGap && (local.y > pY - splitWid / 2 && local.y <= pY + splitWid / 2))) || (!axis.boundaryGap && (local.y > pY - splitWid / 2 && local.y <= pY + splitWid / 2)))
@@ -63,9 +63,12 @@ namespace XCharts
break; break;
} }
} }
else }
else
{
float splitWid = AxisHelper.GetDataWidth(axis, grid.context.width, dataCount, dataZoom);
for (int j = 0; j < axis.GetDataCount(dataZoom); j++)
{ {
float splitWid = AxisHelper.GetDataWidth(axis, grid.context.width, dataCount, dataZoom);
float pX = grid.context.x + j * splitWid; float pX = grid.context.x + j * splitWid;
if ((axis.boundaryGap && (local.x > pX && local.x <= pX + splitWid)) if ((axis.boundaryGap && (local.x > pX && local.x <= pX + splitWid))
|| (!axis.boundaryGap && (local.x > pX - splitWid / 2 && local.x <= pX + splitWid / 2))) || (!axis.boundaryGap && (local.x > pX - splitWid / 2 && local.x <= pX + splitWid / 2)))
@@ -87,7 +90,6 @@ namespace XCharts
if (axis is YAxis) if (axis is YAxis)
{ {
var yRate = axis.context.minMaxRange / grid.context.height; var yRate = axis.context.minMaxRange / grid.context.height;
var yValue = yRate * (chart.pointerPos.y - grid.context.y - axis.context.offset); var yValue = yRate * (chart.pointerPos.y - grid.context.y - axis.context.offset);
if (axis.context.minValue > 0) if (axis.context.minValue > 0)
yValue += axis.context.minValue; yValue += axis.context.minValue;
@@ -104,7 +106,6 @@ namespace XCharts
else else
{ {
var xRate = axis.context.minMaxRange / grid.context.width; var xRate = axis.context.minMaxRange / grid.context.width;
var xValue = xRate * (chart.pointerPos.x - grid.context.x - axis.context.offset); var xValue = xRate * (chart.pointerPos.x - grid.context.x - axis.context.offset);
if (axis.context.minValue > 0) if (axis.context.minValue > 0)
xValue += axis.context.minValue; xValue += axis.context.minValue;

View File

@@ -74,7 +74,6 @@ namespace XCharts.Runtime
return Vector3.zero; return Vector3.zero;
var yAxis = chart.GetChartComponent<YAxis>(component.index); var yAxis = chart.GetChartComponent<YAxis>(component.index);
return GetLabelPosition(i, Orient.Horizonal, component, yAxis, return GetLabelPosition(i, Orient.Horizonal, component, yAxis,
chart.theme.axis, chart.theme.axis,
scaleWid, scaleWid,

View File

@@ -431,6 +431,7 @@ namespace XCharts.Runtime
if (m_PointerContainer is GridCoord) if (m_PointerContainer is GridCoord)
{ {
var grid = m_PointerContainer as GridCoord; var grid = m_PointerContainer as GridCoord;
if (!grid.context.isPointerEnter) return;
if (IsYCategoryOfGrid(grid.index)) if (IsYCategoryOfGrid(grid.index))
DrawYAxisIndicator(vh, tooltip, grid); DrawYAxisIndicator(vh, tooltip, grid);
else else

View File

@@ -6,12 +6,12 @@ namespace XCharts.Runtime
{ {
public class ChartLabel : Image public class ChartLabel : Image
{ {
[SerializeField] private ChartText m_LabelText;
private bool m_AutoHideIconWhenLabelEmpty = false; private bool m_AutoHideIconWhenLabelEmpty = false;
private bool m_LabelAutoSize = true; private bool m_LabelAutoSize = true;
private float m_LabelPaddingLeftRight = 3f; private float m_LabelPaddingLeftRight = 3f;
private float m_LabelPaddingTopBottom = 3f; private float m_LabelPaddingTopBottom = 3f;
private ChartText m_LabelText;
private RectTransform m_LabelRect; private RectTransform m_LabelRect;
private RectTransform m_LabelBackgroundRect; private RectTransform m_LabelBackgroundRect;
private RectTransform m_IconRect; private RectTransform m_IconRect;

View File

@@ -7,6 +7,7 @@ using TMPro;
namespace XCharts.Runtime namespace XCharts.Runtime
{ {
[System.Serializable]
public class ChartText public class ChartText
{ {
private float m_ExtraWidth; private float m_ExtraWidth;

View File

@@ -1,33 +0,0 @@
namespace XCharts.Runtime
{
internal static class XAxisPool
{
private static readonly ObjectPool<XAxis> s_ListPool = new ObjectPool<XAxis>(null, null);
public static XAxis Get()
{
return s_ListPool.Get();
}
public static void Release(XAxis toRelease)
{
s_ListPool.Release(toRelease);
}
}
internal static class YAxisPool
{
private static readonly ObjectPool<YAxis> s_ListPool = new ObjectPool<YAxis>(null, null);
public static YAxis Get()
{
return s_ListPool.Get();
}
public static void Release(YAxis toRelease)
{
s_ListPool.Release(toRelease);
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 3a709ca44e9a445bd86bde1bbfae80de
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -7,6 +7,7 @@ namespace XCharts.Runtime
{ {
internal class ObjectPool<T> where T : new() internal class ObjectPool<T> where T : new()
{ {
private readonly bool m_NewIfEmpty = true;
private readonly Stack<T> m_Stack = new Stack<T>(); private readonly Stack<T> m_Stack = new Stack<T>();
private readonly UnityAction<T> m_ActionOnGet; private readonly UnityAction<T> m_ActionOnGet;
private readonly UnityAction<T> m_ActionOnRelease; private readonly UnityAction<T> m_ActionOnRelease;
@@ -15,8 +16,9 @@ namespace XCharts.Runtime
public int countActive { get { return countAll - countInactive; } } public int countActive { get { return countAll - countInactive; } }
public int countInactive { get { return m_Stack.Count; } } public int countInactive { get { return m_Stack.Count; } }
public ObjectPool(UnityAction<T> actionOnGet, UnityAction<T> actionOnRelease) public ObjectPool(UnityAction<T> actionOnGet, UnityAction<T> actionOnRelease, bool newIfEmpty = true)
{ {
m_NewIfEmpty = newIfEmpty;
m_ActionOnGet = actionOnGet; m_ActionOnGet = actionOnGet;
m_ActionOnRelease = actionOnRelease; m_ActionOnRelease = actionOnRelease;
} }
@@ -26,6 +28,7 @@ namespace XCharts.Runtime
T element; T element;
if (m_Stack.Count == 0) if (m_Stack.Count == 0)
{ {
if (!m_NewIfEmpty) return default(T);
element = new T(); element = new T();
countAll++; countAll++;
} }

View File

@@ -1,7 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
namespace XCharts.Runtime namespace XCharts.Runtime
{ {
@@ -37,15 +36,6 @@ namespace XCharts.Runtime
return element; return element;
} }
private static GameObject CreateSerieLabel(string name, Transform parent, LabelStyle label, Color color,
float iconWidth, float iconHeight, ThemeStyle theme)
{
var element = ChartHelper.AddSerieLabel(name, parent, label.backgroundWidth, label.backgroundHeight,
color, label.textStyle, theme);
ChartHelper.AddIcon("Icon", element.transform, iconWidth, iconHeight);
return element;
}
public static void Release(GameObject element) public static void Release(GameObject element)
{ {
if (element == null) return; if (element == null) return;
@@ -72,5 +62,14 @@ namespace XCharts.Runtime
m_Stack.Clear(); m_Stack.Clear();
m_ReleaseDic.Clear(); m_ReleaseDic.Clear();
} }
private static GameObject CreateSerieLabel(string name, Transform parent, LabelStyle label, Color color,
float iconWidth, float iconHeight, ThemeStyle theme)
{
var element = ChartHelper.AddSerieLabel(name, parent, label.backgroundWidth, label.backgroundHeight,
color, label.textStyle, theme);
ChartHelper.AddIcon("Icon", element.transform, iconWidth, iconHeight);
return element;
}
} }
} }

View File

@@ -233,11 +233,12 @@ namespace XCharts.Runtime
} }
public static ChartText AddTextObject(string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax, public static ChartText AddTextObject(string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax,
Vector2 pivot, Vector2 sizeDelta, TextStyle textStyle, ComponentTheme theme) Vector2 pivot, Vector2 sizeDelta, TextStyle textStyle, ComponentTheme theme, ChartText chartText = null)
{ {
GameObject txtObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta); GameObject txtObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
txtObj.transform.localEulerAngles = new Vector3(0, 0, textStyle.rotate); txtObj.transform.localEulerAngles = new Vector3(0, 0, textStyle.rotate);
var chartText = new ChartText(); if(chartText == null)
chartText = new ChartText();
#if dUI_TextMeshPro #if dUI_TextMeshPro
RemoveComponent<Text>(txtObj); RemoveComponent<Text>(txtObj);
chartText.tmpText = GetOrAddComponent<TextMeshProUGUI>(txtObj); chartText.tmpText = GetOrAddComponent<TextMeshProUGUI>(txtObj);
@@ -377,9 +378,11 @@ namespace XCharts.Runtime
var sizeDelta = new Vector2(width, height); var sizeDelta = new Vector2(width, height);
GameObject iconObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta); GameObject iconObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
var img = GetOrAddComponent<Image>(iconObj); var img = GetOrAddComponent<Image>(iconObj);
img.raycastTarget = false; if (img.raycastTarget != false)
img.type = type; img.raycastTarget = false;
if (sprite != null) if (img.type != type)
img.type = type;
if (sprite != null && img.sprite != sprite)
{ {
img.sprite = sprite; img.sprite = sprite;
if (width == 0 || height == 0) if (width == 0 || height == 0)
@@ -398,15 +401,14 @@ namespace XCharts.Runtime
var iconStyle = axis.iconStyle; var iconStyle = axis.iconStyle;
var labelObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta); var labelObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
var label = GetOrAddComponent<ChartLabel>(labelObj); var label = GetOrAddComponent<ChartLabel>(labelObj);
var labelShow = axis.axisLabel.show && (axis.axisLabel.interval == 0 || index % (axis.axisLabel.interval + 1) == 0); var labelShow = axis.axisLabel.show && (axis.axisLabel.interval == 0 || index % (axis.axisLabel.interval + 1) == 0);
if (labelShow) if (labelShow)
{ {
if (!axis.axisLabel.showStartLabel && index == 0) labelShow = false; if (!axis.axisLabel.showStartLabel && index == 0) labelShow = false;
else if (!axis.axisLabel.showEndLabel && index == total - 1) labelShow = false; else if (!axis.axisLabel.showEndLabel && index == total - 1) labelShow = false;
} }
label.label = AddTextObject("Text", label.gameObject.transform, anchorMin, anchorMax, pivot, sizeDelta, textStyle, theme); label.label = AddTextObject("Text", label.transform, anchorMin, anchorMax, pivot, sizeDelta, textStyle, theme, label.label);
label.icon = ChartHelper.AddIcon("Icon", label.gameObject.transform, iconStyle.width, iconStyle.height); label.icon = ChartHelper.AddIcon("Icon", label.transform, iconStyle.width, iconStyle.height);
label.SetAutoSize(false); label.SetAutoSize(false);
label.UpdateIcon(iconStyle, axis.GetIcon(index)); label.UpdateIcon(iconStyle, axis.GetIcon(index));
label.label.SetActive(labelShow); label.label.SetActive(labelShow);
@@ -421,7 +423,7 @@ namespace XCharts.Runtime
{ {
var labelObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta); var labelObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
var label = GetOrAddComponent<ChartLabel>(labelObj); var label = GetOrAddComponent<ChartLabel>(labelObj);
label.label = AddTextObject("Text", label.gameObject.transform, anchorMin, anchorMax, pivot, sizeDelta, textStyle, theme); label.label = AddTextObject("Text", label.gameObject.transform, anchorMin, anchorMax, pivot, sizeDelta, textStyle, theme, label.label);
label.icon = ChartHelper.AddIcon("Icon", label.gameObject.transform, 0, 0); label.icon = ChartHelper.AddIcon("Icon", label.gameObject.transform, 0, 0);
label.SetAutoSize(true); label.SetAutoSize(true);
label.label.SetActive(true); label.label.SetActive(true);
@@ -468,7 +470,7 @@ namespace XCharts.Runtime
var label = GetOrAddComponent<ChartLabel>(labelGameObject); var label = GetOrAddComponent<ChartLabel>(labelGameObject);
label.labelBackground = ChartHelper.AddIcon("Background", label.gameObject.transform, 50, 20); label.labelBackground = ChartHelper.AddIcon("Background", label.gameObject.transform, 50, 20);
label.labelBackground.color = Color.black; label.labelBackground.color = Color.black;
label.label = AddTextObject("Text", label.gameObject.transform, anchorMin, anchorMax, pivot, sizeDelta, textStyle, theme.tooltip); label.label = AddTextObject("Text", label.gameObject.transform, anchorMin, anchorMax, pivot, sizeDelta, textStyle, theme.tooltip, label.label);
label.SetAutoSize(true); label.SetAutoSize(true);
label.SetText(""); label.SetText("");
label.color = textStyle.color; label.color = textStyle.color;

View File

@@ -14,20 +14,19 @@ namespace XCharts.Runtime
{ {
List<List<SerieData>> m_StackSerieData = new List<List<SerieData>>(); List<List<SerieData>> m_StackSerieData = new List<List<SerieData>>();
private GridCoord m_SerieGrid; private GridCoord m_SerieGrid;
private float m_LastLineWidth = 0f;
private void UpdateSerieGridContext() private void UpdateSerieGridContext()
{ {
if (m_SerieGrid == null) if (m_SerieGrid == null)
return; return;
var lineWidth = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth);
var needCheck = (chart.isPointerInChart && m_SerieGrid.IsPointerEnter()) || m_LegendEnter; var needCheck = (chart.isPointerInChart && m_SerieGrid.IsPointerEnter()) || m_LegendEnter || m_LastLineWidth != lineWidth;
var lineWidth = 0f;
if (!needCheck) if (!needCheck)
{ {
if (m_LastCheckContextFlag != needCheck) if (m_LastCheckContextFlag != needCheck)
{ {
var needAnimation1 = false; var needAnimation1 = false;
lineWidth = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth);
m_LastCheckContextFlag = needCheck; m_LastCheckContextFlag = needCheck;
serie.context.pointerItemDataIndex = -1; serie.context.pointerItemDataIndex = -1;
serie.context.pointerEnter = false; serie.context.pointerEnter = false;
@@ -49,11 +48,10 @@ namespace XCharts.Runtime
} }
return; return;
} }
m_LastLineWidth = lineWidth;
m_LastCheckContextFlag = needCheck; m_LastCheckContextFlag = needCheck;
var themeSymbolSize = chart.theme.serie.lineSymbolSize; var themeSymbolSize = chart.theme.serie.lineSymbolSize;
var themeSymbolSelectedSize = chart.theme.serie.lineSymbolSelectedSize; var themeSymbolSelectedSize = chart.theme.serie.lineSymbolSelectedSize;
lineWidth = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth);
var needInteract = false; var needInteract = false;
if (m_LegendEnter) if (m_LegendEnter)
{ {

View File

@@ -998,11 +998,22 @@ namespace XCharts.Runtime
get get
{ {
double total = 0; double total = 0;
var duration = animation.GetUpdateAnimationDuration(); if (IsPerformanceMode())
foreach (var sdata in data)
{ {
if (sdata.show && !IsIgnoreValue(sdata.data[1])) foreach (var sdata in data)
total += sdata.GetCurrData(1, duration); {
if (sdata.show && !IsIgnoreValue(sdata.data[1]))
total += sdata.data[1];
}
}
else
{
var duration = animation.GetUpdateAnimationDuration();
foreach (var sdata in data)
{
if (sdata.show && !IsIgnoreValue(sdata.data[1]))
total += sdata.GetCurrData(1, duration);
}
} }
return total; return total;
} }
@@ -1590,14 +1601,11 @@ namespace XCharts.Runtime
} }
/// <summary> /// <summary>
/// 是否为性能模式。只有折线图和柱状图才有性能模式。性能模式下不绘制Symbol不刷新Label不单独设置数据项配置。 /// 是否为性能模式。性能模式下不绘制Symbol不刷新Label不单独设置数据项配置。
/// </summary> /// </summary>
public bool IsPerformanceMode() public bool IsPerformanceMode()
{ {
if (IsSerie<Line>() || IsSerie<Bar>()) return m_Large && m_Data.Count > m_LargeThreshold;
return m_Large && m_Data.Count > m_LargeThreshold;
else
return false;
} }
public bool IsLegendName(string legendName) public bool IsLegendName(string legendName)