Ejemplo n.º 1
0
        private void DrawLabelLine(VertexHelper vh, Serie serie, SerieData serieData, Color color)
        {
            if (serie.label.show &&
                serie.label.position == SerieLabel.Position.Outside &&
                serie.label.line)
            {
                var insideRadius  = serieData.runtimePieInsideRadius;
                var outSideRadius = serieData.runtimePieOutsideRadius;
                var center        = serie.runtimePieCenterPos;
                var currAngle     = serieData.runtimePieHalfAngle;
                if (serie.label.lineColor != Color.clear)
                {
                    color = serie.label.lineColor;
                }
                else if (serie.label.lineType == SerieLabel.LineType.HorizontalLine)
                {
                    color *= color;
                }
                float currSin = Mathf.Sin(currAngle * Mathf.Deg2Rad);
                float currCos = Mathf.Cos(currAngle * Mathf.Deg2Rad);
                var   radius1 = serie.label.lineType == SerieLabel.LineType.HorizontalLine ?
                                serie.runtimePieOutsideRadius : outSideRadius;
                var radius2 = serie.runtimePieOutsideRadius + serie.label.lineLength1;
                var radius3 = insideRadius + (outSideRadius - insideRadius) / 2;
                if (radius1 < serie.runtimePieInsideRadius)
                {
                    radius1 = serie.runtimePieInsideRadius;
                }
                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 = new Vector3(center.x + radius2 * currSin, center.y + radius2 * currCos);
                float   tx, ty;
                Vector3 pos3, pos4, pos6;
                var     horizontalLineCircleRadius = serie.label.lineWidth * 4f;
                var     lineCircleDiff             = horizontalLineCircleRadius - 0.3f;
                if (currAngle < 90)
                {
                    ty   = serie.label.lineWidth * Mathf.Cos((90 - currAngle) * Mathf.Deg2Rad);
                    tx   = serie.label.lineWidth * Mathf.Sin((90 - currAngle) * Mathf.Deg2Rad);
                    pos3 = new Vector3(pos2.x - tx, pos2.y + ty - serie.label.lineWidth);
                    var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos * radius3, 2)) - currSin * radius3;
                    r4  += serie.label.lineLength1 - lineCircleDiff;
                    pos6 = pos0 + Vector3.right * lineCircleDiff;
                    pos4 = pos6 + Vector3.right * r4;
                }
                else if (currAngle < 180)
                {
                    ty   = serie.label.lineWidth * Mathf.Sin((180 - currAngle) * Mathf.Deg2Rad);
                    tx   = serie.label.lineWidth * Mathf.Cos((180 - currAngle) * Mathf.Deg2Rad);
                    pos3 = new Vector3(pos2.x - tx, pos2.y - ty + serie.label.lineWidth);
                    var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos * radius3, 2)) - currSin * radius3;
                    r4  += serie.label.lineLength1 - lineCircleDiff;
                    pos6 = pos0 + Vector3.right * lineCircleDiff;
                    pos4 = pos6 + Vector3.right * r4;
                }
                else if (currAngle < 270)
                {
                    ty = serie.label.lineWidth * Mathf.Sin((180 + currAngle) * Mathf.Deg2Rad);
                    tx = serie.label.lineWidth * Mathf.Cos((180 + currAngle) * Mathf.Deg2Rad);
                    var currSin1 = Mathf.Sin((360 - currAngle) * Mathf.Deg2Rad);
                    var currCos1 = Mathf.Cos((360 - currAngle) * Mathf.Deg2Rad);
                    pos3 = new Vector3(pos2.x + tx, pos2.y - ty + serie.label.lineWidth);
                    var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos1 * radius3, 2)) - currSin1 * radius3;
                    r4  += serie.label.lineLength1 - lineCircleDiff;
                    pos6 = pos0 + Vector3.left * lineCircleDiff;
                    pos4 = pos6 + Vector3.left * r4;
                }
                else
                {
                    ty   = serie.label.lineWidth * Mathf.Cos((90 + currAngle) * Mathf.Deg2Rad);
                    tx   = serie.label.lineWidth * Mathf.Sin((90 + currAngle) * Mathf.Deg2Rad);
                    pos3 = new Vector3(pos2.x + tx, pos2.y + ty - serie.label.lineWidth);
                    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  += serie.label.lineLength1 - lineCircleDiff;
                    pos6 = pos0 + Vector3.left * lineCircleDiff;
                    pos4 = pos6 + Vector3.left * r4;
                }
                var pos5 = new Vector3(currAngle > 180 ? pos3.x - serie.label.lineLength2 : pos3.x + serie.label.lineLength2, pos3.y);
                switch (serie.label.lineType)
                {
                case SerieLabel.LineType.BrokenLine:
                    ChartDrawer.DrawLine(vh, pos1, pos2, serie.label.lineWidth, color);
                    ChartDrawer.DrawLine(vh, pos3, pos5, serie.label.lineWidth, color);
                    break;

                case SerieLabel.LineType.Curves:
                    ChartDrawer.DrawCurves(vh, pos1, pos5, pos1, pos2, serie.label.lineWidth, color, m_Settings.lineSmoothness);
                    break;

                case SerieLabel.LineType.HorizontalLine:
                    ChartDrawer.DrawCricle(vh, pos0, horizontalLineCircleRadius, color);
                    ChartDrawer.DrawLine(vh, pos6, pos4, serie.label.lineWidth, color);
                    break;
                }
            }
        }