mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-14 20:00:09 +00:00
增加Radar的splitLine参数配置分割线,去掉lineStyle参数
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
|
||||
# 更新日志
|
||||
|
||||
* (2020.02.11) 增加`Radar`的`splitLine`参数配置分割线,去掉`lineStyle`参数
|
||||
* (2020.02.11) 增加`Tooltip`的`backgroundImage`参数配置背景图
|
||||
* (2020.02.11) 增加`Tooltip`的`paddingLeftRight`和`paddingTopBottom`参数配置文字和边框的间距
|
||||
* (2020.02.11) 增加`Tooltip`的`lineStyle`参数配置指示线样式
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
* [AxisLabel 坐标轴刻度标签](#AxisLabel)
|
||||
* [AxisLine 坐标轴轴线](#AxisLine)
|
||||
* [AxisName 坐标轴名称](#AxisName)
|
||||
* [AxisSplitLine 坐标轴分割线条](#AxisSplitLine)
|
||||
* [AxisSplitArea 坐标轴分割区域](#AxisSplitArea)
|
||||
* [AxisTick 坐标轴刻度](#AxisTick)
|
||||
* [Emphasis 高亮样式](#Emphasis)
|
||||
@@ -143,7 +144,7 @@
|
||||
* `Between`:显示在顶点之间。
|
||||
* `radius`:雷达图的半径。
|
||||
* `center`:雷达图的中心点。数组的第一项是横坐标,第二项是纵坐标。当值为0-1之间时表示百分比,设置成百分比时第一项是相对于容器宽度,第二项是相对于容器高度。
|
||||
* `lineStyle`:线条样式 [LineStyle](#LineStyle)。
|
||||
* `splitLine`:分割线条 [AxisSplitLine](#AxisSplitLine)。
|
||||
* `splitArea`:分割区域 [AxisSplitArea](#AxisSplitArea)。
|
||||
* `indicator`:是否显示指示器。
|
||||
* `indicatorGap`:指示器和雷达的间距。
|
||||
@@ -539,6 +540,7 @@
|
||||
* `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。
|
||||
* `radarIndex`:雷达图所使用的 `radar` 组件的 `index`。
|
||||
* `symbol`:标记的图形 [SerieSymbol](#SerieSymbol)。
|
||||
* `lineStyle`:线条样式 [LineStyle](#LineStyle)。
|
||||
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
|
||||
* `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1`到`n`维数据。
|
||||
|
||||
@@ -714,7 +716,7 @@
|
||||
|
||||
## `LineStyle`
|
||||
|
||||
* `show`:是否显示线条。在折线图中无效。
|
||||
* `show`:是否显示线条。当作为子组件,它的父组件有参数控制是否显示时,改参数无效。
|
||||
* `type`:线条类型。支持以下五种类型:
|
||||
* `None`:不显示分割线。
|
||||
* `Solid`:实线。
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace XCharts
|
||||
SerializedProperty m_Radius;
|
||||
SerializedProperty m_SplitNumber;
|
||||
SerializedProperty m_Center;
|
||||
SerializedProperty m_LineStyle;
|
||||
SerializedProperty m_SplitLine;
|
||||
SerializedProperty m_SplitArea;
|
||||
SerializedProperty m_Indicator;
|
||||
SerializedProperty m_IndicatorGap;
|
||||
@@ -39,7 +39,7 @@ namespace XCharts
|
||||
m_Radius = prop.FindPropertyRelative("m_Radius");
|
||||
m_SplitNumber = prop.FindPropertyRelative("m_SplitNumber");
|
||||
m_Center = prop.FindPropertyRelative("m_Center");
|
||||
m_LineStyle = prop.FindPropertyRelative("m_LineStyle");
|
||||
m_SplitLine = prop.FindPropertyRelative("m_SplitLine");
|
||||
m_SplitArea = prop.FindPropertyRelative("m_SplitArea");
|
||||
m_Indicator = prop.FindPropertyRelative("m_Indicator");
|
||||
m_IndicatorGap = prop.FindPropertyRelative("m_IndicatorGap");
|
||||
@@ -85,8 +85,8 @@ namespace XCharts
|
||||
EditorGUI.PropertyField(drawRect, m_SplitNumber);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
EditorGUI.PropertyField(drawRect, m_LineStyle);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle);
|
||||
EditorGUI.PropertyField(drawRect, m_SplitLine);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_SplitLine);
|
||||
EditorGUI.PropertyField(drawRect, m_SplitArea);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_SplitArea);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
@@ -112,7 +112,7 @@ namespace XCharts
|
||||
propNum += 7;
|
||||
if (m_IndicatorJsonAreaToggle) propNum += 4;
|
||||
float height = propNum * EditorGUIUtility.singleLineHeight + (propNum - 1) * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_SplitLine"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_SplitArea"));
|
||||
|
||||
if (ChartEditorHelper.IsToggle(m_IndicatorToggle, prop))
|
||||
|
||||
@@ -194,6 +194,8 @@ namespace XCharts
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Symbol);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol);
|
||||
EditorGUI.PropertyField(drawRect, m_LineStyle);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle);
|
||||
EditorGUI.PropertyField(drawRect, m_AreaStyle);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_AreaStyle);
|
||||
break;
|
||||
@@ -451,6 +453,7 @@ namespace XCharts
|
||||
case SerieType.Radar:
|
||||
height += 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_AreaStyle"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace XCharts
|
||||
radar.center[0] = center.x;
|
||||
radar.center[1] = center.y;
|
||||
radar.splitArea.show = showSplitArea;
|
||||
radar.lineStyle.width = lineWidth;
|
||||
radar.splitLine.lineStyle.width = lineWidth;
|
||||
m_Radars.Add(radar);
|
||||
return radar;
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace XCharts
|
||||
[SerializeField] private float m_Radius = 100;
|
||||
[SerializeField] private int m_SplitNumber = 5;
|
||||
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.5f };
|
||||
[SerializeField] private LineStyle m_LineStyle = new LineStyle();
|
||||
[SerializeField] private AxisSplitLine m_SplitLine = AxisSplitLine.defaultSplitLine;
|
||||
[SerializeField] private AxisSplitArea m_SplitArea = AxisSplitArea.defaultSplitArea;
|
||||
[SerializeField] private bool m_Indicator = true;
|
||||
[SerializeField] private PositionType m_PositionType = PositionType.Vertice;
|
||||
@@ -155,10 +155,10 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public float[] center { get { return m_Center; } set { m_Center = value; } }
|
||||
/// <summary>
|
||||
/// the line style of radar.
|
||||
/// 线条样式。
|
||||
/// split line.
|
||||
/// 分割线。
|
||||
/// </summary>
|
||||
public LineStyle lineStyle { get { return m_LineStyle; } set { m_LineStyle = value; } }
|
||||
public AxisSplitLine splitLine { get { return m_SplitLine; } set { m_SplitLine = value; } }
|
||||
/// <summary>
|
||||
/// Split area of axis in grid area.
|
||||
/// 分割区域。
|
||||
@@ -220,8 +220,9 @@ namespace XCharts
|
||||
};
|
||||
radar.center[0] = 0.5f;
|
||||
radar.center[1] = 0.45f;
|
||||
radar.splitLine.show = true;
|
||||
radar.splitArea.show = true;
|
||||
radar.lineStyle.width = 0.6f;
|
||||
radar.splitLine.lineStyle.width = 0.6f;
|
||||
return radar;
|
||||
}
|
||||
}
|
||||
@@ -234,6 +235,8 @@ namespace XCharts
|
||||
m_Center[0] = other.center[0];
|
||||
m_Center[1] = other.center[1];
|
||||
m_Indicator = other.indicator;
|
||||
//m_SplitLine.Copy(other.splitLine);
|
||||
//m_SplitArea.Copy(other.splitArea);
|
||||
indicatorList.Clear();
|
||||
foreach (var d in other.indicatorList) indicatorList.Add(d.Clone());
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace XCharts
|
||||
|
||||
internal bool NeedShow(int index)
|
||||
{
|
||||
return interval == 0 || index % (interval + 1) == 0;
|
||||
return show && (interval == 0 || index % (interval + 1) == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ namespace XCharts
|
||||
|
||||
/// <summary>
|
||||
/// Whether show line.
|
||||
/// 是否显示线条。在折线图中无效。
|
||||
/// 是否显示线条。当作为子组件,它的父组件有参数控制是否显示时,改参数无效。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace XCharts
|
||||
|
||||
DrawProgressBar(vh, serie, currAngle);
|
||||
DrawStageColor(vh, serie);
|
||||
DrawSplitLine(vh, serie);
|
||||
DrawLineStyle(vh, serie);
|
||||
DrawAxisTick(vh, serie);
|
||||
DrawPointer(vh, serie, currAngle);
|
||||
UpdateTitle(serie);
|
||||
@@ -215,7 +215,7 @@ namespace XCharts
|
||||
ChartDrawer.DrawPolygon(vh, p1, p3, p2, p4, pointerColor);
|
||||
}
|
||||
|
||||
private void DrawSplitLine(VertexHelper vh, Serie serie)
|
||||
private void DrawLineStyle(VertexHelper vh, Serie serie)
|
||||
{
|
||||
if (serie.gaugeType != GaugeType.Pointer) return;
|
||||
if (!serie.gaugeAxis.show || !serie.gaugeAxis.splitLine.show) return;
|
||||
|
||||
@@ -787,6 +787,31 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
protected void DrawLineStyle(VertexHelper vh, LineStyle lineStyle,
|
||||
Vector3 startPos, Vector3 endPos, Color color)
|
||||
{
|
||||
var type = lineStyle.type;
|
||||
var width = lineStyle.width;
|
||||
switch (type)
|
||||
{
|
||||
case LineStyle.Type.Dashed:
|
||||
ChartDrawer.DrawDashLine(vh, startPos, endPos, width, color);
|
||||
break;
|
||||
case LineStyle.Type.Dotted:
|
||||
ChartDrawer.DrawDotLine(vh, startPos, endPos, width, color);
|
||||
break;
|
||||
case LineStyle.Type.Solid:
|
||||
ChartDrawer.DrawLine(vh, startPos, endPos, width, color);
|
||||
break;
|
||||
case LineStyle.Type.DashDot:
|
||||
ChartDrawer.DrawDashDotLine(vh, startPos, endPos, width, color);
|
||||
break;
|
||||
case LineStyle.Type.DashDotDot:
|
||||
ChartDrawer.DrawDashDotDotLine(vh, startPos, endPos, width, color);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void DrawLabelBackground(VertexHelper vh, Serie serie, SerieData serieData)
|
||||
{
|
||||
var labelHalfWid = serieData.GetLabelWidth() / 2;
|
||||
|
||||
@@ -980,7 +980,7 @@ namespace XCharts
|
||||
{
|
||||
if (yAxis.splitLine.NeedShow(i))
|
||||
{
|
||||
DrawSplitLine(vh, yAxis.splitLine.lineStyle, new Vector3(coordinateX, pY),
|
||||
DrawLineStyle(vh, yAxis.splitLine.lineStyle, new Vector3(coordinateX, pY),
|
||||
new Vector3(coordinateX + coordinateWidth, pY), yAxis.splitLine.GetColor(m_ThemeInfo));
|
||||
}
|
||||
}
|
||||
@@ -1070,7 +1070,7 @@ namespace XCharts
|
||||
{
|
||||
if (xAxis.splitLine.NeedShow(i))
|
||||
{
|
||||
DrawSplitLine(vh, xAxis.splitLine.lineStyle, new Vector3(pX, coordinateY),
|
||||
DrawLineStyle(vh, xAxis.splitLine.lineStyle, new Vector3(pX, coordinateY),
|
||||
new Vector3(pX, coordinateY + coordinateHeight), xAxis.splitLine.GetColor(m_ThemeInfo));
|
||||
}
|
||||
}
|
||||
@@ -1230,31 +1230,6 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
protected void DrawSplitLine(VertexHelper vh, LineStyle lineStyle,
|
||||
Vector3 startPos, Vector3 endPos, Color color)
|
||||
{
|
||||
var type = lineStyle.type;
|
||||
var width = lineStyle.width;
|
||||
switch (type)
|
||||
{
|
||||
case LineStyle.Type.Dashed:
|
||||
ChartDrawer.DrawDashLine(vh, startPos, endPos, width, color);
|
||||
break;
|
||||
case LineStyle.Type.Dotted:
|
||||
ChartDrawer.DrawDotLine(vh, startPos, endPos, width, color);
|
||||
break;
|
||||
case LineStyle.Type.Solid:
|
||||
ChartDrawer.DrawLine(vh, startPos, endPos, width, color);
|
||||
break;
|
||||
case LineStyle.Type.DashDot:
|
||||
ChartDrawer.DrawDashDotLine(vh, startPos, endPos, width, color);
|
||||
break;
|
||||
case LineStyle.Type.DashDotDot:
|
||||
ChartDrawer.DrawDashDotDotLine(vh, startPos, endPos, width, color);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void DrawXTooltipIndicator(VertexHelper vh)
|
||||
{
|
||||
if (!m_Tooltip.show || !m_Tooltip.IsSelected()) return;
|
||||
@@ -1275,12 +1250,12 @@ namespace XCharts
|
||||
if (xAxis.IsValue()) pX = m_Tooltip.runtimePointerPos.x;
|
||||
Vector2 sp = new Vector2(pX, coordinateY);
|
||||
Vector2 ep = new Vector2(pX, coordinateY + coordinateHeight);
|
||||
DrawSplitLine(vh, m_Tooltip.lineStyle, sp, ep, m_Tooltip.GetLineColor(m_ThemeInfo));
|
||||
DrawLineStyle(vh, m_Tooltip.lineStyle, sp, ep, m_Tooltip.GetLineColor(m_ThemeInfo));
|
||||
if (m_Tooltip.type == Tooltip.Type.Corss)
|
||||
{
|
||||
sp = new Vector2(coordinateX, m_Tooltip.runtimePointerPos.y);
|
||||
ep = new Vector2(coordinateX + coordinateWidth, m_Tooltip.runtimePointerPos.y);
|
||||
DrawSplitLine(vh, m_Tooltip.lineStyle, sp, ep, m_Tooltip.GetLineColor(m_ThemeInfo));
|
||||
DrawLineStyle(vh, m_Tooltip.lineStyle, sp, ep, m_Tooltip.GetLineColor(m_ThemeInfo));
|
||||
}
|
||||
break;
|
||||
case Tooltip.Type.Shadow:
|
||||
@@ -1318,12 +1293,12 @@ namespace XCharts
|
||||
float pY = coordinateY + m_Tooltip.runtimeYValues[i] * splitWidth + (yAxis.boundaryGap ? splitWidth / 2 : 0);
|
||||
Vector2 sp = new Vector2(coordinateX, pY);
|
||||
Vector2 ep = new Vector2(coordinateX + coordinateWidth, pY);
|
||||
DrawSplitLine(vh, m_Tooltip.lineStyle, sp, ep, m_Tooltip.GetLineColor(m_ThemeInfo));
|
||||
DrawLineStyle(vh, m_Tooltip.lineStyle, sp, ep, m_Tooltip.GetLineColor(m_ThemeInfo));
|
||||
if (m_Tooltip.type == Tooltip.Type.Corss)
|
||||
{
|
||||
sp = new Vector2(coordinateX, m_Tooltip.runtimePointerPos.y);
|
||||
ep = new Vector2(coordinateX + coordinateWidth, m_Tooltip.runtimePointerPos.y);
|
||||
DrawSplitLine(vh, m_Tooltip.lineStyle, sp, ep, m_Tooltip.GetLineColor(m_ThemeInfo));
|
||||
DrawLineStyle(vh, m_Tooltip.lineStyle, sp, ep, m_Tooltip.GetLineColor(m_ThemeInfo));
|
||||
}
|
||||
break;
|
||||
case Tooltip.Type.Shadow:
|
||||
|
||||
@@ -276,7 +276,7 @@ namespace XCharts
|
||||
}
|
||||
if (serie.lineStyle.show)
|
||||
{
|
||||
ChartDrawer.DrawLine(vh, startPoint, toPoint, serie.lineStyle.width, lineColor);
|
||||
DrawLineStyle(vh, serie.lineStyle, startPoint, toPoint, lineColor);
|
||||
}
|
||||
startPoint = toPoint;
|
||||
}
|
||||
@@ -288,7 +288,7 @@ namespace XCharts
|
||||
}
|
||||
if (serie.lineStyle.show)
|
||||
{
|
||||
ChartDrawer.DrawLine(vh, startPoint, firstPoint, serie.lineStyle.width, lineColor);
|
||||
DrawLineStyle(vh, serie.lineStyle, startPoint, firstPoint, lineColor);
|
||||
}
|
||||
if (serie.symbol.type != SerieSymbolType.None)
|
||||
{
|
||||
@@ -318,7 +318,7 @@ namespace XCharts
|
||||
|
||||
private void DrawRadar(VertexHelper vh, Radar radar)
|
||||
{
|
||||
if (!radar.lineStyle.show && !radar.splitArea.show)
|
||||
if (!radar.splitLine.show && !radar.splitArea.show)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -346,9 +346,9 @@ namespace XCharts
|
||||
{
|
||||
ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, color);
|
||||
}
|
||||
if (radar.lineStyle.show)
|
||||
if (radar.splitLine.NeedShow(i))
|
||||
{
|
||||
ChartDrawer.DrawLine(vh, p2, p3, radar.lineStyle.width, lineColor);
|
||||
DrawLineStyle(vh, radar.splitLine.lineStyle, p2, p3, lineColor);
|
||||
}
|
||||
p1 = p4;
|
||||
p2 = p3;
|
||||
@@ -360,16 +360,16 @@ namespace XCharts
|
||||
float currAngle = j * angle;
|
||||
p3 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
|
||||
p.y + outsideRadius * Mathf.Cos(currAngle));
|
||||
if (radar.lineStyle.show)
|
||||
if (radar.splitLine.show)
|
||||
{
|
||||
ChartDrawer.DrawLine(vh, p, p3, radar.lineStyle.width / 2, lineColor);
|
||||
DrawLineStyle(vh, radar.splitLine.lineStyle, p, p3, lineColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawCricleRadar(VertexHelper vh, Radar radar)
|
||||
{
|
||||
if (!radar.lineStyle.show && !radar.splitArea.show)
|
||||
if (!radar.splitLine.show && !radar.splitArea.show)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -389,9 +389,9 @@ namespace XCharts
|
||||
ChartDrawer.DrawDoughnut(vh, p, insideRadius, outsideRadius, color, Color.clear,
|
||||
m_Settings.cicleSmoothness, 0, 360);
|
||||
}
|
||||
if (radar.lineStyle.show)
|
||||
if (radar.splitLine.show)
|
||||
{
|
||||
ChartDrawer.DrawEmptyCricle(vh, p, outsideRadius, radar.lineStyle.width, lineColor,
|
||||
ChartDrawer.DrawEmptyCricle(vh, p, outsideRadius, radar.splitLine.lineStyle.width, lineColor,
|
||||
Color.clear, m_Settings.cicleSmoothness);
|
||||
}
|
||||
insideRadius = outsideRadius;
|
||||
@@ -401,30 +401,18 @@ namespace XCharts
|
||||
float currAngle = j * angle;
|
||||
p1 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
|
||||
p.y + outsideRadius * Mathf.Cos(currAngle));
|
||||
if (radar.lineStyle.show)
|
||||
if (radar.splitLine.show)
|
||||
{
|
||||
ChartDrawer.DrawLine(vh, p, p1, radar.lineStyle.width / 2, lineColor);
|
||||
ChartDrawer.DrawLine(vh, p, p1, radar.splitLine.lineStyle.width / 2, lineColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Color GetLineColor(Radar radar)
|
||||
{
|
||||
if (radar.lineStyle.color != Color.clear)
|
||||
{
|
||||
var color = radar.lineStyle.color;
|
||||
color.a *= radar.lineStyle.opacity;
|
||||
return color;
|
||||
}
|
||||
else
|
||||
{
|
||||
var color = (Color)m_ThemeInfo.axisLineColor;
|
||||
color.a *= radar.lineStyle.opacity;
|
||||
return color;
|
||||
}
|
||||
return radar.splitLine.GetColor(m_ThemeInfo);
|
||||
}
|
||||
|
||||
|
||||
protected override void CheckTootipArea(Vector2 local)
|
||||
{
|
||||
if (m_IsEnterLegendButtom) return;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user