예제 #1
0
        private void DrawZebraBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
                                  bool highlight, float gap, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
                                  Vector3 prb, bool isYAxis, GridCoord grid, Axis axis, Color32 barColor, Color32 barToColor)
        {
            var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, colorIndex, highlight, false);

            if (!ChartHelper.IsClearColor(backgroundColor))
            {
                UGL.DrawRoundRectangle(vh, serieData.context.backgroundRect, backgroundColor, backgroundColor, 0,
                                       null, isYAxis, chart.settings.cicleSmoothness, false);
            }
            if (isYAxis)
            {
                plt = (plb + plt) / 2;
                prt = (prt + prb) / 2;
                chart.DrawClipZebraLine(vh, plt, prt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap,
                                        barColor, barToColor, serie.clip, grid, grid.context.width);
            }
            else
            {
                plb = (prb + plb) / 2;
                plt = (plt + prt) / 2;
                chart.DrawClipZebraLine(vh, plb, plt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap,
                                        barColor, barToColor, serie.clip, grid, grid.context.height);
            }
        }
예제 #2
0
        private void DrawNormalBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
                                   bool highlight, float gap, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
                                   Vector3 prb, bool isYAxis, GridCoord grid, Axis axis, Color32 areaColor, Color32 areaToColor, double value)
        {
            var borderWidth     = itemStyle.runtimeBorderWidth;
            var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, colorIndex, highlight, false);
            var cornerRadius    = serie.barType == BarType.Capsule && !itemStyle.IsNeedCorner() ?
                                  m_CapusleDefaultCornerRadius :
                                  itemStyle.cornerRadius;
            var invert = value < 0;

            if (!ChartHelper.IsClearColor(backgroundColor))
            {
                UGL.DrawRoundRectangle(vh, serieData.context.backgroundRect, backgroundColor, backgroundColor, 0,
                                       cornerRadius, isYAxis, chart.settings.cicleSmoothness, invert);
            }
            UGL.DrawRoundRectangle(vh, serieData.context.rect, areaColor, areaToColor, 0,
                                   cornerRadius, isYAxis, chart.settings.cicleSmoothness, invert);
            if (serie.barType == BarType.Capsule)
            {
                UGL.DrawBorder(vh, serieData.context.backgroundRect, borderWidth, itemStyle.borderColor,
                               0, cornerRadius, isYAxis, chart.settings.cicleSmoothness, invert, -borderWidth);
            }
            else
            {
                UGL.DrawBorder(vh, serieData.context.rect, borderWidth, itemStyle.borderColor,
                               0, cornerRadius, isYAxis, chart.settings.cicleSmoothness, invert, itemStyle.borderGap);
            }
        }
        private void DrawPolarLineSymbol(VertexHelper vh)
        {
            for (int n = 0; n < chart.series.Count; n++)
            {
                var serie = chart.series[n];

                if (!serie.show)
                {
                    continue;
                }
                if (!(serie is 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.context.position))
                    {
                        continue;
                    }

                    bool highlight = serieData.context.highlight || serie.highlight;
                    if ((!symbol.show || !symbol.ShowSymbol(i, count) || serie.IsPerformanceMode()) &&
                        !serieData.context.highlight)
                    {
                        continue;
                    }

                    var symbolSize = highlight ?
                                     symbol.GetSelectedSize(serieData.data, chart.theme.serie.lineSymbolSize) :
                                     symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);

                    var symbolColor      = SerieHelper.GetItemColor(serie, serieData, chart.theme, n, highlight);
                    var symbolToColor    = SerieHelper.GetItemToColor(serie, serieData, chart.theme, n, highlight);
                    var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, n, highlight, false);
                    var symbolBorder     = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, highlight);
                    var borderColor      = SerieHelper.GetSymbolBorderColor(serie, serieData, chart.theme, highlight);
                    var cornerRadius     = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);

                    symbolSize = serie.animation.GetSysmbolSize(symbolSize);
                    chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, serieData.context.position,
                                     symbolColor, symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius);
                }
            }
        }
