3.0 - bar chart

This commit is contained in:
monitor1394
2021-12-11 18:26:28 +08:00
parent 081cd4b503
commit 9c69774d35
33 changed files with 362 additions and 232 deletions

View File

@@ -10,7 +10,7 @@ using UnityEngine;
namespace XCharts namespace XCharts
{ {
[CustomPropertyDrawer(typeof(SerieAnimation), true)] [CustomPropertyDrawer(typeof(AnimationStyle), true)]
public class AnimationDrawer : BasePropertyDrawer public class AnimationDrawer : BasePropertyDrawer
{ {
public override string ClassName { get { return "Animation"; } } public override string ClassName { get { return "Animation"; } }

View File

@@ -111,8 +111,6 @@ namespace XCharts
protected void PropertyTwoFiled(string relativePropName) protected void PropertyTwoFiled(string relativePropName)
{ {
//TODO:
//PropertyField(relativePropName);
var m_DrawRect = GUILayoutUtility.GetRect(1f, 17f); var m_DrawRect = GUILayoutUtility.GetRect(1f, 17f);
var prop = FindProperty(relativePropName); var prop = FindProperty(relativePropName);
ChartEditorHelper.MakeTwoField(ref m_DrawRect, m_DrawRect.width, prop, prop.displayName); ChartEditorHelper.MakeTwoField(ref m_DrawRect, m_DrawRect.width, prop, prop.displayName);

View File

@@ -22,21 +22,29 @@ namespace XCharts
PropertyField("m_XAxisIndex"); PropertyField("m_XAxisIndex");
PropertyField("m_YAxisIndex"); PropertyField("m_YAxisIndex");
} }
PropertyFieldLimitMin("m_MinShow", 0);
PropertyFieldLimitMin("m_MaxShow", 0);
PropertyFieldLimitMin("m_MaxCache", 0);
PropertyField("m_BarType"); PropertyField("m_BarType");
PropertyField("m_BarPercentStack"); PropertyField("m_BarPercentStack");
PropertyField("m_BarWidth"); PropertyField("m_BarWidth");
PropertyField("m_BarGap"); PropertyField("m_BarGap");
PropertyField("m_BarZebraWidth"); if (serie.barType == BarType.Zebra)
PropertyField("m_BarZebraGap"); {
PropertyField("m_Clip"); PropertyField("m_BarZebraWidth");
PropertyField("m_Ignore"); PropertyField("m_BarZebraGap");
PropertyField("m_IgnoreValue"); }
PropertyField("m_ShowAsPositiveNumber");
PropertyField("m_Large"); PropertyFiledMore(() =>
PropertyField("m_LargeThreshold"); {
PropertyFieldLimitMin("m_MinShow", 0);
PropertyFieldLimitMin("m_MaxShow", 0);
PropertyFieldLimitMin("m_MaxCache", 0);
PropertyField("m_Ignore");
PropertyField("m_IgnoreValue");
PropertyField("m_IgnoreLineBreak");
PropertyField("m_ShowAsPositiveNumber");
PropertyField("m_Large");
PropertyField("m_LargeThreshold");
PropertyField("m_Clip");
});
PropertyField("m_ItemStyle"); PropertyField("m_ItemStyle");
PropertyField("m_IconStyle"); PropertyField("m_IconStyle");

View File

@@ -5,6 +5,8 @@
/* */ /* */
/************************************************/ /************************************************/
using UnityEngine;
namespace XCharts namespace XCharts
{ {
[SerieEditor(typeof(Line))] [SerieEditor(typeof(Line))]
@@ -22,20 +24,23 @@ namespace XCharts
PropertyField("m_XAxisIndex"); PropertyField("m_XAxisIndex");
PropertyField("m_YAxisIndex"); PropertyField("m_YAxisIndex");
} }
PropertyFieldLimitMin("m_MinShow", 0);
PropertyFieldLimitMin("m_MaxShow", 0);
PropertyFieldLimitMin("m_MaxCache", 0);
PropertyField("m_LineType"); PropertyField("m_LineType");
PropertyField("m_SampleDist"); PropertyFiledMore(() =>
PropertyField("m_SampleType"); {
PropertyField("m_SampleAverage"); PropertyFieldLimitMin("m_MinShow", 0);
PropertyField("m_Clip"); PropertyFieldLimitMin("m_MaxShow", 0);
PropertyField("m_Ignore"); PropertyFieldLimitMin("m_MaxCache", 0);
PropertyField("m_IgnoreValue"); PropertyField("m_SampleDist");
PropertyField("m_IgnoreLineBreak"); PropertyField("m_SampleType");
PropertyField("m_ShowAsPositiveNumber"); PropertyField("m_SampleAverage");
PropertyField("m_Large"); PropertyField("m_Ignore");
PropertyField("m_LargeThreshold"); PropertyField("m_IgnoreValue");
PropertyField("m_IgnoreLineBreak");
PropertyField("m_ShowAsPositiveNumber");
PropertyField("m_Large");
PropertyField("m_LargeThreshold");
PropertyField("m_Clip");
});
PropertyField("m_Symbol"); PropertyField("m_Symbol");
PropertyField("m_LineStyle"); PropertyField("m_LineStyle");
PropertyField("m_LineArrow"); PropertyField("m_LineArrow");

View File

@@ -16,11 +16,15 @@ namespace XCharts
PropertyField("m_Space"); PropertyField("m_Space");
PropertyTwoFiled("m_Center"); PropertyTwoFiled("m_Center");
PropertyTwoFiled("m_Radius"); PropertyTwoFiled("m_Radius");
PropertyField("m_MinAngle");
PropertyField("m_RoundCap"); PropertyFiledMore(() =>
PropertyField("m_Ignore"); {
PropertyField("m_IgnoreValue"); PropertyField("m_MinAngle");
PropertyField("m_AvoidLabelOverlap"); PropertyField("m_RoundCap");
PropertyField("m_Ignore");
PropertyField("m_IgnoreValue");
PropertyField("m_AvoidLabelOverlap");
});
PropertyField("m_ItemStyle"); PropertyField("m_ItemStyle");
PropertyField("m_IconStyle"); PropertyField("m_IconStyle");

View File

@@ -97,13 +97,14 @@ namespace XCharts
return baseProperty.FindPropertyRelative(path); return baseProperty.FindPropertyRelative(path);
} }
protected void PropertyField(string path) protected SerializedProperty PropertyField(string path)
{ {
Assert.IsNotNull(path); Assert.IsNotNull(path);
var property = FindProperty(path); var property = FindProperty(path);
Assert.IsNotNull(property, "Can't find:" + path); Assert.IsNotNull(property, "Can't find:" + path);
var title = ChartEditorHelper.GetContent(property.displayName); var title = ChartEditorHelper.GetContent(property.displayName);
PropertyField(property, title); PropertyField(property, title);
return property;
} }
protected void PropertyField(SerializedProperty property) protected void PropertyField(SerializedProperty property)
@@ -126,18 +127,40 @@ namespace XCharts
protected void PropertyTwoFiled(string relativePropName) protected void PropertyTwoFiled(string relativePropName)
{ {
//TODO: var m_DrawRect = GUILayoutUtility.GetRect(1f, 17f);
PropertyField(relativePropName); var prop = FindProperty(relativePropName);
ChartEditorHelper.MakeTwoField(ref m_DrawRect, m_DrawRect.width, prop, prop.displayName);
} }
protected void PropertyFieldLimitMin(string relativePropName, double value) protected void PropertyFieldLimitMin(string relativePropName, double min)
{ {
//TODO: var prop = PropertyField(relativePropName);
PropertyField(relativePropName); switch (prop.propertyType)
{
case SerializedPropertyType.Float:
if (prop.floatValue < min)
prop.floatValue = (float)min;
break;
case SerializedPropertyType.Integer:
if (prop.intValue < min)
prop.intValue = (int)min;
break;
}
} }
protected void PropertyFieldLimitMax(string relativePropName, double value) protected void PropertyFieldLimitMax(string relativePropName, int max)
{ {
//TODO: var prop = PropertyField(relativePropName);
PropertyField(relativePropName); switch (prop.propertyType)
{
case SerializedPropertyType.Float:
if (prop.floatValue > max)
prop.floatValue = (float)max;
break;
case SerializedPropertyType.Integer:
if (prop.intValue > max)
prop.intValue = (int)max;
break;
}
} }
} }
} }

