Ejemplo n.º 1
0
        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 outsideRadius  = serie.runtimeInsideRadius + serie.gaugeAxis.axisLine.width;

            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);
                ChartDrawer.DrawDoughnut(vh, serie.runtimeCenterPos, serie.runtimeInsideRadius, outsideRadius,
                                         stageColor.color, stageColor.color, Color.clear, tempStartAngle, tempEndAngle, 0, Color.clear,
                                         0, m_Settings.cicleSmoothness);
                tempStartAngle = tempEndAngle;
            }
        }
Ejemplo n.º 2
0
        protected override void DrawTooltip(VertexHelper vh)
        {
            if (m_Tooltip.runtimeAngle < 0)
            {
                return;
            }
            var lineColor    = TooltipHelper.GetLineColor(tooltip, m_ThemeInfo);
            var cenPos       = m_Polar.runtimeCenterPos;
            var radius       = m_Polar.runtimeRadius;
            var sp           = m_Polar.runtimeCenterPos;
            var tooltipAngle = m_Tooltip.runtimeAngle + m_AngleAxis.runtimeStartAngle;
            var ep           = ChartHelper.GetPos(sp, radius, tooltipAngle, true);

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

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

            case Tooltip.Type.Shadow:
                ChartDrawer.DrawSector(vh, cenPos, radius, lineColor, tooltipAngle - 2, tooltipAngle + 2, m_Settings.cicleSmoothness);
                break;
            }
        }
Ejemplo n.º 3
0
        private void DrawRadiusAxis(VertexHelper vh)
        {
            var startAngle = m_AngleAxis.runtimeStartAngle;
            var radius     = m_Polar.runtimeRadius;
            var cenPos     = m_Polar.runtimeCenterPos;
            var size       = AxisHelper.GetScaleNumber(m_RadiusAxis, radius, null);
            var totalWidth = 0f;
            var dire       = ChartHelper.GetDire(startAngle, true).normalized;
            var tickVetor  = ChartHelper.GetVertialDire(dire) * m_RadiusAxis.axisTick.length;
            var tickWidth  = AxisHelper.GetTickWidth(m_RadiusAxis);

            for (int i = 0; i < size; i++)
            {
                var scaleWidth = AxisHelper.GetScaleWidth(m_RadiusAxis, radius, i);
                var pos        = ChartHelper.GetPos(cenPos, totalWidth, startAngle, true);
                if (m_RadiusAxis.show && m_RadiusAxis.splitLine.show)
                {
                    var outsideRaidus  = totalWidth + m_RadiusAxis.splitLine.lineStyle.width * 2;
                    var splitLineColor = m_RadiusAxis.splitLine.GetColor(m_ThemeInfo);
                    ChartDrawer.DrawDoughnut(vh, cenPos, totalWidth, outsideRaidus, splitLineColor, Color.clear);
                }
                if (m_RadiusAxis.show && m_RadiusAxis.axisTick.show)
                {
                    ChartDrawer.DrawLine(vh, pos, pos + tickVetor, tickWidth, m_ThemeInfo.axisLineColor);
                }
                totalWidth += scaleWidth;
            }
            if (m_RadiusAxis.show && m_RadiusAxis.axisLine.show)
            {
                var lineStartPos = m_Polar.runtimeCenterPos - dire * m_RadiusAxis.axisTick.width;
                var lineEndPos   = m_Polar.runtimeCenterPos + dire * (radius + m_RadiusAxis.axisTick.width);
                ChartDrawer.DrawLine(vh, lineStartPos, lineEndPos, m_RadiusAxis.axisLine.width, m_ThemeInfo.axisLineColor);
            }
        }
Ejemplo n.º 4
0
        private void DrawAngleAxis(VertexHelper vh)
        {
            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 = AxisHelper.GetTickWidth(m_AngleAxis);

            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_ThemeInfo);
                    ChartDrawer.DrawLine(vh, cenPos, pos, m_AngleAxis.splitLine.lineStyle.width, splitLineColor);
                }
                if (m_AngleAxis.show && m_AngleAxis.axisTick.show)
                {
                    var tickPos = ChartHelper.GetPos(cenPos, radius + m_AngleAxis.axisTick.length, currAngle, true);
                    ChartDrawer.DrawLine(vh, pos, tickPos, tickWidth, m_ThemeInfo.axisLineColor);
                }
                currAngle += scaleWidth;
            }
            if (m_AngleAxis.show && m_AngleAxis.axisLine.show)
            {
                var outsideRaidus = radius + m_AngleAxis.axisLine.width * 2;
                ChartDrawer.DrawDoughnut(vh, cenPos, radius, outsideRaidus, m_ThemeInfo.axisLineColor, Color.clear);
            }
        }
