mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-30 05:08:48 +00:00
优化BarChart设置Corner时正负柱条圆角对称
This commit is contained in:
@@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
## master
|
## master
|
||||||
|
|
||||||
|
* (2021.08.12) Optimize `BarChart` setting `Corner` when the positive and negative columns are fillet symmetric
|
||||||
* (2021.08.03) Fixed y axis not displaying when all data is 0
|
* (2021.08.03) Fixed y axis not displaying when all data is 0
|
||||||
* (2021.07.29) Fixed ignored data will also participate in calculations when `ignore` is enabled (#161)
|
* (2021.07.29) Fixed ignored data will also participate in calculations when `ignore` is enabled (#161)
|
||||||
* (2021.07.29) Improved `BarChart`'s `Zebra` gradient support
|
* (2021.07.29) Improved `BarChart`'s `Zebra` gradient support
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
## master
|
## master
|
||||||
|
|
||||||
|
* (2021.08.12) 优化`BarChart`设置`Corner`时正负柱条圆角对称
|
||||||
* (2021.08.03) 优化`Serie`的数据全为0时Y轴不显示的问题
|
* (2021.08.03) 优化`Serie`的数据全为0时Y轴不显示的问题
|
||||||
* (2021.07.29) 修复`Serie`开启`ignore`时被忽略的数据还会参与计算的问题 (#161)
|
* (2021.07.29) 修复`Serie`开启`ignore`时被忽略的数据还会参与计算的问题 (#161)
|
||||||
* (2021.07.29) 完善`BarChart`的`Zebra`斑马柱图渐变支持
|
* (2021.07.29) 完善`BarChart`的`Zebra`斑马柱图渐变支持
|
||||||
|
|||||||
@@ -329,17 +329,18 @@ namespace XCharts
|
|||||||
var center = new Vector3((plt.x + prb.x) / 2, (prt.y + plb.y) / 2);
|
var center = new Vector3((plt.x + prb.x) / 2, (prt.y + plb.y) / 2);
|
||||||
if (itemWidth > 0 && itemHeight > 0)
|
if (itemWidth > 0 && itemHeight > 0)
|
||||||
{
|
{
|
||||||
|
var invert = center.x < plb.x;
|
||||||
if (ItemStyleHelper.IsNeedCorner(itemStyle))
|
if (ItemStyleHelper.IsNeedCorner(itemStyle))
|
||||||
{
|
{
|
||||||
UGL.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, areaToColor, 0,
|
UGL.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, areaToColor, 0,
|
||||||
itemStyle.cornerRadius, isYAxis);
|
itemStyle.cornerRadius, isYAxis, m_Settings.cicleSmoothness, invert);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Internal_CheckClipAndDrawPolygon(vh, plb, plt, prt, prb, areaColor, areaToColor, serie.clip, grid);
|
Internal_CheckClipAndDrawPolygon(vh, plb, plt, prt, prb, areaColor, areaToColor, serie.clip, grid);
|
||||||
}
|
}
|
||||||
UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, itemStyle.borderColor,
|
UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, itemStyle.borderColor,
|
||||||
itemStyle.borderToColor, 0, itemStyle.cornerRadius, isYAxis);
|
itemStyle.borderToColor, 0, itemStyle.cornerRadius, isYAxis, m_Settings.cicleSmoothness, invert);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -356,10 +357,11 @@ namespace XCharts
|
|||||||
var center = new Vector3((plb.x + prt.x) / 2, (plt.y + prb.y) / 2);
|
var center = new Vector3((plb.x + prt.x) / 2, (plt.y + prb.y) / 2);
|
||||||
if (itemWidth > 0 && itemHeight > 0)
|
if (itemWidth > 0 && itemHeight > 0)
|
||||||
{
|
{
|
||||||
|
var invert = center.y < plb.y;
|
||||||
if (ItemStyleHelper.IsNeedCorner(itemStyle))
|
if (ItemStyleHelper.IsNeedCorner(itemStyle))
|
||||||
{
|
{
|
||||||
UGL.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, areaToColor, 0,
|
UGL.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, areaToColor, 0,
|
||||||
itemStyle.cornerRadius, isYAxis);
|
itemStyle.cornerRadius, isYAxis, m_Settings.cicleSmoothness, invert);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -367,7 +369,7 @@ namespace XCharts
|
|||||||
serie.clip, grid);
|
serie.clip, grid);
|
||||||
}
|
}
|
||||||
UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, itemStyle.borderColor,
|
UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, itemStyle.borderColor,
|
||||||
itemStyle.borderToColor, 0, itemStyle.cornerRadius, isYAxis);
|
itemStyle.borderToColor, 0, itemStyle.cornerRadius, isYAxis, m_Settings.cicleSmoothness, invert);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -483,13 +483,34 @@ namespace XUGL
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void InitCornerRadius(float[] cornerRadius, float width, float height, bool horizontal,
|
private static void InitCornerRadius(float[] cornerRadius, float width, float height, bool horizontal,
|
||||||
ref float brLt, ref float brRt, ref float brRb, ref float brLb, ref bool needRound)
|
bool invert, ref float brLt, ref float brRt, ref float brRb, ref float brLb, ref bool needRound)
|
||||||
{
|
{
|
||||||
if (cornerRadius == null) return;
|
if (cornerRadius == null) return;
|
||||||
|
if (invert)
|
||||||
|
{
|
||||||
|
if (horizontal)
|
||||||
|
{
|
||||||
|
brLt = cornerRadius.Length > 0 ? cornerRadius[1] : 0;
|
||||||
|
brRt = cornerRadius.Length > 1 ? cornerRadius[0] : 0;
|
||||||
|
brRb = cornerRadius.Length > 2 ? cornerRadius[3] : 0;
|
||||||
|
brLb = cornerRadius.Length > 3 ? cornerRadius[2] : 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
brLt = cornerRadius.Length > 0 ? cornerRadius[3] : 0;
|
||||||
|
brRt = cornerRadius.Length > 1 ? cornerRadius[2] : 0;
|
||||||
|
brRb = cornerRadius.Length > 2 ? cornerRadius[1] : 0;
|
||||||
|
brLb = cornerRadius.Length > 3 ? cornerRadius[0] : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
brLt = cornerRadius.Length > 0 ? cornerRadius[0] : 0;
|
brLt = cornerRadius.Length > 0 ? cornerRadius[0] : 0;
|
||||||
brRt = cornerRadius.Length > 1 ? cornerRadius[1] : 0;
|
brRt = cornerRadius.Length > 1 ? cornerRadius[1] : 0;
|
||||||
brRb = cornerRadius.Length > 2 ? cornerRadius[2] : 0;
|
brRb = cornerRadius.Length > 2 ? cornerRadius[2] : 0;
|
||||||
brLb = cornerRadius.Length > 3 ? cornerRadius[3] : 0;
|
brLb = cornerRadius.Length > 3 ? cornerRadius[3] : 0;
|
||||||
|
}
|
||||||
|
|
||||||
needRound = brLb != 0 || brRt != 0 || brRb != 0 || brLb != 0;
|
needRound = brLb != 0 || brRt != 0 || brRb != 0 || brLb != 0;
|
||||||
if (needRound)
|
if (needRound)
|
||||||
{
|
{
|
||||||
@@ -568,18 +589,22 @@ namespace XUGL
|
|||||||
/// <param name="rectWidth"></param>
|
/// <param name="rectWidth"></param>
|
||||||
/// <param name="rectHeight"></param>
|
/// <param name="rectHeight"></param>
|
||||||
/// <param name="color"></param>
|
/// <param name="color"></param>
|
||||||
|
/// <param name="toColor"></param>
|
||||||
/// <param name="rotate"></param>
|
/// <param name="rotate"></param>
|
||||||
/// <param name="cornerRadius"></param>
|
/// <param name="cornerRadius"></param>
|
||||||
|
/// <param name="isYAxis"></param>
|
||||||
|
/// <param name="smoothness"></param>
|
||||||
|
/// <param name="invertCorner"></param>
|
||||||
public static void DrawRoundRectangle(VertexHelper vh, Vector3 center, float rectWidth, float rectHeight,
|
public static void DrawRoundRectangle(VertexHelper vh, Vector3 center, float rectWidth, float rectHeight,
|
||||||
Color32 color, Color32 toColor, float rotate = 0, float[] cornerRadius = null, bool isYAxis = false,
|
Color32 color, Color32 toColor, float rotate = 0, float[] cornerRadius = null, bool isYAxis = false,
|
||||||
float smoothness = 2)
|
float smoothness = 2, bool invertCorner = false)
|
||||||
{
|
{
|
||||||
var isGradient = !UGLHelper.IsValueEqualsColor(color, toColor);
|
var isGradient = !UGLHelper.IsValueEqualsColor(color, toColor);
|
||||||
var halfWid = rectWidth / 2;
|
var halfWid = rectWidth / 2;
|
||||||
var halfHig = rectHeight / 2;
|
var halfHig = rectHeight / 2;
|
||||||
float brLt = 0, brRt = 0, brRb = 0, brLb = 0;
|
float brLt = 0, brRt = 0, brRb = 0, brLb = 0;
|
||||||
bool needRound = false;
|
bool needRound = false;
|
||||||
InitCornerRadius(cornerRadius, rectWidth, rectHeight, isYAxis, ref brLt, ref brRt, ref brRb,
|
InitCornerRadius(cornerRadius, rectWidth, rectHeight, isYAxis, invertCorner, ref brLt, ref brRt, ref brRb,
|
||||||
ref brLb, ref needRound);
|
ref brLb, ref needRound);
|
||||||
var tempCenter = Vector3.zero;
|
var tempCenter = Vector3.zero;
|
||||||
var lbIn = new Vector3(center.x - halfWid, center.y - halfHig);
|
var lbIn = new Vector3(center.x - halfWid, center.y - halfHig);
|
||||||
@@ -811,12 +836,13 @@ namespace XUGL
|
|||||||
/// <param name="color"></param>
|
/// <param name="color"></param>
|
||||||
/// <param name="rotate"></param>
|
/// <param name="rotate"></param>
|
||||||
/// <param name="cornerRadius"></param>
|
/// <param name="cornerRadius"></param>
|
||||||
|
/// <param name="invertCorner"></param>
|
||||||
public static void DrawBorder(VertexHelper vh, Vector3 center, float rectWidth, float rectHeight,
|
public static void DrawBorder(VertexHelper vh, Vector3 center, float rectWidth, float rectHeight,
|
||||||
float borderWidth, Color32 color, float rotate = 0, float[] cornerRadius = null,
|
float borderWidth, Color32 color, float rotate = 0, float[] cornerRadius = null,
|
||||||
bool horizontal = false, float smoothness = 1f)
|
bool horizontal = false, float smoothness = 1f, bool invertCorner = false)
|
||||||
{
|
{
|
||||||
DrawBorder(vh, center, rectWidth, rectHeight, borderWidth, color, s_ClearColor32, rotate,
|
DrawBorder(vh, center, rectWidth, rectHeight, borderWidth, color, s_ClearColor32, rotate,
|
||||||
cornerRadius, horizontal, smoothness);
|
cornerRadius, horizontal, smoothness, invertCorner);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -831,9 +857,12 @@ namespace XUGL
|
|||||||
/// <param name="toColor"></param>
|
/// <param name="toColor"></param>
|
||||||
/// <param name="rotate"></param>
|
/// <param name="rotate"></param>
|
||||||
/// <param name="cornerRadius"></param>
|
/// <param name="cornerRadius"></param>
|
||||||
|
/// <param name="horizontal"></param>
|
||||||
|
/// <param name="smoothness"></param>
|
||||||
|
/// <param name="invertCorner"></param>
|
||||||
public static void DrawBorder(VertexHelper vh, Vector3 center, float rectWidth, float rectHeight,
|
public static void DrawBorder(VertexHelper vh, Vector3 center, float rectWidth, float rectHeight,
|
||||||
float borderWidth, Color32 color, Color32 toColor, float rotate = 0, float[] cornerRadius = null,
|
float borderWidth, Color32 color, Color32 toColor, float rotate = 0, float[] cornerRadius = null,
|
||||||
bool horizontal = false, float smoothness = 1f)
|
bool horizontal = false, float smoothness = 1f, bool invertCorner = false)
|
||||||
{
|
{
|
||||||
if (borderWidth == 0 || UGLHelper.IsClearColor(color)) return;
|
if (borderWidth == 0 || UGLHelper.IsClearColor(color)) return;
|
||||||
var halfWid = rectWidth / 2;
|
var halfWid = rectWidth / 2;
|
||||||
@@ -848,7 +877,7 @@ namespace XUGL
|
|||||||
var rbOt = new Vector3(center.x + halfWid + borderWidth, center.y - halfHig - borderWidth);
|
var rbOt = new Vector3(center.x + halfWid + borderWidth, center.y - halfHig - borderWidth);
|
||||||
float brLt = 0, brRt = 0, brRb = 0, brLb = 0;
|
float brLt = 0, brRt = 0, brRb = 0, brLb = 0;
|
||||||
bool needRound = false;
|
bool needRound = false;
|
||||||
InitCornerRadius(cornerRadius, rectWidth, rectHeight, horizontal, ref brLt, ref brRt, ref brRb,
|
InitCornerRadius(cornerRadius, rectWidth, rectHeight, horizontal, invertCorner, ref brLt, ref brRt, ref brRb,
|
||||||
ref brLb, ref needRound);
|
ref brLb, ref needRound);
|
||||||
var tempCenter = Vector3.zero;
|
var tempCenter = Vector3.zero;
|
||||||
if (UGLHelper.IsClearColor(toColor))
|
if (UGLHelper.IsClearColor(toColor))
|
||||||
|
|||||||
Reference in New Issue
Block a user