View File

@@ -13,6 +13,8 @@ namespace XCharts
{ {
public class SerieEditor<T> : SerieBaseEditor where T : Serie public class SerieEditor<T> : SerieBaseEditor where T : Serie
{ {
protected const string MORE = "More";
protected bool m_MoreFoldout = false;
private bool m_DataFoldout = false; private bool m_DataFoldout = false;
private bool m_DataComponentFoldout = true; private bool m_DataComponentFoldout = true;
private Dictionary<int, bool> m_DataElementFoldout = new Dictionary<int, bool>(); private Dictionary<int, bool> m_DataElementFoldout = new Dictionary<int, bool>();
@@ -90,6 +92,15 @@ namespace XCharts
EditorGUI.indentLevel--; EditorGUI.indentLevel--;
} }
protected void PropertyFiledMore(System.Action action)
{
m_MoreFoldout = ChartEditorHelper.DrawHeader(MORE, m_MoreFoldout, false, null, null);
if (m_MoreFoldout)
{
if (action != null) action();
}
}
private void DrawSerieData(int dimension, SerializedProperty m_Datas, int index, bool showName) private void DrawSerieData(int dimension, SerializedProperty m_Datas, int index, bool showName)
{ {
bool flag; bool flag;

View File

@@ -103,11 +103,11 @@ namespace XCharts
{ {
EditorGUI.LabelField(drawRect, name); EditorGUI.LabelField(drawRect, name);
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH; var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH;
var diff = 14 + EditorGUI.indentLevel * 14; var diff = 13 + EditorGUI.indentLevel * 14;
var offset = diff - INDENT_WIDTH; var offset = diff - INDENT_WIDTH;
var tempWidth = (rectWidth - startX + diff) / 2; var tempWidth = (rectWidth - startX + diff) / 2;
var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height); var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height - 1);
var centerYRect = new Rect(centerXRect.x + tempWidth - offset, drawRect.y, tempWidth, drawRect.height); var centerYRect = new Rect(centerXRect.x + tempWidth - offset, drawRect.y, tempWidth - 1, drawRect.height - 1);
EditorGUI.PropertyField(centerXRect, prop1, GUIContent.none); EditorGUI.PropertyField(centerXRect, prop1, GUIContent.none);
EditorGUI.PropertyField(centerYRect, prop2, GUIContent.none); EditorGUI.PropertyField(centerYRect, prop2, GUIContent.none);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;

View File

@@ -480,6 +480,16 @@ namespace XCharts
} }
public static float GetAxisPosition(GridCoord grid, Axis axis, float scaleWidth, double value) public static float GetAxisPosition(GridCoord grid, Axis axis, float scaleWidth, double value)
{
return GetAxisPositionInternal(grid, axis, scaleWidth, value, true);
}
public static float GetAxisValueLength(GridCoord grid, Axis axis, float scaleWidth, double value)
{
return GetAxisPositionInternal(grid, axis, scaleWidth, value, false);
}
private static float GetAxisPositionInternal(GridCoord grid, Axis axis, float scaleWidth, double value, bool includeGridXY)
{ {
var isY = axis is YAxis; var isY = axis is YAxis;
var gridHeight = isY ? grid.context.height : grid.context.width; var gridHeight = isY ? grid.context.height : grid.context.width;
@@ -489,19 +499,24 @@ namespace XCharts
{ {
int minIndex = axis.GetLogMinIndex(); int minIndex = axis.GetLogMinIndex();
float nowIndex = axis.GetLogValue(value); float nowIndex = axis.GetLogValue(value);
return gridXY + (nowIndex - minIndex) / axis.splitNumber * gridHeight; return includeGridXY
? gridXY + (nowIndex - minIndex) / axis.splitNumber * gridHeight
: (nowIndex - minIndex) / axis.splitNumber * gridHeight;
} }
else if (axis.IsCategory()) else if (axis.IsCategory())
{ {
var categoryIndex = (int)value; var categoryIndex = (int)value;
var categoryStart = gridXY + (axis.boundaryGap ? scaleWidth / 2 : 0); return includeGridXY
return categoryStart + scaleWidth * categoryIndex; ? gridXY + (axis.boundaryGap ? scaleWidth / 2 : 0) + scaleWidth * categoryIndex
: (axis.boundaryGap ? scaleWidth / 2 : 0) + scaleWidth * categoryIndex;
} }
else else
{ {
var yDataHig = (axis.context.minMaxRange == 0) ? 0f : var yDataHig = (axis.context.minMaxRange == 0) ? 0f :
(float)((value - axis.context.minValue) / axis.context.minMaxRange * gridHeight); (float)((value - axis.context.minValue) / axis.context.minMaxRange * gridHeight);
return gridXY + yDataHig; return includeGridXY
? gridXY + yDataHig
: yDataHig;
} }
} }
} }

View File

