示例#1
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 = 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;
                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)
                {
                    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);
                    foreach (var point in pointList)
                    {
                        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();
            }
        }