mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-28 12:08:46 +00:00
3.0 - optimize code
This commit is contained in:
@@ -163,7 +163,7 @@ namespace XCharts.Runtime
|
||||
float barWidth = serie.GetBarWidth(categoryWidth);
|
||||
float offset = (categoryWidth - totalBarWidth) * 0.5f;
|
||||
float barGapWidth = barWidth + barWidth * barGap;
|
||||
float space = serie.barGap == -1 ? offset : offset + chart.GetSerieIndexIfStack<Bar>(serie) * barGapWidth;
|
||||
float gap = serie.barGap == -1 ? offset : offset + chart.GetSerieIndexIfStack<Bar>(serie) * barGapWidth;
|
||||
int maxCount = serie.maxShow > 0
|
||||
? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||
: showData.Count;
|
||||
@@ -209,7 +209,6 @@ namespace XCharts.Runtime
|
||||
var pX = 0f;
|
||||
var pY = 0f;
|
||||
UpdateXYPosition(m_SerieGrid, isY, axis, relativedAxis, i, categoryWidth, barWidth, isStack, value, ref pX, ref pY);
|
||||
|
||||
var barHig = 0f;
|
||||
if (isPercentStack)
|
||||
{
|
||||
@@ -223,7 +222,7 @@ namespace XCharts.Runtime
|
||||
|
||||
float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
|
||||
Vector3 plb, plt, prt, prb, top;
|
||||
UpdateRectPosition(m_SerieGrid, isY, relativedValue, pX, pY, space, borderWidth, barWidth, currHig,
|
||||
UpdateRectPosition(m_SerieGrid, isY, relativedValue, pX, pY, gap, borderWidth, barWidth, currHig,
|
||||
out plb, out plt, out prt, out prb, out top);
|
||||
serieData.context.stackHeight = barHig;
|
||||
serieData.context.position = top;
|
||||
@@ -237,15 +236,15 @@ namespace XCharts.Runtime
|
||||
switch (serie.barType)
|
||||
{
|
||||
case BarType.Normal:
|
||||
DrawNormalBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
|
||||
DrawNormalBar(vh, serie, serieData, itemStyle, colorIndex, highlight, gap, barWidth,
|
||||
pX, pY, plb, plt, prt, prb, isY, m_SerieGrid, axis, areaColor, areaToColor);
|
||||
break;
|
||||
case BarType.Zebra:
|
||||
DrawZebraBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
|
||||
DrawZebraBar(vh, serie, serieData, itemStyle, colorIndex, highlight, gap, barWidth,
|
||||
pX, pY, plb, plt, prt, prb, isY, m_SerieGrid, axis, areaColor, areaToColor);
|
||||
break;
|
||||
case BarType.Capsule:
|
||||
DrawCapsuleBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
|
||||
DrawCapsuleBar(vh, serie, serieData, itemStyle, colorIndex, highlight, gap, barWidth,
|
||||
pX, pY, plb, plt, prt, prb, isY, m_SerieGrid, axis, areaColor, areaToColor);
|
||||
break;
|
||||
}
|
||||
@@ -278,7 +277,11 @@ namespace XCharts.Runtime
|
||||
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);
|
||||
else
|
||||
{
|
||||
var valueLen = (float)((value - axis.context.minValue) / axis.context.minMaxRange) * grid.context.height;
|
||||
pY = grid.context.y + valueLen - categoryWidth * 0.5f;
|
||||
}
|
||||
}
|
||||
pX = AxisHelper.GetAxisValuePosition(grid, relativedAxis, categoryWidth, 0);
|
||||
if (isStack)
|
||||
@@ -296,7 +299,11 @@ namespace XCharts.Runtime
|
||||
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);
|
||||
else
|
||||
{
|
||||
var valueLen = (float)((value - axis.context.minValue) / axis.context.minMaxRange) * grid.context.width;
|
||||
pX = grid.context.x + valueLen - categoryWidth * 0.5f;
|
||||
}
|
||||
}
|
||||
pY = AxisHelper.GetAxisValuePosition(grid, relativedAxis, categoryWidth, 0);
|
||||
if (isStack)
|
||||
@@ -307,7 +314,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateRectPosition(GridCoord grid, bool isY, double yValue, float pX, float pY, float space, float borderWidth,
|
||||
private void UpdateRectPosition(GridCoord grid, bool isY, double yValue, float pX, float pY, float gap, float borderWidth,
|
||||
float barWidth, float currHig,
|
||||
out Vector3 plb, out Vector3 plt, out Vector3 prt, out Vector3 prb, out Vector3 top)
|
||||
{
|
||||
@@ -315,37 +322,37 @@ namespace XCharts.Runtime
|
||||
{
|
||||
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);
|
||||
plt = new Vector3(pX - borderWidth, pY + gap + barWidth - borderWidth);
|
||||
prt = new Vector3(pX + currHig + borderWidth, pY + gap + barWidth - borderWidth);
|
||||
prb = new Vector3(pX + currHig + borderWidth, pY + gap + borderWidth);
|
||||
plb = new Vector3(pX - borderWidth, pY + gap + 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);
|
||||
plt = new Vector3(pX + borderWidth, pY + gap + barWidth - borderWidth);
|
||||
prt = new Vector3(pX + currHig - borderWidth, pY + gap + barWidth - borderWidth);
|
||||
prb = new Vector3(pX + currHig - borderWidth, pY + gap + borderWidth);
|
||||
plb = new Vector3(pX + borderWidth, pY + gap + borderWidth);
|
||||
}
|
||||
top = new Vector3(pX + currHig - borderWidth, pY + space + barWidth / 2);
|
||||
top = new Vector3(pX + currHig - borderWidth, pY + gap + 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);
|
||||
plb = new Vector3(pX + gap + borderWidth, pY - borderWidth);
|
||||
plt = new Vector3(pX + gap + borderWidth, pY + currHig - borderWidth);
|
||||
prt = new Vector3(pX + gap + barWidth - borderWidth, pY + currHig - borderWidth);
|
||||
prb = new Vector3(pX + gap + 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);
|
||||
plb = new Vector3(pX + gap + borderWidth, pY + borderWidth);
|
||||
plt = new Vector3(pX + gap + borderWidth, pY + currHig - borderWidth);
|
||||
prt = new Vector3(pX + gap + barWidth - borderWidth, pY + currHig - borderWidth);
|
||||
prb = new Vector3(pX + gap + barWidth - borderWidth, pY + borderWidth);
|
||||
}
|
||||
top = new Vector3(pX + space + barWidth / 2, pY + currHig - borderWidth);
|
||||
top = new Vector3(pX + gap + barWidth / 2, pY + currHig - borderWidth);
|
||||
}
|
||||
if (serie.clip)
|
||||
{
|
||||
@@ -358,10 +365,10 @@ namespace XCharts.Runtime
|
||||
}
|
||||
|
||||
private void DrawNormalBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
|
||||
bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
||||
bool highlight, float gap, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
||||
Vector3 prb, bool isYAxis, GridCoord grid, Axis axis, Color32 areaColor, Color32 areaToColor)
|
||||
{
|
||||
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid, axis);
|
||||
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, gap, barWidth, isYAxis, grid, axis);
|
||||
var borderWidth = itemStyle.runtimeBorderWidth;
|
||||
if (isYAxis)
|
||||
{
|
||||
@@ -423,10 +430,10 @@ namespace XCharts.Runtime
|
||||
}
|
||||
|
||||
private void DrawZebraBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
|
||||
bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
||||
bool highlight, float gap, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
||||
Vector3 prb, bool isYAxis, GridCoord grid, Axis axis, Color32 barColor, Color32 barToColor)
|
||||
{
|
||||
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid, axis);
|
||||
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, gap, barWidth, isYAxis, grid, axis);
|
||||
if (isYAxis)
|
||||
{
|
||||
plt = (plb + plt) / 2;
|
||||
@@ -444,10 +451,10 @@ namespace XCharts.Runtime
|
||||
}
|
||||
|
||||
private void DrawCapsuleBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
|
||||
bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
||||
bool highlight, float gap, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
||||
Vector3 prb, bool isYAxis, GridCoord grid, Axis axis, Color32 areaColor, Color32 areaToColor)
|
||||
{
|
||||
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid, axis);
|
||||
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, gap, barWidth, isYAxis, grid, axis);
|
||||
var borderWidth = itemStyle.runtimeBorderWidth;
|
||||
var radius = barWidth / 2 - borderWidth;
|
||||
var isGradient = !ChartHelper.IsValueEqualsColor(areaColor, areaToColor);
|
||||
@@ -562,7 +569,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
|
||||
private void DrawBarBackground(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle,
|
||||
int colorIndex, bool highlight, float pX, float pY, float space, float barWidth, bool isYAxis,
|
||||
int colorIndex, bool highlight, float pX, float pY, float gap, float barWidth, bool isYAxis,
|
||||
GridCoord grid, Axis axis)
|
||||
{
|
||||
var color = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, colorIndex, highlight, false);
|
||||
@@ -570,10 +577,10 @@ namespace XCharts.Runtime
|
||||
if (isYAxis)
|
||||
{
|
||||
var axisWidth = axis.axisLine.GetWidth(chart.theme.axis.lineWidth);
|
||||
Vector3 plt = new Vector3(grid.context.x + axisWidth, pY + space + barWidth);
|
||||
Vector3 prt = new Vector3(grid.context.x + axisWidth + grid.context.width, pY + space + barWidth);
|
||||
Vector3 prb = new Vector3(grid.context.x + axisWidth + grid.context.width, pY + space);
|
||||
Vector3 plb = new Vector3(grid.context.x + axisWidth, pY + space);
|
||||
Vector3 plt = new Vector3(grid.context.x + axisWidth, pY + gap + barWidth);
|
||||
Vector3 prt = new Vector3(grid.context.x + axisWidth + grid.context.width, pY + gap + barWidth);
|
||||
Vector3 prb = new Vector3(grid.context.x + axisWidth + grid.context.width, pY + gap);
|
||||
Vector3 plb = new Vector3(grid.context.x + axisWidth, pY + gap);
|
||||
if (serie.barType == BarType.Capsule)
|
||||
{
|
||||
var radius = barWidth / 2;
|
||||
@@ -610,10 +617,10 @@ namespace XCharts.Runtime
|
||||
else
|
||||
{
|
||||
var axisWidth = axis.axisLine.GetWidth(chart.theme.axis.lineWidth);
|
||||
Vector3 plb = new Vector3(pX + space, grid.context.y + axisWidth);
|
||||
Vector3 plt = new Vector3(pX + space, grid.context.y + grid.context.height + axisWidth);
|
||||
Vector3 prt = new Vector3(pX + space + barWidth, grid.context.y + grid.context.height + axisWidth);
|
||||
Vector3 prb = new Vector3(pX + space + barWidth, grid.context.y + axisWidth);
|
||||
Vector3 plb = new Vector3(pX + gap, grid.context.y + axisWidth);
|
||||
Vector3 plt = new Vector3(pX + gap, grid.context.y + grid.context.height + axisWidth);
|
||||
Vector3 prt = new Vector3(pX + gap + barWidth, grid.context.y + grid.context.height + axisWidth);
|
||||
Vector3 prb = new Vector3(pX + gap + barWidth, grid.context.y + axisWidth);
|
||||
if (serie.barType == BarType.Capsule)
|
||||
{
|
||||
var radius = barWidth / 2;
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace XCharts.Runtime
|
||||
float barWidth = serie.GetBarWidth(categoryWidth);
|
||||
float offset = (categoryWidth - totalBarWidth) * 0.5f;
|
||||
float barGapWidth = barWidth + barWidth * barGap;
|
||||
float space = serie.barGap == -1 ? offset : offset + serie.index * barGapWidth;
|
||||
float gap = serie.barGap == -1 ? offset : offset + serie.index * barGapWidth;
|
||||
int maxCount = serie.maxShow > 0
|
||||
? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||
: showData.Count;
|
||||
@@ -194,13 +194,13 @@ namespace XCharts.Runtime
|
||||
var currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
|
||||
|
||||
Vector3 plb, plt, prt, prb, top;
|
||||
UpdateRectPosition(m_SerieGrid, isY, relativedValue, pX, pY, space, borderWidth, barWidth, currHig,
|
||||
UpdateRectPosition(m_SerieGrid, isY, relativedValue, pX, pY, gap, 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);
|
||||
DrawNormalBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
|
||||
DrawNormalBar(vh, serie, serieData, itemStyle, colorIndex, highlight, gap, barWidth,
|
||||
pX, pY, plb, plt, prt, prb, false, m_SerieGrid, areaColor, areaToColor);
|
||||
|
||||
if (serie.animation.CheckDetailBreak(top, isY))
|
||||
@@ -250,7 +250,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateRectPosition(GridCoord grid, bool isY, double yValue, float pX, float pY, float space, float borderWidth,
|
||||
private void UpdateRectPosition(GridCoord grid, bool isY, double yValue, float pX, float pY, float gap, float borderWidth,
|
||||
float barWidth, float currHig,
|
||||
out Vector3 plb, out Vector3 plt, out Vector3 prt, out Vector3 prb, out Vector3 top)
|
||||
{
|
||||
@@ -258,37 +258,37 @@ namespace XCharts.Runtime
|
||||
{
|
||||
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);
|
||||
plt = new Vector3(pX - borderWidth, pY + gap + barWidth - borderWidth);
|
||||
prt = new Vector3(pX + currHig + borderWidth, pY + gap + barWidth - borderWidth);
|
||||
prb = new Vector3(pX + currHig + borderWidth, pY + gap + borderWidth);
|
||||
plb = new Vector3(pX - borderWidth, pY + gap + 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);
|
||||
plt = new Vector3(pX + borderWidth, pY + gap + barWidth - borderWidth);
|
||||
prt = new Vector3(pX + currHig - borderWidth, pY + gap + barWidth - borderWidth);
|
||||
prb = new Vector3(pX + currHig - borderWidth, pY + gap + borderWidth);
|
||||
plb = new Vector3(pX + borderWidth, pY + gap + borderWidth);
|
||||
}
|
||||
top = new Vector3(pX + currHig - borderWidth, pY + space + barWidth / 2);
|
||||
top = new Vector3(pX + currHig - borderWidth, pY + gap + 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);
|
||||
plb = new Vector3(pX + gap + borderWidth, pY - borderWidth);
|
||||
plt = new Vector3(pX + gap + borderWidth, pY + currHig + borderWidth);
|
||||
prt = new Vector3(pX + gap + barWidth - borderWidth, pY + currHig + borderWidth);
|
||||
prb = new Vector3(pX + gap + 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);
|
||||
plb = new Vector3(pX + gap + borderWidth, pY + borderWidth);
|
||||
plt = new Vector3(pX + gap + borderWidth, pY + currHig - borderWidth);
|
||||
prt = new Vector3(pX + gap + barWidth - borderWidth, pY + currHig - borderWidth);
|
||||
prb = new Vector3(pX + gap + barWidth - borderWidth, pY + borderWidth);
|
||||
}
|
||||
top = new Vector3(pX + space + barWidth / 2, pY + currHig - borderWidth);
|
||||
top = new Vector3(pX + gap + barWidth / 2, pY + currHig - borderWidth);
|
||||
}
|
||||
if (serie.clip)
|
||||
{
|
||||
@@ -301,7 +301,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
|
||||
private void DrawNormalBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
|
||||
bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
||||
bool highlight, float gap, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
||||
Vector3 prb, bool isYAxis, GridCoord grid, Color32 areaColor, Color32 areaToColor)
|
||||
{
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace XCharts.Runtime
|
||||
var showData = serie.GetDataList(dataZoom);
|
||||
float categoryWidth = AxisHelper.GetDataWidth(xAxis, grid.context.width, showData.Count, dataZoom);
|
||||
float barWidth = serie.GetBarWidth(categoryWidth);
|
||||
float space = (categoryWidth - barWidth) / 2;
|
||||
float gap = (categoryWidth - barWidth) / 2;
|
||||
int maxCount = serie.maxShow > 0
|
||||
? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||
: showData.Count;
|
||||
@@ -140,11 +140,11 @@ namespace XCharts.Runtime
|
||||
float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
|
||||
Vector3 plb, plt, prt, prb, top;
|
||||
|
||||
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);
|
||||
plb = new Vector3(pX + gap + borderWidth, pY + borderWidth);
|
||||
plt = new Vector3(pX + gap + borderWidth, pY + currHig - borderWidth);
|
||||
prt = new Vector3(pX + gap + barWidth - borderWidth, pY + currHig - borderWidth);
|
||||
prb = new Vector3(pX + gap + barWidth - borderWidth, pY + borderWidth);
|
||||
top = new Vector3(pX + gap + barWidth / 2, pY + currHig - borderWidth);
|
||||
if (serie.clip)
|
||||
{
|
||||
plb = chart.ClampInGrid(grid, plb);
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace XCharts.Runtime
|
||||
var showData = serie.GetDataList(dataZoom);
|
||||
float categoryWidth = AxisHelper.GetDataWidth(xAxis, grid.context.width, showData.Count, dataZoom);
|
||||
float barWidth = serie.GetBarWidth(categoryWidth);
|
||||
float space = (categoryWidth - barWidth) / 2;
|
||||
float gap = (categoryWidth - barWidth) / 2;
|
||||
int maxCount = serie.maxShow > 0
|
||||
? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||
: showData.Count;
|
||||
@@ -140,11 +140,11 @@ namespace XCharts.Runtime
|
||||
float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
|
||||
Vector3 plb, plt, prt, prb, top;
|
||||
|
||||
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);
|
||||
plb = new Vector3(pX + gap + borderWidth, pY + borderWidth);
|
||||
plt = new Vector3(pX + gap + borderWidth, pY + currHig - borderWidth);
|
||||
prt = new Vector3(pX + gap + barWidth - borderWidth, pY + currHig - borderWidth);
|
||||
prb = new Vector3(pX + gap + barWidth - borderWidth, pY + borderWidth);
|
||||
top = new Vector3(pX + gap + barWidth / 2, pY + currHig - borderWidth);
|
||||
// if (serie.clip)
|
||||
// {
|
||||
// plb = chart.ClampInGrid(grid, plb);
|
||||
|
||||
@@ -330,7 +330,7 @@ namespace XCharts.Runtime
|
||||
var needRoundCap = serie.roundCap && insideRadius > 0;
|
||||
UGL.DrawDoughnut(vh, serieData.context.offsetCenter, insideRadius,
|
||||
outsideRadius, color, toColor, Color.clear, serieData.context.startAngle,
|
||||
drawEndDegree, borderWidth, borderColor, serie.pieSpace / 2, chart.settings.cicleSmoothness,
|
||||
drawEndDegree, borderWidth, borderColor, serie.gap / 2, chart.settings.cicleSmoothness,
|
||||
needRoundCap, true);
|
||||
}
|
||||
else
|
||||
@@ -339,7 +339,7 @@ namespace XCharts.Runtime
|
||||
var needRoundCap = serie.roundCap && insideRadius > 0;
|
||||
UGL.DrawDoughnut(vh, serie.context.center, insideRadius,
|
||||
outsideRadius, color, toColor, Color.clear, serieData.context.startAngle,
|
||||
drawEndDegree, borderWidth, borderColor, serie.pieSpace / 2, chart.settings.cicleSmoothness,
|
||||
drawEndDegree, borderWidth, borderColor, serie.gap / 2, chart.settings.cicleSmoothness,
|
||||
needRoundCap, true);
|
||||
DrawPieCenter(vh, serie, itemStyle, insideRadius);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
var serie = chart.AddSerie<Ring>(serieName);
|
||||
serie.roundCap = true;
|
||||
serie.gap = 10;
|
||||
serie.radius = new float[] { 0.3f, 0.35f };
|
||||
|
||||
serie.AddExtraComponent<LabelStyle>();
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace XCharts.Runtime
|
||||
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 outsideRadius = serie.context.outsideRadius - j * (ringWidth + serie.gap);
|
||||
var insideRadius = outsideRadius - ringWidth;
|
||||
var centerRadius = (outsideRadius + insideRadius) / 2;
|
||||
var borderWidth = itemStyle.borderWidth;
|
||||
|
||||
@@ -187,7 +187,6 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private bool m_BarPercentStack = false;
|
||||
[SerializeField] private float m_BarWidth = 0.6f;
|
||||
[SerializeField] private float m_BarGap = 0.3f; // 30%
|
||||
[SerializeField] private float m_BarCategoryGap = 0.2f; // 20%
|
||||
[SerializeField] private float m_BarZebraWidth = 4f;
|
||||
[SerializeField] private float m_BarZebraGap = 2f;
|
||||
|
||||
@@ -200,11 +199,10 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private float m_MinAngle;
|
||||
[SerializeField] private bool m_Clockwise = true;
|
||||
[SerializeField] private bool m_RoundCap;
|
||||
[SerializeField] private float m_RingGap = 10f;
|
||||
[SerializeField] private int m_SplitNumber;
|
||||
[SerializeField] private bool m_ClickOffset = true;
|
||||
[SerializeField] private RoseType m_RoseType = RoseType.None;
|
||||
[SerializeField] private float m_Space;
|
||||
[SerializeField] private float m_Gap;
|
||||
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.48f };
|
||||
[SerializeField] private float[] m_Radius = new float[2] { 0, 80 };
|
||||
|
||||
@@ -488,19 +486,6 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_BarGap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The bar gap of a single series, defaults to be 20% of the category gap, can be set as a fixed value.
|
||||
/// In a single coodinate system, this attribute is shared by multiple 'bar' series.
|
||||
/// This attribute should be set on the last 'bar' series in the coodinate system,
|
||||
/// then it will be adopted by all 'bar' series in the coordinate system.
|
||||
/// 同一系列的柱间距离,默认为类目间距的20%,可设固定值。
|
||||
/// 在同一坐标系上,此属性会被多个 'bar' 系列共享。此属性应设置于此坐标系中最后一个 'bar' 系列上才会生效,并且是对此坐标系中所有 'bar' 系列生效。
|
||||
/// </summary>
|
||||
public float barCategoryGap
|
||||
{
|
||||
get { return m_BarCategoryGap; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BarCategoryGap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 斑马线的粗细。
|
||||
/// </summary>
|
||||
public float barZebraWidth
|
||||
@@ -536,18 +521,13 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_RoseType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the space of pie chart item.
|
||||
/// 饼图项间的空隙留白。
|
||||
/// gap of item.
|
||||
/// 间距。
|
||||
/// </summary>
|
||||
public float pieSpace
|
||||
{
|
||||
get { return m_Space; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Space, value)) SetVerticesDirty(); }
|
||||
}
|
||||
public float gap
|
||||
{
|
||||
get { return m_Space; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Space, value)) SetVerticesDirty(); }
|
||||
get { return m_Gap; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Gap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the center of chart.
|
||||
@@ -632,15 +612,6 @@ namespace XCharts.Runtime
|
||||
get { return m_Clockwise; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Clockwise, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 环形图的环间隙。
|
||||
/// </summary>
|
||||
public float ringGap
|
||||
{
|
||||
get { return m_RingGap; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_RingGap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 刻度分割段数。最大可设置36。
|
||||
/// </summary>
|
||||
@@ -742,15 +713,7 @@ namespace XCharts.Runtime
|
||||
public bool large
|
||||
{
|
||||
get { return m_Large; }
|
||||
set
|
||||
{
|
||||
if (PropertyUtil.SetStruct(ref m_Large, value))
|
||||
{
|
||||
SetAllDirty();
|
||||
if (label != null)
|
||||
label.SetComponentDirty();
|
||||
}
|
||||
}
|
||||
set { if (PropertyUtil.SetStruct(ref m_Large, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 开启大数量优化的阈值。只有当开启了large并且数据量大于该阀值时才进入性能模式。
|
||||
@@ -758,15 +721,7 @@ namespace XCharts.Runtime
|
||||
public int largeThreshold
|
||||
{
|
||||
get { return m_LargeThreshold; }
|
||||
set
|
||||
{
|
||||
if (PropertyUtil.SetStruct(ref m_LargeThreshold, value))
|
||||
{
|
||||
SetAllDirty();
|
||||
if (label != null)
|
||||
label.SetComponentDirty();
|
||||
}
|
||||
}
|
||||
set { if (PropertyUtil.SetStruct(ref m_LargeThreshold, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 在饼图且标签外部显示的情况下,是否启用防止标签重叠策略,默认关闭,在标签拥挤重叠的情况下会挪动各个标签的位置,防止标签间的重叠。
|
||||
@@ -942,6 +897,7 @@ namespace XCharts.Runtime
|
||||
public bool nameDirty { get { return m_NameDirty; } }
|
||||
public bool labelDirty { get; set; }
|
||||
public bool titleDirty { get; set; }
|
||||
public bool dataDirty { get; set; }
|
||||
|
||||
private void SetSerieNameDirty()
|
||||
{
|
||||
@@ -1080,6 +1036,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
m_Data.Clear();
|
||||
m_NeedUpdateFilterData = true;
|
||||
dataDirty = true;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
|
||||
@@ -1105,6 +1062,7 @@ namespace XCharts.Runtime
|
||||
m_Data.RemoveAt(index);
|
||||
m_NeedUpdateFilterData = true;
|
||||
labelDirty = true;
|
||||
dataDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1113,7 +1071,8 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="dataName"></param>
|
||||
public SerieData AddYData(double value, string dataName = null)
|
||||
/// <param name="dataId">the unique id of data</param>
|
||||
public SerieData AddYData(double value, string dataName = null, string dataId = null)
|
||||
{
|
||||
CheckMaxCache();
|
||||
int xValue = m_Data.Count;
|
||||
@@ -1122,11 +1081,13 @@ namespace XCharts.Runtime
|
||||
serieData.data.Add(value);
|
||||
serieData.name = dataName;
|
||||
serieData.index = xValue;
|
||||
serieData.id = dataId;
|
||||
AddSerieData(serieData);
|
||||
m_ShowDataDimension = 1;
|
||||
SetVerticesDirty();
|
||||
CheckDataName(dataName);
|
||||
labelDirty = true;
|
||||
dataDirty = true;
|
||||
return serieData;
|
||||
}
|
||||
|
||||
@@ -1136,6 +1097,8 @@ namespace XCharts.Runtime
|
||||
m_Data.Insert(0, serieData);
|
||||
else
|
||||
m_Data.Add(serieData);
|
||||
SetVerticesDirty();
|
||||
dataDirty = true;
|
||||
m_NeedUpdateFilterData = true;
|
||||
}
|
||||
|
||||
@@ -1153,8 +1116,8 @@ namespace XCharts.Runtime
|
||||
/// <param name="xValue"></param>
|
||||
/// <param name="yValue"></param>
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
public SerieData AddXYData(double xValue, double yValue, string dataName = null)
|
||||
/// <param name="dataId">the unique id of data</param>
|
||||
public SerieData AddXYData(double xValue, double yValue, string dataName = null, string dataId = null)
|
||||
{
|
||||
CheckMaxCache();
|
||||
var serieData = SerieDataPool.Get();
|
||||
@@ -1163,6 +1126,7 @@ namespace XCharts.Runtime
|
||||
serieData.data.Add(yValue);
|
||||
serieData.name = dataName;
|
||||
serieData.index = m_Data.Count;
|
||||
serieData.id = dataId;
|
||||
AddSerieData(serieData);
|
||||
m_ShowDataDimension = 2;
|
||||
SetVerticesDirty();
|
||||
@@ -1179,8 +1143,9 @@ namespace XCharts.Runtime
|
||||
/// <param name="lowest"></param>
|
||||
/// <param name="heighest"></param>
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="dataId">the unique id of data</param>
|
||||
/// <returns></returns>
|
||||
public SerieData AddData(double open, double close, double lowest, double heighest, string dataName = null)
|
||||
public SerieData AddData(double open, double close, double lowest, double heighest, string dataName = null, string dataId = null)
|
||||
{
|
||||
CheckMaxCache();
|
||||
var serieData = SerieDataPool.Get();
|
||||
@@ -1191,6 +1156,7 @@ namespace XCharts.Runtime
|
||||
serieData.data.Add(heighest);
|
||||
serieData.name = dataName;
|
||||
serieData.index = m_Data.Count;
|
||||
serieData.id = dataId;
|
||||
AddSerieData(serieData);
|
||||
m_ShowDataDimension = 4;
|
||||
SetVerticesDirty();
|
||||
@@ -1205,14 +1171,14 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
/// <param name="valueList"></param>
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
public SerieData AddData(List<double> valueList, string dataName = null)
|
||||
/// <param name="dataId">the unique id of data</param>
|
||||
public SerieData AddData(List<double> valueList, string dataName = null, string dataId = null)
|
||||
{
|
||||
if (valueList == null || valueList.Count == 0) return null;
|
||||
if (valueList.Count == 1)
|
||||
return AddYData(valueList[0], dataName);
|
||||
return AddYData(valueList[0], dataName, dataId);
|
||||
else if (valueList.Count == 2)
|
||||
return AddXYData(valueList[0], valueList[1], dataName);
|
||||
return AddXYData(valueList[0], valueList[1], dataName, dataId);
|
||||
else
|
||||
{
|
||||
CheckMaxCache();
|
||||
@@ -1220,6 +1186,7 @@ namespace XCharts.Runtime
|
||||
var serieData = SerieDataPool.Get();
|
||||
serieData.name = dataName;
|
||||
serieData.index = m_Data.Count;
|
||||
serieData.id = dataId;
|
||||
for (int i = 0; i < valueList.Count; i++)
|
||||
{
|
||||
serieData.data.Add(valueList[i]);
|
||||
@@ -1232,29 +1199,42 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
public SerieData AddChildData(SerieData parent, double value, string name = null)
|
||||
public SerieData AddChildData(SerieData parent, double value, string name, string id)
|
||||
{
|
||||
var serieData = new SerieData();
|
||||
serieData.name = name;
|
||||
serieData.index = m_Data.Count;
|
||||
serieData.data = new List<double>() { parent.children.Count, value };
|
||||
serieData.context.parent = parent;
|
||||
AddSerieData(serieData);
|
||||
parent.children.Add(serieData.index);
|
||||
serieData.id = id;
|
||||
serieData.data = new List<double>() { m_Data.Count, value };
|
||||
AddChildData(parent, serieData);
|
||||
return serieData;
|
||||
}
|
||||
public SerieData AddChildData(SerieData parent, List<double> value, string name = null)
|
||||
|
||||
public SerieData AddChildData(SerieData parent, List<double> value, string name, string id)
|
||||
{
|
||||
var serieData = new SerieData();
|
||||
serieData.name = name;
|
||||
serieData.index = m_Data.Count;
|
||||
serieData.id = id;
|
||||
serieData.data = new List<double>(value);
|
||||
serieData.context.parent = parent;
|
||||
AddSerieData(serieData);
|
||||
parent.children.Add(serieData.index);
|
||||
AddChildData(parent, serieData);
|
||||
return serieData;
|
||||
}
|
||||
|
||||
public void AddChildData(SerieData parent, SerieData serieData)
|
||||
{
|
||||
serieData.parentId = parent.id;
|
||||
serieData.context.parent = parent;
|
||||
|
||||
if (!m_Data.Contains(serieData))
|
||||
AddSerieData(serieData);
|
||||
|
||||
if (!parent.context.children.Contains(serieData))
|
||||
{
|
||||
parent.context.children.Add(serieData);
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckMaxCache()
|
||||
{
|
||||
if (m_MaxCache <= 0) return;
|
||||
@@ -1360,23 +1340,23 @@ namespace XCharts.Runtime
|
||||
return null;
|
||||
}
|
||||
|
||||
public SerieData GetSerieData(string uuid, DataZoom dataZoom = null)
|
||||
public SerieData GetSerieData(string id, DataZoom dataZoom = null)
|
||||
{
|
||||
var data = GetDataList(dataZoom);
|
||||
foreach (var serieData in data)
|
||||
{
|
||||
var target = GetSerieData(serieData, uuid);
|
||||
var target = GetSerieData(serieData, id);
|
||||
if (target != null) return target;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public SerieData GetSerieData(SerieData parent, string uuid)
|
||||
public SerieData GetSerieData(SerieData parent, string id)
|
||||
{
|
||||
if (uuid.Equals(parent.uuid)) return parent;
|
||||
foreach (var child in parent.children)
|
||||
if (id.Equals(parent.id)) return parent;
|
||||
foreach (var child in parent.context.children)
|
||||
{
|
||||
var data = GetSerieData(GetSerieData(child), uuid);
|
||||
var data = GetSerieData(child, id);
|
||||
if (data != null)
|
||||
{
|
||||
return data;
|
||||
@@ -1480,7 +1460,11 @@ namespace XCharts.Runtime
|
||||
var animationOpen = animation.enable;
|
||||
var animationDuration = animation.GetUpdateAnimationDuration();
|
||||
var flag = m_Data[index].UpdateData(dimension, value, animationOpen, animationDuration);
|
||||
if (flag) SetVerticesDirty();
|
||||
if (flag)
|
||||
{
|
||||
SetVerticesDirty();
|
||||
dataDirty = true;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
else
|
||||
@@ -1504,6 +1488,7 @@ namespace XCharts.Runtime
|
||||
for (int i = 0; i < values.Count; i++)
|
||||
serieData.UpdateData(i, values[i], animationOpen, animationDuration);
|
||||
SetVerticesDirty();
|
||||
dataDirty = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -89,6 +89,7 @@ namespace XCharts.Runtime
|
||||
/// 排序后的数据
|
||||
/// </summary>
|
||||
public List<SerieData> sortedData = new List<SerieData>();
|
||||
public List<SerieData> rootData = new List<SerieData>();
|
||||
/// <summary>
|
||||
/// theme的颜色索引
|
||||
/// </summary>
|
||||
|
||||
@@ -12,11 +12,10 @@ namespace XCharts.Runtime
|
||||
[System.Serializable]
|
||||
public class SerieData : ChildComponent
|
||||
{
|
||||
[SerializeField] private int m_Index;
|
||||
[SerializeField] private string m_Name;
|
||||
[SerializeField] private string m_Uuid;
|
||||
[SerializeField] private bool m_Selected;
|
||||
[SerializeField] private bool m_Ignore = false;
|
||||
[SerializeField] private float m_Radius;
|
||||
[SerializeField] private string m_Id;
|
||||
[SerializeField] private string m_ParentId;
|
||||
[SerializeField] private List<ItemStyle> m_ItemStyles = new List<ItemStyle>();
|
||||
[SerializeField] private List<LabelStyle> m_Labels = new List<LabelStyle>();
|
||||
[SerializeField] private List<LabelLine> m_LabelLines = new List<LabelLine>();
|
||||
@@ -27,15 +26,18 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private List<AreaStyle> m_AreaStyles = new List<AreaStyle>();
|
||||
[SerializeField] private List<TitleStyle> m_TitleStyles = new List<TitleStyle>();
|
||||
[SerializeField] private List<double> m_Data = new List<double>();
|
||||
[SerializeField] private List<int> m_Children = new List<int>();
|
||||
|
||||
[NonSerialized] public SerieDataContext context = new SerieDataContext();
|
||||
[NonSerialized] public InteractData interact = new InteractData();
|
||||
[NonSerialized] private bool m_Ignore = false;
|
||||
[NonSerialized] private bool m_Selected;
|
||||
[NonSerialized] private float m_Radius;
|
||||
public ChartLabel labelObject { get; set; }
|
||||
public ChartLabel titleObject { get; set; }
|
||||
|
||||
private bool m_Show = true;
|
||||
|
||||
public override int index { get { return m_Index; } set { m_Index = value; } }
|
||||
/// <summary>
|
||||
/// the name of data item.
|
||||
/// 数据项名称。
|
||||
@@ -44,7 +46,8 @@ namespace XCharts.Runtime
|
||||
/// <summary>
|
||||
/// 数据项的唯一id。唯一id不是必须设置的。
|
||||
/// </summary>
|
||||
public string uuid { get { return m_Uuid; } set { m_Uuid = value; } }
|
||||
public string id { get { return m_Id; } set { m_Id = value; } }
|
||||
public string parentId { get { return m_ParentId; } set { m_ParentId = value; } }
|
||||
/// <summary>
|
||||
/// 数据项图例名称。当数据项名称不为空时,图例名称即为系列名称;反之则为索引index。
|
||||
/// </summary>
|
||||
@@ -97,8 +100,6 @@ namespace XCharts.Runtime
|
||||
/// 可指定任意维数的数值列表。
|
||||
/// </summary>
|
||||
public List<double> data { get { return m_Data; } set { m_Data = value; } }
|
||||
|
||||
public List<int> children { get { return m_Children; } set { m_Children = value; } }
|
||||
/// <summary>
|
||||
/// [default:true] Whether the data item is showed.
|
||||
/// 该数据项是否要显示。
|
||||
@@ -113,12 +114,16 @@ namespace XCharts.Runtime
|
||||
public void Reset()
|
||||
{
|
||||
index = 0;
|
||||
m_Id = null;
|
||||
m_ParentId = null;
|
||||
labelObject = null;
|
||||
m_Name = string.Empty;
|
||||
m_Show = true;
|
||||
m_Selected = false;
|
||||
context.canShowLabel = true;
|
||||
context.highlight = false;
|
||||
context.children.Clear();
|
||||
context.dataPoints.Clear();
|
||||
m_Radius = 0;
|
||||
interact.Reset();
|
||||
m_Data.Clear();
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace XCharts.Runtime
|
||||
public float outsideRadius { get; set; }
|
||||
public Vector3 position { get; set; }
|
||||
public List<Vector3> dataPoints = new List<Vector3>();
|
||||
public List<SerieData> children = new List<SerieData>();
|
||||
|
||||
/// <summary>
|
||||
/// 绘制区域。
|
||||
/// </summary>
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace XCharts.Runtime
|
||||
private static readonly string s_SerieTitleObjectName = "title";
|
||||
private static readonly string s_SerieRootObjectName = "serie";
|
||||
protected GameObject m_SerieRoot;
|
||||
protected GameObject m_SerieLabelRoot;
|
||||
protected bool m_InitedLabel;
|
||||
protected bool m_NeedInitComponent;
|
||||
protected bool m_RefreshLabel;
|
||||
@@ -56,6 +57,7 @@ namespace XCharts.Runtime
|
||||
protected int m_LegendEnterIndex;
|
||||
|
||||
public T serie { get; internal set; }
|
||||
public GameObject labelObject { get { return m_SerieLabelRoot; } }
|
||||
|
||||
internal override void SetSerie(Serie serie)
|
||||
{
|
||||
@@ -77,6 +79,11 @@ namespace XCharts.Runtime
|
||||
if (m_InitedLabel)
|
||||
RefreshLabelInternal();
|
||||
}
|
||||
if (serie.dataDirty)
|
||||
{
|
||||
serie.OnDataUpdate();
|
||||
serie.dataDirty = false;
|
||||
}
|
||||
if (serie.label != null && (serie.labelDirty || serie.label.componentDirty))
|
||||
{
|
||||
serie.labelDirty = false;
|
||||
@@ -182,10 +189,11 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (m_SerieRoot == null)
|
||||
InitRoot();
|
||||
var serieLabelRoot = ChartHelper.AddObject(s_SerieLabelObjectName, m_SerieRoot.transform,
|
||||
m_SerieLabelRoot = ChartHelper.AddObject(s_SerieLabelObjectName, m_SerieRoot.transform,
|
||||
chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
||||
serieLabelRoot.hideFlags = chart.chartHideFlags;
|
||||
SerieLabelPool.ReleaseAll(serieLabelRoot.transform);
|
||||
m_SerieLabelRoot.hideFlags = chart.chartHideFlags;
|
||||
//SerieLabelPool.ReleaseAll(m_SerieLabelRoot.transform);
|
||||
ChartHelper.DestroyAllChildren(m_SerieLabelRoot.transform);
|
||||
int count = 0;
|
||||
SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight);
|
||||
for (int j = 0; j < serie.data.Count; j++)
|
||||
@@ -193,7 +201,7 @@ namespace XCharts.Runtime
|
||||
var serieData = serie.data[j];
|
||||
serieData.index = count;
|
||||
serieData.labelObject = null;
|
||||
if (AddSerieLabel(serieLabelRoot, serie, serieData, ref count))
|
||||
if (AddSerieLabel(m_SerieLabelRoot, serie, serieData, ref count))
|
||||
{
|
||||
m_InitedLabel = true;
|
||||
count++;
|
||||
@@ -204,6 +212,8 @@ namespace XCharts.Runtime
|
||||
|
||||
protected bool AddSerieLabel(GameObject serieLabelRoot, Serie serie, SerieData serieData, ref int count)
|
||||
{
|
||||
if (serieData == null)
|
||||
return false;
|
||||
if (serieLabelRoot == null)
|
||||
return false;
|
||||
if (serie.IsPerformanceMode())
|
||||
@@ -217,8 +227,9 @@ namespace XCharts.Runtime
|
||||
var serieEmphasisLabel = SerieHelper.GetSerieEmphasisLabel(serie, serieData);
|
||||
var iconStyle = SerieHelper.GetIconStyle(serie, serieData);
|
||||
|
||||
if (!serieLabel.show && (serieEmphasisLabel == null || !serieEmphasisLabel.show)
|
||||
&& (iconStyle != null && !iconStyle.show))
|
||||
if (!serieLabel.show
|
||||
&& (serieEmphasisLabel == null || !serieEmphasisLabel.show)
|
||||
&& (iconStyle == null || !iconStyle.show))
|
||||
return false;
|
||||
|
||||
var textName = ChartCached.GetSerieLabelName(s_SerieLabelObjectName, serie.index, serieData.index);
|
||||
@@ -239,12 +250,14 @@ namespace XCharts.Runtime
|
||||
item.color = serieLabel.textStyle.backgroundColor;
|
||||
serieData.labelObject = item;
|
||||
|
||||
foreach (var data in serieData.children)
|
||||
if (serieData.context.children.Count > 0)
|
||||
{
|
||||
AddSerieLabel(serieLabelRoot, serie, serie.GetSerieData(data), ref count);
|
||||
count++;
|
||||
foreach (var childSerieData in serieData.context.children)
|
||||
{
|
||||
AddSerieLabel(serieLabelRoot, serie, childSerieData, ref count);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user