@@ -14,12 +14,22 @@ namespace XCharts
public delegate float CustomAnimationDelay(int dataIndex); public delegate float CustomAnimationDelay(int dataIndex);
public delegate float CustomAnimationDuration(int dataIndex); public delegate float CustomAnimationDuration(int dataIndex);
public enum AnimationType
{
Default,
LeftToRight,
BottomToTop,
InsideOut,
Clockwise,
}
/// <summary> /// <summary>
/// the animation of serie. /// the animation of serie.
/// 动画表现。 /// 动画表现。
/// </summary> /// </summary>
[System.Serializable] [System.Serializable]
public class SerieAnimation : ChildComponent public class AnimationStyle : ChildComponent
{ {
public enum Easing public enum Easing
{ {

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: c6560100f155244fba80a175e6a28139 guid: d51f91843500c4092909a6779592b654
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@@ -242,7 +242,7 @@ namespace XCharts
if (legendName.Equals(serie.serieName)) if (legendName.Equals(serie.serieName))
{ {
serie.show = show; serie.show = show;
serie.highlighted = false; serie.highlight = false;
if (serie.show) needShow = true; if (serie.show) needShow = true;
} }
else else
@@ -252,7 +252,7 @@ namespace XCharts
if (legendName.Equals(data.name)) if (legendName.Equals(data.name))
{ {
data.show = show; data.show = show;
data.context.highlighted = false; data.context.highlight = false;
if (data.show) needShow = true; if (data.show) needShow = true;
} }
} }
@@ -268,7 +268,7 @@ namespace XCharts
{ {
if (legendName.Equals(serie.serieName)) if (legendName.Equals(serie.serieName))
{ {
serie.highlighted = heighlight; serie.highlight = heighlight;
} }
else else
{ {
@@ -276,8 +276,8 @@ namespace XCharts
{ {
if (legendName.Equals(data.name)) if (legendName.Equals(data.name))
{ {
data.context.highlighted = heighlight; data.context.highlight = heighlight;
if (data.context.highlighted) show = true; if (data.context.highlight) show = true;
} }
} }
} }

View File

@@ -45,7 +45,7 @@ namespace XCharts
{ {
[SerializeField] private bool m_Show = true; [SerializeField] private bool m_Show = true;
[SerializeField] private int m_SerieIndex = 0; [SerializeField] private int m_SerieIndex = 0;
[SerializeField] private SerieAnimation m_Animation = new SerieAnimation(); [SerializeField] private AnimationStyle m_Animation = new AnimationStyle();
[SerializeField] private List<MarkLineData> m_Data = new List<MarkLineData>(); [SerializeField] private List<MarkLineData> m_Data = new List<MarkLineData>();
/// <summary> /// <summary>
@@ -66,7 +66,7 @@ namespace XCharts
/// The animation of markline. /// The animation of markline.
/// 标线的动画样式。 /// 标线的动画样式。
/// </summary> /// </summary>
public SerieAnimation animation public AnimationStyle animation
{ {
get { return m_Animation; } get { return m_Animation; }
set { if (PropertyUtil.SetClass(ref m_Animation, value)) SetVerticesDirty(); } set { if (PropertyUtil.SetClass(ref m_Animation, value)) SetVerticesDirty(); }

View File

@@ -222,7 +222,7 @@ namespace XCharts
} }
} }
private void DrawMakLineData(VertexHelper vh, MarkLineData data, SerieAnimation animation, Serie serie, private void DrawMakLineData(VertexHelper vh, MarkLineData data, AnimationStyle animation, Serie serie,
GridCoord grid, Color32 serieColor, Vector3 sp, Vector3 ep) GridCoord grid, Color32 serieColor, Vector3 sp, Vector3 ep)
{ {
if (!animation.IsFinish()) if (!animation.IsFinish())

View File

@@ -85,10 +85,6 @@ namespace XCharts
private void DrawCricleRadar(VertexHelper vh, RadarCoord radar) private void DrawCricleRadar(VertexHelper vh, RadarCoord radar)
{ {
if (!radar.splitLine.show && !radar.splitArea.show)
{
return;
}
float insideRadius = 0, outsideRadius = 0; float insideRadius = 0, outsideRadius = 0;
float block = radar.context.radius / radar.splitNumber; float block = radar.context.radius / radar.splitNumber;
int indicatorNum = radar.indicatorList.Count; int indicatorNum = radar.indicatorList.Count;
@@ -96,7 +92,10 @@ namespace XCharts
Vector3 p1; Vector3 p1;
float angle = 2 * Mathf.PI / indicatorNum; float angle = 2 * Mathf.PI / indicatorNum;
var lineColor = radar.axisLine.GetColor(chart.theme.axis.lineColor); var lineColor = radar.axisLine.GetColor(chart.theme.axis.lineColor);
var lineWidth = radar.splitLine.GetWidth(chart.theme.axis.splitLineWidth); var lineWidth = radar.axisLine.GetWidth(chart.theme.axis.lineWidth);
var lineType = radar.axisLine.GetType(chart.theme.axis.lineType);
var splitLineColor = radar.splitLine.GetColor(chart.theme.axis.splitLineColor);
var splitLineWidth = radar.splitLine.GetWidth(chart.theme.axis.splitLineWidth);
for (int i = 0; i < radar.splitNumber; i++) for (int i = 0; i < radar.splitNumber; i++)
{ {
var color = radar.splitArea.GetColor(i, chart.theme.axis); var color = radar.splitArea.GetColor(i, chart.theme.axis);
@@ -108,29 +107,25 @@ namespace XCharts
} }
if (radar.splitLine.show) if (radar.splitLine.show)
{ {
UGL.DrawEmptyCricle(vh, p, outsideRadius, lineWidth, lineColor, UGL.DrawEmptyCricle(vh, p, outsideRadius, splitLineWidth, splitLineColor,
Color.clear, chart.settings.cicleSmoothness); Color.clear, chart.settings.cicleSmoothness);
} }
insideRadius = outsideRadius; insideRadius = outsideRadius;
} }
for (int j = 0; j <= indicatorNum; j++) if (radar.axisLine.show)
{ {
float currAngle = j * angle; for (int j = 0; j <= indicatorNum; j++)
p1 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
p.y + outsideRadius * Mathf.Cos(currAngle));
if (radar.splitLine.show)
{ {
UGL.DrawLine(vh, p, p1, lineWidth / 2, lineColor); float currAngle = j * angle;
p1 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
p.y + outsideRadius * Mathf.Cos(currAngle));
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, p, p1, lineColor);
} }
} }
} }
private void DrawPolygonRadar(VertexHelper vh, RadarCoord radar) private void DrawPolygonRadar(VertexHelper vh, RadarCoord radar)
{ {
if (!radar.splitLine.show && !radar.splitArea.show)
{
return;
}
float insideRadius = 0, outsideRadius = 0; float insideRadius = 0, outsideRadius = 0;
float block = radar.context.radius / radar.splitNumber; float block = radar.context.radius / radar.splitNumber;
int indicatorNum = radar.indicatorList.Count; int indicatorNum = radar.indicatorList.Count;
@@ -145,7 +140,6 @@ namespace XCharts
var splitLineType = radar.splitLine.GetType(chart.theme.axis.splitLineType); var splitLineType = radar.splitLine.GetType(chart.theme.axis.splitLineType);
for (int i = 0; i < radar.splitNumber; i++) for (int i = 0; i < radar.splitNumber; i++)
{ {
var isLast = i == radar.splitNumber - 1;
var color = radar.splitArea.GetColor(i, chart.theme.axis); var color = radar.splitArea.GetColor(i, chart.theme.axis);
outsideRadius = insideRadius + block; outsideRadius = insideRadius + block;
p1 = new Vector3(p.x + insideRadius * Mathf.Sin(0), p.y + insideRadius * Mathf.Cos(0)); p1 = new Vector3(p.x + insideRadius * Mathf.Sin(0), p.y + insideRadius * Mathf.Cos(0));
@@ -163,24 +157,21 @@ namespace XCharts
} }
if (radar.splitLine.NeedShow(i)) if (radar.splitLine.NeedShow(i))
{ {
if (isLast) ChartDrawer.DrawLineStyle(vh, splitLineType, splitLineWidth, p2, p3, splitLineColor);
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, p2, p3, lineColor);
else
ChartDrawer.DrawLineStyle(vh, splitLineType, splitLineWidth, p2, p3, splitLineColor);
} }
p1 = p4; p1 = p4;
p2 = p3; p2 = p3;
} }
insideRadius = outsideRadius; insideRadius = outsideRadius;
} }
for (int j = 0; j <= indicatorNum; j++) if (radar.axisLine.show)
{ {
float currAngle = j * angle; for (int j = 0; j <= indicatorNum; j++)
p3 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
p.y + outsideRadius * Mathf.Cos(currAngle));
if (radar.splitLine.show)
{ {
ChartDrawer.DrawLineStyle(vh, splitLineType, splitLineWidth, p, p3, splitLineColor); float currAngle = j * angle;
p3 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
p.y + outsideRadius * Mathf.Cos(currAngle));
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, p, p3, lineColor);
} }
} }
} }

View File

@@ -291,11 +291,11 @@ namespace XCharts
if (System.Math.Abs(dist) <= symbolSize) if (System.Math.Abs(dist) <= symbolSize)
{ {
serie.context.pointerAxisDataIndexs.Add(i); serie.context.pointerAxisDataIndexs.Add(i);
serieData.context.highlighted = true; serieData.context.highlight = true;
} }
else else
{ {
serieData.context.highlighted = false; serieData.context.highlight = false;
} }
} }
} }

View File