Ejemplo n.º 5
0
        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(m_ThemeInfo, serie.index);
            var backgroundColor = serie.gaugeAxis.GetAxisLineBackgroundColor(m_ThemeInfo, serie.index);
            var outsideRadius   = serie.runtimeInsideRadius + serie.gaugeAxis.axisLine.width;

            ChartDrawer.DrawDoughnut(vh, serie.runtimeCenterPos, serie.runtimeInsideRadius, outsideRadius,
                                     backgroundColor, m_ThemeInfo.backgroundColor, m_Settings.cicleSmoothness, serie.startAngle, serie.endAngle);
            if (serie.arcShaped)
            {
                DrawArcShape(vh, serie, serie.startAngle, backgroundColor, true);
                DrawArcShape(vh, serie, serie.endAngle, backgroundColor);
            }
            ChartDrawer.DrawDoughnut(vh, serie.runtimeCenterPos, serie.runtimeInsideRadius, outsideRadius,
                                     color, m_ThemeInfo.backgroundColor, m_Settings.cicleSmoothness, serie.startAngle, currAngle);
            if (serie.arcShaped && currAngle != serie.startAngle)
            {
                DrawArcShape(vh, serie, currAngle, color);
                DrawArcShape(vh, serie, serie.startAngle, color, true);
            }
        }
Ejemplo n.º 6
0
        private void DrawCirleVessel(VertexHelper vh, Vessel vessel)
        {
            var cenPos      = vessel.runtimeCenterPos;
            var radius      = vessel.runtimeRadius;
            var serie       = SeriesHelper.GetSerieByVesselIndex(m_Series, vessel.index);
            var vesselColor = VesselHelper.GetColor(vessel, serie, m_ThemeInfo, m_LegendRealShowName);

            ChartDrawer.DrawDoughnut(vh, cenPos, radius - vessel.shapeWidth, radius, vesselColor, Color.clear, m_Settings.cicleSmoothness);
        }
Ejemplo n.º 7
0
 private void DrawBorder(VertexHelper vh, Serie serie, float insideRadius, float outsideRadius)
 {
     if (serie.itemStyle.show && serie.itemStyle.borderWidth > 0 && serie.itemStyle.borderColor != Color.clear)
     {
         ChartDrawer.DrawDoughnut(vh, serie.runtimeCenterPos, outsideRadius,
                                  outsideRadius + serie.itemStyle.borderWidth, serie.itemStyle.borderColor,
                                  Color.clear, m_Settings.cicleSmoothness);
         ChartDrawer.DrawDoughnut(vh, serie.runtimeCenterPos, insideRadius,
                                  insideRadius + serie.itemStyle.borderWidth, serie.itemStyle.borderColor,
                                  Color.clear, m_Settings.cicleSmoothness);
     }
 }
Ejemplo n.º 8
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 && itemStyle.borderColor != Color.clear)
            {
                ChartDrawer.DrawDoughnut(vh, serie.runtimeCenterPos, outsideRadius,
                                         outsideRadius + itemStyle.borderWidth, itemStyle.borderColor,
                                         Color.clear, m_Settings.cicleSmoothness);
                ChartDrawer.DrawDoughnut(vh, serie.runtimeCenterPos, insideRadius,
                                         insideRadius + itemStyle.borderWidth, itemStyle.borderColor,
                                         Color.clear, m_Settings.cicleSmoothness);
            }
        }
Ejemplo n.º 9
0
        private void DrawBackground(VertexHelper vh, Serie serie, int index, float insideRadius, float outsideRadius)
        {
            var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, m_ThemeInfo, index, false);

            if (serie.itemStyle.backgroundWidth != 0)
            {
                var centerRadius = (outsideRadius + insideRadius) / 2;
                var inradius     = centerRadius - serie.itemStyle.backgroundWidth / 2;
                var outradius    = centerRadius + serie.itemStyle.backgroundWidth / 2;
                ChartDrawer.DrawDoughnut(vh, serie.runtimeCenterPos, inradius,
                                         outradius, backgroundColor, Color.clear, m_Settings.cicleSmoothness);
            }
            else
            {
                ChartDrawer.DrawDoughnut(vh, serie.runtimeCenterPos, insideRadius,
                                         outsideRadius, backgroundColor, Color.clear, m_Settings.cicleSmoothness);
            }
        }
