private void DrawStageColor(VertexHelper vh, Serie serie)
        {
            if (serie.gaugeType != GaugeType.Pointer)
            {
                return;
            }
            if (!serie.gaugeAxis.show || !serie.gaugeAxis.axisLine.show)
            {
                return;
            }
            var totalAngle     = serie.endAngle - serie.startAngle;
            var tempStartAngle = serie.startAngle;
            var tempEndAngle   = serie.startAngle;
            var lineWidth      = serie.gaugeAxis.axisLine.GetWidth(chart.theme.gauge.lineWidth);
            var outsideRadius  = serie.runtimeInsideRadius + lineWidth;

            serie.gaugeAxis.runtimeStageAngle.Clear();
            for (int i = 0; i < serie.gaugeAxis.axisLine.stageColor.Count; i++)
            {
                var stageColor = serie.gaugeAxis.axisLine.stageColor[i];
                tempEndAngle = serie.startAngle + totalAngle * stageColor.percent;
                serie.gaugeAxis.runtimeStageAngle.Add(tempEndAngle);
                UGL.DrawDoughnut(vh, serie.runtimeCenterPos, serie.runtimeInsideRadius, outsideRadius,
                                 stageColor.color, stageColor.color, Color.clear, tempStartAngle, tempEndAngle, 0, Color.clear,
                                 0, chart.settings.cicleSmoothness);
                tempStartAngle = tempEndAngle;
            }
        }