예제 #4
0
        private void DrawBackground(VertexHelper vh, Serie serie, SerieData serieData, int index, float insideRadius, float outsideRadius)
        {
            var itemStyle       = SerieHelper.GetItemStyle(serie, serieData);
            var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, index, false);

            if (itemStyle.backgroundWidth != 0)
            {
                var centerRadius = (outsideRadius + insideRadius) / 2;
                var inradius     = centerRadius - itemStyle.backgroundWidth / 2;
                var outradius    = centerRadius + itemStyle.backgroundWidth / 2;
                UGL.DrawDoughnut(vh, serie.context.center, inradius,
                                 outradius, backgroundColor, Color.clear, chart.settings.cicleSmoothness);
            }
            else
            {
                UGL.DrawDoughnut(vh, serie.context.center, insideRadius,
                                 outsideRadius, backgroundColor, Color.clear, chart.settings.cicleSmoothness);
            }
        }
 private void DrawRadarSymbol(VertexHelper vh, Serie serie, SerieData serieData, int serieIndex, bool isHighlight,
                              List <Vector3> pointList)
 {
     if (serie.symbol.show && serie.symbol.type != SymbolType.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 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);
         foreach (var point in pointList)
         {
             chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, point, symbolColor,
                              symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius);
         }
     }
 }