Ejemplo n.º 10
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 = GetLineColor(radar);

            for (int i = 0; i < radar.splitNumber; i++)
            {
                Color color = radar.splitArea.color[i % radar.splitArea.color.Count];
                outsideRadius = insideRadius + block;
                if (radar.splitArea.show)
                {
                    ChartDrawer.DrawDoughnut(vh, p, insideRadius, outsideRadius, color, Color.clear,
                                             0, 360, m_Settings.cicleSmoothness);
                }
                if (radar.splitLine.show)
                {
                    ChartDrawer.DrawEmptyCricle(vh, p, outsideRadius, radar.splitLine.lineStyle.width, lineColor,
                                                Color.clear, m_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)
                {
                    ChartDrawer.DrawLine(vh, p, p1, radar.splitLine.lineStyle.width / 2, lineColor);
                }
            }
        }
Ejemplo n.º 11
0
        protected void DrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize,
                                  float tickness, Vector3 pos, Color color)
        {
            switch (type)
            {
            case SerieSymbolType.None:
                break;

            case SerieSymbolType.Circle:
                ChartDrawer.DrawCricle(vh, pos, symbolSize, color, GetSymbolCricleSegment(symbolSize));
                break;

            case SerieSymbolType.EmptyCircle:
                int segment = GetSymbolCricleSegment(symbolSize);
                ChartDrawer.DrawCricle(vh, pos, symbolSize, m_ThemeInfo.backgroundColor, segment);
                ChartDrawer.DrawDoughnut(vh, pos, symbolSize - tickness, symbolSize, 0, 360, color, segment);
                break;

            case SerieSymbolType.Rect:
                ChartDrawer.DrawPolygon(vh, pos, symbolSize, color);
                break;

            case SerieSymbolType.Triangle:
                var x  = symbolSize * Mathf.Cos(30 * Mathf.PI / 180);
                var y  = symbolSize * Mathf.Sin(30 * Mathf.PI / 180);
                var p1 = new Vector2(pos.x - x, pos.y - y);
                var p2 = new Vector2(pos.x, pos.y + symbolSize);
                var p3 = new Vector2(pos.x + x, pos.y - y);
                ChartDrawer.DrawTriangle(vh, p1, p2, p3, color);
                break;

            case SerieSymbolType.Diamond:
                p1 = new Vector2(pos.x - symbolSize, pos.y);
                p2 = new Vector2(pos.x, pos.y + symbolSize);
                p3 = new Vector2(pos.x + symbolSize, pos.y);
                var p4 = new Vector2(pos.x, pos.y - symbolSize);
                ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, color);
                break;
            }
        }
Ejemplo n.º 12
0
        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(m_ThemeInfo, serie.index);
            var backgroundColor = serie.gaugeAxis.GetAxisLineBackgroundColor(m_ThemeInfo, serie.index);
            var outsideRadius   = serie.runtimeInsideRadius + serie.gaugeAxis.axisLine.width;
            var borderWidth     = serie.itemStyle.borderWidth;
            var borderColor     = serie.itemStyle.borderColor;

            ChartDrawer.DrawDoughnut(vh, serie.runtimeCenterPos, serie.runtimeInsideRadius, outsideRadius,
                                     backgroundColor, backgroundColor, Color.clear, serie.startAngle, serie.endAngle, 0, Color.clear,
                                     0, m_Settings.cicleSmoothness, serie.roundCap);
            ChartDrawer.DrawDoughnut(vh, serie.runtimeCenterPos, serie.runtimeInsideRadius, outsideRadius,
                                     color, color, Color.clear, serie.startAngle, currAngle, 0, Color.clear,
                                     0, m_Settings.cicleSmoothness, serie.roundCap);
        }