Exemple #2
0
        private void DrawVesselBackground(VertexHelper vh, Serie serie)
        {
            var vessel = chart.GetVessel(serie.vesselIndex);

            if (vessel != null)
            {
                if (vessel.backgroundColor.a != 0)
                {
                    switch (vessel.shape)
                    {
                    case Vessel.Shape.Circle:
                        var cenPos = vessel.runtimeCenterPos;
                        var radius = vessel.runtimeRadius;
                        UGL.DrawCricle(vh, cenPos, vessel.runtimeInnerRadius + vessel.gap, vessel.backgroundColor,
                                       chart.settings.cicleSmoothness);
                        UGL.DrawDoughnut(vh, cenPos, vessel.runtimeInnerRadius, vessel.runtimeInnerRadius + vessel.gap,
                                         vessel.backgroundColor, Color.clear, chart.settings.cicleSmoothness);
                        break;

                    case Vessel.Shape.Rect:
                        UGL.DrawRectangle(vh, vessel.runtimeCenterPos, vessel.runtimeWidth / 2, vessel.runtimeHeight / 2,
                                          vessel.backgroundColor);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Exemple #3
0
        private void DrawCirleVessel(VertexHelper vh, Vessel vessel)
        {
            var cenPos      = vessel.runtimeCenterPos;
            var radius      = vessel.runtimeRadius;
            var serie       = SeriesHelper.GetSerieByVesselIndex(chart.series, vessel.index);
            var vesselColor = VesselHelper.GetColor(vessel, serie, chart.theme, chart.m_LegendRealShowName);

            UGL.DrawDoughnut(vh, cenPos, radius - vessel.shapeWidth, radius, vesselColor, Color.clear, chart.settings.cicleSmoothness);
        }
        private void DrawRadiusAxis(VertexHelper vh, RadiusAxis radiusAxis)
        {
            var polar = chart.GetChartComponent <PolarCoord>(radiusAxis.polarIndex);

            if (polar == null)
            {
                return;
            }

            var angleAxis = ComponentHelper.GetAngleAxis(chart.components, polar.index);

            if (angleAxis == null)
            {
                return;
            }

            var startAngle = angleAxis.context.startAngle;
            var radius     = polar.context.radius;
            var cenPos     = polar.context.center;
            var size       = AxisHelper.GetScaleNumber(radiusAxis, radius, null);
            var totalWidth = 0f;
            var dire       = ChartHelper.GetDire(startAngle, true).normalized;
            var tickWidth  = radiusAxis.axisTick.GetWidth(chart.theme.axis.tickWidth);
            var tickLength = radiusAxis.axisTick.GetLength(chart.theme.axis.tickLength);
            var tickVetor  = ChartHelper.GetVertialDire(dire) * tickLength;

            for (int i = 0; i <= size; i++)
            {
                var scaleWidth = AxisHelper.GetScaleWidth(radiusAxis, radius, i);
                var pos        = ChartHelper.GetPos(cenPos, totalWidth + tickWidth, startAngle, true);
                if (radiusAxis.show && radiusAxis.splitLine.show)
                {
                    var outsideRaidus  = totalWidth + radiusAxis.splitLine.GetWidth(chart.theme.axis.splitLineWidth) * 2;
                    var splitLineColor = radiusAxis.splitLine.GetColor(chart.theme.axis.splitLineColor);
                    UGL.DrawDoughnut(vh, cenPos, totalWidth, outsideRaidus, splitLineColor, Color.clear);
                }
                if (radiusAxis.show && radiusAxis.axisTick.show)
                {
                    if ((i == 0 && radiusAxis.axisTick.showStartTick) ||
                        (i == size && radiusAxis.axisTick.showEndTick) ||
                        (i > 0 && i < size))
                    {
                        UGL.DrawLine(vh, pos, pos + tickVetor, tickWidth, chart.theme.axis.lineColor);
                    }
                }
                totalWidth += scaleWidth;
            }
            if (radiusAxis.show && radiusAxis.axisLine.show)
            {
                var lineStartPos = polar.context.center - dire * tickWidth;
                var lineEndPos   = polar.context.center + dire * (radius + tickWidth);
                var lineWidth    = radiusAxis.axisLine.GetWidth(chart.theme.axis.lineWidth);
                UGL.DrawLine(vh, lineStartPos, lineEndPos, lineWidth, chart.theme.axis.lineColor);
            }
        }
Exemple #5
0
        private void DrawBorder(VertexHelper vh, Serie serie, SerieData serieData, float insideRadius, float outsideRadius)
        {
            var itemStyle = SerieHelper.GetItemStyle(serie, serieData);

            if (itemStyle.show && itemStyle.borderWidth > 0 && !ChartHelper.IsClearColor(itemStyle.borderColor))
            {
                UGL.DrawDoughnut(vh, serie.runtimeCenterPos, outsideRadius,
                                 outsideRadius + itemStyle.borderWidth, itemStyle.borderColor,
                                 Color.clear, chart.settings.cicleSmoothness);
                UGL.DrawDoughnut(vh, serie.runtimeCenterPos, insideRadius,
                                 insideRadius + itemStyle.borderWidth, itemStyle.borderColor,
                                 Color.clear, chart.settings.cicleSmoothness);
            }
        }
 private void DrawRadiusAxis(VertexHelper vh)
 {
     foreach (var radiusAxis in m_RadiusAxes)
     {
         var polar = GetPolar(radiusAxis.polarIndex);
         if (polar == null)
         {
             continue;
         }
         var angleAxis = GetAngleAxis(polar.index);
         if (angleAxis == null)
         {
             continue;
         }
         var startAngle = angleAxis.runtimeStartAngle;
         var radius     = polar.runtimeRadius;
         var cenPos     = polar.runtimeCenterPos;
         var size       = AxisHelper.GetScaleNumber(radiusAxis, radius, null);
         var totalWidth = 0f;
         var dire       = ChartHelper.GetDire(startAngle, true).normalized;
         var tickWidth  = radiusAxis.axisTick.GetLength(m_Theme.radiusAxis.tickWidth);
         var tickLength = radiusAxis.axisTick.GetLength(m_Theme.radiusAxis.tickLength);
         var tickVetor  = ChartHelper.GetVertialDire(dire) * tickLength;
         for (int i = 0; i < size - 1; i++)
         {
             var scaleWidth = AxisHelper.GetScaleWidth(radiusAxis, radius, i);
             var pos        = ChartHelper.GetPos(cenPos, totalWidth, startAngle, true);
             if (radiusAxis.show && radiusAxis.splitLine.show)
             {
                 var outsideRaidus  = totalWidth + radiusAxis.splitLine.GetWidth(m_Theme.radiusAxis.splitLineWidth) * 2;
                 var splitLineColor = radiusAxis.splitLine.GetColor(m_Theme.radiusAxis.splitLineColor);
                 UGL.DrawDoughnut(vh, cenPos, totalWidth, outsideRaidus, splitLineColor, Color.clear);
             }
             if (radiusAxis.show && radiusAxis.axisTick.show)
             {
                 UGL.DrawLine(vh, pos, pos + tickVetor, tickWidth, m_Theme.axis.lineColor);
             }
             totalWidth += scaleWidth;
         }
         if (radiusAxis.show && radiusAxis.axisLine.show)
         {
             var lineStartPos = polar.runtimeCenterPos - dire * tickWidth;
             var lineEndPos   = polar.runtimeCenterPos + dire * (radius + tickWidth);
             var lineWidth    = radiusAxis.axisLine.GetWidth(m_Theme.polar.lineWidth);
             UGL.DrawLine(vh, lineStartPos, lineEndPos, lineWidth, m_Theme.axis.lineColor);
         }
     }
 }
Exemple #7
0
        private void DrawBackground(VertexHelper vh, Serie serie, SerieData serieData, int index, float insideRadius, float outsideRadius)
        {
            var itemStyle       = SerieHelper.GetItemStyle(serie, serieData);
            var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, index, false);

            if (itemStyle.backgroundWidth != 0)
            {
                var centerRadius = (outsideRadius + insideRadius) / 2;
                var inradius     = centerRadius - itemStyle.backgroundWidth / 2;
                var outradius    = centerRadius + itemStyle.backgroundWidth / 2;
                UGL.DrawDoughnut(vh, serie.runtimeCenterPos, inradius,
                                 outradius, backgroundColor, Color.clear, chart.settings.cicleSmoothness);
            }
            else
            {
                UGL.DrawDoughnut(vh, serie.runtimeCenterPos, insideRadius,
                                 outsideRadius, backgroundColor, Color.clear, chart.settings.cicleSmoothness);
            }
        }
Exemple #8
0
        private void DrawAngleAxis(VertexHelper vh, AngleAxis angleAxis)
        {
            var polar          = chart.GetChartComponent <PolarCoord>(angleAxis.polarIndex);
            var radius         = polar.context.radius;
            var cenPos         = polar.context.center;
            var total          = 360;
            var size           = AxisHelper.GetScaleNumber(angleAxis, total, null);
            var currAngle      = angleAxis.context.startAngle;
            var tickWidth      = angleAxis.axisTick.GetWidth(chart.theme.axis.tickWidth);
            var tickLength     = angleAxis.axisTick.GetLength(chart.theme.axis.tickLength);
            var tickColor      = angleAxis.axisTick.GetColor(chart.theme.axis.lineColor);
            var lineColor      = angleAxis.axisLine.GetColor(chart.theme.axis.lineColor);
            var splitLineColor = angleAxis.splitLine.GetColor(chart.theme.axis.splitLineColor);

            for (int i = 1; i < size; i++)
            {
                var scaleWidth = AxisHelper.GetScaleWidth(angleAxis, total, i);
                var pos        = ChartHelper.GetPos(cenPos, radius, currAngle, true);
                if (angleAxis.show && angleAxis.splitLine.show)
                {
                    var lineWidth = angleAxis.splitLine.GetWidth(chart.theme.axis.splitLineWidth);
                    UGL.DrawLine(vh, cenPos, pos, lineWidth, splitLineColor);
                }
                if (angleAxis.show && angleAxis.axisTick.show)
                {
                    if ((i == 1 && angleAxis.axisTick.showStartTick) ||
                        (i == size - 1 && angleAxis.axisTick.showEndTick) ||
                        (i > 1 && i < size - 1))
                    {
                        var tickY   = radius + tickLength;
                        var tickPos = ChartHelper.GetPos(cenPos, tickY, currAngle, true);
                        UGL.DrawLine(vh, pos, tickPos, tickWidth, tickColor);
                    }
                }
                currAngle += scaleWidth;
            }
            if (angleAxis.show && angleAxis.axisLine.show)
            {
                var lineWidth     = angleAxis.axisLine.GetWidth(chart.theme.axis.lineWidth);
                var outsideRaidus = radius + lineWidth * 2;
                UGL.DrawDoughnut(vh, cenPos, radius, outsideRaidus, lineColor, Color.clear);
            }
        }
Exemple #9
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 DrawPolarIndicator(VertexHelper vh, Tooltip tooltip, PolarCoord m_Polar)
        {
            if (tooltip.context.angle < 0)
            {
                return;
            }
            var theme        = chart.theme;
            var m_AngleAxis  = ComponentHelper.GetAngleAxis(chart.components, m_Polar.index);
            var lineColor    = TooltipHelper.GetLineColor(tooltip, theme);
            var lineType     = tooltip.lineStyle.GetType(theme.tooltip.lineType);
            var lineWidth    = tooltip.lineStyle.GetWidth(theme.tooltip.lineWidth);
            var cenPos       = m_Polar.context.center;
            var radius       = m_Polar.context.radius;
            var sp           = m_Polar.context.center;
            var tooltipAngle = m_AngleAxis.GetValueAngle(tooltip.context.angle);

            var ep = ChartHelper.GetPos(sp, radius, tooltipAngle, true);

            switch (tooltip.type)
            {
            case Tooltip.Type.Corss:
                ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, sp, ep, lineColor);
                var dist = Vector2.Distance(chart.pointerPos, cenPos);
                if (dist > radius)
                {
                    dist = radius;
                }
                var outsideRaidus = dist + tooltip.lineStyle.GetWidth(theme.tooltip.lineWidth) * 2;
                UGL.DrawDoughnut(vh, cenPos, dist, outsideRaidus, lineColor, Color.clear);
                break;

            case Tooltip.Type.Line:
                ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, sp, ep, lineColor);
                break;

            case Tooltip.Type.Shadow:
                UGL.DrawSector(vh, cenPos, radius, lineColor, tooltipAngle - 2, tooltipAngle + 2, chart.settings.cicleSmoothness);
                break;
            }
        }
        protected override void DrawTooltip(VertexHelper vh)
        {
            if (tooltip.runtimeAngle < 0)
            {
                return;
            }
            var m_Polar      = GetPolar(tooltip.runtimePolarIndex);
            var m_AngleAxis  = GetAngleAxis(m_Polar.index);
            var lineColor    = TooltipHelper.GetLineColor(tooltip, m_Theme);
            var lineType     = tooltip.lineStyle.GetType(m_Theme.tooltip.lineType);
            var lineWidth    = tooltip.lineStyle.GetWidth(m_Theme.tooltip.lineWidth);
            var cenPos       = m_Polar.runtimeCenterPos;
            var radius       = m_Polar.runtimeRadius;
            var sp           = m_Polar.runtimeCenterPos;
            var tooltipAngle = tooltip.runtimeAngle + m_AngleAxis.runtimeStartAngle;
            var ep           = ChartHelper.GetPos(sp, radius, tooltipAngle, true);

            switch (tooltip.type)
            {
            case Tooltip.Type.Corss:
                ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, sp, ep, lineColor);
                var dist = Vector2.Distance(pointerPos, cenPos);
                if (dist > radius)
                {
                    dist = radius;
                }
                var outsideRaidus = dist + tooltip.lineStyle.GetWidth(m_Theme.tooltip.lineWidth) * 2;
                UGL.DrawDoughnut(vh, cenPos, dist, outsideRaidus, lineColor, Color.clear);
                break;

            case Tooltip.Type.Line:
                ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, sp, ep, lineColor);
                break;

            case Tooltip.Type.Shadow:
                UGL.DrawSector(vh, cenPos, radius, lineColor, tooltipAngle - 2, tooltipAngle + 2, settings.cicleSmoothness);
                break;
            }
        }
 private void DrawAngleAxis(VertexHelper vh)
 {
     foreach (var m_AngleAxis in m_AngleAxes)
     {
         var m_Polar    = GetPolar(m_AngleAxis.polarIndex);
         var radius     = m_Polar.runtimeRadius;
         var cenPos     = m_Polar.runtimeCenterPos;
         var total      = 360;
         var size       = AxisHelper.GetScaleNumber(m_AngleAxis, total, null);
         var currAngle  = m_AngleAxis.runtimeStartAngle;
         var tickWidth  = m_AngleAxis.axisTick.GetWidth(m_Theme.angleAxis.tickWidth);
         var tickLength = m_AngleAxis.axisTick.GetLength(m_Theme.angleAxis.tickLength);
         for (int i = 0; i < size; i++)
         {
             var scaleWidth = AxisHelper.GetScaleWidth(m_AngleAxis, total, i);
             var pos        = ChartHelper.GetPos(cenPos, radius, currAngle, true);
             if (m_AngleAxis.show && m_AngleAxis.splitLine.show)
             {
                 var splitLineColor = m_AngleAxis.splitLine.GetColor(m_Theme.angleAxis.splitLineColor);
                 var lineWidth      = m_AngleAxis.splitLine.GetWidth(m_Theme.angleAxis.splitLineWidth);
                 UGL.DrawLine(vh, cenPos, pos, lineWidth, splitLineColor);
             }
             if (m_AngleAxis.show && m_AngleAxis.axisTick.show)
             {
                 var tickY   = radius + tickLength;
                 var tickPos = ChartHelper.GetPos(cenPos, tickY, currAngle, true);
                 UGL.DrawLine(vh, pos, tickPos, tickWidth, m_Theme.axis.lineColor);
             }
             currAngle += scaleWidth;
         }
         if (m_AngleAxis.show && m_AngleAxis.axisLine.show)
         {
             var lineWidth     = m_AngleAxis.axisLine.GetWidth(m_Theme.angleAxis.lineWidth);
             var outsideRaidus = radius + lineWidth * 2;
             UGL.DrawDoughnut(vh, cenPos, radius, outsideRaidus, m_Theme.axis.lineColor, Color.clear);
         }
     }
 }
        private void DrawProgressBar(VertexHelper vh, Serie serie, float currAngle)
        {
            if (serie.gaugeType != GaugeType.ProgressBar)
            {
                return;
            }
            if (!serie.gaugeAxis.show || !serie.gaugeAxis.axisLine.show)
            {
                return;
            }
            var color           = serie.gaugeAxis.GetAxisLineColor(chart.theme, serie.index);
            var backgroundColor = serie.gaugeAxis.GetAxisLineBackgroundColor(chart.theme, serie.index);
            var lineWidth       = serie.gaugeAxis.axisLine.GetWidth(chart.theme.gauge.lineWidth);
            var outsideRadius   = serie.runtimeInsideRadius + lineWidth;
            var borderWidth     = serie.itemStyle.borderWidth;
            var borderColor     = serie.itemStyle.borderColor;

            UGL.DrawDoughnut(vh, serie.runtimeCenterPos, serie.runtimeInsideRadius, outsideRadius,
                             backgroundColor, backgroundColor, Color.clear, serie.startAngle, serie.endAngle, 0, Color.clear,
                             0, chart.settings.cicleSmoothness, serie.roundCap);
            UGL.DrawDoughnut(vh, serie.runtimeCenterPos, serie.runtimeInsideRadius, outsideRadius,
                             color, color, Color.clear, serie.startAngle, currAngle, 0, Color.clear,
                             0, chart.settings.cicleSmoothness, serie.roundCap);
        }
        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 DrawPie(VertexHelper vh, Serie serie)
        {
            if (!serie.show || serie.animation.HasFadeOut())
            {
                return;
            }
            var dataChanging = false;
            var interacting  = false;
            var color        = ColorUtil.clearColor32;
            var toColor      = ColorUtil.clearColor32;
            var data         = serie.data;

            serie.animation.InitProgress(0, 360);
            for (int n = 0; n < data.Count; n++)
            {
                var serieData = data[n];
                if (!serieData.show)
                {
                    continue;
                }
                if (serieData.IsDataChanged())
                {
                    dataChanging = true;
                }

                var itemStyle     = SerieHelper.GetItemStyle(serie, serieData, serieData.context.highlight);
                var colorIndex    = chart.GetLegendRealShowNameIndex(serieData.legendName);
                var outsideRadius = 0f;

                var borderWidth = itemStyle.borderWidth;
                var borderColor = itemStyle.borderColor;

                var progress     = AnimationStyleHelper.CheckDataAnimation(chart, serie, n, 1);
                var insideRadius = serieData.context.insideRadius * progress;

                //if (!serieData.interact.TryGetValueAndColor(ref outsideRadius, ref color, ref toColor, ref interacting))
                {
                    color         = SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, serieData.context.highlight);
                    toColor       = SerieHelper.GetItemToColor(serie, serieData, chart.theme, colorIndex, serieData.context.highlight);
                    outsideRadius = serieData.context.outsideRadius * progress;
                    serieData.interact.SetValueAndColor(ref interacting, outsideRadius, color, toColor);
                }

                if (serie.pieClickOffset && serieData.selected)
                {
                    var drawEndDegree = serieData.context.currentAngle;
                    var needRoundCap  = serie.roundCap && insideRadius > 0;
                    UGL.DrawDoughnut(vh, serieData.context.offsetCenter, insideRadius,
                                     outsideRadius, color, toColor, Color.clear, serieData.context.startAngle,
                                     drawEndDegree, borderWidth, borderColor, serie.gap / 2, chart.settings.cicleSmoothness,
                                     needRoundCap, true);
                }
                else
                {
                    var drawEndDegree = serieData.context.currentAngle;
                    var needRoundCap  = serie.roundCap && insideRadius > 0;
                    UGL.DrawDoughnut(vh, serie.context.center, insideRadius,
                                     outsideRadius, color, toColor, Color.clear, serieData.context.startAngle,
                                     drawEndDegree, borderWidth, borderColor, serie.gap / 2, chart.settings.cicleSmoothness,
                                     needRoundCap, true);
                    DrawPieCenter(vh, serie, itemStyle, insideRadius);
                }

                if (serie.animation.CheckDetailBreak(serieData.context.toAngle))
                {
                    break;
                }
            }
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress();
                serie.animation.CheckSymbol(serie.symbol.GetSize(null, chart.theme.serie.lineSymbolSize));
                chart.RefreshPainter(serie);
            }
            if (dataChanging)
            {
                chart.RefreshPainter(serie);
            }
        }
        private void DrawPie(VertexHelper vh, Serie serie)
        {
            var data = serie.data;

            serie.animation.InitProgress(data.Count, 0, 360);
            if (!serie.show || serie.animation.HasFadeOut())
            {
                return;
            }
            bool dataChanging = false;

            for (int n = 0; n < data.Count; n++)
            {
                var serieData = data[n];
                if (!serieData.show)
                {
                    continue;
                }
                var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.highlighted);
                if (serieData.IsDataChanged())
                {
                    dataChanging = true;
                }
                var serieNameCount = chart.m_LegendRealShowName.IndexOf(serieData.legendName);
                var color          = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieNameCount,
                                                              serieData.highlighted);
                var toColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieNameCount,
                                                         serieData.highlighted);
                var borderWidth = itemStyle.borderWidth;
                var borderColor = itemStyle.borderColor;

                if (serie.pieClickOffset && serieData.selected)
                {
                    var drawEndDegree = serieData.runtimePieCurrAngle;
                    var needRoundCap  = serie.roundCap && serieData.runtimePieInsideRadius > 0;
                    UGL.DrawDoughnut(vh, serieData.runtiemPieOffsetCenter, serieData.runtimePieInsideRadius,
                                     serieData.runtimePieOutsideRadius, color, toColor, Color.clear, serieData.runtimePieStartAngle,
                                     drawEndDegree, borderWidth, borderColor, serie.pieSpace / 2, chart.settings.cicleSmoothness,
                                     needRoundCap, true);
                }
                else
                {
                    var drawEndDegree = serieData.runtimePieCurrAngle;
                    var needRoundCap  = serie.roundCap && serieData.runtimePieInsideRadius > 0;
                    UGL.DrawDoughnut(vh, serie.runtimeCenterPos, serieData.runtimePieInsideRadius,
                                     serieData.runtimePieOutsideRadius, color, toColor, Color.clear, serieData.runtimePieStartAngle,
                                     drawEndDegree, borderWidth, borderColor, serie.pieSpace / 2, chart.settings.cicleSmoothness,
                                     needRoundCap, true);
                    DrawPieCenter(vh, serie, itemStyle, serieData.runtimePieInsideRadius);
                }
                if (!serie.animation.CheckDetailBreak(serieData.runtimePieToAngle))
                {
                    serie.animation.SetDataFinish(n);
                }
                else
                {
                    break;
                }
            }
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(360);
                serie.animation.CheckSymbol(serie.symbol.GetSize(null, chart.theme.serie.lineSymbolSize));
                chart.RefreshPainter(serie);
            }
            if (dataChanging)
            {
                chart.RefreshPainter(serie);
            }
            chart.raycastTarget = IsAnyPieClickOffset() || IsAnyPieDataHighlight();
        }
        private void DrawBarBackground(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle,
                                       int colorIndex, bool highlight, float pX, float pY, float space, float barWidth, bool isYAxis, Grid grid)
        {
            var color = SerieHelper.GetItemBackgroundColor(serie, serieData, m_Theme, colorIndex, highlight, false);

            if (ChartHelper.IsClearColor(color))
            {
                return;
            }
            if (isYAxis)
            {
                var     axis      = m_YAxes[serie.yAxisIndex];
                var     axisWidth = axis.axisLine.GetWidth(m_Theme.axis.lineWidth);
                Vector3 plt       = new Vector3(grid.runtimeX + axisWidth, pY + space + barWidth);
                Vector3 prt       = new Vector3(grid.runtimeX + axisWidth + grid.runtimeWidth, pY + space + barWidth);
                Vector3 prb       = new Vector3(grid.runtimeX + axisWidth + grid.runtimeWidth, pY + space);
                Vector3 plb       = new Vector3(grid.runtimeX + axisWidth, pY + space);
                if (serie.barType == BarType.Capsule)
                {
                    var radius = barWidth / 2;
                    var diff   = Vector3.right * radius;
                    var pcl    = (plt + plb) / 2 + diff;
                    var pcr    = (prt + prb) / 2 - diff;
                    Internal_CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, color, color, serie.clip, grid);
                    UGL.DrawSector(vh, pcl, radius, color, 180, 360);
                    UGL.DrawSector(vh, pcr, radius, color, 0, 180);
                    if (itemStyle.NeedShowBorder())
                    {
                        var borderWidth = itemStyle.borderWidth;
                        var borderColor = itemStyle.borderColor;
                        var smoothness  = settings.cicleSmoothness;
                        var inRadius    = radius - borderWidth;
                        var outRadius   = radius;
                        var p1          = plb + diff + Vector3.up * borderWidth / 2;
                        var p2          = prb - diff + Vector3.up * borderWidth / 2;
                        var p3          = plt + diff - Vector3.up * borderWidth / 2;
                        var p4          = prt - diff - Vector3.up * borderWidth / 2;
                        UGL.DrawLine(vh, p1, p2, borderWidth / 2, borderColor);
                        UGL.DrawLine(vh, p3, p4, borderWidth / 2, borderColor);
                        UGL.DrawDoughnut(vh, pcl, inRadius, outRadius, borderColor, ChartConst.clearColor32,
                                         180, 360, smoothness);
                        UGL.DrawDoughnut(vh, pcr, inRadius, outRadius, borderColor, ChartConst.clearColor32,
                                         0, 180, smoothness);
                    }
                }
                else
                {
                    Internal_CheckClipAndDrawPolygon(vh, ref plb, ref plt, ref prt, ref prb, color, color, serie.clip, grid);
                }
            }
            else
            {
                var     axis      = m_XAxes[serie.xAxisIndex];
                var     axisWidth = axis.axisLine.GetWidth(m_Theme.axis.lineWidth);
                Vector3 plb       = new Vector3(pX + space, grid.runtimeY + axisWidth);
                Vector3 plt       = new Vector3(pX + space, grid.runtimeY + grid.runtimeHeight + axisWidth);
                Vector3 prt       = new Vector3(pX + space + barWidth, grid.runtimeY + grid.runtimeHeight + axisWidth);
                Vector3 prb       = new Vector3(pX + space + barWidth, grid.runtimeY + axisWidth);
                if (serie.barType == BarType.Capsule)
                {
                    var radius = barWidth / 2;
                    var diff   = Vector3.up * radius;
                    var pct    = (plt + prt) / 2 - diff;
                    var pcb    = (plb + prb) / 2 + diff;
                    Internal_CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, color, color,
                                                     serie.clip, grid);
                    UGL.DrawSector(vh, pct, radius, color, 270, 450);
                    UGL.DrawSector(vh, pcb, radius, color, 90, 270);
                    if (itemStyle.NeedShowBorder())
                    {
                        var borderWidth = itemStyle.borderWidth;
                        var borderColor = itemStyle.borderColor;
                        var smoothness  = settings.cicleSmoothness;
                        var inRadius    = radius - borderWidth;
                        var outRadius   = radius;
                        var p1          = plb + diff + Vector3.right * borderWidth / 2;
                        var p2          = plt - diff + Vector3.right * borderWidth / 2;
                        var p3          = prb + diff - Vector3.right * borderWidth / 2;
                        var p4          = prt - diff - Vector3.right * borderWidth / 2;
                        UGL.DrawLine(vh, p1, p2, borderWidth / 2, borderColor);
                        UGL.DrawLine(vh, p3, p4, borderWidth / 2, borderColor);
                        UGL.DrawDoughnut(vh, pct, inRadius, outRadius, borderColor, ChartConst.clearColor32,
                                         270, 450, smoothness);
                        UGL.DrawDoughnut(vh, pcb, inRadius, outRadius, borderColor, ChartConst.clearColor32,
                                         90, 270, smoothness);
                    }
                }
                else
                {
                    Internal_CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, color, color, serie.clip, grid);
                }
            }
        }
