增加BarChart绘制渐变边框的支持

This commit is contained in:
monitor1394
2021-04-26 07:17:26 +08:00
parent 2f9af18fd0
commit 0813bbfadd
10 changed files with 118 additions and 53 deletions

View File

@@ -106,8 +106,8 @@ namespace XCharts
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);
prt = new Vector3(pX + currHig - borderWidth, pY + space + barWidth - borderWidth);
prb = new Vector3(pX + currHig - borderWidth, pY + space + borderWidth);
plb = new Vector3(pX + borderWidth, pY + space + borderWidth);
}
top = new Vector3(pX + currHig - borderWidth, pY + space + barWidth / 2);
@@ -301,7 +301,6 @@ namespace XCharts
plt = ClampInGrid(grid, plt);
prt = ClampInGrid(grid, prt);
}
var borderColor = itemStyle.borderColor;
var itemWidth = Mathf.Abs(prb.x - plt.x);
var itemHeight = Mathf.Abs(prt.y - plb.y);
var center = new Vector3((plt.x + prb.x) / 2, (prt.y + plb.y) / 2);
@@ -316,8 +315,8 @@ namespace XCharts
{
CheckClipAndDrawPolygon(vh, plb, plt, prt, prb, areaColor, areaToColor, serie.clip, grid);
}
UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, borderColor, 0,
itemStyle.cornerRadius, isYAxis);
UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, itemStyle.borderColor,
itemStyle.borderToColor, 0, itemStyle.cornerRadius, isYAxis);
}
}
else
@@ -329,7 +328,6 @@ namespace XCharts
plt = ClampInGrid(grid, plt);
prt = ClampInGrid(grid, prt);
}
var borderColor = itemStyle.borderColor;
var itemWidth = Mathf.Abs(prt.x - plb.x);
var itemHeight = Mathf.Abs(plt.y - prb.y);
var center = new Vector3((plb.x + prt.x) / 2, (plt.y + prb.y) / 2);
@@ -345,8 +343,8 @@ namespace XCharts
CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, areaColor, areaToColor,
serie.clip, grid);
}
UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, borderColor, 0,
itemStyle.cornerRadius, isYAxis);
UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, itemStyle.borderColor,
itemStyle.borderToColor, 0, itemStyle.cornerRadius, isYAxis);
}
}
}

View File

@@ -146,8 +146,8 @@ namespace XCharts
}
if (borderWidth != 0)
{
UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, itemStyle.borderColor, 0,
itemStyle.cornerRadius, true, 0.5f);
UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, itemStyle.borderColor,
itemStyle.borderToColor, 0, itemStyle.cornerRadius, true, 0.5f);
}
return new Rect(plb.x, plb.y, xEnd - xStart, barWidth);
}

View File

@@ -137,6 +137,8 @@ namespace XCharts
var borderWidth = serie.itemStyle.show ? serie.itemStyle.borderWidth : 0;
var borderColor = serie.itemStyle.opacity > 0 ? serie.itemStyle.borderColor : ChartConst.clearColor32;
borderColor.a = (byte)(borderColor.a * serie.itemStyle.opacity);
var borderToColor = serie.itemStyle.opacity > 0 ? serie.itemStyle.borderToColor : ChartConst.clearColor32;
borderToColor.a = (byte)(borderToColor.a * serie.itemStyle.opacity);
serie.dataPoints.Clear();
serie.animation.InitProgress(1, 0, xCount);
var animationIndex = serie.animation.GetCurrIndex();
@@ -175,8 +177,8 @@ namespace XCharts
}
if (animationIndex >= 0 && i > animationIndex) continue;
serieData.canShowLabel = true;
var emphasis = (tooltip.show
&& i == (int)tooltip.runtimeXValues[0]
var emphasis = (tooltip.show
&& i == (int)tooltip.runtimeXValues[0]
&& j == (int)tooltip.runtimeYValues[0])
|| visualMap.runtimeSelectedIndex > 0;
var rectWid = xWidth - 2 * borderWidth;
@@ -184,15 +186,18 @@ namespace XCharts
UGL.DrawRectangle(vh, pos, rectWid / 2, rectHig / 2, color);
if (borderWidth > 0 && !ChartHelper.IsClearColor(borderColor))
{
UGL.DrawBorder(vh, pos, rectWid, rectHig, borderWidth, borderColor);
UGL.DrawBorder(vh, pos, rectWid, rectHig, borderWidth, borderColor, borderToColor);
}
if (visualMap.hoverLink && emphasis && serie.emphasis.show
if (visualMap.hoverLink && emphasis && serie.emphasis.show
&& serie.emphasis.itemStyle.borderWidth > 0)
{
var emphasisBorderWidth = serie.emphasis.itemStyle.borderWidth;
var emphasisBorderColor = serie.emphasis.itemStyle.opacity > 0
var emphasisBorderColor = serie.emphasis.itemStyle.opacity > 0
? serie.emphasis.itemStyle.borderColor : ChartConst.clearColor32;
UGL.DrawBorder(vh, pos, rectWid, rectHig, emphasisBorderWidth, emphasisBorderColor);
var emphasisBorderToColor = serie.emphasis.itemStyle.opacity > 0
? serie.emphasis.itemStyle.borderToColor : ChartConst.clearColor32;
UGL.DrawBorder(vh, pos, rectWid, rectHig, emphasisBorderWidth, emphasisBorderColor,
emphasisBorderToColor);
}
}
}