增加RadarCoordstartAngle可设置Radar起始角度

This commit is contained in:
monitor1394
2022-10-26 08:04:44 +08:00
parent 42a77a9439
commit ce4e88c51c
7 changed files with 34 additions and 14 deletions

View File

@@ -59,7 +59,8 @@
## master
* (2022.10.21) 修复`Chart``Layout`布局下时`Label`显示不正常的问题 (#231)
* (2022.10.26) 增加`RadarCoord``startAngle`可设置`Radar`起始角度
* (2022.10.21) 修复`Chart`在受`Layout`控制时`Label`显示不正常的问题 (#231)
* (2022.10.21) 修复`Unity2019.2`上的兼容问题
* (2022.10.18) 优化`Axis`的数值表现
* (2022.10.15) 修复`Axis``Label``DataZoom`开启时可能显示不正常的问题 (#227)
@@ -67,10 +68,10 @@
* (2022.10.13) 修复`Pie`的环形饼图设置边框时效果异常的问题 (#225)
* (2022.10.13) 修复`Download`的接口造成`iOS`平台打包失败的问题
* (2022.10.12) 增加`Animation``UnscaledTime`支持设置动画是否受TimeScale的影响 (#223)
* (2022.10.10) 调整文档格式
* (2022.10.10) 优化`Documentation`文档格式
* (2022.10.10) 增加`Line``SmoothLimit`可控制平滑曲线不同效果
* (2022.10.05) 修复`Serie`隐藏时`Tooltip`还显示信息的问题
* (2022.09.30) 修复`Chart`在很小尺寸时出现`DivideByZeroException`异常的问题
* (2022.09.30) 修复`Chart`在很小尺寸时出现`DivideByZeroException`异常的问题 (#230)
## v3.3.0

View File

@@ -201,6 +201,7 @@ the animation of serie.
|dataChangeEnable|true||是否开启数据变更动画。
|dataChangeDuration|500||The milliseconds duration of the data change animation.
|actualDuration|||The milliseconds actual duration of the first animation.
|unscaledTime||v3.4.0|Animation updates independently of Time.timeScale.
## AreaStyle
@@ -632,7 +633,7 @@ Inherits or Implemented: [Serie](#Serie),[INeedSerieContainer](#INeedSerieContai
|field|default|since|comment|
|--|--|--|--|
|heatmapType||3.3.0|The mapping type of heatmap.<br/>`HeatmapType`:<br/>- `Data`: Data mapping type.By default, the second dimension data is used as the color map.<br/>- `Count`: Number mapping type.The number of occurrences of a statistic in a divided grid, as a color map.<br/>|
|heatmapType||v3.3.0|The mapping type of heatmap.<br/>`HeatmapType`:<br/>- `Data`: Data mapping type.By default, the second dimension data is used as the color map.<br/>- `Count`: Number mapping type.The number of occurrences of a statistic in a divided grid, as a color map.<br/>|
## IconStyle
@@ -692,6 +693,7 @@ Indicator of radar chart, which is used to assign multiple variables(dimensions)
|outRangeColor|Color.red||The color displayed when data out of range.
|connectCenter|false||Whether serie data connect to radar center with line.
|lineGradient|true||Whether need gradient for data line.
|startAngle||v3.4.0|起始角度。和时钟一样12点钟位置是0度顺时针到360度。
|indicatorList|||the indicator list.
## ItemStyle
@@ -1018,7 +1020,7 @@ Inherits or Implemented: [Serie](#Serie),[INeedSerieContainer](#INeedSerieContai
|field|default|since|comment|
|--|--|--|--|
|smooth|false|3.2.0|Whether use smooth curve.
|smooth|false|v3.2.0|Whether use smooth curve.
## RadarAxisTheme
@@ -1093,6 +1095,7 @@ Inherits or Implemented: [BaseSerie](#BaseSerie),[IComparable](#IComparable)
|sampleType|||the type of sample.<br/>`SampleType`:<br/>- `Peak`: Take a peak. When the average value of the filter point is greater than or equal to 'sampleAverage', take the maximum value; If you do it the other way around, you get the minimum.<br/>- `Average`: Take the average of the filter points.<br/>- `Max`: Take the maximum value of the filter point.<br/>- `Min`: Take the minimum value of the filter point.<br/>- `Sum`: Take the sum of the filter points.<br/>|
|sampleAverage|0||设定的采样平均值。当sampleType 为 Peak 时用于和过滤数据的平均值做对比是取最大值还是最小值。默认为0时会实时计算所有数据的平均值。
|lineType|||The type of line chart.<br/>`LineType`:<br/>- `Normal`: the normal line chart<br/>- `Smooth`: the smooth line chart<br/>- `StepStart`: step line.<br/>- `StepMiddle`: step line.<br/>- `StepEnd`: step line.<br/>|
|smoothLimit|true|v3.4.0|Whether to restrict the curve. When true, the curve between two continuous data of the same value is restricted to not exceed the data point, and is flat to the data point.
|barType|||柱形图类型。<br/>`BarType`:<br/>- `Normal`: normal bar.<br/>- `Zebra`: zebra bar.<br/>- `Capsule`: capsule bar.<br/>|
|barPercentStack|false||柱形图是否为百分比堆积。相同stack的serie只要有一个barPercentStack为true则就显示成百分比堆叠柱状图。
|barWidth|0||The width of the bar. Adaptive when default 0.

View File

@@ -201,6 +201,7 @@ Inherits or Implemented: [ChildComponent](#ChildComponent)
|dataChangeEnable|true||是否开启数据变更动画。
|dataChangeDuration|500||数据变更的动画时长(毫秒)。
|actualDuration|||实际的动画时长(毫秒)。
|unscaledTime||v3.4.0|动画是否受TimeScaled的影响。默认为 false 受TimeScaled的影响。
## AreaStyle
@@ -632,7 +633,7 @@ Inherits or Implemented: [Serie](#Serie),[INeedSerieContainer](#INeedSerieContai
|field|default|since|comment|
|--|--|--|--|
|heatmapType||3.3.0|热力图类型。通过颜色映射划分。<br/>`HeatmapType`:<br/>- `Data`: 数据映射型。默认用第2维数据作为颜色映射。要求数据至少有3个维度数据。<br/>- `Count`: 个数映射型。统计数据在划分的格子中出现的次数作为颜色映射。要求数据至少有2个维度数据。<br/>|
|heatmapType||v3.3.0|热力图类型。通过颜色映射划分。<br/>`HeatmapType`:<br/>- `Data`: 数据映射型。默认用第2维数据作为颜色映射。要求数据至少有3个维度数据。<br/>- `Count`: 个数映射型。统计数据在划分的格子中出现的次数作为颜色映射。要求数据至少有2个维度数据。<br/>|
## IconStyle
@@ -692,6 +693,7 @@ Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieExtraComponent
|outRangeColor|Color.red||数值超出范围时显示的颜色。
|connectCenter|false||数值是否连线到中心点。
|lineGradient|true||数值线段是否需要渐变。
|startAngle||v3.4.0|起始角度。和时钟一样12点钟位置是0度顺时针到360度。
|indicatorList|||指示器列表。
## ItemStyle
@@ -1018,7 +1020,7 @@ Inherits or Implemented: [Serie](#Serie),[INeedSerieContainer](#INeedSerieContai
|field|default|since|comment|
|--|--|--|--|
|smooth|false|3.2.0|是否平滑曲线。平滑曲线时不支持区域填充颜色。
|smooth|false|v3.2.0|是否平滑曲线。平滑曲线时不支持区域填充颜色。
## RadarAxisTheme
@@ -1093,6 +1095,7 @@ Inherits or Implemented: [BaseSerie](#BaseSerie),[IComparable](#IComparable)
|sampleType|||采样类型。当sampleDist大于0时有效。<br/>`SampleType`:<br/>- `Peak`: 取峰值。<br/>- `Average`: 取过滤点的平均值。<br/>- `Max`: 取过滤点的最大值。<br/>- `Min`: 取过滤点的最小值。<br/>- `Sum`: 取过滤点的和。<br/>|
|sampleAverage|0||设定的采样平均值。当sampleType 为 Peak 时用于和过滤数据的平均值做对比是取最大值还是最小值。默认为0时会实时计算所有数据的平均值。
|lineType|||折线图样式类型。<br/>`LineType`:<br/>- `Normal`: 普通折线图。<br/>- `Smooth`: 平滑曲线。<br/>- `StepStart`: 阶梯线图:当前点。<br/>- `StepMiddle`: 阶梯线图:当前点和下一个点的中间。<br/>- `StepEnd`: 阶梯线图:下一个拐点。<br/>|
|smoothLimit|true|v3.4.0|是否限制曲线。当为true时两个连续相同数值的数据间的曲线会限制为不超出数据点和数据点是平直的。
|barType|||柱形图类型。<br/>`BarType`:<br/>- `Normal`: 普通柱形图。<br/>- `Zebra`: 斑马柱形图。<br/>- `Capsule`: 胶囊柱形图。<br/>|
|barPercentStack|false||柱形图是否为百分比堆积。相同stack的serie只要有一个barPercentStack为true则就显示成百分比堆叠柱状图。
|barWidth|0||柱条的宽度,不设时自适应。支持设置成相对于类目宽度的百分比。

View File

@@ -15,6 +15,7 @@ namespace XCharts.Editor
PropertyTwoFiled("m_Center");
PropertyField("m_Radius");
PropertyField("m_SplitNumber");
PropertyField("m_StartAngle");
PropertyField("m_CeilRate");
PropertyField("m_IsAxisTooltip");
PropertyField("m_OutRangeColor");

View File

@@ -108,6 +108,7 @@ namespace XCharts.Runtime
[SerializeField] private Color32 m_OutRangeColor = Color.red;
[SerializeField] private bool m_ConnectCenter = false;
[SerializeField] private bool m_LineGradient = true;
[SerializeField][Since("v3.4.0")] private float m_StartAngle;
[SerializeField] private List<Indicator> m_IndicatorList = new List<Indicator>();
public RadarCoordContext context = new RadarCoordContext();
@@ -264,6 +265,14 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_LineGradient, value)) SetAllDirty(); }
}
/// <summary>
/// 起始角度。和时钟一样12点钟位置是0度顺时针到360度。
/// </summary>
public float startAngle
{
get { return m_StartAngle; }
set { if (PropertyUtil.SetStruct(ref m_StartAngle, value)) SetVerticesDirty(); }
}
/// <summary>
/// the indicator list.
/// |指示器列表。
/// </summary>

View File

@@ -124,7 +124,8 @@ namespace XCharts.Runtime
int indicatorNum = radar.indicatorList.Count;
Vector3 p1, p2, p3, p4;
Vector3 p = radar.context.center;
float angle = 2 * Mathf.PI / indicatorNum;
var startAngle = radar.startAngle * Mathf.PI / 180;
var angle = 2 * Mathf.PI / indicatorNum;
var lineColor = radar.axisLine.GetColor(chart.theme.axis.splitLineColor);
var lineWidth = radar.axisLine.GetWidth(chart.theme.axis.lineWidth);
var lineType = radar.axisLine.GetType(chart.theme.axis.lineType);
@@ -135,11 +136,11 @@ namespace XCharts.Runtime
{
var color = radar.splitArea.GetColor(i, chart.theme.axis);
outsideRadius = insideRadius + block;
p1 = new Vector3(p.x + insideRadius * Mathf.Sin(0), p.y + insideRadius * Mathf.Cos(0));
p2 = new Vector3(p.x + outsideRadius * Mathf.Sin(0), p.y + outsideRadius * Mathf.Cos(0));
p1 = new Vector3(p.x + insideRadius * Mathf.Sin(startAngle), p.y + insideRadius * Mathf.Cos(startAngle));
p2 = new Vector3(p.x + outsideRadius * Mathf.Sin(startAngle), p.y + outsideRadius * Mathf.Cos(startAngle));
for (int j = 0; j <= indicatorNum; j++)
{
float currAngle = j * angle;
float currAngle = startAngle + j * angle;
p3 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
p.y + outsideRadius * Mathf.Cos(currAngle));
p4 = new Vector3(p.x + insideRadius * Mathf.Sin(currAngle),
@@ -161,7 +162,7 @@ namespace XCharts.Runtime
{
for (int j = 0; j <= indicatorNum; j++)
{
float currAngle = j * angle;
float currAngle = startAngle + j * angle;
p3 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
p.y + outsideRadius * Mathf.Cos(currAngle));
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, p, p3, lineColor);

View File

@@ -224,6 +224,7 @@ namespace XCharts.Runtime
var unscaledTime = serie.animation.unscaledTime;
SerieHelper.GetAllMinMaxData(serie, m_RadarCoord.ceilRate);
Color32 areaColor, areaToColor;
var startAngle = m_RadarCoord.startAngle * Mathf.PI / 180;
for (int j = 0; j < serie.data.Count; j++)
{
var serieData = serie.data[j];
@@ -264,7 +265,7 @@ namespace XCharts.Runtime
}
}
var radius = (float) (m_RadarCoord.context.dataRadius * (value - min) / (max - min));
var currAngle = (n + (m_RadarCoord.positionType == RadarCoord.PositionType.Between ? 0.5f : 0)) * angle;
var currAngle = startAngle + (n + (m_RadarCoord.positionType == RadarCoord.PositionType.Between ? 0.5f : 0)) * angle;
radius *= rate;
if (n == 0)
{
@@ -365,6 +366,7 @@ namespace XCharts.Runtime
var unscaledTime = serie.animation.unscaledTime;
var startIndex = GetStartShowIndex(serie);
var endIndex = GetEndShowIndex(serie);
var startAngle = m_RadarCoord.startAngle * Mathf.PI / 180;
SerieHelper.UpdateMinMaxData(serie, 1, m_RadarCoord.ceilRate);
for (int j = 0; j < serie.data.Count; j++)
{
@@ -397,7 +399,7 @@ namespace XCharts.Runtime
}
var radius = (float) (max < 0 ? m_RadarCoord.context.dataRadius - m_RadarCoord.context.dataRadius * value / max :
m_RadarCoord.context.dataRadius * value / max);
var currAngle = (index + (m_RadarCoord.positionType == RadarCoord.PositionType.Between ? 0.5f : 0)) * angle;
var currAngle = startAngle + (index + (m_RadarCoord.positionType == RadarCoord.PositionType.Between ? 0.5f : 0)) * angle;
radius *= rate;
if (index == startIndex)
{