mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-20 07:20:08 +00:00
3.0 - bar chart
This commit is contained in:
@@ -10,7 +10,7 @@ using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(SerieAnimation), true)]
|
||||
[CustomPropertyDrawer(typeof(AnimationStyle), true)]
|
||||
public class AnimationDrawer : BasePropertyDrawer
|
||||
{
|
||||
public override string ClassName { get { return "Animation"; } }
|
||||
|
||||
@@ -111,8 +111,6 @@ namespace XCharts
|
||||
|
||||
protected void PropertyTwoFiled(string relativePropName)
|
||||
{
|
||||
//TODO:
|
||||
//PropertyField(relativePropName);
|
||||
var m_DrawRect = GUILayoutUtility.GetRect(1f, 17f);
|
||||
var prop = FindProperty(relativePropName);
|
||||
ChartEditorHelper.MakeTwoField(ref m_DrawRect, m_DrawRect.width, prop, prop.displayName);
|
||||
|
||||
@@ -22,21 +22,29 @@ namespace XCharts
|
||||
PropertyField("m_XAxisIndex");
|
||||
PropertyField("m_YAxisIndex");
|
||||
}
|
||||
PropertyFieldLimitMin("m_MinShow", 0);
|
||||
PropertyFieldLimitMin("m_MaxShow", 0);
|
||||
PropertyFieldLimitMin("m_MaxCache", 0);
|
||||
PropertyField("m_BarType");
|
||||
PropertyField("m_BarPercentStack");
|
||||
PropertyField("m_BarWidth");
|
||||
PropertyField("m_BarGap");
|
||||
PropertyField("m_BarZebraWidth");
|
||||
PropertyField("m_BarZebraGap");
|
||||
PropertyField("m_Clip");
|
||||
PropertyField("m_Ignore");
|
||||
PropertyField("m_IgnoreValue");
|
||||
PropertyField("m_ShowAsPositiveNumber");
|
||||
PropertyField("m_Large");
|
||||
PropertyField("m_LargeThreshold");
|
||||
if (serie.barType == BarType.Zebra)
|
||||
{
|
||||
PropertyField("m_BarZebraWidth");
|
||||
PropertyField("m_BarZebraGap");
|
||||
}
|
||||
|
||||
PropertyFiledMore(() =>
|
||||
{
|
||||
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_IconStyle");
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[SerieEditor(typeof(Line))]
|
||||
@@ -22,20 +24,23 @@ namespace XCharts
|
||||
PropertyField("m_XAxisIndex");
|
||||
PropertyField("m_YAxisIndex");
|
||||
}
|
||||
PropertyFieldLimitMin("m_MinShow", 0);
|
||||
PropertyFieldLimitMin("m_MaxShow", 0);
|
||||
PropertyFieldLimitMin("m_MaxCache", 0);
|
||||
PropertyField("m_LineType");
|
||||
PropertyField("m_SampleDist");
|
||||
PropertyField("m_SampleType");
|
||||
PropertyField("m_SampleAverage");
|
||||
PropertyField("m_Clip");
|
||||
PropertyField("m_Ignore");
|
||||
PropertyField("m_IgnoreValue");
|
||||
PropertyField("m_IgnoreLineBreak");
|
||||
PropertyField("m_ShowAsPositiveNumber");
|
||||
PropertyField("m_Large");
|
||||
PropertyField("m_LargeThreshold");
|
||||
PropertyFiledMore(() =>
|
||||
{
|
||||
PropertyFieldLimitMin("m_MinShow", 0);
|
||||
PropertyFieldLimitMin("m_MaxShow", 0);
|
||||
PropertyFieldLimitMin("m_MaxCache", 0);
|
||||
PropertyField("m_SampleDist");
|
||||
PropertyField("m_SampleType");
|
||||
PropertyField("m_SampleAverage");
|
||||
PropertyField("m_Ignore");
|
||||
PropertyField("m_IgnoreValue");
|
||||
PropertyField("m_IgnoreLineBreak");
|
||||
PropertyField("m_ShowAsPositiveNumber");
|
||||
PropertyField("m_Large");
|
||||
PropertyField("m_LargeThreshold");
|
||||
PropertyField("m_Clip");
|
||||
});
|
||||
PropertyField("m_Symbol");
|
||||
PropertyField("m_LineStyle");
|
||||
PropertyField("m_LineArrow");
|
||||
|
||||
@@ -16,11 +16,15 @@ namespace XCharts
|
||||
PropertyField("m_Space");
|
||||
PropertyTwoFiled("m_Center");
|
||||
PropertyTwoFiled("m_Radius");
|
||||
PropertyField("m_MinAngle");
|
||||
PropertyField("m_RoundCap");
|
||||
PropertyField("m_Ignore");
|
||||
PropertyField("m_IgnoreValue");
|
||||
PropertyField("m_AvoidLabelOverlap");
|
||||
|
||||
PropertyFiledMore(() =>
|
||||
{
|
||||
PropertyField("m_MinAngle");
|
||||
PropertyField("m_RoundCap");
|
||||
PropertyField("m_Ignore");
|
||||
PropertyField("m_IgnoreValue");
|
||||
PropertyField("m_AvoidLabelOverlap");
|
||||
});
|
||||
|
||||
PropertyField("m_ItemStyle");
|
||||
PropertyField("m_IconStyle");
|
||||
|
||||
@@ -97,13 +97,14 @@ namespace XCharts
|
||||
return baseProperty.FindPropertyRelative(path);
|
||||
}
|
||||
|
||||
protected void PropertyField(string path)
|
||||
protected SerializedProperty PropertyField(string path)
|
||||
{
|
||||
Assert.IsNotNull(path);
|
||||
var property = FindProperty(path);
|
||||
Assert.IsNotNull(property, "Can't find:" + path);
|
||||
var title = ChartEditorHelper.GetContent(property.displayName);
|
||||
PropertyField(property, title);
|
||||
return property;
|
||||
}
|
||||
|
||||
protected void PropertyField(SerializedProperty property)
|
||||
@@ -126,18 +127,40 @@ namespace XCharts
|
||||
|
||||
protected void PropertyTwoFiled(string relativePropName)
|
||||
{
|
||||
//TODO:
|
||||
PropertyField(relativePropName);
|
||||
var m_DrawRect = GUILayoutUtility.GetRect(1f, 17f);
|
||||
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:
|
||||
PropertyField(relativePropName);
|
||||
var prop = 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:
|
||||
PropertyField(relativePropName);
|
||||
var prop = 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,8 @@ namespace XCharts
|
||||
{
|
||||
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_DataComponentFoldout = true;
|
||||
private Dictionary<int, bool> m_DataElementFoldout = new Dictionary<int, bool>();
|
||||
@@ -90,6 +92,15 @@ namespace XCharts
|
||||
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)
|
||||
{
|
||||
bool flag;
|
||||
|
||||
@@ -103,11 +103,11 @@ namespace XCharts
|
||||
{
|
||||
EditorGUI.LabelField(drawRect, name);
|
||||
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 tempWidth = (rectWidth - startX + diff) / 2;
|
||||
var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height);
|
||||
var centerYRect = new Rect(centerXRect.x + tempWidth - offset, 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 - 1, drawRect.height - 1);
|
||||
EditorGUI.PropertyField(centerXRect, prop1, GUIContent.none);
|
||||
EditorGUI.PropertyField(centerYRect, prop2, GUIContent.none);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
@@ -480,6 +480,16 @@ namespace XCharts
|
||||
}
|
||||
|
||||
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 gridHeight = isY ? grid.context.height : grid.context.width;
|
||||
@@ -489,19 +499,24 @@ namespace XCharts
|
||||
{
|
||||
int minIndex = axis.GetLogMinIndex();
|
||||
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())
|
||||
{
|
||||
var categoryIndex = (int)value;
|
||||
var categoryStart = gridXY + (axis.boundaryGap ? scaleWidth / 2 : 0);
|
||||
return categoryStart + scaleWidth * categoryIndex;
|
||||
return includeGridXY
|
||||
? gridXY + (axis.boundaryGap ? scaleWidth / 2 : 0) + scaleWidth * categoryIndex
|
||||
: (axis.boundaryGap ? scaleWidth / 2 : 0) + scaleWidth * categoryIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
var yDataHig = (axis.context.minMaxRange == 0) ? 0f :
|
||||
(float)((value - axis.context.minValue) / axis.context.minMaxRange * gridHeight);
|
||||
return gridXY + yDataHig;
|
||||
return includeGridXY
|
||||
? gridXY + yDataHig
|
||||
: yDataHig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,22 @@ namespace XCharts
|
||||
public delegate float CustomAnimationDelay(int dataIndex);
|
||||
public delegate float CustomAnimationDuration(int dataIndex);
|
||||
|
||||
|
||||
public enum AnimationType
|
||||
{
|
||||
Default,
|
||||
LeftToRight,
|
||||
BottomToTop,
|
||||
InsideOut,
|
||||
Clockwise,
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// the animation of serie.
|
||||
/// 动画表现。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class SerieAnimation : ChildComponent
|
||||
public class AnimationStyle : ChildComponent
|
||||
{
|
||||
public enum Easing
|
||||
{
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6560100f155244fba80a175e6a28139
|
||||
guid: d51f91843500c4092909a6779592b654
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -242,7 +242,7 @@ namespace XCharts
|
||||
if (legendName.Equals(serie.serieName))
|
||||
{
|
||||
serie.show = show;
|
||||
serie.highlighted = false;
|
||||
serie.highlight = false;
|
||||
if (serie.show) needShow = true;
|
||||
}
|
||||
else
|
||||
@@ -252,7 +252,7 @@ namespace XCharts
|
||||
if (legendName.Equals(data.name))
|
||||
{
|
||||
data.show = show;
|
||||
data.context.highlighted = false;
|
||||
data.context.highlight = false;
|
||||
if (data.show) needShow = true;
|
||||
}
|
||||
}
|
||||
@@ -268,7 +268,7 @@ namespace XCharts
|
||||
{
|
||||
if (legendName.Equals(serie.serieName))
|
||||
{
|
||||
serie.highlighted = heighlight;
|
||||
serie.highlight = heighlight;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -276,8 +276,8 @@ namespace XCharts
|
||||
{
|
||||
if (legendName.Equals(data.name))
|
||||
{
|
||||
data.context.highlighted = heighlight;
|
||||
if (data.context.highlighted) show = true;
|
||||
data.context.highlight = heighlight;
|
||||
if (data.context.highlight) show = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace XCharts
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[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>();
|
||||
|
||||
/// <summary>
|
||||
@@ -66,7 +66,7 @@ namespace XCharts
|
||||
/// The animation of markline.
|
||||
/// 标线的动画样式。
|
||||
/// </summary>
|
||||
public SerieAnimation animation
|
||||
public AnimationStyle animation
|
||||
{
|
||||
get { return m_Animation; }
|
||||
set { if (PropertyUtil.SetClass(ref m_Animation, value)) SetVerticesDirty(); }
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
if (!animation.IsFinish())
|
||||
|
||||
@@ -85,10 +85,6 @@ namespace XCharts
|
||||
|
||||
private void DrawCricleRadar(VertexHelper vh, RadarCoord radar)
|
||||
{
|
||||
if (!radar.splitLine.show && !radar.splitArea.show)
|
||||
{
|
||||
return;
|
||||
}
|
||||
float insideRadius = 0, outsideRadius = 0;
|
||||
float block = radar.context.radius / radar.splitNumber;
|
||||
int indicatorNum = radar.indicatorList.Count;
|
||||
@@ -96,7 +92,10 @@ namespace XCharts
|
||||
Vector3 p1;
|
||||
float angle = 2 * Mathf.PI / indicatorNum;
|
||||
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++)
|
||||
{
|
||||
var color = radar.splitArea.GetColor(i, chart.theme.axis);
|
||||
@@ -108,29 +107,25 @@ namespace XCharts
|
||||
}
|
||||
if (radar.splitLine.show)
|
||||
{
|
||||
UGL.DrawEmptyCricle(vh, p, outsideRadius, lineWidth, lineColor,
|
||||
UGL.DrawEmptyCricle(vh, p, outsideRadius, splitLineWidth, splitLineColor,
|
||||
Color.clear, chart.settings.cicleSmoothness);
|
||||
}
|
||||
insideRadius = outsideRadius;
|
||||
}
|
||||
for (int j = 0; j <= indicatorNum; j++)
|
||||
if (radar.axisLine.show)
|
||||
{
|
||||
float currAngle = j * angle;
|
||||
p1 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
|
||||
p.y + outsideRadius * Mathf.Cos(currAngle));
|
||||
if (radar.splitLine.show)
|
||||
for (int j = 0; j <= indicatorNum; j++)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (!radar.splitLine.show && !radar.splitArea.show)
|
||||
{
|
||||
return;
|
||||
}
|
||||
float insideRadius = 0, outsideRadius = 0;
|
||||
float block = radar.context.radius / radar.splitNumber;
|
||||
int indicatorNum = radar.indicatorList.Count;
|
||||
@@ -145,7 +140,6 @@ namespace XCharts
|
||||
var splitLineType = radar.splitLine.GetType(chart.theme.axis.splitLineType);
|
||||
for (int i = 0; i < radar.splitNumber; i++)
|
||||
{
|
||||
var isLast = i == radar.splitNumber - 1;
|
||||
var color = radar.splitArea.GetColor(i, chart.theme.axis);
|
||||
outsideRadius = insideRadius + block;
|
||||
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 (isLast)
|
||||
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, p2, p3, lineColor);
|
||||
else
|
||||
ChartDrawer.DrawLineStyle(vh, splitLineType, splitLineWidth, p2, p3, splitLineColor);
|
||||
ChartDrawer.DrawLineStyle(vh, splitLineType, splitLineWidth, p2, p3, splitLineColor);
|
||||
}
|
||||
p1 = p4;
|
||||
p2 = p3;
|
||||
}
|
||||
insideRadius = outsideRadius;
|
||||
}
|
||||
for (int j = 0; j <= indicatorNum; j++)
|
||||
if (radar.axisLine.show)
|
||||
{
|
||||
float currAngle = j * angle;
|
||||
p3 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
|
||||
p.y + outsideRadius * Mathf.Cos(currAngle));
|
||||
if (radar.splitLine.show)
|
||||
for (int j = 0; j <= indicatorNum; j++)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,11 +291,11 @@ namespace XCharts
|
||||
if (System.Math.Abs(dist) <= symbolSize)
|
||||
{
|
||||
serie.context.pointerAxisDataIndexs.Add(i);
|
||||
serieData.context.highlighted = true;
|
||||
serieData.context.highlight = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
serieData.context.highlighted = false;
|
||||
serieData.context.highlight = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace XCharts
|
||||
var numericFormatter = GetItemNumericFormatter(tooltip, serie, serieData);
|
||||
if (isCartesian)
|
||||
{
|
||||
if (serieData != null && serieData.context.highlighted)
|
||||
if (serieData != null && serieData.context.highlight)
|
||||
{
|
||||
sb.Append(key).Append(!string.IsNullOrEmpty(key) ? " : " : "");
|
||||
sb.Append("[").Append(ChartCached.FloatToStr(xValue, numericFormatter)).Append(",")
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace XCharts
|
||||
for (int i = 0; i < serie.dataCount; 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 (!serie.show || !serieData.show)
|
||||
@@ -160,7 +160,7 @@ namespace XCharts
|
||||
{
|
||||
var serieData = serie.GetSerieData(0);
|
||||
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 (!serie.show || !serieData.show)
|
||||
|
||||
@@ -749,7 +749,7 @@ namespace XCharts
|
||||
for (int i = 0; i < m_Series.Count; i++)
|
||||
{
|
||||
var serie = m_Series[i];
|
||||
if (serie is T) continue;
|
||||
if (!(serie is T)) continue;
|
||||
if (string.IsNullOrEmpty(serie.stack))
|
||||
{
|
||||
if (serie.index == currSerie.index) return index;
|
||||
|
||||
@@ -523,7 +523,7 @@ namespace XCharts
|
||||
{
|
||||
if (legendName.Equals(serie.serieName))
|
||||
{
|
||||
serie.highlighted = true;
|
||||
serie.highlight = true;
|
||||
RefreshPainter(serie);
|
||||
}
|
||||
}
|
||||
@@ -541,7 +541,7 @@ namespace XCharts
|
||||
{
|
||||
if (legendName.Equals(serie.serieName))
|
||||
{
|
||||
serie.highlighted = false;
|
||||
serie.highlight = false;
|
||||
RefreshPainter(serie);
|
||||
}
|
||||
}
|
||||
@@ -573,12 +573,13 @@ namespace XCharts
|
||||
for (int i = painter.index * rate; i < (painter.index + 1) * rate && i < maxSeries; i++)
|
||||
{
|
||||
var serie = m_Series[i];
|
||||
serie.context.colorIndex = GetLegendRealShowNameIndex(serie.legendName);
|
||||
serie.context.dataPoints.Clear();
|
||||
serie.context.dataIgnore.Clear();
|
||||
if (m_OnCustomDrawSerieBeforeCallback != null)
|
||||
{
|
||||
m_OnCustomDrawSerieBeforeCallback.Invoke(vh, serie);
|
||||
}
|
||||
serie.context.dataPoints.Clear();
|
||||
serie.context.dataIgnore.Clear();
|
||||
DrawPainterSerie(vh, serie);
|
||||
if (i >= 0 && i < m_SerieHandlers.Count)
|
||||
{
|
||||
|
||||
@@ -67,11 +67,7 @@ namespace XCharts
|
||||
|
||||
public override void DrawSerie(VertexHelper vh)
|
||||
{
|
||||
var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName);
|
||||
var yCategory = ComponentHelper.IsAnyCategoryOfYAxis(chart.components);
|
||||
serie.context.dataPoints.Clear();
|
||||
if (yCategory) DrawYBarSerie(vh, serie, colorIndex);
|
||||
else DrawXBarSerie(vh, serie, colorIndex);
|
||||
DrawXBarSerie(vh, serie, serie.context.colorIndex);
|
||||
}
|
||||
|
||||
private void UpdateSerieContext()
|
||||
@@ -85,12 +81,12 @@ namespace XCharts
|
||||
{
|
||||
serie.context.pointerItemDataIndex = serieData.index;
|
||||
serie.context.pointerEnter = true;
|
||||
serieData.context.highlighted = true;
|
||||
serieData.context.highlight = true;
|
||||
chart.RefreshTopPainter();
|
||||
}
|
||||
else
|
||||
{
|
||||
serieData.context.highlighted = false;
|
||||
serieData.context.highlight = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,8 +133,8 @@ namespace XCharts
|
||||
serie.context.dataPoints.Add(Vector3.zero);
|
||||
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);
|
||||
|
||||
serieData.context.canShowLabel = true;
|
||||
@@ -242,21 +238,51 @@ namespace XCharts
|
||||
|
||||
private void DrawXBarSerie(VertexHelper vh, Bar serie, int colorIndex)
|
||||
{
|
||||
if (!serie.show) return;
|
||||
if (serie.animation.HasFadeOut()) return;
|
||||
var yAxis = chart.GetChartComponent<YAxis>(serie.yAxisIndex);
|
||||
var xAxis = chart.GetChartComponent<XAxis>(serie.xAxisIndex);
|
||||
var grid = chart.GetChartComponent<GridCoord>(xAxis.gridIndex);
|
||||
var dataZoom = chart.GetDataZoomOfAxis(xAxis);
|
||||
if (!serie.show || serie.animation.HasFadeOut())
|
||||
return;
|
||||
|
||||
var isY = ComponentHelper.IsAnyCategoryOfYAxis(chart.components);
|
||||
|
||||
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);
|
||||
|
||||
if (showData.Count <= 0)
|
||||
return;
|
||||
|
||||
var axisLength = isY ? grid.context.height : grid.context.width;
|
||||
|
||||
var isStack = SeriesHelper.IsStack<Bar>(chart.series, serie.stack);
|
||||
m_StackSerieData.Clear();
|
||||
if (isStack) SeriesHelper.UpdateStackDataList(chart.series, serie, dataZoom, m_StackSerieData);
|
||||
float categoryWidth = AxisHelper.GetDataWidth(xAxis, grid.context.width, showData.Count, dataZoom);
|
||||
if (isStack)
|
||||
SeriesHelper.UpdateStackDataList(chart.series, serie, dataZoom, m_StackSerieData);
|
||||
|
||||
float categoryWidth = AxisHelper.GetDataWidth(axis, axisLength, showData.Count, dataZoom);
|
||||
float barGap = chart.GetSerieBarGap<Bar>();
|
||||
float totalBarWidth = chart.GetSerieTotalWidth<Bar>(categoryWidth, barGap);
|
||||
float barWidth = serie.GetBarWidth(categoryWidth);
|
||||
float offset = (categoryWidth - totalBarWidth) / 2;
|
||||
float offset = (categoryWidth - totalBarWidth) * 0.5f;
|
||||
float barGapWidth = barWidth + barWidth * barGap;
|
||||
float space = serie.barGap == -1 ? offset : offset + chart.GetSerieIndexIfStack<Bar>(serie) * barGapWidth;
|
||||
int maxCount = serie.maxShow > 0
|
||||
@@ -266,10 +292,8 @@ namespace XCharts
|
||||
var isPercentStack = SeriesHelper.IsPercentStack<Bar>(chart.series, serie.stack);
|
||||
bool dataChanging = false;
|
||||
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
double xMinValue = xAxis.context.minValue;
|
||||
double xMaxValue = xAxis.context.maxValue;
|
||||
double yMinValue = yAxis.context.minValue;
|
||||
double yMaxValue = yAxis.context.maxValue;
|
||||
double yMinValue = relativedAxis.context.minValue;
|
||||
double yMaxValue = relativedAxis.context.maxValue;
|
||||
var isAllBarEnd = true;
|
||||
serie.containerIndex = grid.index;
|
||||
serie.containterInstanceId = grid.instanceId;
|
||||
@@ -281,88 +305,40 @@ namespace XCharts
|
||||
serie.context.dataPoints.Add(Vector3.zero);
|
||||
continue;
|
||||
}
|
||||
var highlight = serie.data[i].context.highlighted
|
||||
|| serie.highlighted;
|
||||
if (serieData.IsDataChanged())
|
||||
dataChanging = true;
|
||||
|
||||
var highlight = serieData.context.highlight || serie.highlight;
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight);
|
||||
double value = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
|
||||
float borderWidth = value == 0 ? 0 : itemStyle.runtimeBorderWidth;
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
float pX = grid.context.x + i * categoryWidth;
|
||||
if (xAxis.IsValue() || xAxis.IsTime())
|
||||
{
|
||||
space = 0;
|
||||
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 value = axis.IsCategory() ? i : serieData.GetData(0, axis.inverse);
|
||||
var relativedValue = serieData.GetCurrData(1, dataChangeDuration, relativedAxis.inverse, yMinValue, yMaxValue);
|
||||
var borderWidth = relativedValue == 0 ? 0 : itemStyle.runtimeBorderWidth;
|
||||
|
||||
var pX = 0f;
|
||||
var pY = 0f;
|
||||
UpdateXYPosition(grid, isY, axis, relativedAxis, i, categoryWidth, barWidth, isStack, value, ref pX, ref pY);
|
||||
|
||||
var barHig = 0f;
|
||||
double valueTotal = 0f;
|
||||
if (isPercentStack)
|
||||
{
|
||||
valueTotal = chart.GetSerieSameStackTotalValue<Bar>(serie.stack, i);
|
||||
barHig = valueTotal != 0 ? (float)(value / valueTotal * grid.context.height) : 0;
|
||||
var valueTotal = chart.GetSerieSameStackTotalValue<Bar>(serie.stack, i);
|
||||
barHig = valueTotal != 0 ? (float)(relativedValue / valueTotal * axisLength) : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
valueTotal = (double)(yMaxValue - yMinValue);
|
||||
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);
|
||||
}
|
||||
}
|
||||
barHig = AxisHelper.GetAxisValueLength(grid, relativedAxis, categoryWidth, relativedValue);
|
||||
}
|
||||
serieData.context.stackHeight = barHig;
|
||||
|
||||
var isBarEnd = false;
|
||||
float currHig = chart.CheckSerieBarAnimation(serie, i, barHig, out isBarEnd);
|
||||
if (!isBarEnd) isAllBarEnd = false;
|
||||
if (!isBarEnd)
|
||||
isAllBarEnd = false;
|
||||
|
||||
Vector3 plb, plt, prt, prb, top;
|
||||
if (value < 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);
|
||||
}
|
||||
UpdateRectPosition(grid, isY, relativedValue, pX, pY, space, borderWidth, barWidth, currHig,
|
||||
out plb, out plt, out prt, out prb, out top);
|
||||
serieData.context.stackHeight = barHig;
|
||||
serieData.context.position = top;
|
||||
serieData.context.rect = Rect.MinMaxRect(plb.x, plb.y, prb.x, prt.y);
|
||||
serie.context.dataPoints.Add(top);
|
||||
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,
|
||||
bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
||||
Vector3 prb, bool isYAxis, GridCoord grid)
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace XCharts
|
||||
serie.context.dataPoints.Add(Vector3.zero);
|
||||
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 open = serieData.GetCurrData(0, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
|
||||
var close = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
|
||||
|
||||
@@ -44,12 +44,12 @@ namespace XCharts
|
||||
{
|
||||
serie.context.pointerItemDataIndex = serieData.index;
|
||||
serie.context.pointerEnter = true;
|
||||
serieData.context.highlighted = true;
|
||||
serieData.context.highlight = true;
|
||||
chart.RefreshTopPainter();
|
||||
}
|
||||
else
|
||||
{
|
||||
serieData.context.highlighted = false;
|
||||
serieData.context.highlight = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,7 +122,7 @@ namespace XCharts
|
||||
color = visualMap.GetColor(value);
|
||||
if (animationIndex >= 0 && i > animationIndex) continue;
|
||||
serieData.context.canShowLabel = true;
|
||||
var emphasis = (serieData.context.highlighted)
|
||||
var emphasis = (serieData.context.highlight)
|
||||
|| visualMap.context.pointerIndex > 0;
|
||||
|
||||
UGL.DrawRectangle(vh, pos, rectWid / 2, rectHig / 2, color);
|
||||
|
||||
@@ -93,9 +93,6 @@ namespace XCharts
|
||||
|
||||
public override void DrawSerie(VertexHelper vh)
|
||||
{
|
||||
var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName);
|
||||
serie.context.colorIndex = colorIndex;
|
||||
|
||||
if (serie.IsUseCoord<PolarCoord>())
|
||||
{
|
||||
DrawPolarLine(vh, serie);
|
||||
@@ -145,12 +142,12 @@ namespace XCharts
|
||||
{
|
||||
serie.context.pointerItemDataIndex = serieData.index;
|
||||
serie.context.pointerEnter = true;
|
||||
serieData.context.highlighted = true;
|
||||
serieData.context.highlight = true;
|
||||
chart.RefreshTopPainter();
|
||||
}
|
||||
else
|
||||
{
|
||||
serieData.context.highlighted = false;
|
||||
serieData.context.highlight = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -196,7 +193,7 @@ namespace XCharts
|
||||
if (ChartHelper.IsIngore(serie.context.dataPoints[i]))
|
||||
continue;
|
||||
|
||||
var highlight = serie.data[i].context.highlighted || serie.highlighted;
|
||||
var highlight = serie.data[i].context.highlight || serie.highlight;
|
||||
var symbolSize = highlight
|
||||
? symbol.GetSelectedSize(serie.data[i].data, theme.serie.lineSymbolSelectedSize)
|
||||
: symbol.GetSize(serie.data[i].data, theme.serie.lineSymbolSize);
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace XCharts
|
||||
var firstSerieData = datas[0];
|
||||
var startPos = GetPolarPos(m_Polar, m_AngleAxis, firstSerieData, min, max, radius);
|
||||
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 currDetailProgress = 0f;
|
||||
var totalDetailProgress = datas.Count;
|
||||
@@ -86,9 +86,9 @@ namespace XCharts
|
||||
if (ChartHelper.IsIngore(serieData.context.position))
|
||||
continue;
|
||||
|
||||
bool highlight = serieData.context.highlighted || serie.highlighted;
|
||||
bool highlight = serieData.context.highlight || serie.highlight;
|
||||
if ((!symbol.show || !symbol.ShowSymbol(i, count) || serie.IsPerformanceMode())
|
||||
&& !serieData.context.highlighted)
|
||||
&& !serieData.context.highlight)
|
||||
continue;
|
||||
|
||||
var symbolSize = highlight
|
||||
|
||||
@@ -252,7 +252,7 @@ namespace XCharts
|
||||
var isVisualMapGradient = VisualMapHelper.IsNeedGradient(visualMap);
|
||||
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 lineColor = SerieHelper.GetLineColor(serie, theme, serie.context.colorIndex, highlight);
|
||||
|
||||
|
||||
@@ -133,16 +133,16 @@ namespace XCharts
|
||||
if (dataIndex >= 0)
|
||||
{
|
||||
if (lastDataIndex >= 0)
|
||||
serie.GetSerieData(lastDataIndex).context.highlighted = false;
|
||||
serie.GetSerieData(lastDataIndex).context.highlight = false;
|
||||
if (lastDataIndex != dataIndex)
|
||||
chart.RefreshPainter(serie);
|
||||
serie.GetSerieData(dataIndex).context.highlighted = true;
|
||||
serie.GetSerieData(dataIndex).context.highlight = true;
|
||||
serie.context.pointerItemDataIndex = dataIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lastDataIndex >= 0)
|
||||
serie.GetSerieData(lastDataIndex).context.highlighted = false;
|
||||
serie.GetSerieData(lastDataIndex).context.highlight = false;
|
||||
serie.context.pointerItemDataIndex = -1;
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,7 @@ namespace XCharts
|
||||
if (lastPointerEnter)
|
||||
{
|
||||
foreach (var serieData in serie.data)
|
||||
serieData.context.highlighted = false;
|
||||
serieData.context.highlight = false;
|
||||
}
|
||||
serie.context.pointerItemDataIndex = -1;
|
||||
}
|
||||
@@ -213,7 +213,7 @@ namespace XCharts
|
||||
serieData.context.outsideRadius = serie.pieRoseType > 0 ?
|
||||
serie.context.insideRadius + (float)((serie.context.outsideRadius - serie.context.insideRadius) * value / serie.context.dataMax) :
|
||||
serie.context.outsideRadius;
|
||||
if (serieData.context.highlighted)
|
||||
if (serieData.context.highlight)
|
||||
{
|
||||
serieData.context.outsideRadius += chart.theme.serie.pieTooltipExtraRadius;
|
||||
}
|
||||
@@ -311,13 +311,13 @@ namespace XCharts
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.context.highlighted);
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.context.highlight);
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
var serieNameCount = chart.m_LegendRealShowName.IndexOf(serieData.legendName);
|
||||
var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieNameCount,
|
||||
serieData.context.highlighted);
|
||||
serieData.context.highlight);
|
||||
var toColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieNameCount,
|
||||
serieData.context.highlighted);
|
||||
serieData.context.highlight);
|
||||
var borderWidth = itemStyle.borderWidth;
|
||||
var borderColor = itemStyle.borderColor;
|
||||
|
||||
@@ -372,7 +372,7 @@ namespace XCharts
|
||||
{
|
||||
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;
|
||||
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 labelLine = SerieHelper.GetSerieLabelLine(serie, serieData);
|
||||
var iconStyle = SerieHelper.GetIconStyle(serie, serieData);
|
||||
|
||||
@@ -247,7 +247,7 @@ namespace XCharts
|
||||
|
||||
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;
|
||||
var selectedSerieIndex = tooltip.runtimeDataIndex[0];
|
||||
if (selectedSerieIndex < 0) return false;
|
||||
@@ -406,7 +406,7 @@ namespace XCharts
|
||||
{
|
||||
var serieData = serie.data[j];
|
||||
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);
|
||||
var serieIndex = serieData.index;
|
||||
var symbolSize = isHighlight
|
||||
|
||||
@@ -84,9 +84,9 @@ namespace XCharts
|
||||
var degree = (float)(360 * value / max);
|
||||
var startDegree = GetStartAngle(serie);
|
||||
var toDegree = GetToAngle(serie, degree);
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.context.highlighted);
|
||||
var itemColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, j, serieData.context.highlighted);
|
||||
var itemToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, j, serieData.context.highlighted);
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.context.highlight);
|
||||
var itemColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, j, serieData.context.highlight);
|
||||
var itemToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, j, serieData.context.highlight);
|
||||
var outsideRadius = serie.context.outsideRadius - j * (ringWidth + serie.ringGap);
|
||||
var insideRadius = outsideRadius - ringWidth;
|
||||
var centerRadius = (outsideRadius + insideRadius) / 2;
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace XCharts
|
||||
var symbolSize = symbol.GetSize(serieData.data, themeSymbolSize);
|
||||
if (Vector3.Distance(serieData.context.position, chart.pointerPos) <= symbolSize)
|
||||
{
|
||||
serieData.context.highlighted = true;
|
||||
serieData.context.highlight = true;
|
||||
serie.context.pointerItemDataIndex = lastDataIndex;
|
||||
return;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ namespace XCharts
|
||||
serie.context.pointerItemDataIndex = -1;
|
||||
if (lastDataIndex >= 0)
|
||||
{
|
||||
serie.GetSerieData(lastDataIndex).context.highlighted = false;
|
||||
serie.GetSerieData(lastDataIndex).context.highlight = false;
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
for (int i = serie.dataCount - 1; i >= 0; i--)
|
||||
@@ -112,7 +112,7 @@ namespace XCharts
|
||||
var symbolSize = symbol.GetSize(serieData.data, themeSymbolSize);
|
||||
if (Vector3.Distance(serieData.context.position, chart.pointerPos) <= symbolSize)
|
||||
{
|
||||
serieData.context.highlighted = true;
|
||||
serieData.context.highlight = true;
|
||||
serie.context.pointerItemDataIndex = i;
|
||||
serie.context.pointerEnter = true;
|
||||
chart.RefreshPainter(serie);
|
||||
@@ -165,7 +165,7 @@ namespace XCharts
|
||||
if (!symbol.ShowSymbol(serieData.index, maxCount))
|
||||
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 toColor = SerieHelper.GetItemToColor(serie, serieData, theme, colorIndex, highlight);
|
||||
var emptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, colorIndex, highlight, false);
|
||||
@@ -191,7 +191,7 @@ namespace XCharts
|
||||
var datas = serieData.data;
|
||||
float symbolSize = 0;
|
||||
|
||||
if (serie.highlighted || serieData.context.highlighted)
|
||||
if (serie.highlight || serieData.context.highlight)
|
||||
{
|
||||
symbolSize = symbol.GetSelectedSize(datas, theme.serie.scatterSymbolSelectedSize);
|
||||
}
|
||||
@@ -267,7 +267,7 @@ namespace XCharts
|
||||
if (!symbol.ShowSymbol(serieData.index, maxCount))
|
||||
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 toColor = SerieHelper.GetItemToColor(serie, serieData, theme, colorIndex, highlight);
|
||||
var emptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, colorIndex, highlight, false);
|
||||
@@ -296,7 +296,7 @@ namespace XCharts
|
||||
|
||||
var datas = serieData.data;
|
||||
var symbolSize = 0f;
|
||||
if (serie.highlighted || serieData.context.highlighted)
|
||||
if (serie.highlight || serieData.context.highlight)
|
||||
symbolSize = symbol.GetSelectedSize(datas, theme.serie.scatterSymbolSelectedSize);
|
||||
else
|
||||
symbolSize = symbol.GetSize(datas, theme.serie.scatterSymbolSize);
|
||||
|
||||
@@ -232,7 +232,7 @@ namespace XCharts
|
||||
[SerializeField] private float[] m_Radius = new float[2] { 0, 80 };
|
||||
[SerializeField] private LabelStyle m_Label = new LabelStyle();
|
||||
[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 ItemStyle m_ItemStyle = new ItemStyle();
|
||||
[SerializeField] private Emphasis m_Emphasis = new Emphasis();
|
||||
@@ -745,7 +745,7 @@ namespace XCharts
|
||||
/// The start animation.
|
||||
/// 起始动画。
|
||||
/// </summary>
|
||||
public SerieAnimation animation
|
||||
public AnimationStyle animation
|
||||
{
|
||||
get { return m_Animation; }
|
||||
set { if (PropertyUtil.SetClass(ref m_Animation, value, true)) SetVerticesDirty(); }
|
||||
@@ -981,7 +981,7 @@ namespace XCharts
|
||||
/// Whether the serie is highlighted.
|
||||
/// 该系列是否高亮,一般由图例悬停触发。
|
||||
/// </summary>
|
||||
public bool highlighted { get; internal set; }
|
||||
public bool highlight { get; internal set; }
|
||||
/// <summary>
|
||||
/// the count of data list.
|
||||
/// 数据项个数。
|
||||
@@ -1575,9 +1575,9 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public void ClearHighlight()
|
||||
{
|
||||
highlighted = false;
|
||||
highlight = false;
|
||||
foreach (var serieData in m_Data)
|
||||
serieData.context.highlighted = false;
|
||||
serieData.context.highlight = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1587,7 +1587,7 @@ namespace XCharts
|
||||
{
|
||||
var serieData = GetSerieData(index);
|
||||
if (serieData != null)
|
||||
serieData.context.highlighted = flag;
|
||||
serieData.context.highlight = flag;
|
||||
}
|
||||
|
||||
public float GetBarWidth(float categoryWidth)
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace XCharts
|
||||
m_Show = true;
|
||||
m_Selected = false;
|
||||
context.canShowLabel = true;
|
||||
context.highlighted = false;
|
||||
context.highlight = false;
|
||||
m_Radius = 0;
|
||||
m_Data.Clear();
|
||||
m_PreviousData.Clear();
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace XCharts
|
||||
/// Whether the data item is highlighted.
|
||||
/// 该数据项是否被高亮,一般由鼠标悬停或图例悬停触发高亮。
|
||||
/// </summary>
|
||||
public bool highlighted { get; set; }
|
||||
public bool highlight { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user