mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-28 03:58:49 +00:00
3.0 - scatter chart and candlestick chart
This commit is contained in:
@@ -167,6 +167,12 @@ namespace XCharts.Editor
|
|||||||
{
|
{
|
||||||
m_Series.Add(prop.GetArrayElementAtIndex(i));
|
m_Series.Add(prop.GetArrayElementAtIndex(i));
|
||||||
}
|
}
|
||||||
|
m_Series.Sort(delegate (SerializedProperty a, SerializedProperty b)
|
||||||
|
{
|
||||||
|
var index1 = a.FindPropertyRelative("m_Index").intValue;
|
||||||
|
var index2 = b.FindPropertyRelative("m_Index").intValue;
|
||||||
|
return index1.CompareTo(index2);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddComponent()
|
private void AddComponent()
|
||||||
|
|||||||
@@ -102,8 +102,11 @@ namespace XCharts.Editor
|
|||||||
|
|
||||||
for (int i = 0; i < chart.series.Count; i++)
|
for (int i = 0; i < chart.series.Count; i++)
|
||||||
{
|
{
|
||||||
if (chart.series[i] != null)
|
var serie = chart.series[i];
|
||||||
CreateEditor(chart.series[i], m_SeriesProperty[i]);
|
if (serie != null)
|
||||||
|
{
|
||||||
|
CreateEditor(serie, m_SeriesProperty[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,6 +189,7 @@ namespace XCharts.Editor
|
|||||||
{
|
{
|
||||||
m_SerializedObject.Update();
|
m_SerializedObject.Update();
|
||||||
var serieName = chart.GenerateDefaultSerieName();
|
var serieName = chart.GenerateDefaultSerieName();
|
||||||
|
UnityEngine.Debug.LogError("AddSerie:" + type);
|
||||||
type.InvokeMember("AddDefaultSerie",
|
type.InvokeMember("AddDefaultSerie",
|
||||||
BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public, null, null,
|
BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public, null, null,
|
||||||
new object[] { chart, serieName });
|
new object[] { chart, serieName });
|
||||||
|
|||||||
@@ -193,14 +193,14 @@ MonoBehaviour:
|
|||||||
m_PieSelectedOffset: 8
|
m_PieSelectedOffset: 8
|
||||||
m_CandlestickColor:
|
m_CandlestickColor:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
rgba: 4281415106
|
rgba: 4283846390
|
||||||
m_CandlestickColor0:
|
m_CandlestickColor0:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
rgba: 4283844145
|
rgba: 4287818324
|
||||||
m_CandlestickBorderWidth: 1
|
m_CandlestickBorderWidth: 1
|
||||||
m_CandlestickBorderColor:
|
m_CandlestickBorderColor:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
rgba: 4281415106
|
rgba: 4283846390
|
||||||
m_CandlestickBorderColor0:
|
m_CandlestickBorderColor0:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
rgba: 4283844145
|
rgba: 4287818324
|
||||||
|
|||||||
@@ -3,9 +3,8 @@
|
|||||||
--- !u!114 &11400000
|
--- !u!114 &11400000
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
m_PrefabParentObject: {fileID: 0}
|
||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInternal: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 0}
|
m_GameObject: {fileID: 0}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
@@ -194,14 +193,14 @@ MonoBehaviour:
|
|||||||
m_PieSelectedOffset: 8
|
m_PieSelectedOffset: 8
|
||||||
m_CandlestickColor:
|
m_CandlestickColor:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
rgba: 4281415106
|
rgba: 4283716843
|
||||||
m_CandlestickColor0:
|
m_CandlestickColor0:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
rgba: 4283844145
|
rgba: 4284658247
|
||||||
m_CandlestickBorderWidth: 1
|
m_CandlestickBorderWidth: 1
|
||||||
m_CandlestickBorderColor:
|
m_CandlestickBorderColor:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
rgba: 4281415106
|
rgba: 4283716843
|
||||||
m_CandlestickBorderColor0:
|
m_CandlestickBorderColor0:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
rgba: 4283844145
|
rgba: 4284658247
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace XCharts
|
|||||||
HorizontalLine
|
HorizontalLine
|
||||||
}
|
}
|
||||||
|
|
||||||
[SerializeField] private bool m_Show = false;
|
[SerializeField] private bool m_Show = true;
|
||||||
[SerializeField] private LineType m_LineType = LineType.BrokenLine;
|
[SerializeField] private LineType m_LineType = LineType.BrokenLine;
|
||||||
[SerializeField] private Color32 m_LineColor = ChartConst.clearColor32;
|
[SerializeField] private Color32 m_LineColor = ChartConst.clearColor32;
|
||||||
[SerializeField] private float m_LineWidth = 1.0f;
|
[SerializeField] private float m_LineWidth = 1.0f;
|
||||||
|
|||||||
@@ -247,9 +247,10 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
var symbolSize = symbol.GetSize(null, theme.serie.lineSymbolSize);
|
var symbolSize = symbol.GetSize(null, theme.serie.lineSymbolSize);
|
||||||
var tickness = SerieHelper.GetSymbolBorder(serie, null, theme, false);
|
var tickness = SerieHelper.GetSymbolBorder(serie, null, theme, false);
|
||||||
|
var borderColor = SerieHelper.GetSymbolBorderColor(serie, null, theme, false);
|
||||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, null, false);
|
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, null, false);
|
||||||
chart.DrawClipSymbol(vh, symbol.type, symbolSize, tickness, pos, lineColor, lineColor,
|
chart.DrawClipSymbol(vh, symbol.type, symbolSize, tickness, pos, lineColor, lineColor,
|
||||||
ColorUtil.clearColor32, symbol.gap, true, cornerRadius, grid, startPos);
|
ColorUtil.clearColor32, borderColor, symbol.gap, true, cornerRadius, grid, startPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GetStartEndPos(Axis xAxis, Axis yAxis, GridCoord grid, double value, ref Vector3 sp, ref Vector3 ep)
|
private void GetStartEndPos(Axis xAxis, Axis yAxis, GridCoord grid, double value, ref Vector3 sp, ref Vector3 ep)
|
||||||
|
|||||||
@@ -465,30 +465,36 @@ namespace XCharts
|
|||||||
|
|
||||||
public static Color32 GetAreaColor(Serie serie, ThemeStyle theme, int index, bool highlight)
|
public static Color32 GetAreaColor(Serie serie, ThemeStyle theme, int index, bool highlight)
|
||||||
{
|
{
|
||||||
|
Color32 color = ChartConst.clearColor32;
|
||||||
var areaStyle = serie.areaStyle;
|
var areaStyle = serie.areaStyle;
|
||||||
if (areaStyle == null || !areaStyle.show)
|
if (areaStyle == null || !areaStyle.show)
|
||||||
return ColorUtil.clearColor32;
|
return color;
|
||||||
var color = !ChartHelper.IsClearColor(areaStyle.color)
|
|
||||||
? areaStyle.color : theme.GetColor(index);
|
|
||||||
if (highlight)
|
if (highlight)
|
||||||
{
|
{
|
||||||
if (!ChartHelper.IsClearColor(areaStyle.highlightColor))
|
if (!ChartHelper.IsClearColor(areaStyle.highlightColor))
|
||||||
color = areaStyle.highlightColor;
|
color = areaStyle.highlightColor;
|
||||||
else
|
else
|
||||||
color = ChartHelper.GetHighlightColor(color);
|
color = ChartHelper.GetHighlightColor(color);
|
||||||
|
ChartHelper.SetColorOpacity(ref color, areaStyle.opacity);
|
||||||
|
return color;
|
||||||
}
|
}
|
||||||
|
if (!ChartHelper.IsClearColor(areaStyle.color)) color = areaStyle.color;
|
||||||
|
else if (!ChartHelper.IsClearColor(serie.itemStyle.color)) color = serie.itemStyle.color;
|
||||||
|
else color = theme.GetColor(index);
|
||||||
ChartHelper.SetColorOpacity(ref color, areaStyle.opacity);
|
ChartHelper.SetColorOpacity(ref color, areaStyle.opacity);
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Color32 GetAreaToColor(Serie serie, ThemeStyle theme, int index, bool highlight)
|
public static Color32 GetAreaToColor(Serie serie, ThemeStyle theme, int index, bool highlight)
|
||||||
{
|
{
|
||||||
|
Color32 color = ChartConst.clearColor32;
|
||||||
var areaStyle = serie.areaStyle;
|
var areaStyle = serie.areaStyle;
|
||||||
if (areaStyle == null || !areaStyle.show)
|
if (areaStyle == null || !areaStyle.show)
|
||||||
return ColorUtil.clearColor32;
|
return color;
|
||||||
if (!ChartHelper.IsClearColor(areaStyle.toColor))
|
if (!ChartHelper.IsClearColor(areaStyle.toColor))
|
||||||
{
|
{
|
||||||
var color = areaStyle.toColor;
|
color = areaStyle.toColor;
|
||||||
if (highlight)
|
if (highlight)
|
||||||
{
|
{
|
||||||
if (!ChartHelper.IsClearColor(areaStyle.highlightToColor)) color = areaStyle.highlightToColor;
|
if (!ChartHelper.IsClearColor(areaStyle.highlightToColor)) color = areaStyle.highlightToColor;
|
||||||
@@ -534,6 +540,13 @@ namespace XCharts
|
|||||||
else return serie.lineStyle.GetWidth(theme.serie.lineWidth) * 2;
|
else return serie.lineStyle.GetWidth(theme.serie.lineWidth) * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Color32 GetSymbolBorderColor(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight)
|
||||||
|
{
|
||||||
|
var itemStyle = GetItemStyle(serie, serieData, highlight);
|
||||||
|
if (itemStyle != null && !ChartHelper.IsClearColor(itemStyle.borderColor)) return itemStyle.borderColor;
|
||||||
|
else return serie.itemStyle.borderColor;
|
||||||
|
}
|
||||||
|
|
||||||
public static float GetSymbolBorder(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight, float defaultWidth)
|
public static float GetSymbolBorder(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight, float defaultWidth)
|
||||||
{
|
{
|
||||||
var itemStyle = GetItemStyle(serie, serieData, highlight);
|
var itemStyle = GetItemStyle(serie, serieData, highlight);
|
||||||
|
|||||||
@@ -18,11 +18,12 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ResetLabel(ChartText labelObject, LabelStyle label, ThemeStyle theme)
|
public static void ResetLabel(ChartText labelObject, LabelStyle label, ThemeStyle theme,
|
||||||
|
Color textColor, float rotate)
|
||||||
{
|
{
|
||||||
if (labelObject == null) return;
|
if (labelObject == null) return;
|
||||||
labelObject.SetColor(!ChartHelper.IsClearColor(label.textStyle.color) ? label.textStyle.color :
|
labelObject.SetColor(textColor);
|
||||||
theme.common.textColor);
|
labelObject.SetLocalEulerAngles(new Vector3(0, 0, rotate));
|
||||||
labelObject.SetFontSize(label.textStyle.GetFontSize(theme.common));
|
labelObject.SetFontSize(label.textStyle.GetFontSize(theme.common));
|
||||||
labelObject.SetFontStyle(label.textStyle.fontStyle);
|
labelObject.SetFontStyle(label.textStyle.fontStyle);
|
||||||
}
|
}
|
||||||
@@ -247,6 +248,9 @@ namespace XCharts
|
|||||||
|
|
||||||
public static Vector3 GetRealLabelPosition(SerieData serieData, LabelStyle label, LabelLine labelLine)
|
public static Vector3 GetRealLabelPosition(SerieData serieData, LabelStyle label, LabelLine labelLine)
|
||||||
{
|
{
|
||||||
|
if (label == null || labelLine == null)
|
||||||
|
return serieData.context.labelPosition;
|
||||||
|
|
||||||
if (label.position == LabelStyle.Position.Outside && labelLine.lineType != LabelLine.LineType.HorizontalLine)
|
if (label.position == LabelStyle.Position.Outside && labelLine.lineType != LabelLine.LineType.HorizontalLine)
|
||||||
{
|
{
|
||||||
var currAngle = serieData.context.halfAngle;
|
var currAngle = serieData.context.halfAngle;
|
||||||
|
|||||||
@@ -83,12 +83,13 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void DrawClipSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
|
public void DrawClipSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
|
||||||
Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, float gap, bool clip, float[] cornerRadius, GridCoord grid,
|
Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor, float gap,
|
||||||
Vector3 startPos)
|
bool clip, float[] cornerRadius, GridCoord grid, Vector3 startPos)
|
||||||
{
|
{
|
||||||
if (!IsInChart(pos)) return;
|
if (!IsInChart(pos)) return;
|
||||||
if (!clip || (clip && (grid.Contains(pos))))
|
if (!clip || (clip && (grid.Contains(pos))))
|
||||||
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, emptyColor, gap, cornerRadius, startPos);
|
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, emptyColor, borderColor,
|
||||||
|
gap, cornerRadius, startPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawClipZebraLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size, float zebraWidth,
|
public void DrawClipZebraLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size, float zebraWidth,
|
||||||
@@ -99,21 +100,24 @@ namespace XCharts
|
|||||||
UGL.DrawZebraLine(vh, p1, p2, size, zebraWidth, zebraGap, color, toColor, maxDistance);
|
UGL.DrawZebraLine(vh, p1, p2, size, zebraWidth, zebraGap, color, toColor, maxDistance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize,
|
public void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
|
||||||
float tickness, Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, float gap, float[] cornerRadius)
|
Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor,
|
||||||
|
float gap, float[] cornerRadius)
|
||||||
{
|
{
|
||||||
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, emptyColor, gap, cornerRadius, Vector3.zero);
|
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, emptyColor, borderColor,
|
||||||
|
gap, cornerRadius, Vector3.zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize,
|
public void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
|
||||||
float tickness, Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, float gap, float[] cornerRadius, Vector3 startPos)
|
Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor,
|
||||||
|
float gap, float[] cornerRadius, Vector3 startPos)
|
||||||
{
|
{
|
||||||
var backgroundColor = theme.GetBackgroundColor(GetChartComponent<Background>());
|
var backgroundColor = theme.GetBackgroundColor(GetChartComponent<Background>());
|
||||||
if (ChartHelper.IsClearColor(emptyColor))
|
if (ChartHelper.IsClearColor(emptyColor))
|
||||||
emptyColor = backgroundColor;
|
emptyColor = backgroundColor;
|
||||||
var smoothness = settings.cicleSmoothness;
|
var smoothness = settings.cicleSmoothness;
|
||||||
ChartDrawer.DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, gap,
|
ChartDrawer.DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, gap,
|
||||||
cornerRadius, emptyColor, backgroundColor, smoothness, startPos);
|
cornerRadius, emptyColor, backgroundColor, borderColor, smoothness, startPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color32 GetXLerpColor(Color32 areaColor, Color32 areaToColor, Vector3 pos, GridCoord grid)
|
public Color32 GetXLerpColor(Color32 areaColor, Color32 areaToColor, Vector3 pos, GridCoord grid)
|
||||||
|
|||||||
@@ -824,8 +824,6 @@ namespace XCharts
|
|||||||
return serie;
|
return serie;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void ResetSeriesIndex()
|
private void ResetSeriesIndex()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_Series.Count; i++)
|
for (int i = 0; i < m_Series.Count; i++)
|
||||||
|
|||||||
@@ -9,10 +9,9 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
public static class ChartDrawer
|
public static class ChartDrawer
|
||||||
{
|
{
|
||||||
|
public static void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
|
||||||
public static void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize,
|
Vector3 pos, Color32 color, Color32 toColor, float gap, float[] cornerRadius,
|
||||||
float tickness, Vector3 pos, Color32 color, Color32 toColor, float gap, float[] cornerRadius,
|
Color32 emptyColor, Color32 backgroundColor, Color32 borderColor, float smoothness, Vector3 startPos)
|
||||||
Color32 emptyColor, Color32 backgroundColor, float smoothness, Vector3 startPos)
|
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
@@ -25,7 +24,10 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UGL.DrawCricle(vh, pos, symbolSize, color, toColor, smoothness);
|
if (tickness > 0)
|
||||||
|
UGL.DrawDoughnut(vh, pos, symbolSize, symbolSize + tickness, borderColor, borderColor, color, smoothness);
|
||||||
|
else
|
||||||
|
UGL.DrawCricle(vh, pos, symbolSize, color, toColor, smoothness);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SymbolType.EmptyCircle:
|
case SymbolType.EmptyCircle:
|
||||||
@@ -47,7 +49,13 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UGL.DrawRoundRectangle(vh, pos, symbolSize, symbolSize, color, color, 0, cornerRadius, true);
|
if (tickness > 0)
|
||||||
|
{
|
||||||
|
UGL.DrawRoundRectangle(vh, pos, symbolSize, symbolSize, color, color, 0, cornerRadius, true);
|
||||||
|
UGL.DrawBorder(vh, pos, symbolSize, symbolSize, tickness, borderColor, 0, cornerRadius);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
UGL.DrawRoundRectangle(vh, pos, symbolSize, symbolSize, color, color, 0, cornerRadius, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SymbolType.EmptyRect:
|
case SymbolType.EmptyRect:
|
||||||
|
|||||||
@@ -230,9 +230,10 @@ namespace XCharts
|
|||||||
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, theme, serie.index, highlight);
|
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, theme, serie.index, highlight);
|
||||||
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, serie.index, highlight, false);
|
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, serie.index, highlight, false);
|
||||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, highlight);
|
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, highlight);
|
||||||
|
var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, theme, highlight);
|
||||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
|
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
|
||||||
chart.DrawClipSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
|
chart.DrawClipSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
|
||||||
symbolColor, symbolToColor, symbolEmptyColor, symbol.gap, clip, cornerRadius, m_SerieGrid,
|
symbolColor, symbolToColor, symbolEmptyColor, borderColor, symbol.gap, clip, cornerRadius, m_SerieGrid,
|
||||||
i > 0 ? serie.context.dataPoints[i - 1] : m_SerieGrid.context.position);
|
i > 0 ? serie.context.dataPoints[i - 1] : m_SerieGrid.context.position);
|
||||||
}
|
}
|
||||||
if (interacting)
|
if (interacting)
|
||||||
|
|||||||
@@ -91,11 +91,12 @@ namespace XCharts
|
|||||||
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, n, highlight);
|
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, n, highlight);
|
||||||
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, n, highlight, false);
|
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, n, highlight, false);
|
||||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, highlight);
|
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, highlight);
|
||||||
|
var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, chart.theme, highlight);
|
||||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
|
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
|
||||||
|
|
||||||
symbolSize = serie.animation.GetSysmbolSize(symbolSize);
|
symbolSize = serie.animation.GetSysmbolSize(symbolSize);
|
||||||
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, serieData.context.position,
|
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, serieData.context.position,
|
||||||
symbolColor, symbolToColor, symbolEmptyColor, symbol.gap, cornerRadius);
|
symbolColor, symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
|
base.Update();
|
||||||
UpdateSerieContext();
|
UpdateSerieContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,23 +31,10 @@ namespace XCharts
|
|||||||
marker, itemFormatter, numericFormatter);
|
marker, itemFormatter, numericFormatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void RefreshLabelInternal()
|
public override Vector3 GetSerieDataLabelPosition(SerieData serieData, LabelStyle label)
|
||||||
{
|
{
|
||||||
var data = serie.data;
|
var labelLine = SerieHelper.GetSerieLabelLine(serie, serieData);
|
||||||
for (int n = 0; n < data.Count; n++)
|
return SerieLabelHelper.GetRealLabelPosition(serieData, label, labelLine);
|
||||||
{
|
|
||||||
var serieData = data[n];
|
|
||||||
if (!serieData.context.canShowLabel || serie.IsIgnoreValue(serieData))
|
|
||||||
{
|
|
||||||
serieData.SetLabelActive(false);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!serieData.show) continue;
|
|
||||||
|
|
||||||
var colorIndex = chart.GetLegendRealShowNameIndex(serieData.name);
|
|
||||||
Color color = chart.theme.GetColor(colorIndex);
|
|
||||||
DrawPieLabel(serie, n, serieData, color);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnLegendButtonClick(int index, string legendName, bool show)
|
public override void OnLegendButtonClick(int index, string legendName, bool show)
|
||||||
@@ -103,8 +91,7 @@ namespace XCharts
|
|||||||
|
|
||||||
private void UpdateSerieContext()
|
private void UpdateSerieContext()
|
||||||
{
|
{
|
||||||
var needCheck = m_LegendEnter
|
var needCheck = m_LegendEnter || (chart.isPointerInChart && PointerIsInPieSerie(serie, chart.pointerPos));
|
||||||
|| (chart.isPointerInChart && PointerIsInPieSerie(serie, chart.pointerPos));
|
|
||||||
var needInteract = false;
|
var needInteract = false;
|
||||||
if (!needCheck)
|
if (!needCheck)
|
||||||
{
|
{
|
||||||
@@ -118,6 +105,7 @@ namespace XCharts
|
|||||||
var colorIndex = chart.GetLegendRealShowNameIndex(serieData.legendName);
|
var colorIndex = chart.GetLegendRealShowNameIndex(serieData.legendName);
|
||||||
var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, false);
|
var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, false);
|
||||||
var toColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, colorIndex, false);
|
var toColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, colorIndex, false);
|
||||||
|
serieData.context.highlight = false;
|
||||||
serieData.interact.SetValueAndColor(ref needInteract, serieData.context.outsideRadius, color, toColor);
|
serieData.interact.SetValueAndColor(ref needInteract, serieData.context.outsideRadius, color, toColor);
|
||||||
}
|
}
|
||||||
if (needInteract)
|
if (needInteract)
|
||||||
@@ -375,7 +363,8 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
foreach (var serie in chart.series)
|
foreach (var serie in chart.series)
|
||||||
{
|
{
|
||||||
if (serie is Pie && serie.pieClickOffset) return true;
|
if (serie is Pie && serie.pieClickOffset)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -388,7 +377,8 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
foreach (var serieData in serie.data)
|
foreach (var serieData in serie.data)
|
||||||
{
|
{
|
||||||
if (serieData.context.highlight) return true;
|
if (serieData.context.highlight)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -421,8 +411,12 @@ namespace XCharts
|
|||||||
var outSideRadius = serieData.context.outsideRadius;
|
var outSideRadius = serieData.context.outsideRadius;
|
||||||
var center = serie.context.center;
|
var center = serie.context.center;
|
||||||
var currAngle = serieData.context.halfAngle;
|
var currAngle = serieData.context.halfAngle;
|
||||||
if (!ChartHelper.IsClearColor(labelLine.lineColor)) color = labelLine.lineColor;
|
|
||||||
else if (labelLine.lineType == LabelLine.LineType.HorizontalLine) color *= color;
|
if (!ChartHelper.IsClearColor(labelLine.lineColor))
|
||||||
|
color = labelLine.lineColor;
|
||||||
|
else if (labelLine.lineType == LabelLine.LineType.HorizontalLine)
|
||||||
|
color *= color;
|
||||||
|
|
||||||
float currSin = Mathf.Sin(currAngle * Mathf.Deg2Rad);
|
float currSin = Mathf.Sin(currAngle * Mathf.Deg2Rad);
|
||||||
float currCos = Mathf.Cos(currAngle * Mathf.Deg2Rad);
|
float currCos = Mathf.Cos(currAngle * Mathf.Deg2Rad);
|
||||||
var radius1 = labelLine.lineType == LabelLine.LineType.HorizontalLine ?
|
var radius1 = labelLine.lineType == LabelLine.LineType.HorizontalLine ?
|
||||||
@@ -492,91 +486,26 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawPieLabel(Serie serie, int dataIndex, SerieData serieData, Color serieColor)
|
|
||||||
{
|
|
||||||
if (serieData.labelObject == null) return;
|
|
||||||
var emphasis = serie.emphasis;
|
|
||||||
var currAngle = serieData.context.halfAngle;
|
|
||||||
var isHighlight = (serieData.context.highlight && emphasis != null && emphasis.label.show);
|
|
||||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
|
||||||
var labelLine = SerieHelper.GetSerieLabelLine(serie, serieData);
|
|
||||||
var iconStyle = SerieHelper.GetIconStyle(serie, serieData);
|
|
||||||
var showLabel = ((serieLabel.show || isHighlight) && serieData.context.canShowLabel);
|
|
||||||
if (showLabel)
|
|
||||||
{
|
|
||||||
serieData.SetLabelActive(showLabel);
|
|
||||||
float rotate = 0;
|
|
||||||
bool isInsidePosition = serieLabel.position == LabelStyle.Position.Inside;
|
|
||||||
if (serieLabel.textStyle.rotate > 0 && isInsidePosition)
|
|
||||||
{
|
|
||||||
if (currAngle > 180) rotate += 270 - currAngle;
|
|
||||||
else rotate += -(currAngle - 90);
|
|
||||||
}
|
|
||||||
Color color = serieColor;
|
|
||||||
if (isHighlight)
|
|
||||||
{
|
|
||||||
if (!ChartHelper.IsClearColor(emphasis.label.textStyle.color))
|
|
||||||
{
|
|
||||||
color = emphasis.label.textStyle.color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!ChartHelper.IsClearColor(serieLabel.textStyle.color))
|
|
||||||
{
|
|
||||||
color = serieLabel.textStyle.color;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
color = isInsidePosition ? Color.white : serieColor;
|
|
||||||
}
|
|
||||||
var fontSize = isHighlight
|
|
||||||
? emphasis.label.textStyle.GetFontSize(chart.theme.common)
|
|
||||||
: serieLabel.textStyle.GetFontSize(chart.theme.common);
|
|
||||||
var fontStyle = isHighlight
|
|
||||||
? emphasis.label.textStyle.fontStyle
|
|
||||||
: serieLabel.textStyle.fontStyle;
|
|
||||||
|
|
||||||
serieData.labelObject.label.SetColor(color);
|
|
||||||
serieData.labelObject.label.SetFontSize(fontSize);
|
|
||||||
serieData.labelObject.label.SetFontStyle(fontStyle);
|
|
||||||
serieData.labelObject.SetLabelRotate(rotate);
|
|
||||||
if (!string.IsNullOrEmpty(serieLabel.formatter))
|
|
||||||
{
|
|
||||||
var value = serieData.data[1];
|
|
||||||
var total = serie.yTotal;
|
|
||||||
var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, total,
|
|
||||||
serieLabel, serieColor);
|
|
||||||
if (serieData.labelObject.SetText(content)) chart.RefreshPainter(serie);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (serieData.labelObject.SetText(serieData.name)) chart.RefreshPainter(serie);
|
|
||||||
}
|
|
||||||
serieData.labelObject.SetPosition(SerieLabelHelper.GetRealLabelPosition(serieData, serieLabel, labelLine));
|
|
||||||
if (showLabel) serieData.labelObject.SetLabelPosition(serieLabel.offset);
|
|
||||||
else serieData.SetLabelActive(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
serieData.SetLabelActive(false);
|
|
||||||
}
|
|
||||||
serieData.labelObject.UpdateIcon(iconStyle);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int GetPiePosIndex(Serie serie, Vector2 local)
|
private int GetPiePosIndex(Serie serie, Vector2 local)
|
||||||
{
|
{
|
||||||
if (!(serie is Pie)) return -1;
|
if (!(serie is Pie))
|
||||||
|
return -1;
|
||||||
|
|
||||||
var dist = Vector2.Distance(local, serie.context.center);
|
var dist = Vector2.Distance(local, serie.context.center);
|
||||||
var maxRadius = serie.context.outsideRadius + 3 * chart.theme.serie.pieSelectedOffset;
|
var maxRadius = serie.context.outsideRadius + 3 * chart.theme.serie.pieSelectedOffset;
|
||||||
if (dist < serie.context.insideRadius || dist > maxRadius) return -1;
|
if (dist < serie.context.insideRadius || dist > maxRadius)
|
||||||
Vector2 dir = local - new Vector2(serie.context.center.x, serie.context.center.y);
|
return -1;
|
||||||
float angle = ChartHelper.GetAngle360(Vector2.up, dir);
|
|
||||||
|
var dir = local - new Vector2(serie.context.center.x, serie.context.center.y);
|
||||||
|
var angle = ChartHelper.GetAngle360(Vector2.up, dir);
|
||||||
for (int i = 0; i < serie.data.Count; i++)
|
for (int i = 0; i < serie.data.Count; i++)
|
||||||
{
|
{
|
||||||
var serieData = serie.data[i];
|
var serieData = serie.data[i];
|
||||||
if (angle >= serieData.context.startAngle && angle <= serieData.context.toAngle)
|
if (angle >= serieData.context.startAngle && angle <= serieData.context.toAngle)
|
||||||
{
|
{
|
||||||
var ndist = !serieData.selected ? dist :
|
var ndist = serieData.selected
|
||||||
Vector2.Distance(local, serieData.context.offsetCenter);
|
? Vector2.Distance(local, serieData.context.offsetCenter)
|
||||||
|
: dist;
|
||||||
if (ndist >= serieData.context.insideRadius && ndist <= serieData.context.outsideRadius)
|
if (ndist >= serieData.context.insideRadius && ndist <= serieData.context.outsideRadius)
|
||||||
{
|
{
|
||||||
return i;
|
return i;
|
||||||
@@ -588,9 +517,13 @@ namespace XCharts
|
|||||||
|
|
||||||
private bool PointerIsInPieSerie(Serie serie, Vector2 local)
|
private bool PointerIsInPieSerie(Serie serie, Vector2 local)
|
||||||
{
|
{
|
||||||
if (!(serie is Pie)) return false;
|
if (!(serie is Pie))
|
||||||
|
return false;
|
||||||
|
|
||||||
var dist = Vector2.Distance(local, serie.context.center);
|
var dist = Vector2.Distance(local, serie.context.center);
|
||||||
if (dist >= serie.context.insideRadius && dist <= serie.context.outsideRadius) return true;
|
if (dist >= serie.context.insideRadius && dist <= serie.context.outsideRadius)
|
||||||
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ namespace XCharts
|
|||||||
for (int i = 0; i < serieData.data.Count; i++)
|
for (int i = 0; i < serieData.data.Count; i++)
|
||||||
{
|
{
|
||||||
var indicator = radar.GetIndicator(i);
|
var indicator = radar.GetIndicator(i);
|
||||||
|
if (indicator == null) continue;
|
||||||
|
|
||||||
var param = new SerieParams();
|
var param = new SerieParams();
|
||||||
param.serieName = serie.serieName;
|
param.serieName = serie.serieName;
|
||||||
@@ -75,58 +76,13 @@ namespace XCharts
|
|||||||
param.columns.Clear();
|
param.columns.Clear();
|
||||||
|
|
||||||
param.columns.Add(param.marker);
|
param.columns.Add(param.marker);
|
||||||
param.columns.Add(indicator == null ? string.Empty : indicator.name);
|
param.columns.Add(indicator.name);
|
||||||
param.columns.Add(ChartCached.NumberToStr(serieData.GetData(i), param.numericFormatter));
|
param.columns.Add(ChartCached.NumberToStr(serieData.GetData(i), param.numericFormatter));
|
||||||
|
|
||||||
paramList.Add(param);
|
paramList.Add(param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void RefreshLabelInternal()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < chart.series.Count; i++)
|
|
||||||
{
|
|
||||||
var serie = chart.GetSerie(i);
|
|
||||||
if (!(serie is Radar)) continue;
|
|
||||||
if (!serie.show && serie.radarType != RadarType.Single) continue;
|
|
||||||
var radar = chart.GetChartComponent<RadarCoord>(serie.radarIndex);
|
|
||||||
if (radar == null) continue;
|
|
||||||
var center = radar.context.center;
|
|
||||||
for (int n = 0; n < serie.dataCount; n++)
|
|
||||||
{
|
|
||||||
var serieData = serie.data[n];
|
|
||||||
if (serieData.labelObject == null) continue;
|
|
||||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
|
||||||
var iconStyle = SerieHelper.GetIconStyle(serie, serieData);
|
|
||||||
var labelPos = serieData.context.labelPosition;
|
|
||||||
if (serieLabel.margin != 0)
|
|
||||||
{
|
|
||||||
labelPos += serieLabel.margin * (labelPos - center).normalized;
|
|
||||||
}
|
|
||||||
serieData.labelObject.SetPosition(labelPos);
|
|
||||||
serieData.labelObject.UpdateIcon(iconStyle);
|
|
||||||
if (serie.show && serieLabel.show && serieData.context.canShowLabel)
|
|
||||||
{
|
|
||||||
var value = serieData.GetCurrData(1);
|
|
||||||
var max = radar.GetIndicatorMax(n);
|
|
||||||
SerieLabelHelper.ResetLabel(serieData.labelObject.label, serieLabel, chart.theme);
|
|
||||||
serieData.SetLabelActive(serieData.context.labelPosition != Vector3.zero);
|
|
||||||
serieData.labelObject.SetLabelPosition(serieLabel.offset);
|
|
||||||
var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, max,
|
|
||||||
serieLabel, Color.clear);
|
|
||||||
if (serieData.labelObject.SetText(content))
|
|
||||||
{
|
|
||||||
chart.RefreshPainter(serie);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
serieData.SetLabelActive(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnLegendButtonClick(int index, string legendName, bool show)
|
public override void OnLegendButtonClick(int index, string legendName, bool show)
|
||||||
{
|
{
|
||||||
if (!serie.IsLegendName(legendName))
|
if (!serie.IsLegendName(legendName))
|
||||||
@@ -323,9 +279,10 @@ namespace XCharts
|
|||||||
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, j, isHighlight);
|
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, j, isHighlight);
|
||||||
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, j, isHighlight, false);
|
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, j, isHighlight, false);
|
||||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight);
|
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight);
|
||||||
|
var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, chart.theme, isHighlight);
|
||||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
|
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
|
||||||
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, point, symbolColor,
|
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, point, symbolColor,
|
||||||
symbolToColor, symbolEmptyColor, serie.symbol.gap, cornerRadius);
|
symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -458,6 +415,7 @@ namespace XCharts
|
|||||||
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieIndex, isHighlight);
|
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieIndex, isHighlight);
|
||||||
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serieIndex, isHighlight, false);
|
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serieIndex, isHighlight, false);
|
||||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight);
|
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight);
|
||||||
|
var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, chart.theme, isHighlight);
|
||||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
|
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
|
||||||
if (!radar.IsInIndicatorRange(j, serieData.GetData(1)))
|
if (!radar.IsInIndicatorRange(j, serieData.GetData(1)))
|
||||||
{
|
{
|
||||||
@@ -465,7 +423,7 @@ namespace XCharts
|
|||||||
symbolToColor = radar.outRangeColor;
|
symbolToColor = radar.outRangeColor;
|
||||||
}
|
}
|
||||||
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, serieData.context.labelPosition, symbolColor,
|
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, serieData.context.labelPosition, symbolColor,
|
||||||
symbolToColor, symbolEmptyColor, serie.symbol.gap, cornerRadius);
|
symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!serie.animation.IsFinish())
|
if (!serie.animation.IsFinish())
|
||||||
@@ -508,11 +466,12 @@ namespace XCharts
|
|||||||
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieIndex, isHighlight);
|
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieIndex, isHighlight);
|
||||||
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serieIndex, isHighlight, false);
|
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serieIndex, isHighlight, false);
|
||||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight);
|
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight);
|
||||||
|
var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, chart.theme, isHighlight);
|
||||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
|
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
|
||||||
foreach (var point in pointList)
|
foreach (var point in pointList)
|
||||||
{
|
{
|
||||||
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, point, symbolColor,
|
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, point, symbolColor,
|
||||||
symbolToColor, symbolEmptyColor, serie.symbol.gap, cornerRadius);
|
symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ namespace XCharts
|
|||||||
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);
|
||||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, highlight);
|
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, highlight);
|
||||||
|
var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, theme, highlight);
|
||||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
|
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
|
||||||
double xValue = serieData.GetCurrData(0, dataChangeDuration, xAxis.inverse);
|
double xValue = serieData.GetCurrData(0, dataChangeDuration, xAxis.inverse);
|
||||||
double yValue = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse);
|
double yValue = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse);
|
||||||
@@ -194,16 +195,17 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
var nowSize = symbol.animationSize[count];
|
var nowSize = symbol.animationSize[count];
|
||||||
color.a = (byte)(255 * (symbolSize - nowSize) / symbolSize);
|
color.a = (byte)(255 * (symbolSize - nowSize) / symbolSize);
|
||||||
chart.DrawSymbol(vh, symbol.type, nowSize, symbolBorder, pos, color, toColor, emptyColor, symbol.gap, cornerRadius);
|
chart.DrawSymbol(vh, symbol.type, nowSize, symbolBorder, pos,
|
||||||
|
color, toColor, emptyColor, borderColor, symbol.gap, cornerRadius);
|
||||||
}
|
}
|
||||||
chart.RefreshPainter(serie);
|
chart.RefreshPainter(serie);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (symbolSize > 100) symbolSize = 100;
|
if (symbolSize > 100) symbolSize = 100;
|
||||||
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos, color, toColor, emptyColor, symbol.gap, cornerRadius);
|
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
|
||||||
|
color, toColor, emptyColor, borderColor, symbol.gap, cornerRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!serie.animation.IsFinish())
|
if (!serie.animation.IsFinish())
|
||||||
{
|
{
|
||||||
@@ -258,6 +260,7 @@ namespace XCharts
|
|||||||
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);
|
||||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, highlight);
|
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, highlight);
|
||||||
|
var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, theme, highlight);
|
||||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
|
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
|
||||||
var xValue = serieData.GetCurrData(0, dataChangeDuration, axis.inverse);
|
var xValue = serieData.GetCurrData(0, dataChangeDuration, axis.inverse);
|
||||||
|
|
||||||
@@ -296,7 +299,7 @@ namespace XCharts
|
|||||||
var nowSize = symbol.animationSize[count];
|
var nowSize = symbol.animationSize[count];
|
||||||
color.a = (byte)(255 * (symbolSize - nowSize) / symbolSize);
|
color.a = (byte)(255 * (symbolSize - nowSize) / symbolSize);
|
||||||
chart.DrawSymbol(vh, symbol.type, nowSize, symbolBorder, pos,
|
chart.DrawSymbol(vh, symbol.type, nowSize, symbolBorder, pos,
|
||||||
color, toColor, emptyColor, symbol.gap, cornerRadius);
|
color, toColor, emptyColor, borderColor, symbol.gap, cornerRadius);
|
||||||
}
|
}
|
||||||
chart.RefreshPainter(serie);
|
chart.RefreshPainter(serie);
|
||||||
}
|
}
|
||||||
@@ -304,7 +307,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (symbolSize > 100) symbolSize = 100;
|
if (symbolSize > 100) symbolSize = 100;
|
||||||
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
|
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
|
||||||
color, toColor, emptyColor, symbol.gap, cornerRadius);
|
color, toColor, emptyColor, borderColor, symbol.gap, cornerRadius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!serie.animation.IsFinish())
|
if (!serie.animation.IsFinish())
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace XCharts
|
|||||||
public AreaStyle areaStyle { get { return m_AreaStyles.Count > 0 ? m_AreaStyles[0] : null; } }
|
public AreaStyle areaStyle { get { return m_AreaStyles.Count > 0 ? m_AreaStyles[0] : null; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Text label of graphic element,to explain some data information about graphic item like value, name and so on.
|
/// Text label of graphic element,to explain some data information about graphic item like value, name and so on.
|
||||||
/// 图形上的文本标签,可用于说明图形的一些数据信息,比如值,名称等。s
|
/// 图形上的文本标签,可用于说明图形的一些数据信息,比如值,名称等。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LabelStyle label { get { return m_Labels.Count > 0 ? m_Labels[0] : null; } }
|
public LabelStyle label { get { return m_Labels.Count > 0 ? m_Labels[0] : null; } }
|
||||||
public LabelStyle endLabel { get { return m_EndLabels.Count > 0 ? m_EndLabels[0] : null; } }
|
public LabelStyle endLabel { get { return m_EndLabels.Count > 0 ? m_EndLabels[0] : null; } }
|
||||||
|
|||||||
@@ -30,8 +30,10 @@ namespace XCharts
|
|||||||
public virtual void OnScroll(PointerEventData eventData) { }
|
public virtual void OnScroll(PointerEventData eventData) { }
|
||||||
public virtual void RefreshLabelNextFrame() { }
|
public virtual void RefreshLabelNextFrame() { }
|
||||||
public virtual void RefreshLabelInternal() { }
|
public virtual void RefreshLabelInternal() { }
|
||||||
public virtual void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category, string marker,
|
public virtual void UpdateTooltipSerieParams(int dataIndex, bool showCategory,
|
||||||
string itemFormatter, string numericFormatter, ref List<SerieParams> paramList, ref string title)
|
string category, string marker,
|
||||||
|
string itemFormatter, string numericFormatter,
|
||||||
|
ref List<SerieParams> paramList, ref string title)
|
||||||
{ }
|
{ }
|
||||||
public virtual void OnLegendButtonClick(int index, string legendName, bool show) { }
|
public virtual void OnLegendButtonClick(int index, string legendName, bool show) { }
|
||||||
public virtual void OnLegendButtonEnter(int index, string legendName) { }
|
public virtual void OnLegendButtonEnter(int index, string legendName) { }
|
||||||
@@ -59,6 +61,7 @@ namespace XCharts
|
|||||||
this.serie.context.param.serieType = typeof(T);
|
this.serie.context.param.serieType = typeof(T);
|
||||||
m_NeedInitComponent = true;
|
m_NeedInitComponent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
if (m_NeedInitComponent)
|
if (m_NeedInitComponent)
|
||||||
@@ -256,32 +259,64 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (!m_InitedLabel)
|
if (!m_InitedLabel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName);
|
var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName);
|
||||||
var total = serie.yTotal;
|
var total = serie.yTotal;
|
||||||
|
var isNeedInvertPositionSerie = serie is Line;
|
||||||
|
|
||||||
foreach (var serieData in serie.data)
|
foreach (var serieData in serie.data)
|
||||||
{
|
{
|
||||||
if (serieData.labelObject == null)
|
if (serieData.labelObject == null)
|
||||||
continue;
|
continue;
|
||||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
||||||
|
var emphasisLabel = SerieHelper.GetSerieEmphasisLabel(serie, serieData);
|
||||||
|
var isHighlight = (serieData.context.highlight && emphasisLabel != null && emphasisLabel.show);
|
||||||
var iconStyle = SerieHelper.GetIconStyle(serie, serieData);
|
var iconStyle = SerieHelper.GetIconStyle(serie, serieData);
|
||||||
var isIgnore = serie.IsIgnoreIndex(serieData.index);
|
var isIgnore = serie.IsIgnoreIndex(serieData.index);
|
||||||
|
var currLabel = isHighlight && emphasisLabel != null ? emphasisLabel : serieLabel;
|
||||||
|
|
||||||
serieData.labelObject.SetPosition(serieData.context.position);
|
serieData.labelObject.SetPosition(serieData.context.position);
|
||||||
serieData.labelObject.UpdateIcon(iconStyle);
|
serieData.labelObject.UpdateIcon(iconStyle);
|
||||||
if (serie.show && serieLabel != null
|
|
||||||
&& serieLabel.show && serieData.context.canShowLabel && !isIgnore)
|
if (serie.show
|
||||||
|
&& currLabel != null
|
||||||
|
&& (currLabel.show || isHighlight)
|
||||||
|
&& serieData.context.canShowLabel
|
||||||
|
&& !isIgnore)
|
||||||
{
|
{
|
||||||
var value = serieData.GetData(1);
|
var content = serie.useDataNameForColor && string.IsNullOrEmpty(currLabel.formatter)
|
||||||
var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, total,
|
? serieData.name
|
||||||
serieLabel, chart.theme.GetColor(colorIndex));
|
: SerieLabelHelper.GetFormatterContent(serie, serieData, serieData.GetData(1), total,
|
||||||
var invert = serieLabel.autoOffset
|
currLabel, chart.theme.GetColor(colorIndex));
|
||||||
&& serie is Line
|
|
||||||
|
var invert = currLabel.autoOffset
|
||||||
|
&& isNeedInvertPositionSerie
|
||||||
&& SerieHelper.IsDownPoint(serie, serieData.index)
|
&& SerieHelper.IsDownPoint(serie, serieData.index)
|
||||||
&& (serie.areaStyle == null || !serie.areaStyle.show);
|
&& (serie.areaStyle == null || !serie.areaStyle.show);
|
||||||
var labelPosition = GetSerieDataLabelPosition(serieData, serieLabel);
|
var labelPosition = GetSerieDataLabelPosition(serieData, currLabel);
|
||||||
SerieLabelHelper.ResetLabel(serieData.labelObject.label, serieLabel, chart.theme);
|
var isInsidePosition = currLabel.position == LabelStyle.Position.Inside;
|
||||||
|
|
||||||
|
//text color
|
||||||
|
var textColor = chart.theme.common.textColor;
|
||||||
|
if (!ChartHelper.IsClearColor(currLabel.textStyle.color))
|
||||||
|
textColor = currLabel.textStyle.color;
|
||||||
|
else if (isInsidePosition)
|
||||||
|
textColor = Color.white;
|
||||||
|
//text rotate
|
||||||
|
var rotate = currLabel.textStyle.rotate;
|
||||||
|
if (currLabel.textStyle.rotate > 0 && isInsidePosition)
|
||||||
|
{
|
||||||
|
var currAngle = serieData.context.halfAngle;
|
||||||
|
if (currAngle > 0)
|
||||||
|
{
|
||||||
|
if (currAngle > 180) rotate += 270 - currAngle;
|
||||||
|
else rotate += -(currAngle - 90);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SerieLabelHelper.ResetLabel(serieData.labelObject.label, currLabel, chart.theme, textColor, rotate);
|
||||||
serieData.SetLabelActive(!isIgnore);
|
serieData.SetLabelActive(!isIgnore);
|
||||||
serieData.labelObject.SetPosition(labelPosition
|
serieData.labelObject.SetPosition(labelPosition
|
||||||
+ (invert ? -serieLabel.offset : serieLabel.offset));
|
+ (invert ? -currLabel.offset : currLabel.offset));
|
||||||
serieData.labelObject.SetText(content);
|
serieData.labelObject.SetText(content);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -364,7 +399,7 @@ namespace XCharts
|
|||||||
param.color = chart.theme.GetColor(dataIndex);
|
param.color = chart.theme.GetColor(dataIndex);
|
||||||
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||||
param.itemFormatter = itemFormatter;
|
param.itemFormatter = itemFormatter;
|
||||||
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); ;
|
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
|
||||||
param.columns.Clear();
|
param.columns.Clear();
|
||||||
|
|
||||||
param.columns.Add(param.marker);
|
param.columns.Add(param.marker);
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ namespace XCharts
|
|||||||
[SerializeField] protected float m_PieTooltipExtraRadius;
|
[SerializeField] protected float m_PieTooltipExtraRadius;
|
||||||
[SerializeField] protected float m_SelectedRate = 1.3f;
|
[SerializeField] protected float m_SelectedRate = 1.3f;
|
||||||
[SerializeField] protected float m_PieSelectedOffset;
|
[SerializeField] protected float m_PieSelectedOffset;
|
||||||
[SerializeField] protected Color32 m_CandlestickColor = new Color32(194, 53, 49, 255);
|
[SerializeField] protected Color32 m_CandlestickColor = new Color32(235, 84, 84, 255);
|
||||||
[SerializeField] protected Color32 m_CandlestickColor0 = new Color32(49, 70, 86, 255);
|
[SerializeField] protected Color32 m_CandlestickColor0 = new Color32(71, 178, 98, 255);
|
||||||
[SerializeField] protected float m_CandlestickBorderWidth = 1;
|
[SerializeField] protected float m_CandlestickBorderWidth = 1;
|
||||||
[SerializeField] protected Color32 m_CandlestickBorderColor = new Color32(194, 53, 49, 255);
|
[SerializeField] protected Color32 m_CandlestickBorderColor = new Color32(235, 84, 84, 255);
|
||||||
[SerializeField] protected Color32 m_CandlestickBorderColor0 = new Color32(49, 70, 86, 255);
|
[SerializeField] protected Color32 m_CandlestickBorderColor0 = new Color32(71, 178, 98, 255);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the color of text.
|
/// the color of text.
|
||||||
@@ -130,22 +130,22 @@ namespace XCharts
|
|||||||
switch (theme)
|
switch (theme)
|
||||||
{
|
{
|
||||||
case ThemeType.Default:
|
case ThemeType.Default:
|
||||||
m_CandlestickColor = ColorUtil.GetColor("#c23531");
|
m_CandlestickColor = ColorUtil.GetColor("#eb5454");
|
||||||
m_CandlestickColor0 = ColorUtil.GetColor("#314656");
|
m_CandlestickColor0 = ColorUtil.GetColor("#47b262");
|
||||||
m_CandlestickBorderColor = ColorUtil.GetColor("#c23531");
|
m_CandlestickBorderColor = ColorUtil.GetColor("#eb5454");
|
||||||
m_CandlestickBorderColor0 = ColorUtil.GetColor("#314656");
|
m_CandlestickBorderColor0 = ColorUtil.GetColor("#47b262");
|
||||||
break;
|
break;
|
||||||
case ThemeType.Light:
|
case ThemeType.Light:
|
||||||
m_CandlestickColor = ColorUtil.GetColor("#c23531");
|
m_CandlestickColor = ColorUtil.GetColor("#eb5454");
|
||||||
m_CandlestickColor0 = ColorUtil.GetColor("#314656");
|
m_CandlestickColor0 = ColorUtil.GetColor("#47b262");
|
||||||
m_CandlestickBorderColor = ColorUtil.GetColor("#c23531");
|
m_CandlestickBorderColor = ColorUtil.GetColor("#eb5454");
|
||||||
m_CandlestickBorderColor0 = ColorUtil.GetColor("#314656");
|
m_CandlestickBorderColor0 = ColorUtil.GetColor("#47b262");
|
||||||
break;
|
break;
|
||||||
case ThemeType.Dark:
|
case ThemeType.Dark:
|
||||||
m_CandlestickColor = ColorUtil.GetColor("#c23531");
|
m_CandlestickColor = ColorUtil.GetColor("#f64e56");
|
||||||
m_CandlestickColor0 = ColorUtil.GetColor("#314656");
|
m_CandlestickColor0 = ColorUtil.GetColor("#54ea92");
|
||||||
m_CandlestickBorderColor = ColorUtil.GetColor("#c23531");
|
m_CandlestickBorderColor = ColorUtil.GetColor("#f64e56");
|
||||||
m_CandlestickBorderColor0 = ColorUtil.GetColor("#314656");
|
m_CandlestickBorderColor0 = ColorUtil.GetColor("#54ea92");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user