Ejemplo n.º 13
0
        protected override void DrawChart(VertexHelper vh)
        {
            base.DrawChart(vh);
            int  serieNameCount  = -1;
            bool isClickOffset   = false;
            bool isDataHighlight = false;

            for (int i = 0; i < m_Series.Count; i++)
            {
                var serie = m_Series.list[i];
                serie.index = i;
                var data = serie.data;
                serie.animation.InitProgress(data.Count, 0, 360);
                if (!serie.show)
                {
                    continue;
                }
                bool isFinish = true;
                if (serie.pieClickOffset)
                {
                    isClickOffset = true;
                }
                serie.runtimePieDataMax   = serie.yMax;
                serie.runtimePieDataTotal = serie.yTotal;
                UpdatePieCenter(serie);

                float totalDegree   = 360;
                float startDegree   = 0;
                int   showdataCount = 0;
                foreach (var sd in serie.data)
                {
                    if (sd.show && serie.pieRoseType == RoseType.Area)
                    {
                        showdataCount++;
                    }
                    sd.canShowLabel = false;
                }
                for (int n = 0; n < data.Count; n++)
                {
                    if (!serie.animation.NeedAnimation(n))
                    {
                        break;
                    }
                    var serieData = data[n];
                    serieData.index = n;
                    float value = serieData.data[1];
                    serieNameCount = m_LegendRealShowName.IndexOf(serieData.legendName);
                    Color color = m_ThemeInfo.GetColor(serieNameCount);
                    serieData.runtimePieStartAngle = startDegree;
                    serieData.runtimePieToAngle    = startDegree;
                    serieData.runtimePieHalfAngle  = startDegree;
                    serieData.runtimePieCurrAngle  = startDegree;
                    if (!serieData.show)
                    {
                        continue;
                    }
                    float degree = serie.pieRoseType == RoseType.Area ?
                                   (totalDegree / showdataCount) : (totalDegree * value / serie.runtimePieDataTotal);
                    serieData.runtimePieToAngle = startDegree + degree;

                    serieData.runtimePieOutsideRadius = serie.pieRoseType > 0 ?
                                                        serie.runtimePieInsideRadius + (serie.runtimePieOutsideRadius - serie.runtimePieInsideRadius) * value / serie.runtimePieDataMax :
                                                        serie.runtimePieOutsideRadius;
                    if (serieData.highlighted)
                    {
                        isDataHighlight = true;
                        color          *= 1.2f;
                        serieData.runtimePieOutsideRadius += m_Settings.pieTooltipExtraRadius;
                    }
                    var offset = serie.pieSpace;
                    if (serie.pieClickOffset && serieData.selected)
                    {
                        offset += m_Settings.pieSelectedOffset;
                    }
                    var halfDegree = (serieData.runtimePieToAngle - startDegree) / 2;
                    serieData.runtimePieHalfAngle = startDegree + halfDegree;
                    float currRad = serieData.runtimePieHalfAngle * Mathf.Deg2Rad;
                    float currSin = Mathf.Sin(currRad);
                    float currCos = Mathf.Cos(currRad);
                    var   center  = serie.runtimePieCenterPos;

                    serieData.runtimePieCurrAngle    = serieData.runtimePieToAngle;
                    serieData.runtiemPieOffsetCenter = center;
                    serieData.runtimePieInsideRadius = serie.runtimePieInsideRadius;
                    if (serie.animation.CheckDetailBreak(n, serieData.runtimePieToAngle))
                    {
                        isFinish = false;
                        serieData.runtimePieCurrAngle = serie.animation.GetCurrDetail();
                    }
                    if (offset > 0)
                    {
                        serieData.runtimePieOffsetRadius   = serie.pieSpace / Mathf.Sin(halfDegree * Mathf.Deg2Rad);
                        serieData.runtimePieInsideRadius  -= serieData.runtimePieOffsetRadius;
                        serieData.runtimePieOutsideRadius -= serieData.runtimePieOffsetRadius;
                        if (serie.pieClickOffset && serieData.selected)
                        {
                            serieData.runtimePieOffsetRadius += m_Settings.pieSelectedOffset;
                            if (serieData.runtimePieInsideRadius > 0)
                            {
                                serieData.runtimePieInsideRadius += m_Settings.pieSelectedOffset;
                            }
                            serieData.runtimePieOutsideRadius += m_Settings.pieSelectedOffset;
                        }

                        serieData.runtiemPieOffsetCenter = new Vector3(center.x + serieData.runtimePieOffsetRadius * currSin,
                                                                       center.y + serieData.runtimePieOffsetRadius * currCos);

                        ChartDrawer.DrawDoughnut(vh, serieData.runtiemPieOffsetCenter, serieData.runtimePieInsideRadius, serieData.runtimePieOutsideRadius,
                                                 color, m_ThemeInfo.backgroundColor, m_Settings.cicleSmoothness, startDegree, serieData.runtimePieCurrAngle);
                    }
                    else
                    {
                        ChartDrawer.DrawDoughnut(vh, center, serieData.runtimePieInsideRadius, serieData.runtimePieOutsideRadius,
                                                 color, m_ThemeInfo.backgroundColor, m_Settings.cicleSmoothness, startDegree, serieData.runtimePieCurrAngle);
                    }
                    serieData.canShowLabel = serieData.runtimePieCurrAngle >= serieData.runtimePieHalfAngle;
                    isDrawPie   = true;
                    startDegree = serieData.runtimePieToAngle;
                    if (isFinish)
                    {
                        serie.animation.SetDataFinish(n);
                    }
                    else
                    {
                        break;
                    }
                }
                if (!serie.animation.IsFinish())
                {
                    float duration    = serie.animation.duration > 0 ? (float)serie.animation.duration / 1000 : 1;
                    float speed       = 360 / duration;
                    float symbolSpeed = serie.symbol.size / duration;
                    serie.animation.CheckProgress(Time.deltaTime * speed);
                    serie.animation.CheckSymbol(Time.deltaTime * symbolSpeed, serie.symbol.size);
                    RefreshChart();
                }
            }
            DrawLabelLine(vh);
            DrawLabelBackground(vh);
            raycastTarget = isClickOffset && isDataHighlight;
        }
