private void DrawNormalBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
                                   bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
                                   Vector3 prb, bool isYAxis)
        {
            Color areaColor   = SerieHelper.GetItemColor(serie, serieData, m_ThemeInfo, colorIndex, highlight);
            Color areaToColor = SerieHelper.GetItemToColor(serie, serieData, m_ThemeInfo, colorIndex, highlight);

            DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis);
            var borderWidth = itemStyle.runtimeBorderWidth;

            if (isYAxis)
            {
                CheckClipAndDrawPolygon(vh, plb, plt, prt, prb, areaColor, areaToColor, serie.clip);
                if (borderWidth > 0)
                {
                    var borderColor = itemStyle.borderColor;
                    var itemWidth   = Mathf.Abs(prb.x - plt.x);
                    var itemHeight  = Mathf.Abs(prt.y - plb.y);
                    var center      = new Vector3((plt.x + prb.x) / 2, (prt.y + plb.y) / 2);
                    ChartDrawer.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, borderColor);
                }
            }
            else
            {
                CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, areaColor, areaToColor, serie.clip);
                if (borderWidth > 0)
                {
                    var borderColor = itemStyle.borderColor;
                    var itemWidth   = Mathf.Abs(prt.x - plb.x);
                    var itemHeight  = Mathf.Abs(plt.y - prb.y);
                    var center      = new Vector3((plb.x + prt.x) / 2, (plt.y + prb.y) / 2);
                    ChartDrawer.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, borderColor);
                }
            }
        }
Пример #2
0
 private void DrawRadarSymbol(VertexHelper vh, Serie serie, SerieData serieData, int serieIndex, bool isHighlight,
                              List <Vector3> pointList)
 {
     if (serie.symbol.type != SerieSymbolType.None)
     {
         var symbolSize    = (isHighlight ? serie.symbol.selectedSize : serie.symbol.size);
         var symbolColor   = SerieHelper.GetItemColor(serie, serieData, m_ThemeInfo, serieIndex, isHighlight);
         var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, m_ThemeInfo, serieIndex, isHighlight);
         var symbolBorder  = SerieHelper.GetSymbolBorder(serie, serieData, isHighlight);
         foreach (var point in pointList)
         {
             DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, point, symbolColor,
                        symbolToColor, serie.symbol.gap);
         }
     }
 }
Пример #3
0
 private void DrawRadarSymbol(VertexHelper vh, Serie serie, SerieData serieData, int serieIndex, bool isHighlight,
                              List <Vector3> pointList)
 {
     if (serie.symbol.show && serie.symbol.type != SerieSymbolType.None)
     {
         var symbolSize = isHighlight
             ? serie.symbol.GetSelectedSize(serieData.data, chart.theme.serie.lineSymbolSelectedSize)
             : serie.symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
         var symbolColor   = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieIndex, isHighlight);
         var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieIndex, isHighlight);
         var symbolBorder  = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight);
         var cornerRadius  = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
         foreach (var point in pointList)
         {
             chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, point, symbolColor,
                              symbolToColor, serie.symbol.gap, cornerRadius);
         }
     }
 }
