예제 #1
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        = (float)(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;
                if (itemStyle.backgroundColor.a != 0)
                {
                    UGL.DrawDoughnut(vh, serie.runtimeCenterPos, insideRadius, outsideRadius, itemStyle.backgroundColor,
                                     itemStyle.backgroundColor, Color.clear, 0, 360, borderWidth, borderColor, 0,
                                     chart.settings.cicleSmoothness, false, serie.clockwise);
                }
                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();
            }
        }
예제 #2
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);
                SerieHelper.UpdateCenter(serie, chartPosition, 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 itemStyle     = SerieHelper.GetItemStyle(serie, serieData, serieData.highlighted);
                    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;
                    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;
                    ChartDrawer.DrawDoughnut(vh, serie.runtimeCenterPos, insideRadius, outsideRadius, itemColor, itemColor,
                                             Color.clear, startDegree, toDegree, borderWidth, borderColor, 0, m_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);
                    serie.animation.CheckSymbol(serie.symbol.size);
                    RefreshChart();
                }
                if (dataChanging)
                {
                    RefreshChart();
                }
            }
        }
예제 #3
0
        private void UpdateRuntimeData()
        {
            for (int i = 0; i < m_Series.Count; i++)
            {
                var serie = m_Series.list[i];
                if (serie.type != SerieType.Pie)
                {
                    continue;
                }
                serie.index = i;
                var data = serie.data;
                serie.runtimeDataMax      = serie.yMax;
                serie.runtimePieDataTotal = serie.yTotal;
                serie.animation.InitProgress(data.Count, 0, 360);
                SerieHelper.UpdateCenter(serie, chartPosition, chartWidth, chartHeight);
                float totalDegree   = 360f;
                float startDegree   = 0;
                int   showdataCount = 0;
                foreach (var sd in serie.data)
                {
                    if (sd.show && serie.pieRoseType == RoseType.Area)
                    {
                        showdataCount++;
                    }
                    sd.canShowLabel = false;
                }
                float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
                bool  isAllZeroValue     = SerieHelper.IsAllZeroValue(serie, 1);
                float zeroReplaceValue   = totalDegree / data.Count;
                if (isAllZeroValue)
                {
                    serie.runtimeDataMax      = zeroReplaceValue;
                    serie.runtimePieDataTotal = totalDegree;
                }
                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 = isAllZeroValue ? zeroReplaceValue : serieData.GetCurrData(1, dataChangeDuration);
                    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.runtimeDataMax :
                                                        serie.runtimeOutsideRadius;
                    if (serieData.highlighted)
                    {
                        serieData.runtimePieOutsideRadius += m_Settings.pieTooltipExtraRadius;
                    }
                    var offset = 0f;
                    if (serie.pieClickOffset && serieData.selected)
                    {
                        offset += m_Settings.pieSelectedOffset;
                    }
                    if (serie.animation.CheckDetailBreak(serieData.runtimePieToAngle))
                    {
                        serieData.runtimePieCurrAngle = serie.animation.GetCurrDetail();
                    }
                    else
                    {
                        serieData.runtimePieCurrAngle = serieData.runtimePieToAngle;
                    }
                    var halfDegree = (serieData.runtimePieToAngle - startDegree) / 2;
                    serieData.runtimePieHalfAngle    = startDegree + halfDegree;
                    serieData.runtiemPieOffsetCenter = serie.runtimeCenterPos;
                    serieData.runtimePieInsideRadius = serie.runtimeInsideRadius;
                    if (offset > 0)
                    {
                        var currRad = serieData.runtimePieHalfAngle * Mathf.Deg2Rad;
                        var currSin = Mathf.Sin(currRad);
                        var currCos = Mathf.Cos(currRad);
                        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(serie.runtimeCenterPos.x + serieData.runtimePieOffsetRadius * currSin,
                                                                       serie.runtimeCenterPos.y + serieData.runtimePieOffsetRadius * currCos);
                    }
                    serieData.canShowLabel = serieData.runtimePieCurrAngle >= serieData.runtimePieHalfAngle;
                    startDegree            = serieData.runtimePieToAngle;
                    SerieLabelHelper.UpdatePieLabelPosition(serie, serieData);
                }
                SerieLabelHelper.AvoidLabelOverlap(serie);
            }
        }
