private void DrawGauge(VertexHelper vh, Serie serie)
        {
            SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight);
            var destAngle = GetCurrAngle(serie, true);

            serie.animation.InitProgress(0, serie.startAngle, destAngle);
            var currAngle = serie.animation.IsFinish() ? GetCurrAngle(serie, false) : serie.animation.GetCurrDetail();

            DrawProgressBar(vh, serie, currAngle);
            DrawStageColor(vh, serie);
            DrawLineStyle(vh, serie);
            DrawAxisTick(vh, serie);
            DrawPointer(vh, serie, currAngle);
            TitleStyleHelper.CheckTitle(serie, ref chart.m_ReinitTitle, ref m_UpdateTitleText);
            SerieLabelHelper.CheckLabel(serie, ref chart.m_ReinitLabel, ref m_UpdateLabelText);
            CheckAnimation(serie);
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(destAngle - serie.startAngle);
                chart.RefreshPainter(serie);
            }
            else if (NeedRefresh(serie))
            {
                chart.RefreshPainter(serie);
            }
        }
Exemple #2
0
 public void RefreshLabel()
 {
     for (int i = 0; i < chart.series.Count; i++)
     {
         var serie = chart.series.GetSerie(i);
         if (serie.type != SerieType.Radar)
         {
             continue;
         }
         if (!serie.show && serie.radarType != RadarType.Single)
         {
             continue;
         }
         var radar = chart.GetRadar(serie.radarIndex);
         if (radar == null)
         {
             continue;
         }
         var center = radar.runtimeCenterPos;
         for (int n = 0; n < serie.dataCount; n++)
         {
             var serieData = serie.data[n];
             if (serieData.labelObject == null)
             {
                 continue;
             }
             var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
             var iconStyle  = SerieHelper.GetIconStyle(serie, serieData);
             var labelPos   = serieData.labelPosition;
             if (serieLabel.margin != 0)
             {
                 labelPos += serieLabel.margin * (labelPos - center).normalized;
             }
             serieData.labelObject.SetPosition(labelPos);
             serieData.labelObject.UpdateIcon(iconStyle);
             if (serie.show && serieLabel.show && serieData.canShowLabel)
             {
                 var value = serieData.GetCurrData(1);
                 var max   = radar.GetIndicatorMax(n);
                 SerieLabelHelper.ResetLabel(serieData.labelObject.label, serieLabel, chart.theme, i);
                 serieData.SetLabelActive(serieData.labelPosition != Vector3.zero);
                 serieData.labelObject.SetLabelPosition(serieLabel.offset);
                 var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, max,
                                                                    serieLabel, Color.clear);
                 if (serieData.labelObject.SetText(content))
                 {
                     chart.RefreshPainter(serie);
                 }
             }
             else
             {
                 serieData.SetLabelActive(false);
             }
         }
     }
 }
        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();
        }