Пример #4
0
 private void DrawPolarLineSymbol(VertexHelper vh)
 {
     for (int n = 0; n < m_Series.Count; n++)
     {
         var serie = m_Series.GetSerie(n);
         if (!serie.show)
         {
             continue;
         }
         if (serie.type != SerieType.Line)
         {
             continue;
         }
         var count = serie.dataCount;
         for (int i = 0; i < count; i++)
         {
             var serieData = serie.GetSerieData(i);
             var symbol    = SerieHelper.GetSerieSymbol(serie, serieData);
             if (ChartHelper.IsIngore(serieData.runtimePosition))
             {
                 continue;
             }
             bool highlight = serieData.highlighted || serie.highlighted;
             if ((!symbol.show || !symbol.ShowSymbol(i, count) || serie.IsPerformanceMode()) && !serieData.highlighted)
             {
                 continue;
             }
             float symbolSize = highlight
                 ? symbol.GetSelectedSize(serieData.data, m_Theme.serie.lineSymbolSize)
                 : symbol.GetSize(serieData.data, m_Theme.serie.lineSymbolSize);
             var symbolColor   = SerieHelper.GetItemColor(serie, serieData, m_Theme, n, highlight);
             var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, m_Theme, n, highlight);
             var symbolBorder  = SerieHelper.GetSymbolBorder(serie, serieData, m_Theme, highlight);
             var cornerRadius  = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
             symbolSize = serie.animation.GetSysmbolSize(symbolSize);
             DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, serieData.runtimePosition, symbolColor,
                        symbolToColor, symbol.gap, cornerRadius);
         }
     }
 }
        private void DrawZebraBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
                                  bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
                                  Vector3 prb, bool isYAxis, Grid grid)
        {
            var barColor   = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight);
            var barToColor = SerieHelper.GetItemToColor(serie, serieData, m_Theme, colorIndex, highlight);

            DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid);
            if (isYAxis)
            {
                plt = (plb + plt) / 2;
                prt = (prt + prb) / 2;
                Internal_CheckClipAndDrawZebraLine(vh, plt, prt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap,
                                                   barColor, barToColor, serie.clip, grid);
            }
            else
            {
                plb = (prb + plb) / 2;
                plt = (plt + prt) / 2;
                Internal_CheckClipAndDrawZebraLine(vh, plb, plt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap,
                                                   barColor, barToColor, serie.clip, grid);
            }
        }
        private void DrawCapsuleBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
                                    bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
                                    Vector3 prb, bool isYAxis)
        {
            Color areaColor   = SerieHelper.GetItemColor(serie, serieData, m_ThemeInfo, colorIndex, highlight);
            Color areaToColor = SerieHelper.GetItemToColor(serie, serieData, m_ThemeInfo, colorIndex, highlight);

            DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis);
            var borderWidth = itemStyle.runtimeBorderWidth;
            var radius      = barWidth / 2 - borderWidth;

            if (isYAxis)
            {
                var diff = Vector3.right * radius;
                var pcl  = (plt + plb) / 2 + diff;
                var pcr  = (prt + prb) / 2 - diff;
                if (pcr.x > pcl.x)
                {
                    CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, areaColor, areaToColor, serie.clip);
                    ChartDrawer.DrawSector(vh, pcl, radius, areaColor, 180, 360);
                    ChartDrawer.DrawSector(vh, pcr, radius, areaToColor, 0, 180);
                }
            }
            else
            {
                var diff = Vector3.up * radius;
                var pct  = (plt + prt) / 2 - diff;
                var pcb  = (plb + prb) / 2 + diff;
                if (pct.y > pcb.y)
                {
                    CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, areaColor, areaToColor, serie.clip);
                    ChartDrawer.DrawSector(vh, pct, radius, areaToColor, 270, 450);
                    ChartDrawer.DrawSector(vh, pcb, radius, areaColor, 90, 270);
                }
            }
        }
        private void DrawCapsuleBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
                                    bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
                                    Vector3 prb, bool isYAxis, Grid grid)
        {
            var areaColor   = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight);
            var areaToColor = SerieHelper.GetItemToColor(serie, serieData, m_Theme, colorIndex, highlight);

            DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid);
            var borderWidth = itemStyle.runtimeBorderWidth;
            var radius      = barWidth / 2 - borderWidth;
            var isGradient  = !ChartHelper.IsValueEqualsColor(areaColor, areaToColor);

            if (isYAxis)
            {
                var diff = Vector3.right * radius;
                if (plt.x < prt.x)
                {
                    var pcl = (plt + plb) / 2 + diff;
                    var pcr = (prt + prb) / 2 - diff;
                    if (pcr.x > pcl.x)
                    {
                        if (isGradient)
                        {
                            var barLen         = prt.x - plt.x;
                            var rectStartColor = Color32.Lerp(areaColor, areaToColor, radius / barLen);
                            var rectEndColor   = Color32.Lerp(areaColor, areaToColor, (barLen - radius) / barLen);
                            Internal_CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, rectStartColor,
                                                             rectEndColor, serie.clip, grid);
                            UGL.DrawSector(vh, pcl, radius, areaColor, rectStartColor, 180, 360, 1, isYAxis);
                            UGL.DrawSector(vh, pcr, radius, rectEndColor, areaToColor, 0, 180, 1, isYAxis);
                        }
                        else
                        {
                            Internal_CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, areaColor,
                                                             areaToColor, serie.clip, grid);
                            UGL.DrawSector(vh, pcl, radius, areaColor, 180, 360);
                            UGL.DrawSector(vh, pcr, radius, areaToColor, 0, 180);
                        }
                    }
                }
                else if (plt.x > prt.x)
                {
                    var pcl = (plt + plb) / 2 - diff;
                    var pcr = (prt + prb) / 2 + diff;
                    if (pcr.x < pcl.x)
                    {
                        if (isGradient)
                        {
                            var barLen         = plt.x - prt.x;
                            var rectStartColor = Color32.Lerp(areaColor, areaToColor, radius / barLen);
                            var rectEndColor   = Color32.Lerp(areaColor, areaToColor, (barLen - radius) / barLen);
                            Internal_CheckClipAndDrawPolygon(vh, plb - diff, plt - diff, prt + diff, prb + diff, rectStartColor,
                                                             rectEndColor, serie.clip, grid);
                            UGL.DrawSector(vh, pcl, radius, rectStartColor, areaColor, 0, 180, 1, isYAxis);
                            UGL.DrawSector(vh, pcr, radius, areaToColor, rectEndColor, 180, 360, 1, isYAxis);
                        }
                        else
                        {
                            Internal_CheckClipAndDrawPolygon(vh, plb - diff, plt - diff, prt + diff, prb + diff, areaColor,
                                                             areaToColor, serie.clip, grid);
                            UGL.DrawSector(vh, pcl, radius, areaColor, 0, 180);
                            UGL.DrawSector(vh, pcr, radius, areaToColor, 180, 360);
                        }
                    }
                }
            }
            else
            {
                var diff = Vector3.up * radius;
                if (plt.y > plb.y)
                {
                    var pct = (plt + prt) / 2 - diff;
                    var pcb = (plb + prb) / 2 + diff;
                    if (pct.y > pcb.y)
                    {
                        if (isGradient)
                        {
                            var barLen         = plt.y - plb.y;
                            var rectStartColor = Color32.Lerp(areaColor, areaToColor, radius / barLen);
                            var rectEndColor   = Color32.Lerp(areaColor, areaToColor, (barLen - radius) / barLen);
                            Internal_CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, rectStartColor,
                                                             rectEndColor, serie.clip, grid);
                            UGL.DrawSector(vh, pct, radius, rectEndColor, areaToColor, 270, 450, 1, isYAxis);
                            UGL.DrawSector(vh, pcb, radius, rectStartColor, areaColor, 90, 270, 1, isYAxis);
                        }
                        else
                        {
                            Internal_CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, areaColor,
                                                             areaToColor, serie.clip, grid);
                            UGL.DrawSector(vh, pct, radius, areaToColor, 270, 450);
                            UGL.DrawSector(vh, pcb, radius, areaColor, 90, 270);
                        }
                    }
                }
                else if (plt.y < plb.y)
                {
                    var pct = (plt + prt) / 2 + diff;
                    var pcb = (plb + prb) / 2 - diff;
                    if (pct.y < pcb.y)
                    {
                        if (isGradient)
                        {
                            var barLen         = plb.y - plt.y;
                            var rectStartColor = Color32.Lerp(areaColor, areaToColor, radius / barLen);
                            var rectEndColor   = Color32.Lerp(areaColor, areaToColor, (barLen - radius) / barLen);
                            Internal_CheckClipAndDrawPolygon(vh, prb - diff, plb - diff, plt + diff, prt + diff, rectStartColor,
                                                             rectEndColor, serie.clip, grid);
                            UGL.DrawSector(vh, pct, radius, rectEndColor, areaToColor, 90, 270, 1, isYAxis);
                            UGL.DrawSector(vh, pcb, radius, rectStartColor, areaColor, 270, 450, 1, isYAxis);
                        }
                        else
                        {
                            Internal_CheckClipAndDrawPolygon(vh, prb - diff, plb - diff, plt + diff, prt + diff, areaColor,
                                                             areaToColor, serie.clip, grid);
                            UGL.DrawSector(vh, pct, radius, areaToColor, 90, 270);
                            UGL.DrawSector(vh, pcb, radius, areaColor, 270, 450);
                        }
                    }
                }
            }
        }
        private void DrawNormalBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
                                   bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
                                   Vector3 prb, bool isYAxis, Grid grid)
        {
            var areaColor   = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight);
            var areaToColor = SerieHelper.GetItemToColor(serie, serieData, m_Theme, colorIndex, highlight);

            DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid);
            var borderWidth = itemStyle.runtimeBorderWidth;

            if (isYAxis)
            {
                if (serie.clip)
                {
                    prb = ClampInGrid(grid, prb);
                    plb = ClampInGrid(grid, plb);
                    plt = ClampInGrid(grid, plt);
                    prt = ClampInGrid(grid, prt);
                }
                var itemWidth  = Mathf.Abs(prb.x - plt.x);
                var itemHeight = Mathf.Abs(prt.y - plb.y);
                var center     = new Vector3((plt.x + prb.x) / 2, (prt.y + plb.y) / 2);
                if (itemWidth > 0 && itemHeight > 0)
                {
                    if (ItemStyleHelper.IsNeedCorner(itemStyle))
                    {
                        UGL.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, areaToColor, 0,
                                               itemStyle.cornerRadius, isYAxis);
                    }
                    else
                    {
                        Internal_CheckClipAndDrawPolygon(vh, plb, plt, prt, prb, areaColor, areaToColor, serie.clip, grid);
                    }
                    UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, itemStyle.borderColor,
                                   itemStyle.borderToColor, 0, itemStyle.cornerRadius, isYAxis);
                }
            }
            else
            {
                if (serie.clip)
                {
                    prb = ClampInGrid(grid, prb);
                    plb = ClampInGrid(grid, plb);
                    plt = ClampInGrid(grid, plt);
                    prt = ClampInGrid(grid, prt);
                }
                var itemWidth  = Mathf.Abs(prt.x - plb.x);
                var itemHeight = Mathf.Abs(plt.y - prb.y);
                var center     = new Vector3((plb.x + prt.x) / 2, (plt.y + prb.y) / 2);
                if (itemWidth > 0 && itemHeight > 0)
                {
                    if (ItemStyleHelper.IsNeedCorner(itemStyle))
                    {
                        UGL.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, areaToColor, 0,
                                               itemStyle.cornerRadius, isYAxis);
                    }
                    else
                    {
                        Internal_CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, areaColor, areaToColor,
                                                         serie.clip, grid);
                    }
                    UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, itemStyle.borderColor,
                                   itemStyle.borderToColor, 0, itemStyle.cornerRadius, isYAxis);
                }
            }
        }