예제 #6
0
        private void DrawLinePoint(VertexHelper vh, Serie serie)
        {
            if (!serie.show || serie.IsPerformanceMode())
            {
                return;
            }

            if (m_SerieGrid == null)
            {
                return;
            }

            var count               = serie.context.dataPoints.Count;
            var clip                = SeriesHelper.IsAnyClipSerie(chart.series);
            var theme               = chart.theme;
            var interacting         = false;
            var lineArrow           = serie.lineArrow;
            var visualMap           = chart.GetVisualMapOfSerie(serie);
            var isVisualMapGradient = VisualMapHelper.IsNeedLineGradient(visualMap);

            Axis axis;
            Axis relativedAxis;
            var  isY = chart.GetSerieGridCoordAxis(serie, out axis, out relativedAxis);

            for (int i = 0; i < count; i++)
            {
                var serieData = serie.GetSerieData(i);
                if (serieData == null)
                {
                    continue;
                }
                if (serieData.context.isClip)
                {
                    continue;
                }

                var symbol = SerieHelper.GetSerieSymbol(serie, serieData);

                if (!symbol.show || !symbol.ShowSymbol(i, count))
                {
                    continue;
                }

                var pos = serie.context.dataPoints[i];
                if (lineArrow != null && lineArrow.show)
                {
                    if (lineArrow.position == LineArrow.Position.Start && i == 0)
                    {
                        continue;
                    }
                    if (lineArrow.position == LineArrow.Position.End && i == count - 1)
                    {
                        continue;
                    }
                }

                if (ChartHelper.IsIngore(pos))
                {
                    continue;
                }

                var highlight  = serie.data[i].context.highlight || serie.highlight;
                var symbolSize = highlight ?
                                 theme.serie.lineSymbolSelectedSize :
                                 theme.serie.lineSymbolSize;
                if (!serieData.interact.TryGetValue(ref symbolSize, ref interacting))
                {
                    symbolSize = highlight ?
                                 symbol.GetSelectedSize(serieData.data, symbolSize) :
                                 symbol.GetSize(serieData.data, symbolSize);
                    serieData.interact.SetValue(ref interacting, symbolSize);
                    symbolSize = serie.animation.GetSysmbolSize(symbolSize);
                }
                var symbolColor      = SerieHelper.GetItemColor(serie, serieData, theme, serie.index, highlight);
                var symbolToColor    = SerieHelper.GetItemToColor(serie, serieData, theme, serie.index, highlight);
                var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, serie.index, highlight, false);

                if (isVisualMapGradient)
                {
                    symbolColor   = VisualMapHelper.GetLineGradientColor(visualMap, pos, m_SerieGrid, axis, relativedAxis, symbolColor);
                    symbolToColor = symbolColor;
                }
                var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, highlight);
                var borderColor  = SerieHelper.GetSymbolBorderColor(serie, serieData, theme, highlight);
                var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
                chart.DrawClipSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
                                     symbolColor, symbolToColor, symbolEmptyColor, borderColor, symbol.gap, clip, cornerRadius, m_SerieGrid,
                                     i > 0 ? serie.context.dataPoints[i - 1] : m_SerieGrid.context.position);
            }
            if (interacting)
            {
                if (SeriesHelper.IsStack(chart.series))
                {
                    chart.RefreshTopPainter();
                }
                else
                {
                    chart.RefreshPainter(serie);
                }
            }
        }
        protected virtual void DrawSingAxisScatterSerie(VertexHelper vh, BaseScatter serie)
        {
            if (serie.animation.HasFadeOut())
            {
                return;
            }

            if (!serie.show)
            {
                return;
            }

            var axis = chart.GetChartComponent <SingleAxis>(serie.singleAxisIndex);

            if (axis == null)
            {
                return;
            }

            DataZoom xDataZoom;
            DataZoom yDataZoom;

            chart.GetDataZoomOfSerie(serie, out xDataZoom, out yDataZoom);

            var theme    = chart.theme;
            int maxCount = serie.maxShow > 0 ?
                           (serie.maxShow > serie.dataCount ? serie.dataCount : serie.maxShow) :
                           serie.dataCount;

            serie.animation.InitProgress(0, 1);

            var rate = serie.animation.GetCurrRate();
            var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
            var dataChanging       = false;
            var dataList           = serie.GetDataList(xDataZoom);
            var isEffectScatter    = serie is EffectScatter;
            var colorIndex         = serie.context.colorIndex;

            serie.containerIndex       = axis.index;
            serie.containterInstanceId = axis.instanceId;

            foreach (var serieData in dataList)
            {
                var symbol = SerieHelper.GetSerieSymbol(serie, serieData);
                if (!symbol.ShowSymbol(serieData.index, maxCount))
                {
                    continue;
                }

                var highlight    = serie.highlight || serieData.context.highlight;
                var color        = SerieHelper.GetItemColor(serie, serieData, theme, colorIndex, highlight);
                var toColor      = SerieHelper.GetItemToColor(serie, serieData, theme, colorIndex, highlight);
                var emptyColor   = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, colorIndex, highlight, false);
                var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, highlight);
                var borderColor  = SerieHelper.GetSymbolBorderColor(serie, serieData, theme, highlight);
                var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
                var xValue       = serieData.GetCurrData(0, dataChangeDuration, axis.inverse);

                if (serieData.IsDataChanged())
                {
                    dataChanging = true;
                }

                var pos = Vector3.zero;
                if (axis.orient == Orient.Horizonal)
                {
                    var xDataHig = GetDataHig(axis, xValue, axis.context.width);
                    var yDataHig = axis.context.height / 2;
                    pos = new Vector3(axis.context.x + xDataHig, axis.context.y + yDataHig);
                }
                else
                {
                    var yDataHig = GetDataHig(axis, xValue, axis.context.width);
                    var xDataHig = axis.context.height / 2;
                    pos = new Vector3(axis.context.x + xDataHig, axis.context.y + yDataHig);
                }
                serie.context.dataPoints.Add(pos);
                serieData.context.position = pos;

                var datas      = serieData.data;
                var symbolSize = 0f;
                if (serie.highlight || serieData.context.highlight)
                {
                    symbolSize = symbol.GetSelectedSize(datas, theme.serie.scatterSymbolSelectedSize);
                }
                else
                {
                    symbolSize = symbol.GetSize(datas, theme.serie.scatterSymbolSize);
                }
                symbolSize *= rate;

                if (isEffectScatter)
                {
                    if (symbolSize > 100)
                    {
                        symbolSize = 100;
                    }
                    for (int count = 0; count < symbol.animationSize.Count; count++)
                    {
                        var nowSize = symbol.animationSize[count];
                        color.a = (byte)(255 * (symbolSize - nowSize) / symbolSize);
                        chart.DrawSymbol(vh, symbol.type, nowSize, symbolBorder, pos,
                                         color, toColor, emptyColor, borderColor, symbol.gap, cornerRadius);
                    }
                    chart.RefreshPainter(serie);
                }
                else
                {
                    if (symbolSize > 100)
                    {
                        symbolSize = 100;
                    }
                    chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
                                     color, toColor, emptyColor, borderColor, symbol.gap, cornerRadius);
                }
            }
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(1);
                chart.RefreshPainter(serie);
            }
            if (dataChanging)
            {
                chart.RefreshPainter(serie);
            }
        }
        protected virtual void DrawScatterSerie(VertexHelper vh, BaseScatter serie)
        {
            if (serie.animation.HasFadeOut())
            {
                return;
            }

            if (!serie.show)
            {
                return;
            }

            XAxis xAxis;

            if (!chart.TryGetChartComponent <XAxis>(out xAxis, serie.xAxisIndex))
            {
                return;
            }

            YAxis yAxis;

            if (!chart.TryGetChartComponent <YAxis>(out yAxis, serie.yAxisIndex))
            {
                return;
            }

            if (!chart.TryGetChartComponent <GridCoord>(out m_Grid, xAxis.gridIndex))
            {
                return;
            }

            DataZoom xDataZoom;
            DataZoom yDataZoom;

            chart.GetDataZoomOfSerie(serie, out xDataZoom, out yDataZoom);

            var theme    = chart.theme;
            int maxCount = serie.maxShow > 0 ?
                           (serie.maxShow > serie.dataCount ? serie.dataCount : serie.maxShow) :
                           serie.dataCount;

            serie.animation.InitProgress(0, 1);
            var rate = serie.animation.GetCurrRate();
            var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
            var dataChanging       = false;
            var interacting        = false;
            var dataList           = serie.GetDataList(xDataZoom);
            var isEffectScatter    = serie is EffectScatter;
            var colorIndex         = serie.context.colorIndex;

            serie.containerIndex       = m_Grid.index;
            serie.containterInstanceId = m_Grid.instanceId;

            foreach (var serieData in dataList)
            {
                var symbol = SerieHelper.GetSerieSymbol(serie, serieData);
                if (!symbol.ShowSymbol(serieData.index, maxCount))
                {
                    continue;
                }

                var    highlight    = serie.highlight || serieData.context.highlight;
                var    color        = SerieHelper.GetItemColor(serie, serieData, theme, colorIndex, highlight);
                var    toColor      = SerieHelper.GetItemToColor(serie, serieData, theme, colorIndex, highlight);
                var    emptyColor   = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, colorIndex, highlight, false);
                var    symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, highlight);
                var    borderColor  = SerieHelper.GetSymbolBorderColor(serie, serieData, theme, highlight);
                var    cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
                double xValue       = serieData.GetCurrData(0, dataChangeDuration, xAxis.inverse);
                double yValue       = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse);

                if (serieData.IsDataChanged())
                {
                    dataChanging = true;
                }

                float pX       = m_Grid.context.x + xAxis.axisLine.GetWidth(theme.axis.lineWidth);
                float pY       = m_Grid.context.y + yAxis.axisLine.GetWidth(theme.axis.lineWidth);
                float xDataHig = GetDataHig(xAxis, xValue, m_Grid.context.width);
                float yDataHig = GetDataHig(yAxis, yValue, m_Grid.context.height);
                var   pos      = new Vector3(pX + xDataHig, pY + yDataHig);

                if (!m_Grid.Contains(pos))
                {
                    continue;
                }

                serie.context.dataPoints.Add(pos);
                serieData.context.position = pos;
                var datas      = serieData.data;
                var symbolSize = serie.highlight || serieData.context.highlight ?
                                 theme.serie.scatterSymbolSelectedSize :
                                 theme.serie.scatterSymbolSize;
                if (!serieData.interact.TryGetValue(ref symbolSize, ref interacting))
                {
                    symbolSize = highlight ?
                                 symbol.GetSelectedSize(serieData.data, symbolSize) :
                                 symbol.GetSize(serieData.data, symbolSize);
                    serieData.interact.SetValue(ref interacting, symbolSize);
                }

                symbolSize *= rate;

                if (isEffectScatter)
                {
                    for (int count = 0; count < symbol.animationSize.Count; count++)
                    {
                        var nowSize = symbol.animationSize[count];
                        color.a = (byte)(255 * (symbolSize - nowSize) / symbolSize);
                        chart.DrawSymbol(vh, symbol.type, nowSize, symbolBorder, pos,
                                         color, toColor, emptyColor, borderColor, symbol.gap, cornerRadius);
                    }
                    chart.RefreshPainter(serie);
                }
                else
                {
                    if (symbolSize > 100)
                    {
                        symbolSize = 100;
                    }
                    chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
                                     color, toColor, emptyColor, borderColor, symbol.gap, cornerRadius);
                }
            }
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(1);
                chart.RefreshPainter(serie);
            }
            if (dataChanging || interacting)
            {
                chart.RefreshPainter(serie);
            }
        }
        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);
            }
        }