Exemple #4
0
        private void DrawCirleLiquid(VertexHelper vh, Serie serie, Vessel vessel)
        {
            var cenPos    = vessel.runtimeCenterPos;
            var radius    = vessel.runtimeInnerRadius;
            var serieData = serie.GetSerieData(0);

            if (serieData == null)
            {
                return;
            }
            var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
            var value = serieData.GetCurrData(1, dataChangeDuration);

            if (serie.runtimeCheckValue != value)
            {
                serie.runtimeCheckValue = value;
                m_UpdateLabelText       = true;
            }
            if (serieData.labelPosition != cenPos)
            {
                serieData.labelPosition = cenPos;
                m_UpdateLabelText       = true;
            }
            if (value <= 0)
            {
                return;
            }
            var colorIndex = chart.m_LegendRealShowName.IndexOf(serie.name);

            var realHig = (float)((value - serie.min) / (serie.max - serie.min) * radius * 2);

            serie.animation.InitProgress(1, 0, realHig);

            var hig  = serie.animation.IsFinish() ? realHig : serie.animation.GetCurrDetail();
            var a    = Mathf.Abs(radius - hig + (hig > radius ? serie.waveHeight : -serie.waveHeight));
            var diff = Mathf.Sqrt(radius * radius - Mathf.Pow(a, 2));

            var color          = SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, false);
            var toColor        = SerieHelper.GetItemToColor(serie, serieData, chart.theme, colorIndex, false);
            var isNeedGradient = !ChartHelper.IsValueEqualsColor(color, toColor);
            var isFull         = hig >= 2 * radius;

            if (hig >= 2 * radius)
            {
                hig = 2 * radius;
            }
            if (isFull && !isNeedGradient)
            {
                UGL.DrawCricle(vh, cenPos, radius, toColor, chart.settings.cicleSmoothness);
            }
            else
            {
                var startY       = cenPos.y - radius + hig;
                var waveStartPos = new Vector3(cenPos.x - diff, startY);
                var waveEndPos   = new Vector3(cenPos.x + diff, startY);
                var startX       = hig > radius ? cenPos.x - radius : waveStartPos.x;
                var endX         = hig > radius ? cenPos.x + radius : waveEndPos.x;

                var step = vessel.smoothness;
                if (step < 0.5f)
                {
                    step = 0.5f;
                }
                var lup   = hig > radius ? new Vector3(cenPos.x - radius, cenPos.y) : waveStartPos;
                var ldp   = lup;
                var nup   = Vector3.zero;
                var ndp   = Vector3.zero;
                var angle = 0f;
                serie.runtimeWaveSpeed += serie.waveSpeed * Time.deltaTime;
                var isStarted  = false;
                var isEnded    = false;
                var waveHeight = isFull ? 0 : serie.waveHeight;
                while (startX < endX)
                {
                    startX += step;
                    if (startX > endX)
                    {
                        startX = endX;
                    }
                    if (startX > waveStartPos.x && !isStarted)
                    {
                        startX    = waveStartPos.x;
                        isStarted = true;
                    }
                    if (startX > waveEndPos.x && !isEnded)
                    {
                        startX  = waveEndPos.x;
                        isEnded = true;
                    }
                    var py = Mathf.Sqrt(Mathf.Pow(radius, 2) - Mathf.Pow(Mathf.Abs(cenPos.x - startX), 2));
                    if (startX < waveStartPos.x || startX > waveEndPos.x)
                    {
                        nup = new Vector3(startX, cenPos.y + py);
                    }
                    else
                    {
                        var py2  = waveHeight * Mathf.Sin(1 / serie.waveLength * angle + serie.runtimeWaveSpeed + serie.waveOffset);
                        var nupY = waveStartPos.y + py2;
                        if (nupY > cenPos.y + py)
                        {
                            nupY = cenPos.y + py;
                        }
                        else if (nupY < cenPos.y - py)
                        {
                            nupY = cenPos.y - py;
                        }
                        nup    = new Vector3(startX, nupY);
                        angle += step;
                    }
                    ndp = new Vector3(startX, cenPos.y - py);
                    if (!ChartHelper.IsValueEqualsColor(color, toColor))
                    {
                        var colorMin = cenPos.y - radius;
                        var colorMax = startY + serie.waveHeight;
                        var tcolor1  = Color32.Lerp(color, toColor, 1 - (lup.y - colorMin) / (colorMax - colorMin));
                        var tcolor2  = Color32.Lerp(color, toColor, 1 - (ldp.y - colorMin) / (colorMax - colorMin));
                        UGL.DrawQuadrilateral(vh, lup, nup, ndp, ldp, tcolor1, tcolor2);
                    }
                    else
                    {
                        UGL.DrawQuadrilateral(vh, lup, nup, ndp, ldp, color);
                    }
                    lup = nup;
                    ldp = ndp;
                }
            }

            if (serie.waveSpeed != 0 && Application.isPlaying && !isFull)
            {
                chart.RefreshPainter(serie);
            }
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(realHig);
                chart.m_IsPlayingAnimation = true;
                chart.RefreshPainter(serie);
            }
        }