@@ -110,7 +110,7 @@ namespace XCharts
var numericFormatter = GetItemNumericFormatter(tooltip, serie, serieData); var numericFormatter = GetItemNumericFormatter(tooltip, serie, serieData);
if (isCartesian) if (isCartesian)
{ {
if (serieData != null && serieData.context.highlighted) if (serieData != null && serieData.context.highlight)
{ {
sb.Append(key).Append(!string.IsNullOrEmpty(key) ? " : " : ""); sb.Append(key).Append(!string.IsNullOrEmpty(key) ? " : " : "");
sb.Append("[").Append(ChartCached.FloatToStr(xValue, numericFormatter)).Append(",") sb.Append("[").Append(ChartCached.FloatToStr(xValue, numericFormatter)).Append(",")

View File

@@ -125,7 +125,7 @@ namespace XCharts
for (int i = 0; i < serie.dataCount; i++) for (int i = 0; i < serie.dataCount; i++)
{ {
var serieData = serie.data[i]; var serieData = serie.data[i];
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData, serieData.context.highlighted); var serieLabel = SerieHelper.GetSerieLabel(serie, serieData, serieData.context.highlight);
if (serieLabel.show && serieData.labelObject != null) if (serieLabel.show && serieData.labelObject != null)
{ {
if (!serie.show || !serieData.show) if (!serie.show || !serieData.show)
@@ -160,7 +160,7 @@ namespace XCharts
{ {
var serieData = serie.GetSerieData(0); var serieData = serie.GetSerieData(0);
if (serieData == null) return; if (serieData == null) return;
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData, serieData.context.highlighted); var serieLabel = SerieHelper.GetSerieLabel(serie, serieData, serieData.context.highlight);
if (serieLabel.show && serieData.labelObject != null) if (serieLabel.show && serieData.labelObject != null)
{ {
if (!serie.show || !serieData.show) if (!serie.show || !serieData.show)

View File

@@ -749,7 +749,7 @@ namespace XCharts
for (int i = 0; i < m_Series.Count; i++) for (int i = 0; i < m_Series.Count; i++)
{ {
var serie = m_Series[i]; var serie = m_Series[i];
if (serie is T) continue; if (!(serie is T)) continue;
if (string.IsNullOrEmpty(serie.stack)) if (string.IsNullOrEmpty(serie.stack))
{ {
if (serie.index == currSerie.index) return index; if (serie.index == currSerie.index) return index;

View File

@@ -523,7 +523,7 @@ namespace XCharts
{ {
if (legendName.Equals(serie.serieName)) if (legendName.Equals(serie.serieName))
{ {
serie.highlighted = true; serie.highlight = true;
RefreshPainter(serie); RefreshPainter(serie);
} }
} }
@@ -541,7 +541,7 @@ namespace XCharts
{ {
if (legendName.Equals(serie.serieName)) if (legendName.Equals(serie.serieName))
{ {
serie.highlighted = false; serie.highlight = false;
RefreshPainter(serie); RefreshPainter(serie);
} }
} }
@@ -573,12 +573,13 @@ namespace XCharts
for (int i = painter.index * rate; i < (painter.index + 1) * rate && i < maxSeries; i++) for (int i = painter.index * rate; i < (painter.index + 1) * rate && i < maxSeries; i++)
{ {
var serie = m_Series[i]; var serie = m_Series[i];
serie.context.colorIndex = GetLegendRealShowNameIndex(serie.legendName);
serie.context.dataPoints.Clear();
serie.context.dataIgnore.Clear();
if (m_OnCustomDrawSerieBeforeCallback != null) if (m_OnCustomDrawSerieBeforeCallback != null)
{ {
m_OnCustomDrawSerieBeforeCallback.Invoke(vh, serie); m_OnCustomDrawSerieBeforeCallback.Invoke(vh, serie);
} }
serie.context.dataPoints.Clear();
serie.context.dataIgnore.Clear();
DrawPainterSerie(vh, serie); DrawPainterSerie(vh, serie);
if (i >= 0 && i < m_SerieHandlers.Count) if (i >= 0 && i < m_SerieHandlers.Count)
{ {

View File

@@ -67,11 +67,7 @@ namespace XCharts
public override void DrawSerie(VertexHelper vh) public override void DrawSerie(VertexHelper vh)
{ {
var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName); DrawXBarSerie(vh, serie, serie.context.colorIndex);
var yCategory = ComponentHelper.IsAnyCategoryOfYAxis(chart.components);
serie.context.dataPoints.Clear();
if (yCategory) DrawYBarSerie(vh, serie, colorIndex);
else DrawXBarSerie(vh, serie, colorIndex);
} }
private void UpdateSerieContext() private void UpdateSerieContext()
@@ -85,12 +81,12 @@ namespace XCharts
{ {
serie.context.pointerItemDataIndex = serieData.index; serie.context.pointerItemDataIndex = serieData.index;
serie.context.pointerEnter = true; serie.context.pointerEnter = true;
serieData.context.highlighted = true; serieData.context.highlight = true;
chart.RefreshTopPainter(); chart.RefreshTopPainter();
} }
else else
{ {
serieData.context.highlighted = false; serieData.context.highlight = false;
} }
} }
} }
@@ -137,8 +133,8 @@ namespace XCharts
serie.context.dataPoints.Add(Vector3.zero); serie.context.dataPoints.Add(Vector3.zero);
continue; continue;
} }
var highlight = serie.data[i].context.highlighted var highlight = serie.data[i].context.highlight
|| serie.highlighted; || serie.highlight;
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight); var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight);
serieData.context.canShowLabel = true; serieData.context.canShowLabel = true;
@@ -242,21 +238,51 @@ namespace XCharts
private void DrawXBarSerie(VertexHelper vh, Bar serie, int colorIndex) private void DrawXBarSerie(VertexHelper vh, Bar serie, int colorIndex)
{ {
if (!serie.show) return; if (!serie.show || serie.animation.HasFadeOut())
if (serie.animation.HasFadeOut()) return; return;
var yAxis = chart.GetChartComponent<YAxis>(serie.yAxisIndex);
var xAxis = chart.GetChartComponent<XAxis>(serie.xAxisIndex); var isY = ComponentHelper.IsAnyCategoryOfYAxis(chart.components);
var grid = chart.GetChartComponent<GridCoord>(xAxis.gridIndex);
var dataZoom = chart.GetDataZoomOfAxis(xAxis); Axis axis;
Axis relativedAxis;
GridCoord grid;
if (isY)
{
axis = chart.GetChartComponent<YAxis>(serie.yAxisIndex);
relativedAxis = chart.GetChartComponent<XAxis>(serie.xAxisIndex);
}
else
{
axis = chart.GetChartComponent<XAxis>(serie.xAxisIndex);
relativedAxis = chart.GetChartComponent<YAxis>(serie.yAxisIndex);
}
grid = chart.GetChartComponent<GridCoord>(axis.gridIndex);
if (axis == null)
return;
if (relativedAxis == null)
return;
if (grid == null)
return;
var dataZoom = chart.GetDataZoomOfAxis(axis);
var showData = serie.GetDataList(dataZoom); var showData = serie.GetDataList(dataZoom);
if (showData.Count <= 0)
return;
var axisLength = isY ? grid.context.height : grid.context.width;
var isStack = SeriesHelper.IsStack<Bar>(chart.series, serie.stack); var isStack = SeriesHelper.IsStack<Bar>(chart.series, serie.stack);
m_StackSerieData.Clear(); if (isStack)
if (isStack) SeriesHelper.UpdateStackDataList(chart.series, serie, dataZoom, m_StackSerieData); SeriesHelper.UpdateStackDataList(chart.series, serie, dataZoom, m_StackSerieData);
float categoryWidth = AxisHelper.GetDataWidth(xAxis, grid.context.width, showData.Count, dataZoom);
float categoryWidth = AxisHelper.GetDataWidth(axis, axisLength, showData.Count, dataZoom);
float barGap = chart.GetSerieBarGap<Bar>(); float barGap = chart.GetSerieBarGap<Bar>();
float totalBarWidth = chart.GetSerieTotalWidth<Bar>(categoryWidth, barGap); float totalBarWidth = chart.GetSerieTotalWidth<Bar>(categoryWidth, barGap);
float barWidth = serie.GetBarWidth(categoryWidth); float barWidth = serie.GetBarWidth(categoryWidth);
float offset = (categoryWidth - totalBarWidth) / 2; float offset = (categoryWidth - totalBarWidth) * 0.5f;
float barGapWidth = barWidth + barWidth * barGap; float barGapWidth = barWidth + barWidth * barGap;
float space = serie.barGap == -1 ? offset : offset + chart.GetSerieIndexIfStack<Bar>(serie) * barGapWidth; float space = serie.barGap == -1 ? offset : offset + chart.GetSerieIndexIfStack<Bar>(serie) * barGapWidth;
int maxCount = serie.maxShow > 0 int maxCount = serie.maxShow > 0
@@ -266,10 +292,8 @@ namespace XCharts
var isPercentStack = SeriesHelper.IsPercentStack<Bar>(chart.series, serie.stack); var isPercentStack = SeriesHelper.IsPercentStack<Bar>(chart.series, serie.stack);
bool dataChanging = false; bool dataChanging = false;
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration(); float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
double xMinValue = xAxis.context.minValue; double yMinValue = relativedAxis.context.minValue;
double xMaxValue = xAxis.context.maxValue; double yMaxValue = relativedAxis.context.maxValue;
double yMinValue = yAxis.context.minValue;
double yMaxValue = yAxis.context.maxValue;
var isAllBarEnd = true; var isAllBarEnd = true;
serie.containerIndex = grid.index; serie.containerIndex = grid.index;
serie.containterInstanceId = grid.instanceId; serie.containterInstanceId = grid.instanceId;
@@ -281,88 +305,40 @@ namespace XCharts
serie.context.dataPoints.Add(Vector3.zero); serie.context.dataPoints.Add(Vector3.zero);
continue; continue;
} }
var highlight = serie.data[i].context.highlighted if (serieData.IsDataChanged())
|| serie.highlighted; dataChanging = true;
var highlight = serieData.context.highlight || serie.highlight;
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight); var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight);
double value = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue); var value = axis.IsCategory() ? i : serieData.GetData(0, axis.inverse);
float borderWidth = value == 0 ? 0 : itemStyle.runtimeBorderWidth; var relativedValue = serieData.GetCurrData(1, dataChangeDuration, relativedAxis.inverse, yMinValue, yMaxValue);
if (serieData.IsDataChanged()) dataChanging = true; var borderWidth = relativedValue == 0 ? 0 : itemStyle.runtimeBorderWidth;
float pX = grid.context.x + i * categoryWidth;
if (xAxis.IsValue() || xAxis.IsTime()) var pX = 0f;
{ var pY = 0f;
space = 0; UpdateXYPosition(grid, isY, axis, relativedAxis, i, categoryWidth, barWidth, isStack, value, ref pX, ref pY);
if ((xMaxValue - xMinValue) <= 0) pX = grid.context.x;
else pX = grid.context.x + (float)((serieData.GetData(0) - xMinValue) / (xMaxValue - xMinValue)) * (grid.context.width - barWidth);
//if (xAxis.boundaryGap) pX += barWidth / 2;
}
else
{
if (!xAxis.boundaryGap) pX -= categoryWidth / 2;
}
float zeroY = grid.context.y + yAxis.context.offset;
float axisLineWidth = value == 0 ? 0 :
((value < 0 ? -1 : 1) * xAxis.axisLine.GetWidth(chart.theme.axis.lineWidth));
float pY = zeroY + axisLineWidth;
if (isStack)
{
for (int n = 0; n < m_StackSerieData.Count - 1; n++)
{
pY += m_StackSerieData[n][i].context.stackHeight;
}
}
var barHig = 0f; var barHig = 0f;
double valueTotal = 0f;
if (isPercentStack) if (isPercentStack)
{ {
valueTotal = chart.GetSerieSameStackTotalValue<Bar>(serie.stack, i); var valueTotal = chart.GetSerieSameStackTotalValue<Bar>(serie.stack, i);
barHig = valueTotal != 0 ? (float)(value / valueTotal * grid.context.height) : 0; barHig = valueTotal != 0 ? (float)(relativedValue / valueTotal * axisLength) : 0;
} }
else else
{ {
valueTotal = (double)(yMaxValue - yMinValue); barHig = AxisHelper.GetAxisValueLength(grid, relativedAxis, categoryWidth, relativedValue);
if (valueTotal != 0)
{
if (yAxis.IsLog())
{
int minIndex = yAxis.GetLogMinIndex();
var nowIndex = yAxis.GetLogValue(value);
barHig = (nowIndex - minIndex) / yAxis.splitNumber * grid.context.height;
}
else
{
barHig = (float)((yMinValue > 0 ? value - yMinValue : value) / valueTotal * grid.context.height);
}
}
} }
serieData.context.stackHeight = barHig;
var isBarEnd = false; var isBarEnd = false;
float currHig = chart.CheckSerieBarAnimation(serie, i, barHig, out isBarEnd); float currHig = chart.CheckSerieBarAnimation(serie, i, barHig, out isBarEnd);
if (!isBarEnd) isAllBarEnd = false; if (!isBarEnd)
isAllBarEnd = false;
Vector3 plb, plt, prt, prb, top; Vector3 plb, plt, prt, prb, top;
if (value < 0) UpdateRectPosition(grid, isY, relativedValue, pX, pY, space, borderWidth, barWidth, currHig,
{ out plb, out plt, out prt, out prb, out top);
plb = new Vector3(pX + space + borderWidth, pY - borderWidth); serieData.context.stackHeight = barHig;
plt = new Vector3(pX + space + borderWidth, pY + currHig + borderWidth); serieData.context.position = top;
prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig + borderWidth);
prb = new Vector3(pX + space + barWidth - borderWidth, pY - borderWidth);
}
else
{
plb = new Vector3(pX + space + borderWidth, pY + borderWidth);
plt = new Vector3(pX + space + borderWidth, pY + currHig - borderWidth);
prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig - borderWidth);
prb = new Vector3(pX + space + barWidth - borderWidth, pY + borderWidth);
}
top = new Vector3(pX + space + barWidth / 2, pY + currHig - borderWidth);
if (serie.clip)
{
plb = chart.ClampInGrid(grid, plb);
plt = chart.ClampInGrid(grid, plt);
prt = chart.ClampInGrid(grid, prt);
prb = chart.ClampInGrid(grid, prb);
top = chart.ClampInGrid(grid, top);
}
serieData.context.rect = Rect.MinMaxRect(plb.x, plb.y, prb.x, prt.y); serieData.context.rect = Rect.MinMaxRect(plb.x, plb.y, prb.x, prt.y);
serie.context.dataPoints.Add(top); serie.context.dataPoints.Add(top);
if (serie.show && currHig != 0) if (serie.show && currHig != 0)
@@ -394,6 +370,97 @@ namespace XCharts
} }
} }
private void UpdateXYPosition(GridCoord grid, bool isY, Axis axis, Axis relativedAxis, int i, float categoryWidth, float barWidth, bool isStack,
double value, ref float pX, ref float pY)
{
if (isY)
{
if (axis.IsCategory())
{
pY = grid.context.y + i * categoryWidth + (axis.boundaryGap ? 0 : -categoryWidth * 0.5f);
}
else
{
if (axis.context.minMaxRange <= 0) pY = grid.context.y;
else pY = grid.context.y + (float)((value - axis.context.minValue) / axis.context.minMaxRange) * (grid.context.height - barWidth);
}
pX = AxisHelper.GetAxisPosition(grid, relativedAxis, categoryWidth, 0);
if (isStack)
{
for (int n = 0; n < m_StackSerieData.Count - 1; n++)
pX += m_StackSerieData[n][i].context.stackHeight;
}
}
else
{
if (axis.IsCategory())
{
pX = grid.context.x + i * categoryWidth + (axis.boundaryGap ? 0 : -categoryWidth * 0.5f);
}
else
{
if (axis.context.minMaxRange <= 0) pX = grid.context.x;
else pX = grid.context.x + (float)((value - axis.context.minValue) / axis.context.minMaxRange) * (grid.context.width - barWidth);
}
pY = AxisHelper.GetAxisPosition(grid, relativedAxis, categoryWidth, 0);
if (isStack)
{
for (int n = 0; n < m_StackSerieData.Count - 1; n++)
pY += m_StackSerieData[n][i].context.stackHeight;
}
}
}
private void UpdateRectPosition(GridCoord grid, bool isY, double yValue, float pX, float pY, float space, float borderWidth,
float barWidth, float currHig,
out Vector3 plb, out Vector3 plt, out Vector3 prt, out Vector3 prb, out Vector3 top)
{
if (isY)
{
if (yValue < 0)
{
plt = new Vector3(pX - borderWidth, pY + space + barWidth - borderWidth);
prt = new Vector3(pX + currHig + borderWidth, pY + space + barWidth - borderWidth);
prb = new Vector3(pX + currHig + borderWidth, pY + space + borderWidth);
plb = new Vector3(pX - borderWidth, pY + space + borderWidth);
}
else
{
plt = new Vector3(pX + borderWidth, pY + space + barWidth - borderWidth);
prt = new Vector3(pX + currHig - borderWidth, pY + space + barWidth - borderWidth);
prb = new Vector3(pX + currHig - borderWidth, pY + space + borderWidth);
plb = new Vector3(pX + borderWidth, pY + space + borderWidth);
}
top = new Vector3(pX + currHig - borderWidth, pY + space + barWidth / 2);
}
else
{
if (yValue < 0)
{
plb = new Vector3(pX + space + borderWidth, pY - borderWidth);
plt = new Vector3(pX + space + borderWidth, pY + currHig + borderWidth);
prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig + borderWidth);
prb = new Vector3(pX + space + barWidth - borderWidth, pY - borderWidth);
}
else
{
plb = new Vector3(pX + space + borderWidth, pY + borderWidth);
plt = new Vector3(pX + space + borderWidth, pY + currHig - borderWidth);
prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig - borderWidth);
prb = new Vector3(pX + space + barWidth - borderWidth, pY + borderWidth);
}
top = new Vector3(pX + space + barWidth / 2, pY + currHig - borderWidth);
}
if (serie.clip)
{
plb = chart.ClampInGrid(grid, plb);
plt = chart.ClampInGrid(grid, plt);
prt = chart.ClampInGrid(grid, prt);
prb = chart.ClampInGrid(grid, prb);
top = chart.ClampInGrid(grid, top);
}
}
private void DrawNormalBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex, private void DrawNormalBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt, bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
Vector3 prb, bool isYAxis, GridCoord grid) Vector3 prb, bool isYAxis, GridCoord grid)