Пример #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();
        }
Пример #10
0
        private void DrawSingleRadar(VertexHelper vh, Serie serie, int i)
        {
            var startPoint = Vector3.zero;
            var toPoint    = Vector3.zero;
            var firstPoint = Vector3.zero;

            var radar          = m_Radars[serie.radarIndex];
            var indicatorNum   = radar.indicatorList.Count;
            var angle          = 2 * Mathf.PI / indicatorNum;
            var centerPos      = radar.runtimeCenterPos;
            var serieNameCount = -1;

            serie.animation.InitProgress(1, 0, 1);
            if (!IsActive(i) || serie.animation.HasFadeOut())
            {
                return;
            }
            var rate               = serie.animation.GetCurrRate();
            var dataChanging       = false;
            var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
            int key = i * 1000;

            if (!radar.runtimeDataPosList.ContainsKey(key))
            {
                radar.runtimeDataPosList.Add(i * 1000, new List <Vector3>(serie.dataCount));
            }
            else
            {
                radar.runtimeDataPosList[key].Clear();
            }
            var pointList  = radar.runtimeDataPosList[key];
            var startIndex = GetStartShowIndex(serie);
            var endIndex   = GetEndShowIndex(serie);

            SerieHelper.GetDimensionMinMaxData(serie, 1, radar.ceilRate);
            for (int j = 0; j < serie.data.Count; j++)
            {
                var serieData = serie.data[j];
                serieData.index = j;
                string dataName   = serieData.name;
                int    serieIndex = 0;
                if (string.IsNullOrEmpty(dataName))
                {
                    serieNameCount++;
                    serieIndex = serieNameCount;
                }
                else if (!serieNameSet.ContainsKey(dataName))
                {
                    serieNameSet.Add(dataName, serieNameCount);
                    serieNameCount++;
                    serieIndex = serieNameCount;
                }
                else
                {
                    serieIndex = serieNameSet[dataName];
                }
                if (!serieData.show)
                {
                    serieData.labelPosition = Vector3.zero;
                    continue;
                }
                var isHighlight = serie.highlighted || serieData.highlighted ||
                                  (m_Tooltip.show && m_Tooltip.runtimeDataIndex[0] == i && m_Tooltip.runtimeDataIndex[1] == j);
                var areaColor   = SerieHelper.GetAreaColor(serie, m_ThemeInfo, serieIndex, isHighlight);
                var areaToColor = SerieHelper.GetAreaToColor(serie, m_ThemeInfo, serieIndex, isHighlight);
                var lineColor   = SerieHelper.GetLineColor(serie, m_ThemeInfo, serieIndex, isHighlight);
                int dataCount   = radar.indicatorList.Count;
                var index       = serieData.index;
                var p           = radar.runtimeCenterPos;
                var max         = radar.GetIndicatorMax(index);
                var value       = serieData.GetCurrData(1, dataChangeDuration);
                if (serieData.IsDataChanged())
                {
                    dataChanging = true;
                }
                if (max == 0)
                {
                    max = serie.runtimeDataMax;
                }
                var radius = max < 0 ? radar.runtimeDataRadius - radar.runtimeDataRadius * value / max
                : radar.runtimeDataRadius * value / max;
                var currAngle = (index + (radar.positionType == Radar.PositionType.Between ? 0.5f : 0)) * angle;
                radius *= rate;
                if (index == startIndex)
                {
                    startPoint = new Vector3(p.x + radius * Mathf.Sin(currAngle),
                                             p.y + radius * Mathf.Cos(currAngle));
                    firstPoint = startPoint;
                }
                else
                {
                    toPoint = new Vector3(p.x + radius * Mathf.Sin(currAngle),
                                          p.y + radius * Mathf.Cos(currAngle));
                    if (serie.areaStyle.show)
                    {
                        ChartDrawer.DrawTriangle(vh, startPoint, toPoint, p, areaColor, areaColor, areaToColor);
                    }
                    if (serie.lineStyle.show)
                    {
                        ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, toPoint, lineColor);
                    }
                    startPoint = toPoint;
                }
                serieData.labelPosition = startPoint;
                pointList.Add(startPoint);

                if (serie.areaStyle.show && j == endIndex)
                {
                    ChartDrawer.DrawTriangle(vh, startPoint, firstPoint, centerPos, areaColor, areaColor, areaToColor);
                }
                if (serie.lineStyle.show && j == endIndex)
                {
                    ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, firstPoint, lineColor);
                }
            }
            if (serie.symbol.show && serie.symbol.type != SerieSymbolType.None)
            {
                for (int j = 0; j < serie.data.Count; j++)
                {
                    var serieData = serie.data[j];
                    if (!serieData.show)
                    {
                        continue;
                    }
                    var isHighlight = serie.highlighted || serieData.highlighted ||
                                      (m_Tooltip.show && m_Tooltip.runtimeDataIndex[0] == i && m_Tooltip.runtimeDataIndex[1] == j);
                    var serieIndex    = serieData.index;
                    var symbolSize    = (isHighlight ? serie.symbol.selectedSize : serie.symbol.size);
                    var symbolColor   = SerieHelper.GetItemColor(serie, serieData, m_ThemeInfo, serieIndex, isHighlight);
                    var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, m_ThemeInfo, serieIndex, isHighlight);
                    var symbolBorder  = SerieHelper.GetSymbolBorder(serie, serieData, isHighlight);
                    var cornerRadius  = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
                    DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, serieData.labelPosition, symbolColor,
                               symbolToColor, serie.symbol.gap, cornerRadius);
                }
            }
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(1);
                RefreshChart();
            }
            if (dataChanging)
            {
                RefreshChart();
            }
        }
