Example #1
0
        private void DrawLineArrow(VertexHelper vh, Serie serie)
        {
            if (!serie.show || serie.lineArrow == null || !serie.lineArrow.show)
            {
                return;
            }

            if (serie.context.dataPoints.Count < 2)
            {
                return;
            }

            var lineColor  = SerieHelper.GetLineColor(serie, null, chart.theme, serie.index, false);
            var startPos   = Vector3.zero;
            var arrowPos   = Vector3.zero;
            var lineArrow  = serie.lineArrow.arrow;
            var dataPoints = serie.context.drawPoints;

            switch (serie.lineArrow.position)
            {
            case LineArrow.Position.End:
                if (dataPoints.Count < 3)
                {
                    startPos = dataPoints[dataPoints.Count - 2].position;
                    arrowPos = dataPoints[dataPoints.Count - 1].position;
                }
                else
                {
                    startPos = dataPoints[dataPoints.Count - 3].position;
                    arrowPos = dataPoints[dataPoints.Count - 2].position;
                }
                UGL.DrawArrow(vh, startPos, arrowPos, lineArrow.width, lineArrow.height,
                              lineArrow.offset, lineArrow.dent, lineArrow.GetColor(lineColor));

                break;

            case LineArrow.Position.Start:
                startPos = dataPoints[1].position;
                arrowPos = dataPoints[0].position;
                UGL.DrawArrow(vh, startPos, arrowPos, lineArrow.width, lineArrow.height,
                              lineArrow.offset, lineArrow.dent, lineArrow.GetColor(lineColor));

                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;
            }
        }
        internal static void DrawAxisTick(VertexHelper vh, Axis axis, AxisTheme theme, DataZoom dataZoom,
                                          Orient orient, float startX, float startY, float axisLength)
        {
            var lineWidth  = axis.axisLine.GetWidth(theme.lineWidth);
            var tickLength = axis.axisTick.GetLength(theme.tickLength);

            if (AxisHelper.NeedShowSplit(axis))
            {
                var size = AxisHelper.GetScaleNumber(axis, axisLength, dataZoom);

                var current = orient == Orient.Horizonal ?
                              startX :
                              startY;

                for (int i = 0; i < size; i++)
                {
                    var scaleWidth = AxisHelper.GetScaleWidth(axis, axisLength, i + 1, dataZoom);
                    if (i == 0 && (!axis.axisTick.showStartTick || axis.axisTick.alignWithLabel))
                    {
                        current += scaleWidth;
                        continue;
                    }
                    if (i == size - 1 && !axis.axisTick.showEndTick)
                    {
                        current += scaleWidth;
                        continue;
                    }
                    if (axis.axisTick.show)
                    {
                        if (orient == Orient.Horizonal)
                        {
                            float pX = axis.IsTime() ?
                                       (startX + axis.GetDistance(axis.GetLabelValue(i), axisLength)) :
                                       current;

                            if (axis.boundaryGap && axis.axisTick.alignWithLabel)
                            {
                                pX -= scaleWidth / 2;
                            }

                            var sY = 0f;
                            var eY = 0f;
                            if ((axis.axisTick.inside && axis.IsBottom()) ||
                                (!axis.axisTick.inside && axis.IsTop()))
                            {
                                sY = startY + lineWidth;
                                eY = sY + tickLength;
                            }
                            else
                            {
                                sY = startY - lineWidth;
                                eY = sY - tickLength;
                            }

                            UGL.DrawLine(vh, new Vector3(pX, sY), new Vector3(pX, eY),
                                         axis.axisTick.GetWidth(theme.tickWidth),
                                         axis.axisTick.GetColor(theme.tickColor));
                        }
                        else
                        {
                            float pY = axis.IsTime() ?
                                       (startY + axis.GetDistance(axis.GetLabelValue(i), axisLength)) :
                                       current;

                            if (axis.boundaryGap && axis.axisTick.alignWithLabel)
                            {
                                pY -= scaleWidth / 2;
                            }

                            var sX = 0f;
                            var eX = 0f;
                            if ((axis.axisTick.inside && axis.IsLeft()) ||
                                (!axis.axisTick.inside && axis.IsRight()))
                            {
                                sX = startX + lineWidth;
                                eX = sX + tickLength;
                            }
                            else
                            {
                                sX = startX - lineWidth;
                                eX = sX - tickLength;
                            }

                            UGL.DrawLine(vh, new Vector3(sX, pY), new Vector3(eX, pY),
                                         axis.axisTick.GetWidth(theme.tickWidth),
                                         axis.axisTick.GetColor(theme.tickColor));
                        }
                    }
                    current += scaleWidth;
                }
            }
            if (axis.show && axis.axisLine.show && axis.axisLine.showArrow)
            {
                var lineY     = startY + axis.offset;
                var inverse   = axis.IsValue() && axis.inverse;
                var axisArrow = axis.axisLine.arrow;
                if (orient == Orient.Horizonal)
                {
                    if (inverse)
                    {
                        var startPos = new Vector3(startX + axisLength, lineY);
                        var arrowPos = new Vector3(startX, lineY);
                        UGL.DrawArrow(vh, startPos, arrowPos, axisArrow.width, axisArrow.height,
                                      axisArrow.offset, axisArrow.dent,
                                      axisArrow.GetColor(axis.axisLine.GetColor(theme.lineColor)));
                    }
                    else
                    {
                        var arrowPosX = startX + axisLength + lineWidth;
                        var startPos  = new Vector3(startX, lineY);
                        var arrowPos  = new Vector3(arrowPosX, lineY);
                        UGL.DrawArrow(vh, startPos, arrowPos, axisArrow.width, axisArrow.height,
                                      axisArrow.offset, axisArrow.dent,
                                      axisArrow.GetColor(axis.axisLine.GetColor(theme.lineColor)));
                    }
                }
                else
                {
                    if (inverse)
                    {
                        var startPos = new Vector3(startX, startY + axisLength);
                        var arrowPos = new Vector3(startX, startY);
                        UGL.DrawArrow(vh, startPos, arrowPos, axisArrow.width, axisArrow.height,
                                      axisArrow.offset, axisArrow.dent,
                                      axisArrow.GetColor(axis.axisLine.GetColor(theme.lineColor)));
                    }
                    else
                    {
                        var startPos = new Vector3(startX, startY);
                        var arrowPos = new Vector3(startX, startY + axisLength + lineWidth);
                        UGL.DrawArrow(vh, startPos, arrowPos, axisArrow.width, axisArrow.height,
                                      axisArrow.offset, axisArrow.dent,
                                      axisArrow.GetColor(axis.axisLine.GetColor(theme.lineColor)));
                    }
                }
            }
        }