View File

@@ -56,7 +56,7 @@ namespace XCharts
serie.context.dataPoints.Add(Vector3.zero); serie.context.dataPoints.Add(Vector3.zero);
continue; continue;
} }
var highlight = serie.data[i].context.highlighted || serie.highlighted; var highlight = serie.data[i].context.highlight || serie.highlight;
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight); var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight);
var open = serieData.GetCurrData(0, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue); var open = serieData.GetCurrData(0, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
var close = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue); var close = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);

View File

@@ -44,12 +44,12 @@ namespace XCharts
{ {
serie.context.pointerItemDataIndex = serieData.index; serie.context.pointerItemDataIndex = serieData.index;
serie.context.pointerEnter = true; serie.context.pointerEnter = true;
serieData.context.highlighted = true; serieData.context.highlight = true;
chart.RefreshTopPainter(); chart.RefreshTopPainter();
} }
else else
{ {
serieData.context.highlighted = false; serieData.context.highlight = false;
} }
} }
} }
@@ -122,7 +122,7 @@ namespace XCharts
color = visualMap.GetColor(value); color = visualMap.GetColor(value);
if (animationIndex >= 0 && i > animationIndex) continue; if (animationIndex >= 0 && i > animationIndex) continue;
serieData.context.canShowLabel = true; serieData.context.canShowLabel = true;
var emphasis = (serieData.context.highlighted) var emphasis = (serieData.context.highlight)
|| visualMap.context.pointerIndex > 0; || visualMap.context.pointerIndex > 0;
UGL.DrawRectangle(vh, pos, rectWid / 2, rectHig / 2, color); UGL.DrawRectangle(vh, pos, rectWid / 2, rectHig / 2, color);