Ejemplo n.º 14
0
        protected override void DrawChart(VertexHelper vh)
        {
            base.DrawChart(vh);
            int  serieNameCount  = -1;
            bool isClickOffset   = false;
            bool isDataHighlight = false;

            for (int i = 0; i < m_Series.Count; i++)
            {
                var serie = m_Series.list[i];
                serie.index = i;
                var data = serie.data;
                serie.animation.InitProgress(data.Count, 0, 360);
                if (!serie.show || serie.animation.HasFadeOut())
                {
                    continue;
                }
                bool isFinish = true;
                if (serie.pieClickOffset)
                {
                    isClickOffset = true;
                }
                serie.runtimePieDataMax   = serie.yMax;
                serie.runtimePieDataTotal = serie.yTotal;
                SerieHelper.UpdateCenter(serie, chartPosition, chartWidth, chartHeight);

                float totalDegree   = 360;
                float startDegree   = 0;
                int   showdataCount = 0;
                foreach (var sd in serie.data)
                {
                    if (sd.show && serie.pieRoseType == RoseType.Area)
                    {
                        showdataCount++;
                    }
                    sd.canShowLabel = false;
                }
                bool  dataChanging       = false;
                float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
                for (int n = 0; n < data.Count; n++)
                {
                    var serieData = data[n];
                    var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.highlighted);
                    serieData.index = n;
                    float value = serieData.GetCurrData(1, dataChangeDuration);
                    if (serieData.IsDataChanged())
                    {
                        dataChanging = true;
                    }
                    serieNameCount = m_LegendRealShowName.IndexOf(serieData.legendName);
                    var color       = SerieHelper.GetItemColor(serie, serieData, m_ThemeInfo, serieNameCount, serieData.highlighted);
                    var toColor     = SerieHelper.GetItemToColor(serie, serieData, m_ThemeInfo, serieNameCount, serieData.highlighted);
                    var borderWidth = itemStyle.borderWidth;
                    var borderColor = itemStyle.borderColor;

                    serieData.runtimePieStartAngle = startDegree;
                    serieData.runtimePieToAngle    = startDegree;
                    serieData.runtimePieHalfAngle  = startDegree;
                    serieData.runtimePieCurrAngle  = startDegree;
                    if (!serieData.show)
                    {
                        continue;
                    }
                    float degree = serie.pieRoseType == RoseType.Area ?
                                   (totalDegree / showdataCount) : (totalDegree * value / serie.runtimePieDataTotal);
                    serieData.runtimePieToAngle = startDegree + degree;

                    serieData.runtimePieOutsideRadius = serie.pieRoseType > 0 ?
                                                        serie.runtimeInsideRadius + (serie.runtimeOutsideRadius - serie.runtimeInsideRadius) * value / serie.runtimePieDataMax :
                                                        serie.runtimeOutsideRadius;
                    if (serieData.highlighted)
                    {
                        isDataHighlight = true;
                        serieData.runtimePieOutsideRadius += m_Settings.pieTooltipExtraRadius;
                    }
                    var offset = 0f;
                    if (serie.pieClickOffset && serieData.selected)
                    {
                        offset += m_Settings.pieSelectedOffset;
                    }
                    var halfDegree = (serieData.runtimePieToAngle - startDegree) / 2;
                    serieData.runtimePieHalfAngle = startDegree + halfDegree;
                    float currRad = serieData.runtimePieHalfAngle * Mathf.Deg2Rad;
                    float currSin = Mathf.Sin(currRad);
                    float currCos = Mathf.Cos(currRad);
                    var   center  = serie.runtimeCenterPos;

                    serieData.runtimePieCurrAngle    = serieData.runtimePieToAngle;
                    serieData.runtiemPieOffsetCenter = center;
                    serieData.runtimePieInsideRadius = serie.runtimeInsideRadius;
                    if (serie.animation.CheckDetailBreak(serieData.runtimePieToAngle))
                    {
                        isFinish = false;
                        serieData.runtimePieCurrAngle = serie.animation.GetCurrDetail();
                    }
                    if (offset > 0)
                    {
                        serieData.runtimePieOffsetRadius   = 0;
                        serieData.runtimePieInsideRadius  -= serieData.runtimePieOffsetRadius;
                        serieData.runtimePieOutsideRadius -= serieData.runtimePieOffsetRadius;
                        if (serie.pieClickOffset && serieData.selected)
                        {
                            serieData.runtimePieOffsetRadius += m_Settings.pieSelectedOffset;
                            if (serieData.runtimePieInsideRadius > 0)
                            {
                                serieData.runtimePieInsideRadius += m_Settings.pieSelectedOffset;
                            }
                            serieData.runtimePieOutsideRadius += m_Settings.pieSelectedOffset;
                        }

                        serieData.runtiemPieOffsetCenter = new Vector3(center.x + serieData.runtimePieOffsetRadius * currSin,
                                                                       center.y + serieData.runtimePieOffsetRadius * currCos);
                        var drawEndDegree = serieData.runtimePieCurrAngle;
                        var needRoundCap  = serie.roundCap && serieData.runtimePieInsideRadius > 0;
                        ChartDrawer.DrawDoughnut(vh, serieData.runtiemPieOffsetCenter, serieData.runtimePieInsideRadius,
                                                 serieData.runtimePieOutsideRadius, color, toColor, Color.clear, startDegree, drawEndDegree,
                                                 borderWidth, borderColor, serie.pieSpace / 2, m_Settings.cicleSmoothness, needRoundCap, serie.clockwise);
                    }
                    else //if(n==0)
                    {
                        var drawEndDegree = serieData.runtimePieCurrAngle;
                        var needRoundCap  = serie.roundCap && serieData.runtimePieInsideRadius > 0;
                        ChartDrawer.DrawDoughnut(vh, center, serieData.runtimePieInsideRadius, serieData.runtimePieOutsideRadius,
                                                 color, toColor, Color.clear, startDegree, drawEndDegree, borderWidth, borderColor, serie.pieSpace / 2,
                                                 m_Settings.cicleSmoothness, needRoundCap, serie.clockwise);
                        DrawCenter(vh, serie, itemStyle, serieData.runtimePieInsideRadius);
                    }
                    serieData.canShowLabel = serieData.runtimePieCurrAngle >= serieData.runtimePieHalfAngle;
                    isDrawPie   = true;
                    startDegree = serieData.runtimePieToAngle;
                    if (isFinish)
                    {
                        serie.animation.SetDataFinish(n);
                    }
                    else
                    {
                        break;
                    }
                }
                if (!serie.animation.IsFinish())
                {
                    serie.animation.CheckProgress(360);
                    serie.animation.CheckSymbol(serie.symbol.size);
                    RefreshChart();
                }
                if (dataChanging)
                {
                    RefreshChart();
                }
            }
            DrawLabelLine(vh);
            DrawLabelBackground(vh);
            raycastTarget = isClickOffset && isDataHighlight;
        }