Пример #11
0
        protected void DrawScatterSerie(VertexHelper vh, int colorIndex, Serie serie)
        {
            if (serie.animation.HasFadeOut())
            {
                return;
            }
            if (!serie.show)
            {
                return;
            }
            var yAxis    = m_YAxes[serie.yAxisIndex];
            var xAxis    = m_XAxes[serie.xAxisIndex];
            var grid     = GetSerieGridOrDefault(serie);
            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;
            var dataList           = serie.GetDataList(dataZoom);

            foreach (var serieData in dataList)
            {
                var symbol = SerieHelper.GetSerieSymbol(serie, serieData);
                if (!symbol.ShowSymbol(serieData.index, maxCount))
                {
                    continue;
                }
                var   highlight    = serie.highlighted || serieData.highlighted;
                var   color        = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight);
                var   toColor      = SerieHelper.GetItemToColor(serie, serieData, m_Theme, colorIndex, highlight);
                var   symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, m_Theme, 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       = grid.runtimeX + xAxis.axisLine.GetWidth(m_Theme.axis.lineWidth);
                float pY       = grid.runtimeY + yAxis.axisLine.GetWidth(m_Theme.axis.lineWidth);
                float xDataHig = GetDataHig(xAxis, xValue, grid.runtimeWidth);
                float yDataHig = GetDataHig(yAxis, yValue, grid.runtimeHeight);
                var   pos      = new Vector3(pX + xDataHig, pY + yDataHig);
                if (!IsInGrid(grid, pos))
                {
                    continue;
                }
                serie.dataPoints.Add(pos);
                serieData.runtimePosition = pos;
                var   datas      = serieData.data;
                float symbolSize = 0;
                if (serie.highlighted || serieData.highlighted)
                {
                    symbolSize = symbol.GetSelectedSize(datas, m_Theme.serie.scatterSymbolSelectedSize);
                }
                else
                {
                    symbolSize = symbol.GetSize(datas, m_Theme.serie.scatterSymbolSize);
                }
                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 = (byte)(255 * (symbolSize - nowSize) / symbolSize);
                        DrawSymbol(vh, symbol.type, nowSize, symbolBorder, pos, color, toColor, symbol.gap, cornerRadius);
                    }
                    RefreshPainter(serie);
                }
                else
                {
                    DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos, color, toColor, symbol.gap, cornerRadius);
                }
            }
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(1);
                m_IsPlayingAnimation = true;
                RefreshPainter(serie);
            }
            if (dataChanging)
            {
                RefreshPainter(serie);
            }
        }