View File

@@ -93,9 +93,6 @@ namespace XCharts
public override void DrawSerie(VertexHelper vh) public override void DrawSerie(VertexHelper vh)
{ {
var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName);
serie.context.colorIndex = colorIndex;
if (serie.IsUseCoord<PolarCoord>()) if (serie.IsUseCoord<PolarCoord>())
{ {
DrawPolarLine(vh, serie); DrawPolarLine(vh, serie);
@@ -145,12 +142,12 @@ namespace XCharts
{ {
serie.context.pointerItemDataIndex = serieData.index; serie.context.pointerItemDataIndex = serieData.index;
serie.context.pointerEnter = true; serie.context.pointerEnter = true;
serieData.context.highlighted = true; serieData.context.highlight = true;
chart.RefreshTopPainter(); chart.RefreshTopPainter();
} }
else else
{ {
serieData.context.highlighted = false; serieData.context.highlight = false;
} }
} }
} }
@@ -196,7 +193,7 @@ namespace XCharts
if (ChartHelper.IsIngore(serie.context.dataPoints[i])) if (ChartHelper.IsIngore(serie.context.dataPoints[i]))
continue; continue;
var highlight = serie.data[i].context.highlighted || serie.highlighted; var highlight = serie.data[i].context.highlight || serie.highlight;
var symbolSize = highlight var symbolSize = highlight
? symbol.GetSelectedSize(serie.data[i].data, theme.serie.lineSymbolSelectedSize) ? symbol.GetSelectedSize(serie.data[i].data, theme.serie.lineSymbolSelectedSize)
: symbol.GetSize(serie.data[i].data, theme.serie.lineSymbolSize); : symbol.GetSize(serie.data[i].data, theme.serie.lineSymbolSize);

View File

@@ -39,7 +39,7 @@ namespace XCharts
var firstSerieData = datas[0]; var firstSerieData = datas[0];
var startPos = GetPolarPos(m_Polar, m_AngleAxis, firstSerieData, min, max, radius); var startPos = GetPolarPos(m_Polar, m_AngleAxis, firstSerieData, min, max, radius);
var nextPos = Vector3.zero; var nextPos = Vector3.zero;
var lineColor = SerieHelper.GetLineColor(serie, chart.theme, serie.index, serie.highlighted); var lineColor = SerieHelper.GetLineColor(serie, chart.theme, serie.index, serie.highlight);
var lineWidth = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth); var lineWidth = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth);
var currDetailProgress = 0f; var currDetailProgress = 0f;
var totalDetailProgress = datas.Count; var totalDetailProgress = datas.Count;
@@ -86,9 +86,9 @@ namespace XCharts
if (ChartHelper.IsIngore(serieData.context.position)) if (ChartHelper.IsIngore(serieData.context.position))
continue; continue;
bool highlight = serieData.context.highlighted || serie.highlighted; bool highlight = serieData.context.highlight || serie.highlight;
if ((!symbol.show || !symbol.ShowSymbol(i, count) || serie.IsPerformanceMode()) if ((!symbol.show || !symbol.ShowSymbol(i, count) || serie.IsPerformanceMode())
&& !serieData.context.highlighted) && !serieData.context.highlight)
continue; continue;
var symbolSize = highlight var symbolSize = highlight

View File

