Ejemplo n.º 1
0
        private void DrawCricleRadar(VertexHelper vh, Radar radar)
        {
            if (!radar.splitLine.show && !radar.splitArea.show)
            {
                return;
            }
            float   insideRadius = 0, outsideRadius = 0;
            float   block        = radar.runtimeRadius / radar.splitNumber;
            int     indicatorNum = radar.indicatorList.Count;
            Vector3 p            = radar.runtimeCenterPos;
            Vector3 p1;
            float   angle     = 2 * Mathf.PI / indicatorNum;
            var     lineColor = radar.axisLine.GetColor(chart.theme.radar.lineColor);
            var     lineWidth = radar.splitLine.GetWidth(chart.theme.radar.splitLineWidth);

            for (int i = 0; i < radar.splitNumber; i++)
            {
                var color = radar.splitArea.GetColor(i, chart.theme.radiusAxis);
                outsideRadius = insideRadius + block;
                if (radar.splitArea.show)
                {
                    UGL.DrawDoughnut(vh, p, insideRadius, outsideRadius, color, Color.clear,
                                     0, 360, chart.settings.cicleSmoothness);
                }
                if (radar.splitLine.show)
                {
                    UGL.DrawEmptyCricle(vh, p, outsideRadius, lineWidth, lineColor,
                                        Color.clear, chart.settings.cicleSmoothness);
                }
                insideRadius = outsideRadius;
            }
            for (int j = 0; j <= indicatorNum; j++)
            {
                float currAngle = j * angle;
                p1 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
                                 p.y + outsideRadius * Mathf.Cos(currAngle));
                if (radar.splitLine.show)
                {
                    UGL.DrawLine(vh, p, p1, lineWidth / 2, lineColor);
                }
            }
        }
        private void DrawLegend(VertexHelper vh)
        {
            if (chart.series.Count == 0)
            {
                return;
            }
            var legend = component;

            if (!legend.show)
            {
                return;
            }
            if (legend.iconType == Legend.Type.Custom)
            {
                return;
            }
            foreach (var kv in legend.context.buttonList)
            {
                var item     = kv.Value;
                var rect     = item.GetIconRect();
                var radius   = Mathf.Min(rect.width, rect.height) / 2;
                var color    = item.GetIconColor();
                var iconType = legend.iconType;
                if (legend.iconType == Legend.Type.Auto)
                {
                    var serie = chart.GetSerie(item.legendName);
                    if (serie != null && serie is Line)
                    {
                        var sp = new Vector3(rect.center.x - rect.width / 2, rect.center.y);
                        var ep = new Vector3(rect.center.x + rect.width / 2, rect.center.y);
                        UGL.DrawLine(vh, sp, ep, chart.settings.legendIconLineWidth, color);
                        if (!serie.symbol.show)
                        {
                            continue;
                        }
                        switch (serie.symbol.type)
                        {
                        case SymbolType.None:
                            continue;

                        case SymbolType.Circle:
                            iconType = Legend.Type.Circle;
                            break;

                        case SymbolType.Diamond:
                            iconType = Legend.Type.Diamond;
                            break;

                        case SymbolType.EmptyCircle:
                            iconType = Legend.Type.EmptyCircle;
                            break;

                        case SymbolType.Rect:
                            iconType = Legend.Type.Rect;
                            break;

                        case SymbolType.Triangle:
                            iconType = Legend.Type.Triangle;
                            break;
                        }
                    }
                    else
                    {
                        iconType = Legend.Type.Rect;
                    }
                }
                switch (iconType)
                {
                case Legend.Type.Rect:
                    var cornerRadius = chart.settings.legendIconCornerRadius;
                    UGL.DrawRoundRectangle(vh, rect.center, rect.width, rect.height, color, color,
                                           0, cornerRadius, false, 0.5f);
                    break;

                case Legend.Type.Circle:
                    UGL.DrawCricle(vh, rect.center, radius, color);
                    break;

                case Legend.Type.Diamond:
                    UGL.DrawDiamond(vh, rect.center, radius, color);
                    break;

                case Legend.Type.EmptyCircle:
                    var backgroundColor = chart.GetChartBackgroundColor();
                    UGL.DrawEmptyCricle(vh, rect.center, radius, 2 * chart.settings.legendIconLineWidth,
                                        color, color, backgroundColor, 1f);
                    break;

                case Legend.Type.Triangle:
                    UGL.DrawTriangle(vh, rect.center, 1.2f * radius, color);
                    break;
                }
            }
        }
        public static void DrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize,
                                      float tickness, Vector3 pos, Color32 color, Color32 toColor, float gap, float[] cornerRadius,
                                      Color32 backgroundColor, float smoothness, Vector3 startPos)
        {
            switch (type)
            {
            case SerieSymbolType.None:
                break;

            case SerieSymbolType.Circle:
                if (gap > 0)
                {
                    UGL.DrawDoughnut(vh, pos, symbolSize, symbolSize + gap, backgroundColor, backgroundColor, color, smoothness);
                }
                else
                {
                    UGL.DrawCricle(vh, pos, symbolSize, color, toColor, smoothness);
                }
                break;

            case SerieSymbolType.EmptyCircle:
                if (gap > 0)
                {
                    UGL.DrawCricle(vh, pos, symbolSize + gap, backgroundColor, smoothness);
                    UGL.DrawEmptyCricle(vh, pos, symbolSize, tickness, color, color, backgroundColor, smoothness);
                }
                else
                {
                    UGL.DrawEmptyCricle(vh, pos, symbolSize, tickness, color, color, backgroundColor, smoothness);
                }
                break;

            case SerieSymbolType.Rect:
                if (gap > 0)
                {
                    UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor);
                    UGL.DrawSquare(vh, pos, symbolSize, color, toColor);
                }
                else
                {
                    UGL.DrawRoundRectangle(vh, pos, symbolSize, symbolSize, color, color, 0, cornerRadius, true);
                }
                break;

            case SerieSymbolType.Triangle:
                if (gap > 0)
                {
                    UGL.DrawTriangle(vh, pos, symbolSize + gap, backgroundColor);
                    UGL.DrawTriangle(vh, pos, symbolSize, color, toColor);
                }
                else
                {
                    UGL.DrawTriangle(vh, pos, symbolSize, color, toColor);
                }
                break;

            case SerieSymbolType.Diamond:
                if (gap > 0)
                {
                    UGL.DrawDiamond(vh, pos, symbolSize + gap, backgroundColor);
                    UGL.DrawDiamond(vh, pos, symbolSize, color, toColor);
                }
                else
                {
                    UGL.DrawDiamond(vh, pos, symbolSize, color, toColor);
                }
                break;

            case SerieSymbolType.Arrow:
                var arrowWidth  = symbolSize * 2;
                var arrowHeight = arrowWidth * 1.5f;
                var arrowOffset = 0;
                var arrowDent   = arrowWidth / 3.3f;
                UGL.DrawArrow(vh, startPos, pos, arrowWidth, arrowHeight,
                              arrowOffset, arrowDent, color);
                break;
            }
        }
