private void DrawParallelSerie(VertexHelper vh, Parallel serie) { if (!serie.show) { return; } if (serie.animation.HasFadeOut()) { return; } var parallel = chart.GetChartComponent <ParallelCoord>(serie.parallelIndex); if (parallel == null) { return; } var axisCount = parallel.context.parallelAxes.Count; if (axisCount <= 0) { return; } var animationIndex = serie.animation.GetCurrIndex(); var isHorizonal = parallel.orient == Orient.Horizonal; var lineColor = SerieHelper.GetLineColor(serie, null, chart.theme, serie.context.colorIndex, false); var lineWidth = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth); float currDetailProgress = !isHorizonal ? parallel.context.x : parallel.context.y; float totalDetailProgress = !isHorizonal ? parallel.context.x + parallel.context.width : parallel.context.y + parallel.context.height; serie.animation.InitProgress(currDetailProgress, totalDetailProgress); serie.context.dataPoints.Clear(); serie.containerIndex = parallel.index; serie.containterInstanceId = parallel.instanceId; var currProgress = serie.animation.GetCurrDetail(); var isSmooth = serie.lineType == LineType.Smooth; foreach (var serieData in serie.data) { m_Points.Clear(); var count = Mathf.Min(axisCount, serieData.data.Count); var lp = Vector3.zero; for (int i = 0; i < count; i++) { if (animationIndex >= 0 && i > animationIndex) { continue; } var pos = GetPos(parallel, i, serieData.data[i], isHorizonal); if (!isHorizonal) { if (isSmooth) { m_Points.Add(pos); } else if (pos.x <= currProgress) { m_Points.Add(pos); } else { var currProgressStart = new Vector3(currProgress, parallel.context.y - 50); var currProgressEnd = new Vector3(currProgress, parallel.context.y + parallel.context.height + 50); var intersectionPos = Vector3.zero; if (UGLHelper.GetIntersection(lp, pos, currProgressStart, currProgressEnd, ref intersectionPos)) { m_Points.Add(intersectionPos); } else { m_Points.Add(pos); } break; } } else { if (isSmooth) { m_Points.Add(pos); } else if (pos.y <= currProgress) { m_Points.Add(pos); } else { var currProgressStart = new Vector3(parallel.context.x - 50, currProgress); var currProgressEnd = new Vector3(parallel.context.x + parallel.context.width + 50, currProgress); var intersectionPos = Vector3.zero; if (UGLHelper.GetIntersection(lp, pos, currProgressStart, currProgressEnd, ref intersectionPos)) { m_Points.Add(intersectionPos); } else { m_Points.Add(pos); } break; } } lp = pos; } if (isSmooth) { UGL.DrawCurves(vh, m_Points, lineWidth, lineColor, chart.settings.lineSmoothness, currProgress, isHorizonal); } else { UGL.DrawLine(vh, m_Points, lineWidth, lineColor, isSmooth); } } if (!serie.animation.IsFinish()) { serie.animation.CheckProgress(totalDetailProgress - currDetailProgress); chart.RefreshPainter(serie); } }
private void DrawPieLabelLine(VertexHelper vh, Serie serie, SerieData serieData, Color color) { var serieLabel = SerieHelper.GetSerieLabel(serie, serieData); if (serieLabel.show && serieLabel.position == SerieLabel.Position.Outside && serieLabel.line) { var insideRadius = serieData.runtimePieInsideRadius; var outSideRadius = serieData.runtimePieOutsideRadius; var center = serie.runtimeCenterPos; var currAngle = serieData.runtimePieHalfAngle; if (!ChartHelper.IsClearColor(serieLabel.lineColor)) { color = serieLabel.lineColor; } else if (serieLabel.lineType == SerieLabel.LineType.HorizontalLine) { color *= color; } float currSin = Mathf.Sin(currAngle * Mathf.Deg2Rad); float currCos = Mathf.Cos(currAngle * Mathf.Deg2Rad); var radius1 = serieLabel.lineType == SerieLabel.LineType.HorizontalLine ? serie.runtimeOutsideRadius : outSideRadius; var radius2 = serie.runtimeOutsideRadius + serieLabel.lineLength1; var radius3 = insideRadius + (outSideRadius - insideRadius) / 2; if (radius1 < serie.runtimeInsideRadius) { radius1 = serie.runtimeInsideRadius; } radius1 -= 0.1f; var pos0 = new Vector3(center.x + radius3 * currSin, center.y + radius3 * currCos); var pos1 = new Vector3(center.x + radius1 * currSin, center.y + radius1 * currCos); var pos2 = serieData.labelPosition; if (pos2.x == 0) { pos2 = new Vector3(center.x + radius2 * currSin, center.y + radius2 * currCos); } Vector3 pos4, pos6; var horizontalLineCircleRadius = serieLabel.lineWidth * 4f; var lineCircleDiff = horizontalLineCircleRadius - 0.3f; if (currAngle < 90) { var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos * radius3, 2)) - currSin * radius3; r4 += serieLabel.lineLength1 - lineCircleDiff; pos6 = pos0 + Vector3.right * lineCircleDiff; pos4 = pos6 + Vector3.right * r4; } else if (currAngle < 180) { var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos * radius3, 2)) - currSin * radius3; r4 += serieLabel.lineLength1 - lineCircleDiff; pos6 = pos0 + Vector3.right * lineCircleDiff; pos4 = pos6 + Vector3.right * r4; } else if (currAngle < 270) { var currSin1 = Mathf.Sin((360 - currAngle) * Mathf.Deg2Rad); var currCos1 = Mathf.Cos((360 - currAngle) * Mathf.Deg2Rad); var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos1 * radius3, 2)) - currSin1 * radius3; r4 += serieLabel.lineLength1 - lineCircleDiff; pos6 = pos0 + Vector3.left * lineCircleDiff; pos4 = pos6 + Vector3.left * r4; } else { var currSin1 = Mathf.Sin((360 - currAngle) * Mathf.Deg2Rad); var currCos1 = Mathf.Cos((360 - currAngle) * Mathf.Deg2Rad); var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos1 * radius3, 2)) - currSin1 * radius3; r4 += serieLabel.lineLength1 - lineCircleDiff; pos6 = pos0 + Vector3.left * lineCircleDiff; pos4 = pos6 + Vector3.left * r4; } var pos5X = currAngle > 180 ? pos2.x - serieLabel.lineLength2 : pos2.x + serieLabel.lineLength2; var pos5 = new Vector3(pos5X, pos2.y); switch (serieLabel.lineType) { case SerieLabel.LineType.BrokenLine: UGL.DrawLine(vh, pos1, pos2, pos5, serieLabel.lineWidth, color); break; case SerieLabel.LineType.Curves: UGL.DrawCurves(vh, pos1, pos5, pos1, pos2, serieLabel.lineWidth, color, chart.settings.lineSmoothness); break; case SerieLabel.LineType.HorizontalLine: UGL.DrawCricle(vh, pos0, horizontalLineCircleRadius, color); UGL.DrawLine(vh, pos6, pos4, serieLabel.lineWidth, color); break; } } }
private void DrawPieLabelLine(VertexHelper vh, Serie serie, SerieData serieData, Color color) { var serieLabel = SerieHelper.GetSerieLabel(serie, serieData); var labelLine = SerieHelper.GetSerieLabelLine(serie, serieData); if (serieLabel != null && serieLabel.show && labelLine != null && labelLine.show && (serieLabel.IsDefaultPosition(LabelStyle.Position.Outside))) { var insideRadius = serieData.context.insideRadius; var outSideRadius = serieData.context.outsideRadius; var center = serie.context.center; var currAngle = serieData.context.halfAngle; if (!ChartHelper.IsClearColor(labelLine.lineColor)) { color = labelLine.lineColor; } else if (labelLine.lineType == LabelLine.LineType.HorizontalLine) { color *= color; } float currSin = Mathf.Sin(currAngle * Mathf.Deg2Rad); float currCos = Mathf.Cos(currAngle * Mathf.Deg2Rad); var radius1 = labelLine.lineType == LabelLine.LineType.HorizontalLine ? serie.context.outsideRadius : outSideRadius; var radius3 = insideRadius + (outSideRadius - insideRadius) / 2; if (radius1 < serie.context.insideRadius) { radius1 = serie.context.insideRadius; } radius1 -= 0.1f; var pos0 = new Vector3(center.x + radius3 * currSin, center.y + radius3 * currCos); var pos1 = new Vector3(center.x + radius1 * currSin, center.y + radius1 * currCos); var pos2 = serieData.context.labelPosition; Vector3 pos4, pos6; var horizontalLineCircleRadius = labelLine.lineWidth * 4f; var lineCircleDiff = horizontalLineCircleRadius - 0.3f; var startAngle = serie.context.startAngle; if (currAngle < 90) { var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos * radius3, 2)) - currSin * radius3; r4 += labelLine.lineLength1 - lineCircleDiff; pos6 = pos0 + Vector3.right * lineCircleDiff; pos4 = pos6 + Vector3.right * r4; } else if (currAngle < 180) { var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos * radius3, 2)) - currSin * radius3; r4 += labelLine.lineLength1 - lineCircleDiff; pos6 = pos0 + Vector3.right * lineCircleDiff; pos4 = pos6 + Vector3.right * r4; } else if (currAngle < 270) { var currSin1 = Mathf.Sin((360 - currAngle) * Mathf.Deg2Rad); var currCos1 = Mathf.Cos((360 - currAngle) * Mathf.Deg2Rad); var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos1 * radius3, 2)) - currSin1 * radius3; r4 += labelLine.lineLength1 - lineCircleDiff; pos6 = pos0 + Vector3.left * lineCircleDiff; pos4 = pos6 + Vector3.left * r4; } else { var currSin1 = Mathf.Sin((360 - currAngle) * Mathf.Deg2Rad); var currCos1 = Mathf.Cos((360 - currAngle) * Mathf.Deg2Rad); var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos1 * radius3, 2)) - currSin1 * radius3; r4 += labelLine.lineLength1 - lineCircleDiff; pos6 = pos0 + Vector3.left * lineCircleDiff; pos4 = pos6 + Vector3.left * r4; } var pos5X = (currAngle - startAngle) % 360 > 180 ? pos2.x - labelLine.lineLength2 : pos2.x + labelLine.lineLength2; var pos5 = new Vector3(pos5X, pos2.y); var angle = Vector3.Angle(pos1 - center, pos2 - pos1); if (angle > 15) { UGL.DrawLine(vh, pos1, pos5, labelLine.lineWidth, color); } else { switch (labelLine.lineType) { case LabelLine.LineType.BrokenLine: UGL.DrawLine(vh, pos1, pos2, pos5, labelLine.lineWidth, color); break; case LabelLine.LineType.Curves: UGL.DrawCurves(vh, pos1, pos5, pos1, pos2, labelLine.lineWidth, color, chart.settings.lineSmoothness); break; case LabelLine.LineType.HorizontalLine: UGL.DrawCricle(vh, pos0, horizontalLineCircleRadius, color); UGL.DrawLine(vh, pos6, pos4, labelLine.lineWidth, color); break; } } } }