예제 #10
0
        private void DrawMutipleRadar(VertexHelper vh)
        {
            if (!serie.show)
            {
                return;
            }
            m_RadarCoord = chart.GetChartComponent <RadarCoord>(serie.radarIndex);
            if (m_RadarCoord == null)
            {
                return;
            }

            serie.containerIndex       = m_RadarCoord.index;
            serie.containterInstanceId = m_RadarCoord.instanceId;

            var startPoint   = Vector3.zero;
            var toPoint      = Vector3.zero;
            var firstPoint   = Vector3.zero;
            var indicatorNum = m_RadarCoord.indicatorList.Count;
            var angle        = 2 * Mathf.PI / indicatorNum;
            var centerPos    = m_RadarCoord.context.center;

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

            SerieHelper.GetAllMinMaxData(serie, m_RadarCoord.ceilRate);
            for (int j = 0; j < serie.data.Count; j++)
            {
                var    serieData = serie.data[j];
                string dataName  = serieData.name;
                if (!serieData.show)
                {
                    continue;
                }
                var lineStyle   = SerieHelper.GetLineStyle(serie, serieData);
                var areaStyle   = SerieHelper.GetAreaStyle(serie, serieData);
                var symbol      = SerieHelper.GetSerieSymbol(serie, serieData);
                var isHighlight = serieData.context.highlight;
                var colorIndex  = chart.GetLegendRealShowNameIndex(serieData.legendName);
                var areaColor   = SerieHelper.GetAreaColor(serie, serieData, chart.theme, colorIndex, isHighlight);
                var areaToColor = SerieHelper.GetAreaToColor(serie, serieData, chart.theme, colorIndex, isHighlight);
                var lineColor   = SerieHelper.GetLineColor(serie, serieData, chart.theme, colorIndex, isHighlight);
                var lineWidth   = lineStyle.GetWidth(chart.theme.serie.lineWidth);
                int dataCount   = m_RadarCoord.indicatorList.Count;
                serieData.context.dataPoints.Clear();
                for (int n = 0; n < dataCount; n++)
                {
                    if (n >= serieData.data.Count)
                    {
                        break;
                    }
                    var min   = m_RadarCoord.GetIndicatorMin(n);
                    var max   = m_RadarCoord.GetIndicatorMax(n);
                    var value = serieData.GetCurrData(n, dataChangeDuration);
                    if (serieData.IsDataChanged())
                    {
                        dataChanging = true;
                    }
                    if (max == 0)
                    {
                        if (serie.data.Count > 1)
                        {
                            SerieHelper.GetMinMaxData(serie, n, out min, out max);
                            min = ChartHelper.GetMinDivisibleValue(min, 0);
                            max = ChartHelper.GetMaxDivisibleValue(max, 0);
                            if (min > 0)
                            {
                                min = 0;
                            }
                        }
                        else
                        {
                            max = serie.context.dataMax;
                        }
                    }
                    var radius    = (float)(m_RadarCoord.context.dataRadius * (value - min) / (max - min));
                    var currAngle = (n + (m_RadarCoord.positionType == RadarCoord.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 (areaStyle != null && areaStyle.show)
                        {
                            UGL.DrawTriangle(vh, startPoint, toPoint, centerPos, areaColor, areaColor, areaToColor);
                        }
                        if (lineStyle.show)
                        {
                            ChartDrawer.DrawLineStyle(vh, lineStyle.type, lineWidth, startPoint, toPoint, lineColor);
                        }
                        startPoint = toPoint;
                    }
                    serieData.context.dataPoints.Add(startPoint);
                }
                if (areaStyle != null && areaStyle.show)
                {
                    UGL.DrawTriangle(vh, startPoint, firstPoint, centerPos, areaColor, areaColor, areaToColor);
                }
                if (lineStyle.show)
                {
                    ChartDrawer.DrawLineStyle(vh, lineStyle.type, lineWidth, startPoint, firstPoint, lineColor);
                }
                if (symbol.show && symbol.type != SymbolType.None)
                {
                    for (int m = 0; m < serieData.context.dataPoints.Count; m++)
                    {
                        var point      = serieData.context.dataPoints[m];
                        var symbolSize = isHighlight ?
                                         symbol.GetSelectedSize(null, chart.theme.serie.lineSymbolSelectedSize) :
                                         symbol.GetSize(null, chart.theme.serie.lineSymbolSize);
                        if (!serieData.interact.TryGetValue(ref symbolSize, ref interacting))
                        {
                            symbolSize = isHighlight ?
                                         symbol.GetSelectedSize(serieData.data, symbolSize) :
                                         symbol.GetSize(serieData.data, symbolSize);
                            serieData.interact.SetValue(ref interacting, symbolSize);
                            symbolSize = serie.animation.GetSysmbolSize(symbolSize);
                        }
                        var symbolColor      = SerieHelper.GetItemColor(serie, serieData, chart.theme, j, isHighlight);
                        var symbolToColor    = SerieHelper.GetItemToColor(serie, serieData, chart.theme, j, isHighlight);
                        var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, j, 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);
                        chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, point, symbolColor,
                                         symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius);
                    }
                }
            }
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(1);
                chart.RefreshPainter(serie);
            }
            if (dataChanging || interacting)
            {
                chart.RefreshPainter(serie);
            }
        }