增加AreaStyle对虚线、点线、点划线的支持

This commit is contained in:
monitor1394
2019-10-16 13:02:42 +08:00
parent 8a4b9fd2bf
commit 620cdf78c7
2 changed files with 61 additions and 15 deletions

View File

@@ -193,20 +193,10 @@ namespace XCharts
areaColor, areaToColor, zeroPos);
break;
case LineType.Dash:
ChartDrawer.DrawDashLine(vh, lp, np, serie.lineStyle.width, lineColor);
isFinish = true;
break;
case LineType.Dot:
ChartDrawer.DrawDotLine(vh, lp, np, serie.lineStyle.width, lineColor);
isFinish = true;
break;
case LineType.DashDot:
ChartDrawer.DrawDashDotLine(vh, lp, np, serie.lineStyle.width, lineColor);
isFinish = true;
break;
case LineType.DashDotDot:
ChartDrawer.DrawDashDotDotLine(vh, lp, np, serie.lineStyle.width, lineColor);
isFinish = true;
DrawOtherLine(vh, serie, xAxis, lp, np, i, lineColor, areaColor, areaToColor, zeroPos);
break;
}
if (isFinish) serie.animation.SetDataFinish(i);
@@ -829,6 +819,45 @@ namespace XCharts
}
}
private List<Vector3> posList = new List<Vector3>();
private bool DrawOtherLine(VertexHelper vh, Serie serie, Axis axis, Vector3 lp,
Vector3 np, int dataIndex, Color lineColor, Color areaColor,
Color areaToColor, Vector3 zeroPos)
{
bool isYAxis = axis is YAxis;
var lineWidth = serie.lineStyle.width;
posList.Clear();
switch (serie.lineType)
{
case LineType.Dash:
ChartDrawer.DrawDashLine(vh, lp, np, lineWidth, lineColor, 15, 7, posList);
break;
case LineType.Dot:
ChartDrawer.DrawDotLine(vh, lp, np, lineWidth, lineColor, 5, 5, posList);
break;
case LineType.DashDot:
ChartDrawer.DrawDashDotLine(vh, lp, np, lineWidth, lineColor, 15, 15, posList);
break;
case LineType.DashDotDot:
ChartDrawer.DrawDashDotDotLine(vh, lp, np, lineWidth, lineColor, 15, 20, posList);
break;
}
if (serie.areaStyle.show && !isYAxis && posList.Count > 0)
{
lp = posList[0];
var value = serie.GetSerieData(dataIndex).data[1];
for (int i = 0; i < posList.Count; i++)
{
np = posList[i];
var start = new Vector3(lp.x, value > 0 ? (lp.y - lineWidth) : (lp.y + lineWidth));
var end = new Vector3(np.x, value > 0 ? (np.y - lineWidth) : (np.y + lineWidth));
DrawPolygonToZero(vh, start, end, axis, zeroPos, areaColor, areaToColor, Vector3.zero);
lp = np;
}
}
return true;
}
private List<Vector3> bezierPoints = new List<Vector3>();
private Vector3 smoothStartPosUp, smoothStartPosDn;
private bool DrawSmoothLine(VertexHelper vh, Serie serie, Axis xAxis, Vector3 lp,