Пример #12
0
        private void DrawSerie(VertexHelper vh, Serie serie)
        {
            var vessel = GetVessel(serie.vesselIndex);

            if (vessel == null)
            {
                return;
            }
            var cenPos    = vessel.runtimeCenterPos;
            var radius    = vessel.runtimeInnerRadius;
            var serieData = serie.GetSerieData(0);

            if (serieData == null)
            {
                return;
            }

            var value = serieData.GetData(1);

            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 = m_LegendRealShowName.IndexOf(serie.name);

            var realHig = (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, m_ThemeInfo, colorIndex, false);
            var toColor = SerieHelper.GetItemToColor(serie, serieData, m_ThemeInfo, colorIndex, false);

            if (hig >= 2 * radius)
            {
                ChartDrawer.DrawCricle(vh, cenPos, radius, toColor, m_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;
                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  = serie.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  = Color.Lerp(color, toColor, 1 - (lup.y - colorMin) / (colorMax - colorMin));
                        var tcolor2  = Color.Lerp(color, toColor, 1 - (ldp.y - colorMin) / (colorMax - colorMin));
                        ChartDrawer.DrawPolygon(vh, lup, nup, ndp, ldp, tcolor1, tcolor2);
                    }
                    else
                    {
                        ChartDrawer.DrawPolygon(vh, lup, nup, ndp, ldp, color);
                    }
                    lup = nup;
                    ldp = ndp;
                }
            }

            if (serie.waveSpeed != 0 && Application.isPlaying)
            {
                RefreshChart();
            }
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(realHig);
                m_IsPlayingAnimation = true;
                RefreshChart();
            }
        }