Exemple #18
0
        public void DrawSerie(VertexHelper vh, Serie serie)
        {
            if (serie.type != SerieType.Ring)
            {
                return;
            }
            if (!serie.show || serie.animation.HasFadeOut())
            {
                return;
            }
            var data = serie.data;

            serie.animation.InitProgress(data.Count, serie.startAngle, serie.startAngle + 360);
            SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight);
            TitleStyleHelper.CheckTitle(serie, ref chart.m_ReinitTitle, ref m_UpdateTitleText);
            SerieLabelHelper.CheckLabel(serie, ref chart.m_ReinitLabel, ref m_UpdateLabelText);
            var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
            var ringWidth          = serie.runtimeOutsideRadius - serie.runtimeInsideRadius;
            var dataChanging       = false;

            for (int j = 0; j < data.Count; j++)
            {
                var serieData = data[j];
                if (!serieData.show)
                {
                    continue;
                }
                if (serieData.IsDataChanged())
                {
                    dataChanging = true;
                }
                var value         = serieData.GetFirstData(dataChangeDuration);
                var max           = serieData.GetLastData();
                var degree        = 360 * value / max;
                var startDegree   = GetStartAngle(serie);
                var toDegree      = GetToAngle(serie, degree);
                var itemStyle     = SerieHelper.GetItemStyle(serie, serieData, serieData.highlighted);
                var itemColor     = SerieHelper.GetItemColor(serie, serieData, chart.theme, j, serieData.highlighted);
                var itemToColor   = SerieHelper.GetItemToColor(serie, serieData, chart.theme, j, serieData.highlighted);
                var outsideRadius = serie.runtimeOutsideRadius - j * (ringWidth + serie.ringGap);
                var insideRadius  = outsideRadius - ringWidth;
                var centerRadius  = (outsideRadius + insideRadius) / 2;
                var borderWidth   = itemStyle.borderWidth;
                var borderColor   = itemStyle.borderColor;
                var roundCap      = serie.roundCap && insideRadius > 0;

                serieData.runtimePieStartAngle    = serie.clockwise ? startDegree : toDegree;
                serieData.runtimePieToAngle       = serie.clockwise ? toDegree : startDegree;
                serieData.runtimePieInsideRadius  = insideRadius;
                serieData.runtimePieOutsideRadius = outsideRadius;
                UGL.DrawDoughnut(vh, serie.runtimeCenterPos, insideRadius, outsideRadius, itemColor, itemToColor,
                                 Color.clear, startDegree, toDegree, borderWidth, borderColor, 0, chart.settings.cicleSmoothness,
                                 roundCap, serie.clockwise);
                DrawCenter(vh, serie, serieData, insideRadius, j == data.Count - 1);
                UpateLabelPosition(serie, serieData, j, startDegree, toDegree, centerRadius);
            }
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(360);
                chart.RefreshChart();
            }
            if (dataChanging)
            {
                chart.RefreshChart();
            }
        }