@@ -252,7 +252,7 @@ namespace XCharts
var isVisualMapGradient = VisualMapHelper.IsNeedGradient(visualMap); var isVisualMapGradient = VisualMapHelper.IsNeedGradient(visualMap);
var isLineStyleGradient = serie.lineStyle.IsNeedGradient(); var isLineStyleGradient = serie.lineStyle.IsNeedGradient();
var highlight = serie.highlighted || serie.context.pointerEnter; var highlight = serie.highlight || serie.context.pointerEnter;
var lineWidth = serie.lineStyle.GetWidth(theme.serie.lineWidth); var lineWidth = serie.lineStyle.GetWidth(theme.serie.lineWidth);
var lineColor = SerieHelper.GetLineColor(serie, theme, serie.context.colorIndex, highlight); var lineColor = SerieHelper.GetLineColor(serie, theme, serie.context.colorIndex, highlight);

View File

@@ -133,16 +133,16 @@ namespace XCharts
if (dataIndex >= 0) if (dataIndex >= 0)
{ {
if (lastDataIndex >= 0) if (lastDataIndex >= 0)
serie.GetSerieData(lastDataIndex).context.highlighted = false; serie.GetSerieData(lastDataIndex).context.highlight = false;
if (lastDataIndex != dataIndex) if (lastDataIndex != dataIndex)
chart.RefreshPainter(serie); chart.RefreshPainter(serie);
serie.GetSerieData(dataIndex).context.highlighted = true; serie.GetSerieData(dataIndex).context.highlight = true;
serie.context.pointerItemDataIndex = dataIndex; serie.context.pointerItemDataIndex = dataIndex;
} }
else else
{ {
if (lastDataIndex >= 0) if (lastDataIndex >= 0)
serie.GetSerieData(lastDataIndex).context.highlighted = false; serie.GetSerieData(lastDataIndex).context.highlight = false;
serie.context.pointerItemDataIndex = -1; serie.context.pointerItemDataIndex = -1;
} }
} }
@@ -151,7 +151,7 @@ namespace XCharts
if (lastPointerEnter) if (lastPointerEnter)
{ {
foreach (var serieData in serie.data) foreach (var serieData in serie.data)
serieData.context.highlighted = false; serieData.context.highlight = false;
} }
serie.context.pointerItemDataIndex = -1; serie.context.pointerItemDataIndex = -1;
} }
@@ -213,7 +213,7 @@ namespace XCharts
serieData.context.outsideRadius = serie.pieRoseType > 0 ? serieData.context.outsideRadius = serie.pieRoseType > 0 ?
serie.context.insideRadius + (float)((serie.context.outsideRadius - serie.context.insideRadius) * value / serie.context.dataMax) : serie.context.insideRadius + (float)((serie.context.outsideRadius - serie.context.insideRadius) * value / serie.context.dataMax) :
serie.context.outsideRadius; serie.context.outsideRadius;
if (serieData.context.highlighted) if (serieData.context.highlight)
{ {
serieData.context.outsideRadius += chart.theme.serie.pieTooltipExtraRadius; serieData.context.outsideRadius += chart.theme.serie.pieTooltipExtraRadius;
} }
@@ -311,13 +311,13 @@ namespace XCharts
{ {
continue; continue;
} }
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.context.highlighted); var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.context.highlight);
if (serieData.IsDataChanged()) dataChanging = true; if (serieData.IsDataChanged()) dataChanging = true;
var serieNameCount = chart.m_LegendRealShowName.IndexOf(serieData.legendName); var serieNameCount = chart.m_LegendRealShowName.IndexOf(serieData.legendName);
var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieNameCount, var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieNameCount,
serieData.context.highlighted); serieData.context.highlight);
var toColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieNameCount, var toColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieNameCount,
serieData.context.highlighted); serieData.context.highlight);
var borderWidth = itemStyle.borderWidth; var borderWidth = itemStyle.borderWidth;
var borderColor = itemStyle.borderColor; var borderColor = itemStyle.borderColor;
@@ -372,7 +372,7 @@ namespace XCharts
{ {
foreach (var serieData in serie.data) foreach (var serieData in serie.data)
{ {
if (serieData.context.highlighted) return true; if (serieData.context.highlight) return true;
} }
} }
} }
@@ -480,7 +480,7 @@ namespace XCharts
{ {
if (serieData.labelObject == null) return; if (serieData.labelObject == null) return;
var currAngle = serieData.context.halfAngle; var currAngle = serieData.context.halfAngle;
var isHighlight = (serieData.context.highlighted && serie.emphasis.label.show); var isHighlight = (serieData.context.highlight && serie.emphasis.label.show);
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData); var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
var labelLine = SerieHelper.GetSerieLabelLine(serie, serieData); var labelLine = SerieHelper.GetSerieLabelLine(serie, serieData);
var iconStyle = SerieHelper.GetIconStyle(serie, serieData); var iconStyle = SerieHelper.GetIconStyle(serie, serieData);

View File

@@ -247,7 +247,7 @@ namespace XCharts
private bool IsHighlight(RadarCoord radar, Serie serie, SerieData serieData, Tooltip tooltip, int dataIndex, int dimension) private bool IsHighlight(RadarCoord radar, Serie serie, SerieData serieData, Tooltip tooltip, int dataIndex, int dimension)
{ {
if (serie.highlighted || serieData.context.highlighted) return true; if (serie.highlight || serieData.context.highlight) return true;
if (tooltip == null) return false; if (tooltip == null) return false;
var selectedSerieIndex = tooltip.runtimeDataIndex[0]; var selectedSerieIndex = tooltip.runtimeDataIndex[0];
if (selectedSerieIndex < 0) return false; if (selectedSerieIndex < 0) return false;
@@ -406,7 +406,7 @@ namespace XCharts
{ {
var serieData = serie.data[j]; var serieData = serie.data[j];
if (!serieData.show) continue; if (!serieData.show) continue;
var isHighlight = serie.highlighted || serieData.context.highlighted || var isHighlight = serie.highlight || serieData.context.highlight ||
(tooltip.show && tooltip.runtimeDataIndex[0] == i && tooltip.runtimeDataIndex[1] == j); (tooltip.show && tooltip.runtimeDataIndex[0] == i && tooltip.runtimeDataIndex[1] == j);
var serieIndex = serieData.index; var serieIndex = serieData.index;
var symbolSize = isHighlight var symbolSize = isHighlight

View File

@@ -84,9 +84,9 @@ namespace XCharts
var degree = (float)(360 * value / max); var degree = (float)(360 * value / max);
var startDegree = GetStartAngle(serie); var startDegree = GetStartAngle(serie);
var toDegree = GetToAngle(serie, degree); var toDegree = GetToAngle(serie, degree);
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.context.highlighted); var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.context.highlight);
var itemColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, j, serieData.context.highlighted); var itemColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, j, serieData.context.highlight);
var itemToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, j, serieData.context.highlighted); var itemToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, j, serieData.context.highlight);
var outsideRadius = serie.context.outsideRadius - j * (ringWidth + serie.ringGap); var outsideRadius = serie.context.outsideRadius - j * (ringWidth + serie.ringGap);
var insideRadius = outsideRadius - ringWidth; var insideRadius = outsideRadius - ringWidth;
var centerRadius = (outsideRadius + insideRadius) / 2; var centerRadius = (outsideRadius + insideRadius) / 2;

View File