Ejemplo n.º 15
0
        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)
        {
            Color color = SerieHelper.GetItemBackgroundColor(serie, serieData, m_ThemeInfo, colorIndex, highlight, false);

            if (ChartHelper.IsClearColor(color))
            {
                return;
            }
            if (isYAxis)
            {
                var     axis      = m_YAxises[serie.axisIndex];
                var     axisWidth = axis.axisLine.width;
                Vector3 plt       = new Vector3(m_CoordinateX + axisWidth, pY + space + barWidth);
                Vector3 prt       = new Vector3(m_CoordinateX + axisWidth + m_CoordinateWidth, pY + space + barWidth);
                Vector3 prb       = new Vector3(m_CoordinateX + axisWidth + m_CoordinateWidth, pY + space);
                Vector3 plb       = new Vector3(m_CoordinateX + 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;
                    CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, color, color, serie.clip);
                    ChartDrawer.DrawSector(vh, pcl, radius, color, 180, 360);
                    ChartDrawer.DrawSector(vh, pcr, radius, color, 0, 180);
                    if (itemStyle.NeedShowBorder())
                    {
                        var borderWidth = itemStyle.borderWidth;
                        var borderColor = itemStyle.borderColor;
                        var smoothness  = m_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;
                        ChartDrawer.DrawLine(vh, p1, p2, borderWidth / 2, borderColor);
                        ChartDrawer.DrawLine(vh, p3, p4, borderWidth / 2, borderColor);
                        ChartDrawer.DrawDoughnut(vh, pcl, inRadius, outRadius, borderColor, Color.clear, 180, 360, smoothness);
                        ChartDrawer.DrawDoughnut(vh, pcr, inRadius, outRadius, borderColor, Color.clear, 0, 180, smoothness);
                    }
                }
                else
                {
                    CheckClipAndDrawPolygon(vh, ref plb, ref plt, ref prt, ref prb, color, color, serie.clip);
                }
            }
            else
            {
                var     axis      = m_XAxises[serie.axisIndex];
                var     axisWidth = axis.axisLine.width;
                Vector3 plb       = new Vector3(pX + space, m_CoordinateY + axisWidth);
                Vector3 plt       = new Vector3(pX + space, m_CoordinateY + m_CoordinateHeight + axisWidth);
                Vector3 prt       = new Vector3(pX + space + barWidth, m_CoordinateY + m_CoordinateHeight + axisWidth);
                Vector3 prb       = new Vector3(pX + space + barWidth, m_CoordinateY + 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;
                    CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, color, color, serie.clip);
                    ChartDrawer.DrawSector(vh, pct, radius, color, 270, 450);
                    ChartDrawer.DrawSector(vh, pcb, radius, color, 90, 270);
                    if (itemStyle.NeedShowBorder())
                    {
                        var borderWidth = itemStyle.borderWidth;
                        var borderColor = itemStyle.borderColor;
                        var smoothness  = m_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;
                        ChartDrawer.DrawLine(vh, p1, p2, borderWidth / 2, borderColor);
                        ChartDrawer.DrawLine(vh, p3, p4, borderWidth / 2, borderColor);
                        ChartDrawer.DrawDoughnut(vh, pct, inRadius, outRadius, borderColor, Color.clear, 270, 450, smoothness);
                        ChartDrawer.DrawDoughnut(vh, pcb, inRadius, outRadius, borderColor, Color.clear, 90, 270, smoothness);
                    }
                }
                else
                {
                    CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, color, color, serie.clip);
                }
            }
        }