예제 #4
0
        protected void DrawScatterSerie(VertexHelper vh, int colorIndex, Serie serie)
        {
            if (serie.animation.HasFadeOut())
            {
                return;
            }
            if (!serie.show)
            {
                return;
            }
            var yAxis    = m_YAxises[serie.axisIndex];
            var xAxis    = m_XAxises[serie.axisIndex];
            int maxCount = serie.maxShow > 0 ?
                           (serie.maxShow > serie.dataCount ? serie.dataCount : serie.maxShow)
                : serie.dataCount;

            serie.animation.InitProgress(1, 0, 1);
            var rate = serie.animation.GetCurrRate();
            var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
            var dataChanging       = false;

            for (int n = serie.minShow; n < maxCount; n++)
            {
                var serieData = serie.GetDataList(m_DataZoom)[n];
                var symbol    = SerieHelper.GetSerieSymbol(serie, serieData);
                if (!symbol.ShowSymbol(n, maxCount))
                {
                    continue;
                }
                var   highlight    = serie.highlighted || serieData.highlighted;
                var   color        = SerieHelper.GetItemColor(serie, serieData, m_ThemeInfo, colorIndex, highlight);
                var   toColor      = SerieHelper.GetItemToColor(serie, serieData, m_ThemeInfo, colorIndex, highlight);
                var   symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, highlight);
                var   cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
                float xValue       = serieData.GetCurrData(0, dataChangeDuration, xAxis.inverse);
                float yValue       = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse);
                if (serieData.IsDataChanged())
                {
                    dataChanging = true;
                }
                float pX       = m_CoordinateX + xAxis.axisLine.width;
                float pY       = m_CoordinateY + yAxis.axisLine.width;
                float xDataHig = (xValue - xAxis.runtimeMinValue) / (xAxis.runtimeMaxValue - xAxis.runtimeMinValue) * m_CoordinateWidth;
                float yDataHig = (yValue - yAxis.runtimeMinValue) / (yAxis.runtimeMaxValue - yAxis.runtimeMinValue) * m_CoordinateHeight;
                var   pos      = new Vector3(pX + xDataHig, pY + yDataHig);
                serie.dataPoints.Add(pos);
                serieData.runtimePosition = pos;
                var   datas      = serie.data[n].data;
                float symbolSize = 0;
                if (serie.highlighted || serieData.highlighted)
                {
                    symbolSize = symbol.GetSelectedSize(datas);
                }
                else
                {
                    symbolSize = symbol.GetSize(datas);
                }
                symbolSize *= rate;
                if (symbolSize > 100)
                {
                    symbolSize = 100;
                }
                if (serie.type == SerieType.EffectScatter)
                {
                    for (int count = 0; count < symbol.animationSize.Count; count++)
                    {
                        var nowSize = symbol.animationSize[count];
                        color.a = (symbolSize - nowSize) / symbolSize;
                        DrawSymbol(vh, symbol.type, nowSize, symbolBorder, pos, color, toColor, symbol.gap, cornerRadius);
                    }
                    RefreshChart();
                }
                else
                {
                    DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos, color, toColor, symbol.gap, cornerRadius);
                }
            }
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(1);
                m_IsPlayingAnimation = true;
                RefreshChart();
            }
            if (dataChanging)
            {
                RefreshChart();
            }
        }
예제 #5
0
        private void DrawLabel(Serie serie, int dataIndex, SerieData serieData, Color serieColor)
        {
            if (serieData.labelObject == null)
            {
                return;
            }
            var currAngle   = serieData.runtimePieHalfAngle;
            var isHighlight = (serieData.highlighted && serie.emphasis.label.show);
            var serieLabel  = SerieHelper.GetSerieLabel(serie, serieData);
            var showLabel   = ((serieLabel.show || isHighlight) && serieData.canShowLabel);

            if (showLabel || serieData.iconStyle.show)
            {
                serieData.SetLabelActive(showLabel);
                float rotate           = 0;
                bool  isInsidePosition = serieLabel.position == SerieLabel.Position.Inside;
                if (serieLabel.rotate > 0 && isInsidePosition)
                {
                    if (currAngle > 180)
                    {
                        rotate += 270 - currAngle;
                    }
                    else
                    {
                        rotate += -(currAngle - 90);
                    }
                }
                Color color = serieColor;
                if (isHighlight)
                {
                    if (!ChartHelper.IsClearColor(serie.emphasis.label.color))
                    {
                        color = serie.emphasis.label.color;
                    }
                }
                else if (!ChartHelper.IsClearColor(serieLabel.color))
                {
                    color = serieLabel.color;
                }
                else
                {
                    color = isInsidePosition ? Color.white : serieColor;
                }
                var fontSize  = isHighlight ? serie.emphasis.label.fontSize : serieLabel.fontSize;
                var fontStyle = isHighlight ? serie.emphasis.label.fontStyle : serieLabel.fontStyle;

                serieData.labelObject.label.color     = color;
                serieData.labelObject.label.fontSize  = fontSize;
                serieData.labelObject.label.fontStyle = fontStyle;
                serieData.labelObject.SetLabelRotate(rotate);
                if (!string.IsNullOrEmpty(serieLabel.formatter))
                {
                    var value   = serieData.data[1];
                    var total   = serie.yTotal;
                    var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, total, serieLabel);
                    if (serieData.labelObject.SetText(content))
                    {
                        RefreshChart();
                    }
                }
                else
                {
                    if (serieData.labelObject.SetText(serieData.name))
                    {
                        RefreshChart();
                    }
                }
                serieData.labelObject.SetPosition(SerieLabelHelper.GetRealLabelPosition(serieData, serieLabel));
                if (showLabel)
                {
                    serieData.labelObject.SetLabelPosition(serieLabel.offset);
                }
                else
                {
                    serieData.SetLabelActive(false);
                }
            }
            else
            {
                serieData.SetLabelActive(false);
            }
            serieData.labelObject.UpdateIcon(serieData.iconStyle);
        }