Ejemplo n.º 4
0
        public static void DrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize,
                                      float tickness, Vector3 pos, Color32 color, Color32 toColor, float gap, float[] cornerRadius,
                                      Color32 backgroundColor, float smoothness)
        {
            switch (type)
            {
            case SerieSymbolType.None:
                break;

            case SerieSymbolType.Circle:
                if (gap > 0)
                {
                    UGL.DrawDoughnut(vh, pos, symbolSize, symbolSize + gap, backgroundColor, backgroundColor, color, smoothness);
                }
                else
                {
                    UGL.DrawCricle(vh, pos, symbolSize, color, toColor, smoothness);
                }
                break;

            case SerieSymbolType.EmptyCircle:
                if (gap > 0)
                {
                    UGL.DrawCricle(vh, pos, symbolSize + gap, backgroundColor, smoothness);
                    UGL.DrawEmptyCricle(vh, pos, symbolSize, tickness, color, color, backgroundColor, smoothness);
                }
                else
                {
                    UGL.DrawEmptyCricle(vh, pos, symbolSize, tickness, color, color, backgroundColor, smoothness);
                }
                break;

            case SerieSymbolType.Rect:
                if (gap > 0)
                {
                    UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor);
                    UGL.DrawSquare(vh, pos, symbolSize, color, toColor);
                }
                else
                {
                    UGL.DrawRoundRectangle(vh, pos, symbolSize, symbolSize, color, color, 0, cornerRadius, true);
                }
                break;

            case SerieSymbolType.Triangle:
                if (gap > 0)
                {
                    UGL.DrawTriangle(vh, pos, symbolSize + gap, backgroundColor);
                    UGL.DrawTriangle(vh, pos, symbolSize, color, toColor);
                }
                else
                {
                    UGL.DrawTriangle(vh, pos, symbolSize, color, toColor);
                }
                break;

            case SerieSymbolType.Diamond:
                if (gap > 0)
                {
                    UGL.DrawDiamond(vh, pos, symbolSize + gap, backgroundColor);
                    UGL.DrawDiamond(vh, pos, symbolSize, color, toColor);
                }
                else
                {
                    UGL.DrawDiamond(vh, pos, symbolSize, color, toColor);
                }
                break;
            }
        }