Ejemplo n.º 16
0
        private void DrawPie(VertexHelper vh)
        {
            bool isClickOffset   = false;
            bool isDataHighlight = false;

            for (int i = 0; i < m_Series.Count; i++)
            {
                var serie = m_Series.list[i];
                serie.index = i;
                var data = serie.data;
                serie.animation.InitProgress(data.Count, 0, 360);
                if (!serie.show || serie.animation.HasFadeOut())
                {
                    continue;
                }
                if (serie.pieClickOffset)
                {
                    isClickOffset = true;
                }
                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 = m_LegendRealShowName.IndexOf(serieData.legendName);
                    var color          = SerieHelper.GetItemColor(serie, serieData, m_ThemeInfo, serieNameCount, serieData.highlighted);
                    var toColor        = SerieHelper.GetItemToColor(serie, serieData, m_ThemeInfo, serieNameCount, serieData.highlighted);
                    var borderWidth    = itemStyle.borderWidth;
                    var borderColor    = itemStyle.borderColor;

                    if (serieData.highlighted)
                    {
                        isDataHighlight = true;
                    }
                    if (serie.pieClickOffset && serieData.selected)
                    {
                        var drawEndDegree = serieData.runtimePieCurrAngle;
                        var needRoundCap  = serie.roundCap && serieData.runtimePieInsideRadius > 0;
                        ChartDrawer.DrawDoughnut(vh, serieData.runtiemPieOffsetCenter, serieData.runtimePieInsideRadius,
                                                 serieData.runtimePieOutsideRadius, color, toColor, Color.clear, serieData.runtimePieStartAngle, drawEndDegree,
                                                 borderWidth, borderColor, serie.pieSpace / 2, m_Settings.cicleSmoothness, needRoundCap, true);
                    }
                    else
                    {
                        var drawEndDegree = serieData.runtimePieCurrAngle;
                        var needRoundCap  = serie.roundCap && serieData.runtimePieInsideRadius > 0;
                        ChartDrawer.DrawDoughnut(vh, serie.runtimeCenterPos, serieData.runtimePieInsideRadius, serieData.runtimePieOutsideRadius,
                                                 color, toColor, Color.clear, serieData.runtimePieStartAngle, drawEndDegree, borderWidth, borderColor, serie.pieSpace / 2,
                                                 m_Settings.cicleSmoothness, needRoundCap, true);
                        DrawCenter(vh, serie, itemStyle, serieData.runtimePieInsideRadius);
                    }
                    isDrawPie = true;
                    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.size);
                    RefreshChart();
                }
                if (dataChanging)
                {
                    RefreshChart();
                }
            }
            raycastTarget = isClickOffset && isDataHighlight;
        }