예제 #6
0
        private void DrawLabelLine(VertexHelper vh, Serie serie, SerieData serieData, Color color)
        {
            var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);

            if (serieLabel.show &&
                serieLabel.position == SerieLabel.Position.Outside &&
                serieLabel.line)
            {
                var insideRadius  = serieData.runtimePieInsideRadius;
                var outSideRadius = serieData.runtimePieOutsideRadius;
                var center        = serie.runtimeCenterPos;
                var currAngle     = serieData.runtimePieHalfAngle;
                if (!ChartHelper.IsClearColor(serieLabel.lineColor))
                {
                    color = serieLabel.lineColor;
                }
                else if (serieLabel.lineType == SerieLabel.LineType.HorizontalLine)
                {
                    color *= color;
                }
                float currSin = Mathf.Sin(currAngle * Mathf.Deg2Rad);
                float currCos = Mathf.Cos(currAngle * Mathf.Deg2Rad);
                var   radius1 = serieLabel.lineType == SerieLabel.LineType.HorizontalLine ?
                                serie.runtimeOutsideRadius : outSideRadius;
                var radius2 = serie.runtimeOutsideRadius + serieLabel.lineLength1;
                var radius3 = insideRadius + (outSideRadius - insideRadius) / 2;
                if (radius1 < serie.runtimeInsideRadius)
                {
                    radius1 = serie.runtimeInsideRadius;
                }
                radius1 -= 0.1f;
                var pos0 = new Vector3(center.x + radius3 * currSin, center.y + radius3 * currCos);
                var pos1 = new Vector3(center.x + radius1 * currSin, center.y + radius1 * currCos);
                var pos2 = serieData.labelPosition;
                if (pos2.x == 0)
                {
                    pos2 = new Vector3(center.x + radius2 * currSin, center.y + radius2 * currCos);
                }
                float   tx, ty;
                Vector3 pos4, pos6;
                var     horizontalLineCircleRadius = serieLabel.lineWidth * 4f;
                var     lineCircleDiff             = horizontalLineCircleRadius - 0.3f;
                if (currAngle < 90)
                {
                    ty = serieLabel.lineWidth * Mathf.Cos((90 - currAngle) * Mathf.Deg2Rad);
                    tx = serieLabel.lineWidth * Mathf.Sin((90 - currAngle) * Mathf.Deg2Rad);
                    var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos * radius3, 2)) - currSin * radius3;
                    r4  += serieLabel.lineLength1 - lineCircleDiff;
                    pos6 = pos0 + Vector3.right * lineCircleDiff;
                    pos4 = pos6 + Vector3.right * r4;
                }
                else if (currAngle < 180)
                {
                    ty = serieLabel.lineWidth * Mathf.Sin((180 - currAngle) * Mathf.Deg2Rad);
                    tx = serieLabel.lineWidth * Mathf.Cos((180 - currAngle) * Mathf.Deg2Rad);
                    var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos * radius3, 2)) - currSin * radius3;
                    r4  += serieLabel.lineLength1 - lineCircleDiff;
                    pos6 = pos0 + Vector3.right * lineCircleDiff;
                    pos4 = pos6 + Vector3.right * r4;
                }
                else if (currAngle < 270)
                {
                    ty = serieLabel.lineWidth * Mathf.Sin((180 + currAngle) * Mathf.Deg2Rad);
                    tx = serieLabel.lineWidth * Mathf.Cos((180 + currAngle) * Mathf.Deg2Rad);
                    var currSin1 = Mathf.Sin((360 - currAngle) * Mathf.Deg2Rad);
                    var currCos1 = Mathf.Cos((360 - currAngle) * Mathf.Deg2Rad);
                    var r4       = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos1 * radius3, 2)) - currSin1 * radius3;
                    r4  += serieLabel.lineLength1 - lineCircleDiff;
                    pos6 = pos0 + Vector3.left * lineCircleDiff;
                    pos4 = pos6 + Vector3.left * r4;
                }
                else
                {
                    ty = serieLabel.lineWidth * Mathf.Cos((90 + currAngle) * Mathf.Deg2Rad);
                    tx = serieLabel.lineWidth * Mathf.Sin((90 + currAngle) * Mathf.Deg2Rad);
                    var currSin1 = Mathf.Sin((360 - currAngle) * Mathf.Deg2Rad);
                    var currCos1 = Mathf.Cos((360 - currAngle) * Mathf.Deg2Rad);
                    var r4       = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos1 * radius3, 2)) - currSin1 * radius3;
                    r4  += serieLabel.lineLength1 - lineCircleDiff;
                    pos6 = pos0 + Vector3.left * lineCircleDiff;
                    pos4 = pos6 + Vector3.left * r4;
                }
                var pos5 = new Vector3(currAngle > 180 ? pos2.x - serieLabel.lineLength2 : pos2.x + serieLabel.lineLength2, pos2.y);
                switch (serieLabel.lineType)
                {
                case SerieLabel.LineType.BrokenLine:
                    ChartDrawer.DrawLine(vh, pos1, pos2, pos5, serieLabel.lineWidth, color);
                    break;

                case SerieLabel.LineType.Curves:
                    ChartDrawer.DrawCurves(vh, pos1, pos5, pos1, pos2, serieLabel.lineWidth, color, m_Settings.lineSmoothness);
                    break;

                case SerieLabel.LineType.HorizontalLine:
                    ChartDrawer.DrawCricle(vh, pos0, horizontalLineCircleRadius, color);
                    ChartDrawer.DrawLine(vh, pos6, pos4, serieLabel.lineWidth, color);
                    break;
                }
            }
        }