@@ -89,7 +89,7 @@ namespace XCharts
var symbolSize = symbol.GetSize(serieData.data, themeSymbolSize); var symbolSize = symbol.GetSize(serieData.data, themeSymbolSize);
if (Vector3.Distance(serieData.context.position, chart.pointerPos) <= symbolSize) if (Vector3.Distance(serieData.context.position, chart.pointerPos) <= symbolSize)
{ {
serieData.context.highlighted = true; serieData.context.highlight = true;
serie.context.pointerItemDataIndex = lastDataIndex; serie.context.pointerItemDataIndex = lastDataIndex;
return; return;
} }
@@ -98,7 +98,7 @@ namespace XCharts
serie.context.pointerItemDataIndex = -1; serie.context.pointerItemDataIndex = -1;
if (lastDataIndex >= 0) if (lastDataIndex >= 0)
{ {
serie.GetSerieData(lastDataIndex).context.highlighted = false; serie.GetSerieData(lastDataIndex).context.highlight = false;
chart.RefreshPainter(serie); chart.RefreshPainter(serie);
} }
for (int i = serie.dataCount - 1; i >= 0; i--) for (int i = serie.dataCount - 1; i >= 0; i--)
@@ -112,7 +112,7 @@ namespace XCharts
var symbolSize = symbol.GetSize(serieData.data, themeSymbolSize); var symbolSize = symbol.GetSize(serieData.data, themeSymbolSize);
if (Vector3.Distance(serieData.context.position, chart.pointerPos) <= symbolSize) if (Vector3.Distance(serieData.context.position, chart.pointerPos) <= symbolSize)
{ {
serieData.context.highlighted = true; serieData.context.highlight = true;
serie.context.pointerItemDataIndex = i; serie.context.pointerItemDataIndex = i;
serie.context.pointerEnter = true; serie.context.pointerEnter = true;
chart.RefreshPainter(serie); chart.RefreshPainter(serie);
@@ -165,7 +165,7 @@ namespace XCharts
if (!symbol.ShowSymbol(serieData.index, maxCount)) if (!symbol.ShowSymbol(serieData.index, maxCount))
continue; continue;
var highlight = serie.highlighted || serieData.context.highlighted; var highlight = serie.highlight || serieData.context.highlight;
var color = SerieHelper.GetItemColor(serie, serieData, theme, colorIndex, highlight); var color = SerieHelper.GetItemColor(serie, serieData, theme, colorIndex, highlight);
var toColor = SerieHelper.GetItemToColor(serie, serieData, theme, colorIndex, highlight); var toColor = SerieHelper.GetItemToColor(serie, serieData, theme, colorIndex, highlight);
var emptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, colorIndex, highlight, false); var emptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, colorIndex, highlight, false);
@@ -191,7 +191,7 @@ namespace XCharts
var datas = serieData.data; var datas = serieData.data;
float symbolSize = 0; float symbolSize = 0;
if (serie.highlighted || serieData.context.highlighted) if (serie.highlight || serieData.context.highlight)
{ {
symbolSize = symbol.GetSelectedSize(datas, theme.serie.scatterSymbolSelectedSize); symbolSize = symbol.GetSelectedSize(datas, theme.serie.scatterSymbolSelectedSize);
} }
@@ -267,7 +267,7 @@ namespace XCharts
if (!symbol.ShowSymbol(serieData.index, maxCount)) if (!symbol.ShowSymbol(serieData.index, maxCount))
continue; continue;
var highlight = serie.highlighted || serieData.context.highlighted; var highlight = serie.highlight || serieData.context.highlight;
var color = SerieHelper.GetItemColor(serie, serieData, theme, colorIndex, highlight); var color = SerieHelper.GetItemColor(serie, serieData, theme, colorIndex, highlight);
var toColor = SerieHelper.GetItemToColor(serie, serieData, theme, colorIndex, highlight); var toColor = SerieHelper.GetItemToColor(serie, serieData, theme, colorIndex, highlight);
var emptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, colorIndex, highlight, false); var emptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, colorIndex, highlight, false);
@@ -296,7 +296,7 @@ namespace XCharts
var datas = serieData.data; var datas = serieData.data;
var symbolSize = 0f; var symbolSize = 0f;
if (serie.highlighted || serieData.context.highlighted) if (serie.highlight || serieData.context.highlight)
symbolSize = symbol.GetSelectedSize(datas, theme.serie.scatterSymbolSelectedSize); symbolSize = symbol.GetSelectedSize(datas, theme.serie.scatterSymbolSelectedSize);
else else
symbolSize = symbol.GetSize(datas, theme.serie.scatterSymbolSize); symbolSize = symbol.GetSize(datas, theme.serie.scatterSymbolSize);

View File

@@ -232,7 +232,7 @@ namespace XCharts
[SerializeField] private float[] m_Radius = new float[2] { 0, 80 }; [SerializeField] private float[] m_Radius = new float[2] { 0, 80 };
[SerializeField] private LabelStyle m_Label = new LabelStyle(); [SerializeField] private LabelStyle m_Label = new LabelStyle();
[SerializeField] private LabelLine m_LabelLine = new LabelLine(); [SerializeField] private LabelLine m_LabelLine = new LabelLine();
[SerializeField] private SerieAnimation m_Animation = new SerieAnimation(); [SerializeField] private AnimationStyle m_Animation = new AnimationStyle();
[SerializeField] private LineArrow m_LineArrow = new LineArrow(); [SerializeField] private LineArrow m_LineArrow = new LineArrow();
[SerializeField] private ItemStyle m_ItemStyle = new ItemStyle(); [SerializeField] private ItemStyle m_ItemStyle = new ItemStyle();
[SerializeField] private Emphasis m_Emphasis = new Emphasis(); [SerializeField] private Emphasis m_Emphasis = new Emphasis();
@@ -745,7 +745,7 @@ namespace XCharts
/// The start animation. /// The start animation.
/// 起始动画。 /// 起始动画。
/// </summary> /// </summary>
public SerieAnimation animation public AnimationStyle animation
{ {
get { return m_Animation; } get { return m_Animation; }
set { if (PropertyUtil.SetClass(ref m_Animation, value, true)) SetVerticesDirty(); } set { if (PropertyUtil.SetClass(ref m_Animation, value, true)) SetVerticesDirty(); }
@@ -981,7 +981,7 @@ namespace XCharts
/// Whether the serie is highlighted. /// Whether the serie is highlighted.
/// 该系列是否高亮,一般由图例悬停触发。 /// 该系列是否高亮,一般由图例悬停触发。
/// </summary> /// </summary>
public bool highlighted { get; internal set; } public bool highlight { get; internal set; }
/// <summary> /// <summary>
/// the count of data list. /// the count of data list.
/// 数据项个数。 /// 数据项个数。
@@ -1575,9 +1575,9 @@ namespace XCharts
/// </summary> /// </summary>
public void ClearHighlight() public void ClearHighlight()
{ {
highlighted = false; highlight = false;
foreach (var serieData in m_Data) foreach (var serieData in m_Data)
serieData.context.highlighted = false; serieData.context.highlight = false;
} }
/// <summary> /// <summary>
@@ -1587,7 +1587,7 @@ namespace XCharts
{ {
var serieData = GetSerieData(index); var serieData = GetSerieData(index);
if (serieData != null) if (serieData != null)
serieData.context.highlighted = flag; serieData.context.highlight = flag;
} }
public float GetBarWidth(float categoryWidth) public float GetBarWidth(float categoryWidth)

View File

@@ -115,7 +115,7 @@ namespace XCharts
m_Show = true; m_Show = true;
m_Selected = false; m_Selected = false;
context.canShowLabel = true; context.canShowLabel = true;
context.highlighted = false; context.highlight = false;
m_Radius = 0; m_Radius = 0;
m_Data.Clear(); m_Data.Clear();
m_PreviousData.Clear(); m_PreviousData.Clear();

View File

@@ -58,7 +58,7 @@ namespace XCharts
/// Whether the data item is highlighted. /// Whether the data item is highlighted.
/// 该数据项是否被高亮,一般由鼠标悬停或图例悬停触发高亮。 /// 该数据项是否被高亮,一般由鼠标悬停或图例悬停触发高亮。
/// </summary> /// </summary>
public bool highlighted { get; set; } public bool highlight { get; set; }
} }
} }