mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-24 01:40:06 +00:00
增加Radar的splitLine参数配置分割线,去掉lineStyle参数
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user