Exemple #19
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;
            }
        }
        public override void DrawSerie(VertexHelper vh)
        {
            if (!serie.show || serie.animation.HasFadeOut())
            {
                return;
            }
            var data = serie.data;

            serie.animation.InitProgress(serie.startAngle, serie.startAngle + 360);
            SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight);
            var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
            var ringWidth          = serie.context.outsideRadius - serie.context.insideRadius;
            var dataChanging       = false;

            for (int j = 0; j < data.Count; j++)
            {
                var serieData = data[j];
                serieData.index = j;
                if (!serieData.show)
                {
                    continue;
                }
                if (serieData.IsDataChanged())
                {
                    dataChanging = true;
                }
                var value         = serieData.GetFirstData(dataChangeDuration);
                var max           = serieData.GetLastData();
                var degree        = (float)(360 * value / max);
                var startDegree   = GetStartAngle(serie);
                var toDegree      = GetToAngle(serie, degree);
                var itemStyle     = SerieHelper.GetItemStyle(serie, serieData, serieData.context.highlight);
                var colorIndex    = chart.GetLegendRealShowNameIndex(serieData.legendName);
                var itemColor     = SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, serieData.context.highlight);
                var itemToColor   = SerieHelper.GetItemToColor(serie, serieData, chart.theme, colorIndex, serieData.context.highlight);
                var outsideRadius = serie.context.outsideRadius - j * (ringWidth + serie.gap);
                var insideRadius  = outsideRadius - ringWidth;
                var borderWidth   = itemStyle.borderWidth;
                var borderColor   = itemStyle.borderColor;
                var roundCap      = serie.roundCap && insideRadius > 0;

                serieData.context.startAngle    = serie.clockwise ? startDegree : toDegree;
                serieData.context.toAngle       = serie.clockwise ? toDegree : startDegree;
                serieData.context.insideRadius  = insideRadius;
                serieData.context.outsideRadius = serieData.radius > 0 ? serieData.radius : outsideRadius;
                DrawBackground(vh, serie, serieData, j, insideRadius, outsideRadius);
                UGL.DrawDoughnut(vh, serie.context.center, insideRadius, outsideRadius, itemColor, itemToColor,
                                 Color.clear, startDegree, toDegree, borderWidth, borderColor, 0, chart.settings.cicleSmoothness,
                                 roundCap, serie.clockwise);
                DrawCenter(vh, serie, serieData, insideRadius, j == data.Count - 1);
            }
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(360);
                chart.RefreshChart();
            }
            if (dataChanging)
            {
                chart.RefreshChart();
            }
        }