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;
            }
        }
        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;
                }
            }
        }
Example #3
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;
            }
        }