Пример #13
0
        protected void DrawXBarSerie(VertexHelper vh, Serie serie, int colorIndex, ref List <float> seriesHig)
        {
            if (!IsActive(serie.name))
            {
                return;
            }
            if (serie.animation.HasFadeOut())
            {
                return;
            }
            var showData = serie.GetDataList(m_DataZoom);
            var yAxis    = m_YAxises[serie.axisIndex];
            var xAxis    = m_XAxises[serie.axisIndex];

            if (!xAxis.show)
            {
                xAxis = m_XAxises[(serie.axisIndex + 1) % m_XAxises.Count];
            }

            float categoryWidth = xAxis.GetDataWidth(coordinateWidth, showData.Count, m_DataZoom);
            float barGap        = GetBarGap();
            float totalBarWidth = GetBarTotalWidth(categoryWidth, barGap);
            float barWidth      = serie.GetBarWidth(categoryWidth);
            float offset        = (categoryWidth - totalBarWidth) / 2;
            float barGapWidth   = barWidth + barWidth * barGap;
            float space         = serie.barGap == -1 ? offset : offset + m_BarLastOffset;
            int   maxCount      = serie.maxShow > 0 ?
                                  (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
                : showData.Count;

            if (seriesHig.Count < serie.minShow)
            {
                for (int i = 0; i < serie.minShow; i++)
                {
                    seriesHig.Add(0);
                }
            }

            var   isPercentStack     = m_Series.IsPercentStack(serie.stack, SerieType.Bar);
            bool  dataChanging       = false;
            float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
            float yMinValue          = yAxis.GetCurrMinValue(dataChangeDuration);
            float yMaxValue          = yAxis.GetCurrMaxValue(dataChangeDuration);

            for (int i = serie.minShow; i < maxCount; i++)
            {
                if (i >= seriesHig.Count)
                {
                    seriesHig.Add(0);
                }
                var serieData = showData[i];
                if (serie.IsIgnoreValue(serieData.GetData(1)))
                {
                    serie.dataPoints.Add(Vector3.zero);
                    continue;
                }
                var highlight = (m_Tooltip.show && m_Tooltip.IsSelected(i)) ||
                                serie.data[i].highlighted ||
                                serie.highlighted;
                var   itemStyle   = SerieHelper.GetItemStyle(serie, serieData, highlight);
                var   borderWidth = itemStyle.runtimeBorderWidth;
                float value       = serieData.GetCurrData(1, dataChangeDuration);
                if (serieData.IsDataChanged())
                {
                    dataChanging = true;
                }
                float pX    = coordinateX + i * categoryWidth;
                float zeroY = coordinateY + yAxis.runtimeZeroYOffset;
                if (!xAxis.boundaryGap)
                {
                    pX -= categoryWidth / 2;
                }
                float pY = seriesHig[i] + zeroY + xAxis.axisLine.width;

                var barHig     = 0f;
                var valueTotal = 0f;
                if (isPercentStack)
                {
                    valueTotal    = GetSameStackTotalValue(serie.stack, i);
                    barHig        = valueTotal != 0 ? (value / valueTotal * coordinateHeight) : 0;
                    seriesHig[i] += barHig;
                }
                else
                {
                    valueTotal = yMaxValue - yMinValue;
                    if (valueTotal != 0)
                    {
                        barHig = (yMinValue > 0 ? value - yMinValue : value)
                                 / valueTotal * coordinateHeight;
                    }
                    seriesHig[i] += barHig;
                }

                float   currHig = CheckAnimation(serie, i, barHig);
                Vector3 p1      = new Vector3(pX + space + borderWidth, pY + borderWidth);
                Vector3 p2      = new Vector3(pX + space + borderWidth, pY + currHig - 2 * borderWidth);
                Vector3 p3      = new Vector3(pX + space + barWidth, pY + currHig - 2 * borderWidth);
                Vector3 p4      = new Vector3(pX + space + barWidth, pY + borderWidth);
                Vector3 top     = new Vector3(pX + space + barWidth / 2, pY + currHig - borderWidth);
                p1  = ClampInCoordinate(p1);
                p2  = ClampInCoordinate(p2);
                p3  = ClampInCoordinate(p3);
                p4  = ClampInCoordinate(p4);
                top = ClampInCoordinate(top);
                serie.dataPoints.Add(top);

                if (serie.show)
                {
                    Color areaColor   = SerieHelper.GetItemColor(serie, serieData, m_ThemeInfo, colorIndex, highlight);
                    Color areaToColor = SerieHelper.GetItemToColor(serie, serieData, m_ThemeInfo, colorIndex, highlight);
                    DrawBarBackground(vh, serie, serieData, colorIndex, highlight, pX, pY, space, barWidth, false);
                    if (serie.barType == BarType.Zebra)
                    {
                        p1 = (p4 + p1) / 2;
                        p2 = (p2 + p3) / 2;
                        CheckClipAndDrawZebraLine(vh, p1, p2, barWidth / 2, serie.barZebraWidth, serie.barZebraGap,
                                                  areaColor, serie.clip);
                    }
                    else
                    {
                        CheckClipAndDrawPolygon(vh, ref p4, ref p1, ref p2, ref p3, areaColor, areaToColor, serie.clip);
                        if (borderWidth > 0)
                        {
                            var borderColor = itemStyle.borderColor;
                            var itemWidth   = Mathf.Abs(p3.x - p1.x);
                            var itemHeight  = Mathf.Abs(p2.y - p4.y);
                            var center      = new Vector3((p1.x + p3.x) / 2, (p2.y + p4.y) / 2);
                            ChartDrawer.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, borderColor);
                        }
                    }
                }
            }
            if (dataChanging)
            {
                RefreshChart();
            }
            if (!m_Series.IsStack(serie.stack, SerieType.Bar))
            {
                m_BarLastOffset += barGapWidth;
            }
        }
        protected void DrawScatterSerie(VertexHelper vh, int colorIndex, Serie serie)
        {
            if (serie.animation.HasFadeOut())
            {
                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   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);
                float yValue       = serieData.GetCurrData(1, dataChangeDuration);
                if (serieData.IsDataChanged())
                {
                    dataChanging = true;
                }
                float pX       = coordinateX + xAxis.axisLine.width;
                float pY       = coordinateY + yAxis.axisLine.width;
                float xDataHig = (xValue - xAxis.runtimeMinValue) / (xAxis.runtimeMaxValue - xAxis.runtimeMinValue) * coordinateWidth;
                float yDataHig = (yValue - yAxis.runtimeMinValue) / (yAxis.runtimeMaxValue - yAxis.runtimeMinValue) * coordinateHeight;
                var   pos      = new Vector3(pX + xDataHig, pY + yDataHig);
                serie.dataPoints.Add(pos);
                var   datas      = serie.data[n].data;
                float symbolSize = 0;
                if (serie.highlighted || serieData.highlighted)
                {
                    symbolSize = serie.symbol.GetSelectedSize(datas);
                }
                else
                {
                    symbolSize = serie.symbol.GetSize(datas);
                }
                symbolSize *= rate;
                if (symbolSize > 100)
                {
                    symbolSize = 100;
                }
                if (serie.type == SerieType.EffectScatter)
                {
                    for (int count = 0; count < serie.symbol.animationSize.Count; count++)
                    {
                        var nowSize = serie.symbol.animationSize[count];
                        color.a = (symbolSize - nowSize) / symbolSize;
                        DrawSymbol(vh, serie.symbol.type, nowSize, symbolBorder, pos, color, toColor, serie.symbol.gap, cornerRadius);
                    }
                    RefreshChart();
                }
                else
                {
                    DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, pos, color, toColor, serie.symbol.gap, cornerRadius);
                }
            }
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(1);
                m_IsPlayingAnimation = true;
                RefreshChart();
            }
            if (dataChanging)
            {
                RefreshChart();
            }
        }