Ejemplo n.º 17
0
        protected override void DrawChart(VertexHelper vh)
        {
            base.DrawChart(vh);
            for (int i = 0; i < m_Series.list.Count; i++)
            {
                var serie = m_Series.list[i];
                var data  = serie.data;
                serie.index = i;
                if (!serie.show || serie.type != SerieType.Ring || serie.animation.HasFadeOut())
                {
                    continue;
                }
                serie.animation.InitProgress(data.Count, serie.startAngle, serie.startAngle + 360);
                serie.UpdateCenter(chartWidth, chartHeight);
                TitleStyleHelper.CheckTitle(serie, ref m_ReinitTitle, ref m_UpdateTitleText);
                SerieLabelHelper.CheckLabel(serie, ref 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 itemColor     = SerieHelper.GetItemColor(serie, serieData, m_ThemeInfo, j, serieData.highlighted);
                    var outsideRadius = serie.runtimeOutsideRadius - j * (ringWidth + serie.ringGap);
                    var insideRadius  = outsideRadius - ringWidth;
                    var centerRadius  = (outsideRadius + insideRadius) / 2;

                    serieData.runtimePieStartAngle    = serie.clockwise ? startDegree : toDegree;
                    serieData.runtimePieToAngle       = serie.clockwise ? toDegree : startDegree;
                    serieData.runtimePieInsideRadius  = insideRadius;
                    serieData.runtimePieOutsideRadius = outsideRadius;

                    DrawBackground(vh, serie, serieData, j, insideRadius, outsideRadius);
                    DrawRoundCap(vh, serie, serie.runtimeCenterPos, itemColor, insideRadius, outsideRadius,
                                 ref startDegree, ref toDegree);
                    ChartDrawer.DrawDoughnut(vh, serie.runtimeCenterPos, insideRadius,
                                             outsideRadius, itemColor, Color.clear, m_Settings.cicleSmoothness,
                                             startDegree, toDegree);
                    DrawBorder(vh, serie, serieData, insideRadius, outsideRadius);
                    DrawCenter(vh, serie, serieData, insideRadius, j == data.Count - 1);
                    UpateLabelPosition(serie, serieData, j, startDegree, toDegree, centerRadius);
                }
                if (!serie.animation.IsFinish())
                {
                    serie.animation.CheckProgress(360);
                    serie.animation.CheckSymbol(serie.symbol.size);
                    RefreshChart();
                }
                if (dataChanging)
                {
                    RefreshChart();
                }
            }
        }
Ejemplo n.º 18
0
        protected void DrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize,
                                  float tickness, Vector3 pos, Color color, Color toColor, float gap, float[] cornerRadius)
        {
            var backgroundColor = m_ThemeInfo.backgroundColor;
            var smoothness      = m_Settings.cicleSmoothness;

            switch (type)
            {
            case SerieSymbolType.None:
                break;

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

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

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

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

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