コード例 #1
0
        private void DrawSingleRadar(VertexHelper vh)
        {
            var radar = chart.GetChartComponent <RadarCoord>(serie.radarIndex);

            if (radar == null)
            {
                return;
            }

            var indicatorNum = radar.indicatorList.Count;
            var angle        = 2 * Mathf.PI / indicatorNum;
            var centerPos    = radar.context.center;

            serie.animation.InitProgress(0, 1);
            serie.context.dataPoints.Clear();
            if (!serie.show || serie.animation.HasFadeOut())
            {
                return;
            }
            var startPoint = Vector3.zero;
            var toPoint    = Vector3.zero;
            var firstPoint = Vector3.zero;
            var lastColor  = ColorUtil.clearColor32;
            var firstColor = ColorUtil.clearColor32;

            var rate               = serie.animation.GetCurrRate();
            var dataChanging       = false;
            var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
            var startIndex         = GetStartShowIndex(serie);
            var endIndex           = GetEndShowIndex(serie);

            SerieHelper.UpdateMinMaxData(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;

                if (!serieData.show)
                {
                    serieData.context.labelPosition = Vector3.zero;
                    continue;
                }
                var lineStyle   = SerieHelper.GetLineStyle(serie, serieData);
                var areaStyle   = SerieHelper.GetAreaStyle(serie, serieData);
                var isHighlight = serie.context.pointerEnter;
                var areaColor   = SerieHelper.GetAreaColor(serie, serieData, chart.theme, j, isHighlight);
                var areaToColor = SerieHelper.GetAreaToColor(serie, serieData, chart.theme, j, isHighlight);
                var lineColor   = SerieHelper.GetLineColor(serie, serieData, chart.theme, j, isHighlight);
                int dataCount   = radar.indicatorList.Count;
                var index       = serieData.index;
                var p           = radar.context.center;
                var max         = radar.GetIndicatorMax(index);
                var value       = serieData.GetCurrData(1, dataChangeDuration);
                if (serieData.IsDataChanged())
                {
                    dataChanging = true;
                }
                if (max == 0)
                {
                    max = serie.context.dataMax;
                }
                if (!radar.IsInIndicatorRange(j, serieData.GetData(1)))
                {
                    lineColor = radar.outRangeColor;
                }
                var radius = (float)(max < 0 ? radar.context.dataRadius - radar.context.dataRadius * value / max :
                                     radar.context.dataRadius * value / max);
                var currAngle = (index + (radar.positionType == RadarCoord.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;
                    lastColor  = lineColor;
                    firstColor = lineColor;
                }
                else
                {
                    toPoint = new Vector3(p.x + radius * Mathf.Sin(currAngle),
                                          p.y + radius * Mathf.Cos(currAngle));
                    if (areaStyle != null && areaStyle.show)
                    {
                        UGL.DrawTriangle(vh, startPoint, toPoint, p, areaColor, areaColor, areaToColor);
                    }
                    if (lineStyle.show)
                    {
                        if (radar.connectCenter)
                        {
                            ChartDrawer.DrawLineStyle(vh, lineStyle, startPoint, centerPos,
                                                      chart.theme.serie.lineWidth, LineStyle.Type.Solid, lastColor, lastColor);
                        }
                        ChartDrawer.DrawLineStyle(vh, lineStyle, startPoint, toPoint, chart.theme.serie.lineWidth,
                                                  LineStyle.Type.Solid, radar.lineGradient ? lastColor : lineColor, lineColor);
                    }
                    startPoint = toPoint;
                    lastColor  = lineColor;
                }
                serieData.context.position      = startPoint;
                serieData.context.labelPosition = startPoint;

                if (areaStyle != null && areaStyle.show && j == endIndex)
                {
                    UGL.DrawTriangle(vh, startPoint, firstPoint, centerPos, areaColor, areaColor, areaToColor);
                }
                if (lineStyle.show && j == endIndex)
                {
                    if (radar.connectCenter)
                    {
                        ChartDrawer.DrawLineStyle(vh, lineStyle, startPoint, centerPos,
                                                  chart.theme.serie.lineWidth, LineStyle.Type.Solid, lastColor, lastColor);
                    }
                    ChartDrawer.DrawLineStyle(vh, lineStyle, startPoint, firstPoint, chart.theme.serie.lineWidth,
                                              LineStyle.Type.Solid, lineColor, radar.lineGradient ? firstColor : lineColor);
                }
            }
            if (serie.symbol.show && serie.symbol.type != SymbolType.None)
            {
                for (int j = 0; j < serie.data.Count; j++)
                {
                    var serieData = serie.data[j];
                    if (!serieData.show)
                    {
                        continue;
                    }
                    var isHighlight = serie.highlight || serieData.context.highlight || serie.context.pointerEnter;
                    var serieIndex  = serieData.index;
                    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 symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serieIndex, isHighlight, false);
                    var symbolBorder     = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight);
                    var borderColor      = SerieHelper.GetSymbolBorderColor(serie, serieData, chart.theme, isHighlight);
                    var cornerRadius     = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
                    if (!radar.IsInIndicatorRange(j, serieData.GetData(1)))
                    {
                        symbolColor   = radar.outRangeColor;
                        symbolToColor = radar.outRangeColor;
                    }
                    chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, serieData.context.labelPosition, symbolColor,
                                     symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius);
                }
            }
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(1);
                chart.RefreshPainter(serie);
            }
            if (dataChanging)
            {
                chart.RefreshPainter(serie);
            }
        }