Пример #15
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;
        }
Пример #16
0
        public void DrawSerie(VertexHelper vh, Serie serie)
        {
            if (serie.type != SerieType.Ring)
            {
                return;
            }
            if (!serie.show || serie.animation.HasFadeOut())
            {
                return;
            }
            var data = serie.data;

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

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

                serieData.runtimePieStartAngle    = serie.clockwise ? startDegree : toDegree;
                serieData.runtimePieToAngle       = serie.clockwise ? toDegree : startDegree;
                serieData.runtimePieInsideRadius  = insideRadius;
                serieData.runtimePieOutsideRadius = outsideRadius;
                UGL.DrawDoughnut(vh, serie.runtimeCenterPos, insideRadius, outsideRadius, itemColor, itemToColor,
                                 Color.clear, startDegree, toDegree, borderWidth, borderColor, 0, chart.settings.cicleSmoothness,
                                 roundCap, serie.clockwise);
                DrawCenter(vh, serie, serieData, insideRadius, j == data.Count - 1);
                UpateLabelPosition(serie, serieData, j, startDegree, toDegree, centerRadius);
            }
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(360);
                chart.RefreshChart();
            }
            if (dataChanging)
            {
                chart.RefreshChart();
            }
        }
Пример #17
0
        private void DrawRectLiquid(VertexHelper vh, Serie serie, Vessel vessel)
        {
            var cenPos    = vessel.runtimeCenterPos;
            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 = (value - serie.min) / (serie.max - serie.min) * vessel.runtimeHeight;

            serie.animation.InitProgress(1, 0, (float)realHig);
            var hig            = serie.animation.IsFinish() ? realHig : serie.animation.GetCurrDetail();
            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 >= vessel.runtimeHeight;

            if (hig >= vessel.runtimeHeight)
            {
                hig = vessel.runtimeHeight;
            }
            if (isFull && !isNeedGradient)
            {
                UGL.DrawRectangle(vh, cenPos, vessel.runtimeWidth / 2, vessel.runtimeHeight / 2, toColor);
            }
            else
            {
                var startY       = (float)(cenPos.y - vessel.runtimeHeight / 2 + hig);
                var waveStartPos = new Vector3(cenPos.x - vessel.runtimeWidth / 2, startY);
                var waveEndPos   = new Vector3(cenPos.x + vessel.runtimeWidth / 2, startY);
                var startX       = waveStartPos.x;
                var endX         = waveEndPos.x;

                var step = vessel.smoothness;
                if (step < 0.5f)
                {
                    step = 0.5f;
                }
                var lup        = waveStartPos;
                var ldp        = new Vector3(startX, vessel.runtimeCenterPos.y - vessel.runtimeHeight / 2);
                var nup        = Vector3.zero;
                var ndp        = Vector3.zero;
                var angle      = 0f;
                var isStarted  = false;
                var isEnded    = false;
                var waveHeight = isFull ? 0 : serie.waveHeight;
                serie.runtimeWaveSpeed += serie.waveSpeed * Time.deltaTime;
                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(vessel.runtimeHeight, 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;
                        nup    = new Vector3(startX, nupY);
                        angle += step;
                    }

                    ndp = new Vector3(startX, cenPos.y - vessel.runtimeHeight / 2);
                    if (nup.y > cenPos.y + vessel.runtimeHeight / 2)
                    {
                        nup.y = cenPos.y + vessel.runtimeHeight / 2;
                    }
                    if (nup.y < cenPos.y - vessel.runtimeHeight / 2)
                    {
                        nup.y = cenPos.y - vessel.runtimeHeight / 2;
                    }
                    if (!ChartHelper.IsValueEqualsColor(color, toColor))
                    {
                        var colorMin = cenPos.y - vessel.runtimeHeight;
                        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);
            }
        }
