diff --git a/Assets/XCharts/CHANGELOG.md b/Assets/XCharts/CHANGELOG.md
index 3563d3a4..aea906fb 100644
--- a/Assets/XCharts/CHANGELOG.md
+++ b/Assets/XCharts/CHANGELOG.md
@@ -1,6 +1,7 @@
# 更新日志
+* (2020.05.21) 增加`圆角柱图`支持渐变
* (2020.05.21) 增加`Background`背景组件
* (2020.05.19) 隐藏`Hierarchy`试图下自动生成的子节点
* (2020.05.18) 增加`chartName`属性可指定图表的别称,可通过`XChartMgr.Instance.GetChart(chartName)`获取图表
diff --git a/Assets/XCharts/Documentation/XCharts配置项手册.md b/Assets/XCharts/Documentation/XCharts配置项手册.md
index dfdbdf0c..c79ada69 100644
--- a/Assets/XCharts/Documentation/XCharts配置项手册.md
+++ b/Assets/XCharts/Documentation/XCharts配置项手册.md
@@ -772,7 +772,7 @@
* `opacity`:透明度。
* `tooltipFormatter`:提示框单项的字符串模版格式器。具体配置参考`Tooltip`的`formatter`。
* `numericFormatter`:标准数字格式字符串。用于将数值格式化显示为字符串。使用`Axx`的形式:`A`是格式说明符的单字符,支持`C`货币、`D`十进制、`E`指数、`F`顶点数、`G`常规、`N`数字、`P`百分比、`R`往返过程、`X`十六进制等九种。`xx`是精度说明,从`0`-`99`。此字段优先于`SerieLabel`和`Tooltip`的`numericFormatter`。
-* `cornerRadius`:圆角半径。用数组分别指定4个圆角半径(顺时针左上,右上,右下,左下)。
+* `cornerRadius`:圆角半径。用数组分别指定4个圆角半径(顺时针左上,右上,右下,左下)。支持用0-1的浮点数设置百分比。
## `LineArrow`
diff --git a/Assets/XCharts/Runtime/Internal/CoordinateChart_DrawBar.cs b/Assets/XCharts/Runtime/Internal/CoordinateChart_DrawBar.cs
index 04a77116..db5daf72 100644
--- a/Assets/XCharts/Runtime/Internal/CoordinateChart_DrawBar.cs
+++ b/Assets/XCharts/Runtime/Internal/CoordinateChart_DrawBar.cs
@@ -310,7 +310,7 @@ namespace XCharts
{
if (ItemStyleHelper.IsNeedCorner(itemStyle))
{
- ChartDrawer.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, 0, itemStyle.cornerRadius);
+ ChartDrawer.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, areaToColor, 0, itemStyle.cornerRadius, isYAxis);
}
else
{
@@ -336,7 +336,7 @@ namespace XCharts
{
if (ItemStyleHelper.IsNeedCorner(itemStyle))
{
- ChartDrawer.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, 0, itemStyle.cornerRadius);
+ ChartDrawer.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, areaToColor, 0, itemStyle.cornerRadius, isYAxis);
}
else
{
diff --git a/Assets/XCharts/Runtime/Utility/ChartDrawer.cs b/Assets/XCharts/Runtime/Utility/ChartDrawer.cs
index 23d0a1f3..717d8f52 100644
--- a/Assets/XCharts/Runtime/Utility/ChartDrawer.cs
+++ b/Assets/XCharts/Runtime/Utility/ChartDrawer.cs
@@ -327,7 +327,7 @@ namespace XCharts
///
///
public static void DrawRoundRectangle(VertexHelper vh, Vector3 center, float rectWidth, float rectHeight,
- Color32 color, float rotate = 0, float[] cornerRadius = null)
+ Color32 color, Color32 toColor, float rotate = 0, float[] cornerRadius = null, bool isYAxis = false)
{
var halfWid = rectWidth / 2;
var halfHig = rectHeight / 2;
@@ -352,49 +352,76 @@ namespace XCharts
if (brLt > 0)
{
roundLt = new Vector3(center.x - halfWid + brLt, center.y + halfHig - brLt);
- DrawSector(vh, roundLt, brLt, color, color, 270, 360, 1);
+ if (isYAxis) DrawSector(vh, roundLt, brLt, color, color, 270, 360, 1);
+ else DrawSector(vh, roundLt, brLt, toColor, toColor, 270, 360, 1);
ltIn = roundLt + brLt * Vector3.left;
ltIn2 = roundLt + brLt * Vector3.up;
}
if (brRt > 0)
{
roundRt = new Vector3(center.x + halfWid - brRt, center.y + halfHig - brRt);
- DrawSector(vh, roundRt, brRt, color, color, 0, 90, 1);
+ if (isYAxis) DrawSector(vh, roundRt, brRt, toColor, toColor, 0, 90, 1);
+ else DrawSector(vh, roundRt, brRt, toColor, toColor, 0, 90, 1);
rtIn = roundRt + brRt * Vector3.up;
rtIn2 = roundRt + brRt * Vector3.right;
}
if (brRb > 0)
{
roundRb = new Vector3(center.x + halfWid - brRb, center.y - halfHig + brRb);
- DrawSector(vh, roundRb, brRb, color, color, 90, 180, 1);
+ if (isYAxis) DrawSector(vh, roundRb, brRb, toColor, toColor, 90, 180, 1);
+ else DrawSector(vh, roundRb, brRb, color, color, 90, 180, 1);
rbIn = roundRb + brRb * Vector3.right;
rbIn2 = roundRb + brRb * Vector3.down;
}
if (brLb > 0)
{
roundLb = new Vector3(center.x - halfWid + brLb, center.y - halfHig + brLb);
- DrawSector(vh, roundLb, brLb, color, color, 180, 270, 1);
+ if (isYAxis) DrawSector(vh, roundLb, brLb, color, color, 180, 270, 1);
+ else DrawSector(vh, roundLb, brLb, color, color, 180, 270, 1);
lbIn = roundLb + brLb * Vector3.left;
lbIn2 = roundLb + brLb * Vector3.down;
}
var maxup = Mathf.Max(brLt, brRt);
- DrawPolygon(vh, ltIn2, rtIn, rtIn + maxup * Vector3.down, ltIn2 + maxup * Vector3.down, color);
- DrawPolygon(vh, ltIn, roundLt, roundLt + (maxup - brLt) * Vector3.down, ltIn + (maxup - brLt) * Vector3.down, color);
- DrawPolygon(vh, roundRt, rtIn2, rtIn2 + (maxup - brRt) * Vector3.down, roundRt + (maxup - brRt) * Vector3.down, color);
+ if (isYAxis)
+ {
+ DrawPolygon(vh, ltIn2 + maxup * Vector3.down, ltIn2, rtIn, rtIn + maxup * Vector3.down, color, toColor);
+ DrawPolygon(vh, ltIn + (maxup - brLt) * Vector3.down, ltIn, roundLt, roundLt + (maxup - brLt) * Vector3.down, color, color);
+ DrawPolygon(vh, roundRt + (maxup - brRt) * Vector3.down, roundRt, rtIn2, rtIn2 + (maxup - brRt) * Vector3.down, toColor, toColor);
+ }
+ else
+ {
+ DrawPolygon(vh, ltIn2, rtIn, rtIn + maxup * Vector3.down, ltIn2 + maxup * Vector3.down, toColor, toColor);
+ DrawPolygon(vh, ltIn, roundLt, roundLt + (maxup - brLt) * Vector3.down, ltIn + (maxup - brLt) * Vector3.down, toColor, toColor);
+ DrawPolygon(vh, roundRt, rtIn2, rtIn2 + (maxup - brRt) * Vector3.down, roundRt + (maxup - brRt) * Vector3.down, toColor, toColor);
+ }
+
var maxdown = Mathf.Max(brLb, brRb);
- DrawPolygon(vh, lbIn2, lbIn2 + maxdown * Vector3.up, rbIn2 + maxdown * Vector3.up, rbIn2, color);
- DrawPolygon(vh, lbIn, lbIn + (maxdown - brLb) * Vector3.up, roundLb + (maxdown - brLb) * Vector3.up, roundLb, color);
- DrawPolygon(vh, roundRb, roundRb + (maxdown - brRb) * Vector3.up, rbIn2 + (maxdown - brRb) * Vector3.up, rbIn2, color);
+ if (isYAxis)
+ {
+ DrawPolygon(vh, lbIn2, lbIn2 + maxdown * Vector3.up, rbIn2 + maxdown * Vector3.up, rbIn2, color, toColor);
+ DrawPolygon(vh, lbIn, lbIn + (maxdown - brLb) * Vector3.up, roundLb + (maxdown - brLb) * Vector3.up, roundLb, color, color);
+ DrawPolygon(vh, roundRb, roundRb + (maxdown - brRb) * Vector3.up, rbIn2 + (maxdown - brRb) * Vector3.up, rbIn2, toColor, toColor);
+ }
+ else
+ {
+ DrawPolygon(vh, lbIn2, lbIn2 + maxdown * Vector3.up, rbIn2 + maxdown * Vector3.up, rbIn2, color, color);
+ DrawPolygon(vh, lbIn, lbIn + (maxdown - brLb) * Vector3.up, roundLb + (maxdown - brLb) * Vector3.up, roundLb, color, color);
+ DrawPolygon(vh, roundRb, roundRb + (maxdown - brRb) * Vector3.up, rbIn2 + (maxdown - brRb) * Vector3.up, rbIn2, color, color);
+ }
var clt = new Vector3(center.x - halfWid, center.y + halfHig - maxup);
var crt = new Vector3(center.x + halfWid, center.y + halfHig - maxup);
var crb = new Vector3(center.x + halfWid, center.y - halfHig + maxdown);
var clb = new Vector3(center.x - halfWid, center.y - halfHig + maxdown);
if (clt.y > clb.y)
- DrawPolygon(vh, clt, crt, crb, clb, color);
+ {
+ if (isYAxis) DrawPolygon(vh, clb, clt, crt, crb, color, toColor);
+ else DrawPolygon(vh, clt, crt, crb, clb, toColor, color);
+ }
+
}
else
{
- DrawPolygon(vh, lbIn, ltIn, rtIn, rbIn, color);
+ DrawPolygon(vh, lbIn, ltIn, rtIn, rbIn, toColor, color);
}
}
@@ -1082,7 +1109,7 @@ namespace XCharts
else
{
//ChartDrawer.DrawPolygon(vh, pos, symbolSize, color, toColor);
- ChartDrawer.DrawRoundRectangle(vh, pos, symbolSize, symbolSize, color, 0, cornerRadius);
+ ChartDrawer.DrawRoundRectangle(vh, pos, symbolSize, symbolSize, color, color, 0, cornerRadius, true);
}
break;
case SerieSymbolType.Triangle: