Compare commits

...

17 Commits

Author SHA1 Message Date
monitor1394
5149376806 v2.4.0 2021-08-31 22:29:49 +08:00
monitor1394
d8f739cbdf v2.4.0 2021-08-31 21:13:59 +08:00
monitor1394
71fb45af9f 优化RingChart的渐变效果 2021-08-31 21:05:02 +08:00
monitor1394
ca63d041b9 修复DataZoom拖动时SerieLabel不刷新的问题 (#165) 2021-08-31 13:41:46 +08:00
monitor1394
8fccfdb5fc Fixed the problem of displaying exceptions after adding data again when DataZoom is enable (#163) 2021-08-26 20:46:50 +08:00
monitor1394
f08ae794ae 修复Theme主题切换无法保持到场景上的问题 (#166) 2021-08-26 20:42:11 +08:00
monitor1394
8efa8145b1 匀速动画优化 2021-08-25 13:41:41 +08:00
monitor1394
e247ad9e71 增加AnimationalongWithLinePath参数设置折线轨迹匀速动画 2021-08-24 07:21:00 +08:00
monitor1394
645506a6fd Added serie's ignoreLineBreak parameter (#164) 2021-08-22 09:26:14 +08:00
monitor1394
c5ef7e765b Fixed axis label may not be updated when datazoom is turn on (#164) 2021-08-22 07:55:16 +08:00
monitor1394
3949018555 Improved Axis's AxisLabel text rotate setting to avoid inconsistency offset in DataZoom (#163) 2021-08-15 22:36:14 +08:00
monitor1394
34b0a97198 Added Legend's textAutoColor to set the text color match with Serie color (#163) 2021-08-15 22:36:06 +08:00
monitor1394
de3e482687 优化BarChart设置Corner时正负柱条圆角对称 2021-08-12 22:16:36 +08:00
monitor1394
8dbbbd7405 优化Serie的数据全为0时Y轴不显示的问题 2021-08-03 08:23:02 +08:00
monitor1394
3316fce8a5 修复Serie开启ignore时被忽略的数据还会参与计算的问题 (#161) 2021-07-29 08:27:23 +08:00
monitor1394
f85f96a560 完善BarChartZebra斑马柱图渐变支持 2021-07-29 08:05:54 +08:00
monitor1394
8f6f5790b6 修复TextMeshPro Enable时找不到XCharts路径的问题 (#160) 2021-07-26 21:28:13 +08:00
25 changed files with 366 additions and 141 deletions

View File

@@ -2,6 +2,7 @@
# 更新日志
[master](#master)
[v2.4.0](#v2.4.0)
[v2.3.0](#v2.3.0)
[v2.2.3](#v2.2.3)
[v2.2.2](#v2.2.2)
@@ -39,6 +40,31 @@
## master
## v2.4.0
### Main points
* LineChart support the line of ignore data is disconnected or connected
* LineChart support animation at a constant speed
* Other optimizations and bug fixes
### Details
* (2021.08.31) Release `v2.4.0` version
* (2021.08.31) Optimized the gradient effect of `RingChart`
* (2021.08.31) Fixed bug where `SerieLabel` does not refresh when `DataZoom` is dragged (#165)
* (2021.08.25) Fixed an issue where the theme switch could not be save to the scene (#166)
* (2021.08.24) Added `Animation`'s `alongWithLinePath`
* (2021.08.22) Added `Serie`'s `ignoreLineBreak` (#164)
* (2021.08.22) Fixed `Axis` label may not be updated when `DataZoom` is turn on (#164)
* (2021.08.15) Improved `Axis`'s `AxisLabel` text rotate setting to avoid inconsistency offset in `DataZoom` (#163)
* (2021.08.14) Added `Legend`'s `textAutoColor` to set the text color match with `Serie` color (#163)
* (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.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.26) Fixed issue where `XCharts` path could not be found when `TextMeshPro Enable` (#160)
## v2.3.0
### Main points

View File

@@ -2,6 +2,7 @@
# 更新日志
[master](#master)
[v2.4.0](#v2.4.0)
[v2.3.0](#v2.3.0)
[v2.2.3](#v2.2.3)
[v2.2.2](#v2.2.2)
@@ -39,6 +40,31 @@
## master
## v2.4.0
### 版本要点
* 折线图支持忽略数据的连线是断开还是连接
* 折线图支持轨迹匀速动画
* 其他优化和问题修复
### 日志详情
* (2021.08.31) 发布`v2.4.0`版本
* (2021.08.31) 优化`RingChart`的渐变效果
* (2021.08.31) 修复`DataZoom`拖动时`SerieLabel`不刷新的问题 (#165)
* (2021.08.25) 修复`Theme`主题切换无法保持到场景上的问题 (#166)
* (2021.08.24) 增加`Animation``alongWithLinePath`参数设置折线轨迹匀速动画
* (2021.08.22) 增加`Serie``ignoreLineBreak`参数设置忽略数据连线是否断开 (#164)
* (2021.08.22) 修复`Axis``DataZoom`开启时`Label`可能不更新的问题 (#164)
* (2021.08.15) 优化`Axis``AxisLabel`文本旋转设置避免在DataZoom开启时偏移不一致 (#163)
* (2021.08.14) 增加`Legend``textAutoColor`设置文本颜色和`Serie`一致 (#163)
* (2021.08.12) 优化`BarChart`设置`Corner`时正负柱条圆角对称
* (2021.08.03) 优化`Serie`的数据全为0时Y轴不显示的问题
* (2021.07.29) 修复`Serie`开启`ignore`时被忽略的数据还会参与计算的问题 (#161)
* (2021.07.29) 完善`BarChart``Zebra`斑马柱图渐变支持
* (2021.07.26) 修复`TextMeshPro Enable`时找不到`XCharts`路径的问题 (#160)
## v2.3.0
### 版本要点

View File

@@ -810,6 +810,7 @@ K线图系列。
* `fadeOutDuration`:设定的渐出动画时长,单位毫秒。如果要设置单个数据项的渐出时长,可以用代码定制:`customFadeOutDuration`
* `dataChangeEnable`:是否开启数据变更动画。
* `dataChangeDuration`:数据变更动画时长,单位毫秒。
* `alongWithLinePath`:是否沿着线的轨迹进行匀速动画。
## `AreaStyle`

View File

@@ -28,6 +28,7 @@ namespace XCharts
PropertyField(prop, "m_DataChangeEnable");
PropertyField(prop, "m_DataChangeDuration");
PropertyField(prop, "m_ActualDuration");
PropertyField(prop, "m_AlongWithLinePath");
--EditorGUI.indentLevel;
}
}

View File

@@ -25,6 +25,7 @@ namespace XCharts
PropertyField(prop, "m_ItemHeight");
PropertyField(prop, "m_ItemGap");
PropertyField(prop, "m_ItemAutoColor");
PropertyField(prop, "m_TextAutoColor");
PropertyField(prop, "m_SelectedMode");
PropertyField(prop, "m_Orient");
PropertyField(prop, "m_Location");

View File

@@ -68,6 +68,7 @@ namespace XCharts
PropertyField(prop, "m_Clip");
PropertyField(prop, "m_Ignore");
PropertyField(prop, "m_IgnoreValue");
PropertyField(prop, "m_IgnoreLineBreak");
PropertyField(prop, "m_ShowAsPositiveNumber");
PropertyField(prop, "m_Large");
PropertyField(prop, "m_LargeThreshold");

View File

@@ -543,7 +543,7 @@ namespace XCharts
foreach (var legend in m_Legends)
{
var iconColor = LegendHelper.GetIconColor(this, legendIndex, legendName, active);
var contentColor = LegendHelper.GetContentColor(legend, m_Theme, active);
var contentColor = LegendHelper.GetContentColor(legendIndex, legend, m_Theme, active);
legend.UpdateButtonColor(legendName, iconColor);
legend.UpdateContentColor(legendName, contentColor);
}
@@ -643,6 +643,9 @@ namespace XCharts
{
m_Theme.CopyTheme(theme);
SetAllComponentDirty();
#if UNITY_EDITOR
UnityEditor.EditorUtility.SetDirty(this);
#endif
}
/// <summary>

View File

@@ -489,6 +489,12 @@ namespace XCharts
return axis;
}
public override void SetComponentDirty()
{
m_NeedUpdateFilterData = true;
base.SetComponentDirty();
}
public void Copy(Axis axis)
{
show = axis.show;

View File

@@ -78,6 +78,7 @@ namespace XCharts
[SerializeField] private float m_ItemHeight = 12.0f;
[SerializeField] private float m_ItemGap = 10f;
[SerializeField] private bool m_ItemAutoColor = true;
[SerializeField] private bool m_TextAutoColor = false;
[SerializeField] private string m_Formatter;
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
[SerializeField] private List<string> m_Data = new List<string>();
@@ -176,6 +177,16 @@ namespace XCharts
set { if (PropertyUtil.SetStruct(ref m_ItemAutoColor, value)) SetComponentDirty(); }
}
/// <summary>
/// Whether the legend text matches the color automatically.
/// 图例标记的文本是否自动匹配颜色。
/// [default:false]
/// </summary>
public bool textAutoColor
{
get { return m_TextAutoColor; }
set { if (PropertyUtil.SetStruct(ref m_TextAutoColor, value)) SetComponentDirty(); }
}
/// <summary>
/// Legend content string template formatter. Support for wrapping lines with \n. Template:{name}.
/// 图例内容字符串模版格式器。支持用 \n 换行。
/// 模板变量为图例名称 {name}。

View File

@@ -327,6 +327,7 @@ namespace XCharts
[SerializeField] private bool m_Clip = false;
[SerializeField] private bool m_Ignore = false;
[SerializeField] private double m_IgnoreValue = 0;
[SerializeField] private bool m_IgnoreLineBreak = false;
[SerializeField] private bool m_ShowAsPositiveNumber = false;
[SerializeField] private bool m_Large = true;
[SerializeField] private int m_LargeThreshold = 200;
@@ -771,6 +772,15 @@ namespace XCharts
set { if (PropertyUtil.SetStruct(ref m_IgnoreValue, value)) SetVerticesDirty(); }
}
/// <summary>
/// 忽略数据时折线是断开还是连接。默认false为连接。
/// </summary>
/// <value></value>
public bool ignoreLineBreak
{
get { return m_IgnoreLineBreak; }
set { if (PropertyUtil.SetStruct(ref m_IgnoreLineBreak, value)) SetVerticesDirty(); }
}
/// <summary>
/// 雷达图类型。
/// </summary>
public RadarType radarType
@@ -1245,7 +1255,7 @@ namespace XCharts
var max = double.MinValue;
foreach (var sdata in data)
{
if (sdata.show && sdata.data[1] > max)
if (sdata.show && !IsIgnoreValue(sdata.data[1]) && sdata.data[1] > max)
{
max = sdata.data[1];
}
@@ -1264,7 +1274,7 @@ namespace XCharts
var max = double.MinValue;
foreach (var sdata in data)
{
if (sdata.show && sdata.data[0] > max)
if (sdata.show && !IsIgnoreValue(sdata.data[0]) && sdata.data[0] > max)
{
max = sdata.data[0];
}
@@ -1283,7 +1293,7 @@ namespace XCharts
var min = double.MaxValue;
foreach (var sdata in data)
{
if (sdata.show && sdata.data[1] < min)
if (sdata.show && !IsIgnoreValue(sdata.data[1]) && sdata.data[1] < min)
{
min = sdata.data[1];
}
@@ -1302,7 +1312,7 @@ namespace XCharts
var min = double.MaxValue;
foreach (var sdata in data)
{
if (sdata.show && sdata.data[0] < min)
if (sdata.show && !IsIgnoreValue(sdata.data[0]) && sdata.data[0] < min)
{
min = sdata.data[0];
}
@@ -1321,9 +1331,8 @@ namespace XCharts
double total = 0;
foreach (var sdata in data)
{
if (sdata.show)
if (sdata.show && !IsIgnoreValue(sdata.data[1]))
total += sdata.GetCurrData(1, animation.GetUpdateAnimationDuration());
//total += sdata.GetData(1);
}
return total;
}
@@ -1339,7 +1348,7 @@ namespace XCharts
double total = 0;
foreach (var sdata in data)
{
if (sdata.show)
if (sdata.show && !IsIgnoreValue(sdata.data[1]))
total += sdata.data[0];
}
return total;
@@ -1356,6 +1365,7 @@ namespace XCharts
RemoveData(0);
}
m_Data.Clear();
m_NeedUpdateFilterData = true;
SetVerticesDirty();
}
@@ -1389,6 +1399,7 @@ namespace XCharts
m_DownSmoothPoints.Remove(serieData.index);
}
m_Data.RemoveAt(index);
m_NeedUpdateFilterData = true;
}
}
@@ -1417,6 +1428,7 @@ namespace XCharts
{
if (m_InsertDataToHead) m_Data.Insert(0, serieData);
else m_Data.Add(serieData);
m_NeedUpdateFilterData = true;
}
private void CheckDataName(string dataName)

View File

@@ -35,6 +35,7 @@ namespace XCharts
[SerializeField] private bool m_DataChangeEnable = true;
[SerializeField] private float m_DataChangeDuration = 500;
[SerializeField] private float m_ActualDuration;
[SerializeField] private bool m_AlongWithLinePath;
/// <summary>
/// 自定义渐入动画延时函数。返回ms值。
/// </summary>
@@ -101,6 +102,10 @@ namespace XCharts
/// </summary>
public float dataChangeDuration { get { return m_DataChangeDuration; } set { m_DataChangeDuration = value < 0 ? 0 : value; } }
/// <summary>
/// 是否沿着线的轨迹进行匀速动画。
/// </summary>
public bool alongWithLinePath { get { return m_AlongWithLinePath; } set { m_AlongWithLinePath = value; } }
/// <summary>
/// 渐入动画完成回调
/// </summary>
public Action fadeInFinishCallback { get; set; }
@@ -123,6 +128,8 @@ namespace XCharts
[SerializeField] private float m_CurrDetailProgress;
[SerializeField] private float m_DestDetailProgress;
private float m_CurrSymbolProgress;
private Vector3 m_LinePathLastPos;
private float m_LinePathCurrTotalDist = 0f;
public void FadeIn()
{
@@ -343,11 +350,29 @@ namespace XCharts
return !IsFinish() && detail > m_CurrDetailProgress;
}
public void SetLinePathStartPos(Vector3 pos)
{
if (m_AlongWithLinePath)
{
m_LinePathLastPos = pos;
m_LinePathCurrTotalDist = 0;
}
}
public bool CheckDetailBreak(Vector3 pos, bool isYAxis)
{
if (IsFinish()) return false;
if (isYAxis) return pos.y > m_CurrDetailProgress;
else return pos.x > m_CurrDetailProgress;
if (m_AlongWithLinePath)
{
m_LinePathCurrTotalDist += Vector3.Distance(pos, m_LinePathLastPos);
m_LinePathLastPos = pos;
return CheckDetailBreak(m_LinePathCurrTotalDist);
}
else
{
if (isYAxis) return pos.y > m_CurrDetailProgress;
else return pos.x > m_CurrDetailProgress;
}
}
public bool NeedAnimation(int dataIndex)

View File

@@ -118,7 +118,8 @@ namespace XCharts
int split = GetSplitNumber(axis, coordinateWidth, dataZoom);
if (axis.type == Axis.AxisType.Value)
{
if (minValue == 0 && maxValue == 0) return string.Empty;
if (minValue == 0 && maxValue == 0)
maxValue = axis.max != 0 ? axis.max : 1;
double value = 0;
if (forcePercent) maxValue = 100;
if (axis.interval > 0)
@@ -396,7 +397,6 @@ namespace XCharts
{
if (!axis.show) return false;
if (axis.IsCategory() && axis.GetDataList().Count <= 0) return false;
else if (axis.IsValue() && axis.runtimeMinValue == 0 && axis.runtimeMaxValue == 0) return false;
else return true;
}

View File

@@ -11,10 +11,14 @@ namespace XCharts
{
public static class LegendHelper
{
public static Color GetContentColor(Legend legend, ChartTheme theme, bool active)
public static Color GetContentColor(int legendIndex, Legend legend, ChartTheme theme, bool active)
{
var textStyle = legend.textStyle;
if (active) return !ChartHelper.IsClearColor(textStyle.color) ? textStyle.color : theme.legend.textColor;
if (active)
{
if (legend.textAutoColor) return theme.GetColor(legendIndex);
else return !ChartHelper.IsClearColor(textStyle.color) ? textStyle.color : theme.legend.textColor;
}
else return theme.legend.unableColor;
}
@@ -34,7 +38,7 @@ namespace XCharts
}
public static LegendItem AddLegendItem(Legend legend, int i, string legendName, Transform parent,
ChartTheme theme, string content, Color itemColor, bool active)
ChartTheme theme, string content, Color itemColor, bool active, int legendIndex)
{
var objName = i + "_" + legendName;
var anchorMin = new Vector2(0, 0.5f);
@@ -43,7 +47,7 @@ namespace XCharts
var sizeDelta = new Vector2(100, 30);
var iconSizeDelta = new Vector2(legend.itemWidth, legend.itemHeight);
var textStyle = legend.textStyle;
var contentColor = GetContentColor(legend, theme, active);
var contentColor = GetContentColor(legendIndex, legend, theme, active);
var objAnchorMin = new Vector2(0, 1);
var objAnchorMax = new Vector2(0, 1);

View File

@@ -23,7 +23,7 @@ namespace XCharts
if (serieData.show && serieData.data.Count > dimension)
{
var value = serieData.data[dimension];
if (value < min) min = value;
if (value < min && !serie.IsIgnoreValue(value)) min = value;
}
}
return min == double.MaxValue ? 0 : min;
@@ -39,7 +39,7 @@ namespace XCharts
if (serieData.show && serieData.data.Count > dimension)
{
var value = serieData.data[dimension];
if (value < min)
if (value < min && !serie.IsIgnoreValue(value))
{
min = value;
minData = serieData;
@@ -58,7 +58,7 @@ namespace XCharts
if (serieData.show && serieData.data.Count > dimension)
{
var value = serieData.data[dimension];
if (value > max) max = value;
if (value > max && !serie.IsIgnoreValue(value)) max = value;
}
}
return max == double.MinValue ? 0 : max;
@@ -74,7 +74,7 @@ namespace XCharts
if (serieData.show && serieData.data.Count > dimension)
{
var value = serieData.data[dimension];
if (value > max)
if (value > max && !serie.IsIgnoreValue(value))
{
max = value;
maxData = serieData;
@@ -93,7 +93,9 @@ namespace XCharts
var serieData = dataList[i];
if (serieData.show && serieData.data.Count > dimension)
{
total += serieData.data[dimension];
var value = serieData.data[dimension];
if (!serie.IsIgnoreValue(value))
total += value;
}
}
return total != 0 ? total / dataList.Count : 0;
@@ -109,7 +111,9 @@ namespace XCharts
var serieData = dataList[i];
if (serieData.show && serieData.data.Count > dimension)
{
s_TempList.Add(serieData.data[dimension]);
var value = serieData.data[dimension];
if (!serie.IsIgnoreValue(value))
s_TempList.Add(value);
}
}
s_TempList.Sort();
@@ -139,8 +143,11 @@ namespace XCharts
if (serieData.show && serieData.data.Count > dimension)
{
var value = serieData.data[dimension];
if (value > max) max = value;
if (value < min) min = value;
if (!serie.IsIgnoreValue(value))
{
if (value > max) max = value;
if (value < min) min = value;
}
}
}
}
@@ -171,8 +178,11 @@ namespace XCharts
for (int j = 0; j < count; j++)
{
var value = serieData.data[j];
if (value > max) max = value;
if (value < min) min = value;
if (!serie.IsIgnoreValue(value))
{
if (value > max) max = value;
if (value < min) min = value;
}
}
}
}
@@ -421,7 +431,7 @@ namespace XCharts
public static IconStyle GetIconStyle(Serie serie, SerieData serieData)
{
if(serieData.enableIconStyle) return serieData.iconStyle;
if (serieData.enableIconStyle) return serieData.iconStyle;
else return serie.iconStyle;
}
@@ -690,7 +700,6 @@ namespace XCharts
});
break;
case SerieDataSortType.None:
break;
}
}

View File

@@ -444,28 +444,29 @@ namespace XCharts
var serie = series.GetSerie(i);
if ((isPolar && serie.polarIndex != axisIndex)
|| (!isPolar && serie.yAxisIndex != axisIndex)) continue;
if (series.IsActive(i))
if (isPercentStack && SeriesHelper.IsPercentStack(series, serie.name, SerieType.Bar))
{
if (isPercentStack && SeriesHelper.IsPercentStack(series, serie.name, SerieType.Bar))
if (100 > max) max = 100;
if (0 < min) min = 0;
}
else
{
var showData = serie.GetDataList(dataZoom);
foreach (var data in showData)
{
if (100 > max) max = 100;
if (0 < min) min = 0;
}
else
{
var showData = serie.GetDataList(dataZoom);
foreach (var data in showData)
if (serie.type == SerieType.Candlestick)
{
if (serie.type == SerieType.Candlestick)
var dataMin = data.GetMinData(inverse);
var dataMax = data.GetMaxData(inverse);
if (dataMax > max) max = dataMax;
if (dataMin < min) min = dataMin;
}
else
{
var currData = data.GetData(yValue ? 1 : 0, inverse);
if (!serie.IsIgnoreValue(currData))
{
var dataMin = data.GetMinData(inverse);
var dataMax = data.GetMaxData(inverse);
if (dataMax > max) max = dataMax;
if (dataMin < min) min = dataMin;
}
else
{
var currData = data.GetData(yValue ? 1 : 0, inverse);
if (currData > max) max = currData;
if (currData < min) min = currData;
}
@@ -484,8 +485,7 @@ namespace XCharts
{
var serie = ss.Value[i];
if ((isPolar && serie.polarIndex != axisIndex)
|| (!isPolar && serie.yAxisIndex != axisIndex)
|| !series.IsActive(i)) continue;
|| (!isPolar && serie.yAxisIndex != axisIndex)) continue;
var showData = serie.GetDataList(dataZoom);
if (SeriesHelper.IsPercentStack(series, serie.stack, SerieType.Bar))
{
@@ -510,7 +510,8 @@ namespace XCharts
currData = yValue ? showData[j].GetData(1) : showData[j].GetData(0);
}
if (inverse) currData = -currData;
_serieTotalValueForMinMax[j] = _serieTotalValueForMinMax[j] + currData;
if(!serie.IsIgnoreValue(currData))
_serieTotalValueForMinMax[j] = _serieTotalValueForMinMax[j] + currData;
}
}
}

View File

@@ -224,6 +224,9 @@ namespace XCharts
{
m_CheckTheme = m_Theme.theme;
m_Theme.CopyTheme(m_CheckTheme);
#if UNITY_EDITOR
UnityEditor.EditorUtility.SetDirty(this);
#endif
SetAllComponentDirty();
OnThemeChanged();
}
@@ -450,7 +453,7 @@ namespace XCharts
var active = IsActiveByLegend(datas[i]);
var bgColor = LegendHelper.GetIconColor(this, readIndex, datas[i], active);
var item = LegendHelper.AddLegendItem(legend, i, datas[i], legendObject.transform, m_Theme,
legendName, bgColor, active);
legendName, bgColor, active,readIndex);
legend.SetButton(legendName, item, totalLegend);
ChartHelper.ClearEventListener(item.button.gameObject);
ChartHelper.AddEventListener(item.button.gameObject, EventTriggerType.PointerDown, (data) =>

View File

@@ -728,12 +728,12 @@ namespace XCharts
var labelName = AxisHelper.GetLabelName(xAxis, grid.runtimeWidth, i, xAxis.runtimeMinValue,
xAxis.runtimeMaxValue, dataZoom, isPercentStack);
var label = ChartHelper.AddAxisLabelObject(splitNumber, i, ChartCached.GetXAxisName(xAxisIndex, i),
axisObj.transform, new Vector2(0, 1), new Vector2(0, 1), new Vector2(1, 0.5f),
axisObj.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f),
new Vector2(textWidth, textHeight), xAxis, theme.axis, labelName);
if (i == 0) xAxis.axisLabel.SetRelatedText(label.label, labelWidth);
label.label.SetAlignment(axisLabelTextStyle.GetAlignment(TextAnchor.MiddleCenter));
label.SetPosition(GetLabelXPosition(totalWidth + textWidth / 2 + gapWidth, i, xAxisIndex, xAxis));
label.SetPosition(GetLabelXPosition(totalWidth + gapWidth, i, xAxisIndex, xAxis));
xAxis.runtimeAxisLabelList.Add(label);
totalWidth += labelWidth;
}
@@ -1464,10 +1464,11 @@ namespace XCharts
if (!serie.show) continue;
if (serie.IsPerformanceMode()) continue;
if (!serie.IsCoordinateSerie()) continue;
for (int j = 0; j < serie.data.Count; j++)
DataZoomHelper.GetSerieRelatedDataZoom(serie, dataZooms, out var xDataZoom, out var yDataZoom);
var showData = serie.GetDataList(xDataZoom);
for (int j = 0; j < showData.Count; j++)
{
var serieData = serie.data[j];
var serieData = showData[j];
if (serieData.labelObject == null) continue;
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData, serieData.highlighted);
serieData.index = j;
@@ -1546,9 +1547,13 @@ namespace XCharts
if (!serie.IsCoordinateSerie()) continue;
var total = serie.yTotal;
var isPercentStack = SeriesHelper.IsPercentStack(m_Series, serie.stack, SerieType.Bar);
for (int j = 0; j < serie.data.Count; j++)
DataZoomHelper.GetSerieRelatedDataZoom(serie, dataZooms, out var xDataZoom, out var yDataZoom);
var showData = serie.GetDataList(xDataZoom);
if (xDataZoom != null)
ChartHelper.HideAllObject(m_SerieLabelRoot, "label_" + i);
for (int j = 0; j < showData.Count; j++)
{
var serieData = serie.data[j];
var serieData = showData[j];
if (serieData.labelObject == null) continue;
if (j >= serie.dataPoints.Count)
{
@@ -1556,6 +1561,7 @@ namespace XCharts
serieData.SetIconActive(false);
continue;
}
serieData.labelObject.SetActive(true);
var pos = serie.dataPoints[j];
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
var iconStyle = SerieHelper.GetIconStyle(serie, serieData);
@@ -1689,11 +1695,11 @@ namespace XCharts
}
public void Internal_CheckClipAndDrawZebraLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size, float zebraWidth,
float zebraGap, Color32 color, bool clip, Grid grid)
float zebraGap, Color32 color, Color32 toColor, bool clip, Grid grid)
{
ClampInChart(ref p1);
ClampInChart(ref p2);
UGL.DrawZebraLine(vh, p1, p2, size, zebraWidth, zebraGap, color);
UGL.DrawZebraLine(vh, p1, p2, size, zebraWidth, zebraGap, color, toColor);
}
protected Color32 GetXLerpColor(Color32 areaColor, Color32 areaToColor, Vector3 pos, Grid grid)

View File

@@ -329,17 +329,18 @@ namespace XCharts
var center = new Vector3((plt.x + prb.x) / 2, (prt.y + plb.y) / 2);
if (itemWidth > 0 && itemHeight > 0)
{
var invert = center.x < plb.x;
if (ItemStyleHelper.IsNeedCorner(itemStyle))
{
UGL.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, areaToColor, 0,
itemStyle.cornerRadius, isYAxis);
itemStyle.cornerRadius, isYAxis, m_Settings.cicleSmoothness, invert);
}
else
{
Internal_CheckClipAndDrawPolygon(vh, plb, plt, prt, prb, areaColor, areaToColor, serie.clip, grid);
}
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
@@ -356,10 +357,11 @@ namespace XCharts
var center = new Vector3((plb.x + prt.x) / 2, (plt.y + prb.y) / 2);
if (itemWidth > 0 && itemHeight > 0)
{
var invert = center.y < plb.y;
if (ItemStyleHelper.IsNeedCorner(itemStyle))
{
UGL.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, areaToColor, 0,
itemStyle.cornerRadius, isYAxis);
itemStyle.cornerRadius, isYAxis, m_Settings.cicleSmoothness, invert);
}
else
{
@@ -367,7 +369,7 @@ namespace XCharts
serie.clip, grid);
}
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);
}
}
}
@@ -376,21 +378,22 @@ namespace XCharts
bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
Vector3 prb, bool isYAxis, Grid grid)
{
var areaColor = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight);
var barColor = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight);
var barToColor = SerieHelper.GetItemToColor(serie, serieData, m_Theme, colorIndex, highlight);
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid);
if (isYAxis)
{
plt = (plb + plt) / 2;
prt = (prt + prb) / 2;
Internal_CheckClipAndDrawZebraLine(vh, plt, prt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap,
areaColor, serie.clip, grid);
barColor, barToColor, serie.clip, grid);
}
else
{
plb = (prb + plb) / 2;
plt = (plt + prt) / 2;
Internal_CheckClipAndDrawZebraLine(vh, plb, plt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap,
areaColor, serie.clip, grid);
barColor, barToColor, serie.clip, grid);
}
}

View File

@@ -167,15 +167,11 @@ namespace XCharts
}
var startIndex = 0;
var endIndex = serie.dataPoints.Count;
var startPos = GetStartPos(serie.dataPoints, ref startIndex);
var endPos = GetEndPos(serie.dataPoints, ref endIndex);
var startPos = GetStartPos(serie.dataPoints, ref startIndex, serie.ignoreLineBreak);
var endPos = GetEndPos(serie.dataPoints, ref endIndex, serie.ignoreLineBreak);
lp = startPos;
stPos1 = stPos2 = lastDir = lastDnPos = Vector3.zero;
smoothStartPosUp = smoothStartPosDn = Vector3.zero;
float currDetailProgress = lp.x;
float totalDetailProgress = endPos.x;
serie.animation.InitProgress(serie.dataPoints.Count, currDetailProgress, totalDetailProgress);
serie.animation.SetDataFinish(startIndex);
Vector3 firstLastPos = Vector3.zero, lastNextPos = Vector3.zero;
if (serie.minShow > 0 && serie.minShow < showData.Count)
@@ -215,14 +211,41 @@ namespace XCharts
lastNextPos = endPos;
}
VisualMapHelper.AutoSetLineMinMax(visualMap, serie, xAxis, yAxis);
float currDetailProgress = lp.x;
float totalDetailProgress = endPos.x;
if (serie.animation.alongWithLinePath)
{
currDetailProgress = 0;
totalDetailProgress = 0;
var tempLp = startPos;
for (i = startIndex + 1; i < serie.dataPoints.Count; i++)
{
np = serie.dataPoints[i];
if (np != Vector3.zero)
{
totalDetailProgress += Vector3.Distance(np, tempLp);
tempLp = np;
}
}
serie.animation.SetLinePathStartPos(startPos);
}
serie.animation.InitProgress(serie.dataPoints.Count, currDetailProgress, totalDetailProgress);
serie.animation.SetDataFinish(startIndex);
for (i = startIndex + 1; i < serie.dataPoints.Count; i++)
{
np = serie.dataPoints[i];
serie.ClearSmoothList(i);
var isIgnoreBreak = false;
if (np == Vector3.zero)
{
serie.animation.SetDataFinish(i);
continue;
if (serie.ignoreLineBreak)
isIgnoreBreak = true;
else
{
serie.animation.SetDataFinish(i);
continue;
}
}
if (!serie.animation.NeedAnimation(i)) break;
bool isFinish = true;
@@ -239,34 +262,54 @@ namespace XCharts
switch (serie.lineType)
{
case LineType.Normal:
lp = GetLastPos(serie.dataPoints, i, np);
nnp = GetNNPos(serie.dataPoints, i, np);
isFinish = DrawNormalLine(vh, serie, xAxis, lp, np, nnp, i, lineColor,
areaColor, areaToColor, zeroPos, startIndex);
lp = GetLastPos(serie.dataPoints, i, np, serie.ignoreLineBreak);
nnp = GetNNPos(serie.dataPoints, i, np, serie.ignoreLineBreak);
if (lp == Vector3.zero && serie.ignoreLineBreak) isIgnoreBreak = true;
isFinish = DrawNormalLine(vh, serie, xAxis, lp, np, nnp, i,
isIgnoreBreak ? ColorUtil.clearColor32 : lineColor,
isIgnoreBreak ? ColorUtil.clearColor32 : areaColor,
isIgnoreBreak ? ColorUtil.clearColor32 : areaToColor,
zeroPos, startIndex);
break;
case LineType.Smooth:
case LineType.SmoothDash:
llp = GetLLPos(serie.dataPoints, i, firstLastPos);
nnp = GetNNPos(serie.dataPoints, i, lastNextPos);
llp = GetLLPos(serie.dataPoints, i, firstLastPos, serie.ignoreLineBreak);
nnp = GetNNPos(serie.dataPoints, i, lastNextPos, serie.ignoreLineBreak);
if (lp == Vector3.zero && serie.ignoreLineBreak) isIgnoreBreak = true;
isFinish = DrawSmoothLine(vh, serie, xAxis, lp, np, llp, nnp, i,
lineColor, areaColor, areaToColor, isStack, zeroPos, startIndex);
isIgnoreBreak ? ColorUtil.clearColor32 : lineColor,
isIgnoreBreak ? ColorUtil.clearColor32 : areaColor,
isIgnoreBreak ? ColorUtil.clearColor32 : areaToColor,
isStack, zeroPos, startIndex);
break;
case LineType.StepStart:
case LineType.StepMiddle:
case LineType.StepEnd:
nnp = GetNNPos(serie.dataPoints, i, np);
isFinish = DrawStepLine(vh, serie, xAxis, lp, np, nnp, i, lineColor,
areaColor, areaToColor, zeroPos);
nnp = GetNNPos(serie.dataPoints, i, np, serie.ignoreLineBreak);
if (lp == Vector3.zero && serie.ignoreLineBreak) isIgnoreBreak = true;
isFinish = DrawStepLine(vh, serie, xAxis, lp, np, nnp, i,
isIgnoreBreak ? ColorUtil.clearColor32 : lineColor,
isIgnoreBreak ? ColorUtil.clearColor32 : areaColor,
isIgnoreBreak ? ColorUtil.clearColor32 : areaToColor,
zeroPos);
break;
case LineType.Dash:
case LineType.Dot:
case LineType.DashDot:
case LineType.DashDotDot:
DrawOtherLine(vh, serie, xAxis, lp, np, i, lineColor, areaColor, areaToColor, zeroPos);
if (lp == Vector3.zero && serie.ignoreLineBreak) isIgnoreBreak = true;
DrawOtherLine(vh, serie, xAxis, lp, np, i,
isIgnoreBreak ? ColorUtil.clearColor32 : lineColor,
isIgnoreBreak ? ColorUtil.clearColor32 : areaColor,
isIgnoreBreak ? ColorUtil.clearColor32 : areaToColor,
zeroPos);
break;
}
if (isFinish) serie.animation.SetDataFinish(i);
if (np != Vector3.zero) lp = np;
if (np != Vector3.zero || serie.ignoreLineBreak)
{
lp = np;
}
}
if (!serie.animation.IsFinish())
{
@@ -277,22 +320,22 @@ namespace XCharts
}
}
private Vector3 GetNNPos(List<Vector3> dataPoints, int index, Vector3 np)
private Vector3 GetNNPos(List<Vector3> dataPoints, int index, Vector3 np, bool ignoreLineBreak)
{
int size = dataPoints.Count;
if (index >= size) return np;
for (int i = index + 1; i < size; i++)
{
if (dataPoints[i] != Vector3.zero) return dataPoints[i];
if (dataPoints[i] != Vector3.zero || ignoreLineBreak) return dataPoints[i];
}
return np;
}
private Vector3 GetStartPos(List<Vector3> dataPoints, ref int start)
private Vector3 GetStartPos(List<Vector3> dataPoints, ref int start, bool ignoreLineBreak)
{
for (int i = 0; i < dataPoints.Count; i++)
{
if (dataPoints[i] != Vector3.zero)
if (dataPoints[i] != Vector3.zero || ignoreLineBreak)
{
start = i;
return dataPoints[i];
@@ -301,11 +344,11 @@ namespace XCharts
return Vector3.zero;
}
private Vector3 GetEndPos(List<Vector3> dataPoints, ref int end)
private Vector3 GetEndPos(List<Vector3> dataPoints, ref int end, bool ignoreLineBreak)
{
for (int i = dataPoints.Count - 1; i >= 0; i--)
{
if (dataPoints[i] != Vector3.zero)
if (dataPoints[i] != Vector3.zero || ignoreLineBreak)
{
end = i;
return dataPoints[i];
@@ -314,22 +357,22 @@ namespace XCharts
return Vector3.zero;
}
private Vector3 GetLastPos(List<Vector3> dataPoints, int index, Vector3 pos)
private Vector3 GetLastPos(List<Vector3> dataPoints, int index, Vector3 pos, bool ignoreLineBreak)
{
if (index <= 0) return pos;
for (int i = index - 1; i >= 0; i--)
{
if (dataPoints[i] != Vector3.zero) return dataPoints[i];
if (dataPoints[i] != Vector3.zero || ignoreLineBreak) return dataPoints[i];
}
return pos;
}
private Vector3 GetLLPos(List<Vector3> dataPoints, int index, Vector3 lp)
private Vector3 GetLLPos(List<Vector3> dataPoints, int index, Vector3 lp, bool ignoreLineBreak)
{
if (index <= 1) return lp;
for (int i = index - 2; i >= 0; i--)
{
if (dataPoints[i] != Vector3.zero) return dataPoints[i];
if (dataPoints[i] != Vector3.zero || ignoreLineBreak) return dataPoints[i];
}
return lp;
}
@@ -618,7 +661,7 @@ namespace XCharts
case LineType.Normal:
nnp = i < serie.dataPoints.Count - 1 ? serie.dataPoints[i + 1] : np;
isFinish = DrawNormalLine(vh, serie, yAxis, lp, np, nnp, i, lineColor,
areaColor, areaToColor, zeroPos);
areaColor, areaToColor, zeroPos, 0);
break;
case LineType.Smooth:
case LineType.SmoothDash:
@@ -635,11 +678,11 @@ namespace XCharts
areaColor, areaToColor, zeroPos);
break;
case LineType.Dash:
UGL.DrawDashLine(vh, lp, np, serie.lineStyle.GetWidth(m_Theme.serie.lineWidth), lineColor);
UGL.DrawDashLine(vh, lp, np, serie.lineStyle.GetWidth(m_Theme.serie.lineWidth), lineColor, lineColor);
isFinish = true;
break;
case LineType.Dot:
UGL.DrawDotLine(vh, lp, np, serie.lineStyle.GetWidth(m_Theme.serie.lineWidth), lineColor);
UGL.DrawDotLine(vh, lp, np, serie.lineStyle.GetWidth(m_Theme.serie.lineWidth), lineColor, lineColor);
isFinish = true;
break;
case LineType.DashDot:
@@ -678,7 +721,7 @@ namespace XCharts
private bool lastIsDown;
private bool DrawNormalLine(VertexHelper vh, Serie serie, Axis axis, Vector3 lp, Vector3 np, Vector3 nnp,
int dataIndex, Color32 lineColor, Color32 areaColor, Color32 areaToColor,
Vector3 zeroPos, int startIndex = 0)
Vector3 zeroPos, int startIndex)
{
var defaultLineColor = lineColor;
var isSecond = dataIndex == startIndex + 1;
@@ -941,8 +984,8 @@ namespace XCharts
Vector3 aep = isYAxis ? new Vector3(zeroPos.x, zeroPos.y + grid.runtimeHeight) : new Vector3(zeroPos.x + grid.runtimeWidth, zeroPos.y);
var sindex = 0;
var eindex = 0;
var sp = GetStartPos(points, ref sindex);
var ep = GetEndPos(points, ref eindex);
var sp = GetStartPos(points, ref sindex, serie.ignoreLineBreak);
var ep = GetEndPos(points, ref eindex, serie.ignoreLineBreak);
var cross = ChartHelper.GetIntersection(lp, np, zeroPos, aep);
if (cross == Vector3.zero || smoothDownPoints.Count <= 3)
{
@@ -1172,10 +1215,10 @@ namespace XCharts
switch (serie.lineType)
{
case LineType.Dash:
UGL.DrawDashLine(vh, lp, np, lineWidth, lineColor, 0, 0, posList);
UGL.DrawDashLine(vh, lp, np, lineWidth, lineColor, lineColor, 0, 0, posList);
break;
case LineType.Dot:
UGL.DrawDotLine(vh, lp, np, lineWidth, lineColor, 0, 0, posList);
UGL.DrawDotLine(vh, lp, np, lineWidth, lineColor, lineColor, 0, 0, posList);
break;
case LineType.DashDot:
UGL.DrawDashDotLine(vh, lp, np, lineWidth, lineColor, 0, 0, 0, posList);

View File

@@ -104,6 +104,14 @@ namespace XCharts
itemStyle.backgroundColor, Color.clear, 0, 360, borderWidth, borderColor, 0,
chart.settings.cicleSmoothness, false, serie.clockwise);
}
var isGradient = !UGLHelper.IsValueEqualsColor(itemColor, itemToColor);
if (isGradient)
{
if (serie.clockwise)
itemToColor = Color.Lerp(itemColor, itemToColor, toDegree / (startDegree + 360));
else
itemToColor = Color.Lerp(itemToColor, itemColor, toDegree / (startDegree + 360));
}
UGL.DrawDoughnut(vh, serie.runtimeCenterPos, insideRadius, outsideRadius, itemColor, itemToColor,
Color.clear, startDegree, toDegree, borderWidth, borderColor, 0, chart.settings.cicleSmoothness,
roundCap, serie.clockwise);

View File

@@ -104,10 +104,10 @@ namespace XCharts
switch (lineType)
{
case LineStyle.Type.Dashed:
UGL.DrawDashLine(vh, startPos, endPos, lineWidth, color);
UGL.DrawDashLine(vh, startPos, endPos, lineWidth, color, color);
break;
case LineStyle.Type.Dotted:
UGL.DrawDotLine(vh, startPos, endPos, lineWidth, color);
UGL.DrawDotLine(vh, startPos, endPos, lineWidth, color, color);
break;
case LineStyle.Type.Solid:
UGL.DrawLine(vh, startPos, endPos, lineWidth, color);

View File

@@ -33,8 +33,8 @@ namespace XCharts
[ExecuteInEditMode]
public class XChartsMgr : MonoBehaviour
{
internal static string _version = "2.3.0";
internal static int _versionDate = 20210724;
internal static string _version = "2.4.0";
internal static int _versionDate = 20210831;
public static string version { get { return _version; } }
public static int versionDate { get { return _versionDate; } }
public static string fullVersion { get { return version + "-" + versionDate; } }
@@ -337,7 +337,7 @@ namespace XCharts
// Search for potential alternative locations in the user project
string[] matchingPaths = Directory.GetDirectories(packagePath, "XCharts", SearchOption.AllDirectories);
string path = ValidateLocation(matchingPaths, packagePath);
if (path != null) return packagePath + path;
if (path != null) return Path.Combine(packagePath, path);
}
return null;

View File

@@ -119,12 +119,13 @@ namespace XUGL
/// <param name="startPoint">起始点</param>
/// <param name="endPoint">结束点</param>
/// <param name="width">线宽</param>
/// <param name="color">颜色</param>
/// <param name="color">起始颜色</param>
/// <param name="toColor">结束颜色</param>
/// <param name="lineLength">实线部分长度默认为线宽的12倍</param>
/// <param name="gapLength">间隙部分长度默认为线宽的3倍</param>
/// <param name="posList">可选,输出的关键点</param>
public static void DrawDashLine(VertexHelper vh, Vector3 startPoint, Vector3 endPoint, float width,
Color32 color, float lineLength = 0f, float gapLength = 0f, List<Vector3> posList = null)
Color32 color, Color32 toColor, float lineLength = 0f, float gapLength = 0f, List<Vector3> posList = null)
{
float dist = Vector3.Distance(startPoint, endPoint);
if (dist < 0.1f) return;
@@ -133,17 +134,18 @@ namespace XUGL
int segment = Mathf.CeilToInt(dist / (lineLength + gapLength));
Vector3 dir = (endPoint - startPoint).normalized;
Vector3 sp = startPoint, np;
var isGradient = !color.Equals(toColor);
if (posList != null) posList.Clear();
for (int i = 1; i <= segment; i++)
{
if (posList != null) posList.Add(sp);
np = startPoint + dir * dist * i / segment;
var dashep = np - dir * gapLength;
DrawLine(vh, sp, dashep, width, color);
DrawLine(vh, sp, dashep, width, isGradient ? Color32.Lerp(color, toColor, i * 1.0f / segment) : color);
sp = np;
}
if (posList != null) posList.Add(endPoint);
DrawLine(vh, sp, endPoint, width, color);
DrawLine(vh, sp, endPoint, width, toColor);
}
/// <summary>
@@ -153,31 +155,34 @@ namespace XUGL
/// <param name="startPoint">起始点</param>
/// <param name="endPoint">结束点</param>
/// <param name="width">线宽</param>
/// <param name="color">颜色</param>
/// <param name="color">起始颜色</param>
/// <param name="toColor">结束颜色</param>
/// <param name="lineLength">实线部分长度默认为线宽的3倍</param>
/// <param name="gapLength">间隙部分长度默认为线宽的3倍</param>
/// <param name="posList">可选,输出的关键点</param>
public static void DrawDotLine(VertexHelper vh, Vector3 startPoint, Vector3 endPoint, float width,
Color32 color, float lineLength = 0f, float gapLength = 0f, List<Vector3> posList = null)
Color32 color, Color32 toColor, float lineLength = 0f, float gapLength = 0f, List<Vector3> posList = null)
{
float dist = Vector3.Distance(startPoint, endPoint);
var dist = Vector3.Distance(startPoint, endPoint);
if (dist < 0.1f) return;
if (lineLength == 0) lineLength = 3 * width;
if (gapLength == 0) gapLength = 3 * width;
int segment = Mathf.CeilToInt(dist / (lineLength + gapLength));
Vector3 dir = (endPoint - startPoint).normalized;
Vector3 sp = startPoint, np;
var segment = Mathf.CeilToInt(dist / (lineLength + gapLength));
var dir = (endPoint - startPoint).normalized;
var sp = startPoint;
var np = Vector3.zero;
var isGradient = !color.Equals(toColor);
if (posList != null) posList.Clear();
for (int i = 1; i <= segment; i++)
{
if (posList != null) posList.Add(sp);
np = startPoint + dir * dist * i / segment;
var dashep = np - dir * gapLength;
DrawLine(vh, sp, dashep, width, color);
DrawLine(vh, sp, dashep, width, isGradient ? Color32.Lerp(color, toColor, i * 1.0f / segment) : color);
sp = np;
}
if (posList != null) posList.Add(endPoint);
DrawLine(vh, sp, endPoint, width, color);
DrawLine(vh, sp, endPoint, width, toColor);
}
/// <summary>
@@ -277,11 +282,12 @@ namespace XUGL
/// <param name="width">线宽</param>
/// <param name="zebraWidth">斑马条纹宽</param>
/// <param name="zebraGap">间隙宽</param>
/// <param name="color">颜色</param>
/// <param name="color">起始颜色</param>
/// <param name="toColor">结束颜色</param>
public static void DrawZebraLine(VertexHelper vh, Vector3 startPoint, Vector3 endPoint, float width,
float zebraWidth, float zebraGap, Color32 color)
float zebraWidth, float zebraGap, Color32 color, Color32 toColor)
{
DrawDotLine(vh, startPoint, endPoint, width, color, zebraWidth, zebraGap);
DrawDotLine(vh, startPoint, endPoint, width, color, toColor, zebraWidth, zebraGap);
}
/// <summary>
@@ -477,13 +483,34 @@ namespace XUGL
}
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;
brLt = cornerRadius.Length > 0 ? cornerRadius[0] : 0;
brRt = cornerRadius.Length > 1 ? cornerRadius[1] : 0;
brRb = cornerRadius.Length > 2 ? cornerRadius[2] : 0;
brLb = cornerRadius.Length > 3 ? cornerRadius[3] : 0;
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;
brRt = cornerRadius.Length > 1 ? cornerRadius[1] : 0;
brRb = cornerRadius.Length > 2 ? cornerRadius[2] : 0;
brLb = cornerRadius.Length > 3 ? cornerRadius[3] : 0;
}
needRound = brLb != 0 || brRt != 0 || brRb != 0 || brLb != 0;
if (needRound)
{
@@ -562,18 +589,22 @@ namespace XUGL
/// <param name="rectWidth"></param>
/// <param name="rectHeight"></param>
/// <param name="color"></param>
/// <param name="toColor"></param>
/// <param name="rotate"></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,
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 halfWid = rectWidth / 2;
var halfHig = rectHeight / 2;
float brLt = 0, brRt = 0, brRb = 0, brLb = 0;
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);
var tempCenter = Vector3.zero;
var lbIn = new Vector3(center.x - halfWid, center.y - halfHig);
@@ -805,12 +836,13 @@ namespace XUGL
/// <param name="color"></param>
/// <param name="rotate"></param>
/// <param name="cornerRadius"></param>
/// <param name="invertCorner"></param>
public static void DrawBorder(VertexHelper vh, Vector3 center, float rectWidth, float rectHeight,
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,
cornerRadius, horizontal, smoothness);
cornerRadius, horizontal, smoothness, invertCorner);
}
/// <summary>
@@ -825,9 +857,12 @@ namespace XUGL
/// <param name="toColor"></param>
/// <param name="rotate"></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,
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;
var halfWid = rectWidth / 2;
@@ -842,7 +877,7 @@ namespace XUGL
var rbOt = new Vector3(center.x + halfWid + borderWidth, center.y - halfHig - borderWidth);
float brLt = 0, brRt = 0, brRb = 0, brLb = 0;
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);
var tempCenter = Vector3.zero;
if (UGLHelper.IsClearColor(toColor))

View File

@@ -1,9 +1,9 @@
{
"name": "com.monitor1394.xcharts",
"displayName": "XCharts",
"version": "2.3.0",
"date": "20210724",
"checkdate": "20210724",
"version": "2.4.0",
"date": "20210831",
"checkdate": "20210831",
"desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!",
"unity": "2018.3",
"description": "A charting and data visualization library for Unity.",

View File

@@ -1,7 +1,7 @@
{
"version": "2.3.0",
"date": "20210724",
"checkdate": "20210724",
"version": "2.4.0",
"date": "20210831",
"checkdate": "20210831",
"desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!",
"homepage": "https://github.com/monitor1394/unity-ugui-XCharts"
}