Пример #18
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;
        }
Пример #19
0
        private void DrawMutipleRadar(VertexHelper vh, Serie serie, int i)
        {
            var startPoint = Vector3.zero;
            var toPoint    = Vector3.zero;
            var firstPoint = Vector3.zero;

            var radar          = m_Radars[serie.radarIndex];
            var indicatorNum   = radar.indicatorList.Count;
            var angle          = 2 * Mathf.PI / indicatorNum;
            var centerPos      = radar.runtimeCenterPos;
            var serieNameCount = -1;

            serie.animation.InitProgress(1, 0, 1);
            if (!IsActive(i) || serie.animation.HasFadeOut())
            {
                return;
            }
            var rate               = serie.animation.GetCurrRate();
            var dataChanging       = false;
            var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();

            SerieHelper.GetAllMinMaxData(serie, radar.ceilRate);
            for (int j = 0; j < serie.data.Count; j++)
            {
                var serieData = serie.data[j];
                int key       = i * 1000 + j;
                if (!radar.runtimeDataPosList.ContainsKey(key))
                {
                    radar.runtimeDataPosList.Add(i * 1000 + j, new List <Vector3>(serieData.data.Count));
                }
                else
                {
                    radar.runtimeDataPosList[key].Clear();
                }
                string dataName   = serieData.name;
                int    serieIndex = 0;
                if (string.IsNullOrEmpty(dataName))
                {
                    serieNameCount++;
                    serieIndex = serieNameCount;
                }
                else if (!serieNameSet.ContainsKey(dataName))
                {
                    serieNameSet.Add(dataName, serieNameCount);
                    serieNameCount++;
                    serieIndex = serieNameCount;
                }
                else
                {
                    serieIndex = serieNameSet[dataName];
                }
                if (!serieData.show)
                {
                    continue;
                }
                var            isHighlight = IsHighlight(radar, serie, serieData, j, 0);
                var            areaColor   = SerieHelper.GetAreaColor(serie, m_ThemeInfo, serieIndex, isHighlight);
                var            areaToColor = SerieHelper.GetAreaToColor(serie, m_ThemeInfo, serieIndex, isHighlight);
                var            lineColor   = SerieHelper.GetLineColor(serie, m_ThemeInfo, serieIndex, isHighlight);
                int            dataCount   = radar.indicatorList.Count;
                List <Vector3> pointList   = radar.runtimeDataPosList[key];
                for (int n = 0; n < dataCount; n++)
                {
                    if (n >= serieData.data.Count)
                    {
                        break;
                    }
                    float max   = radar.GetIndicatorMax(n);
                    float value = serieData.GetCurrData(n, dataChangeDuration);
                    if (serieData.IsDataChanged())
                    {
                        dataChanging = true;
                    }
                    if (max == 0)
                    {
                        max = serie.runtimeDataMax;
                    }
                    var radius = max < 0 ? radar.runtimeDataRadius - radar.runtimeDataRadius * value / max
                    : radar.runtimeDataRadius * value / max;
                    var currAngle = (n + (radar.positionType == Radar.PositionType.Between ? 0.5f : 0)) * angle;
                    radius *= rate;
                    if (n == 0)
                    {
                        startPoint = new Vector3(centerPos.x + radius * Mathf.Sin(currAngle),
                                                 centerPos.y + radius * Mathf.Cos(currAngle));
                        firstPoint = startPoint;
                    }
                    else
                    {
                        toPoint = new Vector3(centerPos.x + radius * Mathf.Sin(currAngle),
                                              centerPos.y + radius * Mathf.Cos(currAngle));
                        if (serie.areaStyle.show)
                        {
                            ChartDrawer.DrawTriangle(vh, startPoint, toPoint, centerPos, areaColor, areaColor, areaToColor);
                        }
                        if (serie.lineStyle.show)
                        {
                            ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, toPoint, lineColor);
                        }
                        startPoint = toPoint;
                    }
                    pointList.Add(startPoint);
                }
                if (serie.areaStyle.show)
                {
                    ChartDrawer.DrawTriangle(vh, startPoint, firstPoint, centerPos, areaColor, areaColor, areaToColor);
                }
                if (serie.lineStyle.show)
                {
                    ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, firstPoint, lineColor);
                }
                if (serie.symbol.show && serie.symbol.type != SerieSymbolType.None)
                {
                    for (int m = 0; m < pointList.Count; m++)
                    {
                        var point = pointList[m];
                        isHighlight = IsHighlight(radar, serie, serieData, j, m);
                        var symbolSize    = (isHighlight ? serie.symbol.selectedSize : serie.symbol.size);
                        var symbolColor   = SerieHelper.GetItemColor(serie, serieData, m_ThemeInfo, serieIndex, isHighlight);
                        var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, m_ThemeInfo, serieIndex, isHighlight);
                        var symbolBorder  = SerieHelper.GetSymbolBorder(serie, serieData, isHighlight);
                        var cornerRadius  = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
                        DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, point, symbolColor,
                                   symbolToColor, serie.symbol.gap, cornerRadius);
                    }
                }
            }
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(1);
                RefreshChart();
            }
            if (dataChanging)
            {
                RefreshChart();
            }
        }