增加MarkLine标线 (#142)

This commit is contained in:
monitor1394
2021-07-15 21:18:23 +08:00
parent 9da1b9cca6
commit 162aeb02e6
20 changed files with 1050 additions and 97 deletions

View File

@@ -82,7 +82,7 @@ namespace XCharts
internal bool m_IsPlayingAnimation = false;
internal protected List<string> m_LegendRealShowName = new List<string>();
protected List<Painter> m_PainterList = new List<Painter>();
protected Painter m_PainterTop;
internal Painter m_PainterTop;
protected GameObject m_SerieLabelRoot;
private Theme m_CheckTheme = 0;
@@ -120,8 +120,8 @@ namespace XCharts
if (m_Tooltips.Count == 0) m_Tooltips = new List<Tooltip>() { Tooltip.defaultTooltip };
CheckTheme();
base.Awake();
m_Series.AnimationReset();
m_Series.AnimationFadeIn();
AnimationReset();
AnimationFadeIn();
XChartsMgr.Instance.AddChart(this);
}
@@ -732,7 +732,7 @@ namespace XCharts
if (!m_CheckAnimation)
{
m_CheckAnimation = true;
m_Series.AnimationFadeIn();
AnimationFadeIn();
}
}
@@ -1011,11 +1011,16 @@ namespace XCharts
public void DrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize,
float tickness, Vector3 pos, Color32 color, Color32 toColor, float gap, float[] cornerRadius)
{
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, gap, cornerRadius, Vector3.zero);
}
public void DrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize,
float tickness, Vector3 pos, Color32 color, Color32 toColor, float gap, float[] cornerRadius, Vector3 startPos)
{
var backgroundColor = ThemeHelper.GetBackgroundColor(m_Theme, m_Background);
var smoothness = settings.cicleSmoothness;
ChartDrawer.DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, gap,
cornerRadius, backgroundColor, smoothness);
cornerRadius, backgroundColor, smoothness, startPos);
}
public void DrawLabelBackground(VertexHelper vh, Serie serie, SerieData serieData)

View File

@@ -32,6 +32,10 @@ namespace XCharts
InitAxisX();
InitAxisY();
tooltip.UpdateToTop();
var handler = new MarkLineHandler(this);
m_ComponentHandlers.Add(handler);
handler.Init();
}
protected override void Update()
@@ -1675,11 +1679,11 @@ namespace XCharts
}
public void Internal_CheckClipAndDrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize, float tickness,
Vector3 pos, Color32 color, Color32 toColor, float gap, bool clip, float[] cornerRadius, Grid grid)
Vector3 pos, Color32 color, Color32 toColor, float gap, bool clip, float[] cornerRadius, Grid grid, Vector3 startPos)
{
if (!IsInChart(pos)) return;
if (!clip || (clip && (IsInGrid(grid, pos))))
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, gap, cornerRadius);
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, gap, cornerRadius, startPos);
}
public void Internal_CheckClipAndDrawZebraLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size, float zebraWidth,

View File

@@ -46,7 +46,7 @@ namespace XCharts
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
symbolSize = serie.animation.GetSysmbolSize(symbolSize);
Internal_CheckClipAndDrawSymbol(vh, symbol.type, symbolSize, symbolBorder, serie.dataPoints[i], symbolColor,
symbolToColor, symbol.gap, clip, cornerRadius, grid);
symbolToColor, symbol.gap, clip, cornerRadius, grid, i > 0 ? serie.dataPoints[i - 1] : grid.runtimePosition);
}
}

View File

@@ -15,9 +15,10 @@ namespace XCharts
{
public static class ChartDrawer
{
public static void DrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize,
float tickness, Vector3 pos, Color32 color, Color32 toColor, float gap, float[] cornerRadius,
Color32 backgroundColor, float smoothness)
Color32 backgroundColor, float smoothness, Vector3 startPos)
{
switch (type)
{
@@ -77,6 +78,14 @@ namespace XCharts
UGL.DrawDiamond(vh, pos, symbolSize, color, toColor);
}
break;
case SerieSymbolType.Arrow:
var arrowWidth = symbolSize * 2;
var arrowHeight = arrowWidth * 1.5f;
var arrowOffset = 0;
var arrowDent = arrowWidth / 3.3f;
UGL.DrawArrow(vh, startPos, pos, arrowWidth, arrowHeight,
arrowOffset, arrowDent, color);
break;
}
}