예제 #7
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;
                float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
                bool  isAllZeroValue     = SerieHelper.IsAllZeroValue(serie, 1);
                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;
        }
예제 #8
0
        protected override void CheckTootipArea(Vector2 local, bool isActivedOther)
        {
            if (isActivedOther)
            {
                return;
            }
            tooltip.runtimePolarIndex = GetPointerInPoloar(local);
            if (tooltip.runtimePolarIndex < 0)
            {
                tooltip.runtimeAngle = -1;
                if (tooltip.IsActive())
                {
                    foreach (var kv in tooltip.runtimeSerieIndex)
                    {
                        var serie = m_Series.GetSerie(kv.Key);
                        foreach (var dataIndex in kv.Value)
                        {
                            serie.GetSerieData(dataIndex).highlighted = false;
                        }
                    }
                    tooltip.ClearSerieDataIndex();
                    tooltip.SetActive(false);
                    foreach (var axis in m_AngleAxes)
                    {
                        axis.SetTooltipLabelActive(false);
                    }
                    foreach (var axis in m_RadiusAxes)
                    {
                        axis.SetTooltipLabelActive(false);
                    }
                    RefreshChart();
                }
                return;
            }
            var m_Polar     = GetPolar(tooltip.runtimePolarIndex);
            var m_AngleAxis = GetAngleAxis(m_Polar.index);

            tooltip.ClearSerieDataIndex();
            Vector2 dir   = local - new Vector2(m_Polar.runtimeCenterPos.x, m_Polar.runtimeCenterPos.y);
            float   angle = ChartHelper.GetAngle360(Vector2.up, dir);

            foreach (var serie in m_Series.list)
            {
                switch (serie.type)
                {
                case SerieType.Line:
                    bool refresh = false;
                    var  count   = serie.data.Count;
                    SerieHelper.UpdateMinMaxData(serie, 1, -1);
                    var diff = (serie.runtimeDataMax - serie.runtimeDataMin) / (count - 1);
                    for (int j = 0; j < count; j++)
                    {
                        var serieData = serie.data[j];
                        var flag      = Mathf.Abs(serieData.runtimeAngle - angle) < Mathf.Abs(diff / 2);
                        if (serieData.highlighted != flag)
                        {
                            refresh = true;
                        }
                        serieData.highlighted = flag;
                        if (flag)
                        {
                            tooltip.runtimeAngle = (serieData.runtimeAngle - m_AngleAxis.runtimeStartAngle + 360) % 360;
                            tooltip.AddSerieDataIndex(serie.index, j);
                        }
                    }
                    if (refresh)
                    {
                        RefreshChart();
                    }
                    break;

                case SerieType.Bar:
                    break;

                case SerieType.Scatter:
                case SerieType.EffectScatter:
                    break;
                }
            }
            tooltip.UpdateContentPos(local + tooltip.offset);
            UpdateTooltip();
            if (tooltip.type == Tooltip.Type.Corss)
            {
                RefreshChart();
            }
        }
예제 #9
0
        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();
        }