Ejemplo n.º 1
0
        public static void DrawTriangle(VertexHelper vh, Vector3 pos, float size, Color32 color)
        {
            var x  = size * Mathf.Cos(30 * Mathf.PI / 180);
            var y  = size * Mathf.Sin(30 * Mathf.PI / 180);
            var p1 = new Vector2(pos.x - x, pos.y - y);
            var p2 = new Vector2(pos.x, pos.y + size);
            var p3 = new Vector2(pos.x + x, pos.y - y);

            ChartDrawer.DrawTriangle(vh, p1, p2, p3, color);
        }
Ejemplo n.º 2
0
        private void DrawPointer(VertexHelper vh, Serie serie, float currAngle)
        {
            if (!serie.gaugePointer.show)
            {
                return;
            }
            var pointerColor   = serie.gaugeAxis.GetPointerColor(m_ThemeInfo, serie.index, currAngle, serie.itemStyle);
            var pointerToColor = serie.itemStyle.toColor != Color.clear ? serie.itemStyle.toColor : pointerColor;
            var len            = serie.gaugePointer.length <1 && serie.gaugePointer.length> -1 ?
                                 serie.runtimeInsideRadius * serie.gaugePointer.length :
                                 serie.gaugePointer.length;
            var p1 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle, len);
            var p2 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle + 180, serie.gaugePointer.width);
            var p3 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle - 90, serie.gaugePointer.width / 2);
            var p4 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle + 90, serie.gaugePointer.width / 2);

            ChartDrawer.DrawTriangle(vh, p2, p3, p1, pointerColor, pointerColor, pointerToColor);
            ChartDrawer.DrawTriangle(vh, p4, p2, p1, pointerColor, pointerColor, pointerToColor);
        }
Ejemplo n.º 3
0
        protected void DrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize,
                                  float tickness, Vector3 pos, Color color)
        {
            switch (type)
            {
            case SerieSymbolType.None:
                break;

            case SerieSymbolType.Circle:
                ChartDrawer.DrawCricle(vh, pos, symbolSize, color, GetSymbolCricleSegment(symbolSize));
                break;

            case SerieSymbolType.EmptyCircle:
                int segment = GetSymbolCricleSegment(symbolSize);
                ChartDrawer.DrawCricle(vh, pos, symbolSize, m_ThemeInfo.backgroundColor, segment);
                ChartDrawer.DrawDoughnut(vh, pos, symbolSize - tickness, symbolSize, 0, 360, color, segment);
                break;

            case SerieSymbolType.Rect:
                ChartDrawer.DrawPolygon(vh, pos, symbolSize, color);
                break;

            case SerieSymbolType.Triangle:
                var x  = symbolSize * Mathf.Cos(30 * Mathf.PI / 180);
                var y  = symbolSize * Mathf.Sin(30 * Mathf.PI / 180);
                var p1 = new Vector2(pos.x - x, pos.y - y);
                var p2 = new Vector2(pos.x, pos.y + symbolSize);
                var p3 = new Vector2(pos.x + x, pos.y - y);
                ChartDrawer.DrawTriangle(vh, p1, p2, p3, color);
                break;

            case SerieSymbolType.Diamond:
                p1 = new Vector2(pos.x - symbolSize, pos.y);
                p2 = new Vector2(pos.x, pos.y + symbolSize);
                p3 = new Vector2(pos.x + symbolSize, pos.y);
                var p4 = new Vector2(pos.x, pos.y - symbolSize);
                ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, color);
                break;
            }
        }
Ejemplo n.º 4
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();
            }
        }
Ejemplo n.º 5
0
        private void DrawData(VertexHelper vh)
        {
            Vector3 startPoint = Vector3.zero;
            Vector3 toPoint    = Vector3.zero;
            Vector3 firstPoint = Vector3.zero;

            serieNameSet.Clear();
            int serieNameCount = -1;

            for (int i = 0; i < m_Series.Count; i++)
            {
                var     serie        = m_Series.list[i];
                var     radar        = m_Radars[serie.radarIndex];
                int     indicatorNum = radar.indicatorList.Count;
                var     angle        = 2 * Mathf.PI / indicatorNum;
                Vector3 p            = radar.centerPos;
                serie.animation.InitProgress(1, 0, 1);
                if (!IsActive(i))
                {
                    continue;
                }
                var rate = serie.animation.GetCurrRate();
                for (int j = 0; j < serie.data.Count; j++)
                {
                    var serieData = serie.data[j];
                    int key       = i * 100 + j;
                    if (!radar.dataPosList.ContainsKey(key))
                    {
                        radar.dataPosList.Add(i * 100 + j, new List <Vector3>(serieData.data.Count));
                    }
                    else
                    {
                        radar.dataPosList[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.dataIndex[0] == i && m_Tooltip.dataIndex[1] == j);
                    var            areaColor = serie.GetAreaColor(m_ThemeInfo, serieIndex, isHighlight);
                    var            lineColor = serie.GetLineColor(m_ThemeInfo, serieIndex, isHighlight);
                    int            dataCount = radar.indicatorList.Count;
                    List <Vector3> pointList = radar.dataPosList[key];
                    for (int n = 0; n < dataCount; n++)
                    {
                        if (n >= serieData.data.Count)
                        {
                            break;
                        }
                        float min   = radar.GetIndicatorMin(n);
                        float max   = radar.GetIndicatorMax(n);
                        float value = serieData.data[n];
                        if (max == 0)
                        {
                            serie.GetMinMaxData(n, out min, out max);
                            min = radar.GetIndicatorMin(n);
                        }
                        var radius = max < 0 ? radar.actualRadius - radar.actualRadius * value / max
                        : radar.actualRadius * value / max;
                        var currAngle = n * angle;
                        radius *= rate;
                        if (n == 0)
                        {
                            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, p, startPoint, toPoint, areaColor);
                            }
                            if (serie.lineStyle.show)
                            {
                                ChartDrawer.DrawLine(vh, startPoint, toPoint, serie.lineStyle.width, lineColor);
                            }
                            startPoint = toPoint;
                        }
                        pointList.Add(startPoint);
                    }
                    if (serie.areaStyle.show)
                    {
                        ChartDrawer.DrawTriangle(vh, p, startPoint, firstPoint, areaColor);
                    }
                    if (serie.lineStyle.show)
                    {
                        ChartDrawer.DrawLine(vh, startPoint, firstPoint, serie.lineStyle.width, lineColor);
                    }
                    if (serie.symbol.type != SerieSymbolType.None)
                    {
                        var symbolSize  = (isHighlight ? serie.symbol.selectedSize : serie.symbol.size);
                        var symbolColor = serie.symbol.color != Color.clear ? serie.symbol.color : lineColor;
                        symbolColor.a *= serie.symbol.opacity;
                        foreach (var point in pointList)
                        {
                            DrawSymbol(vh, serie.symbol.type, symbolSize, serie.lineStyle.width, point, symbolColor);
                        }
                    }
                }
                if (!serie.animation.IsFinish())
                {
                    float duration = serie.animation.duration > 0 ? (float)serie.animation.duration / 1000 : 1;
                    float speed    = 1 / duration;
                    serie.animation.CheckProgress(Time.deltaTime * speed);
                    RefreshChart();
                }
            }
        }
Ejemplo n.º 6
0
        protected void DrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize,
                                  float tickness, Vector3 pos, Color color, Color toColor, float gap, float[] cornerRadius)
        {
            var backgroundColor = m_ThemeInfo.backgroundColor;
            var smoothness      = m_Settings.cicleSmoothness;

            switch (type)
            {
            case SerieSymbolType.None:
                break;

            case SerieSymbolType.Circle:
                if (gap > 0)
                {
                    ChartDrawer.DrawDoughnut(vh, pos, symbolSize, symbolSize + gap, backgroundColor, color, toColor, smoothness);
                }
                else
                {
                    ChartDrawer.DrawCricle(vh, pos, symbolSize, color, toColor, smoothness);
                }
                break;

            case SerieSymbolType.EmptyCircle:
                if (gap > 0)
                {
                    ChartDrawer.DrawCricle(vh, pos, symbolSize + gap, backgroundColor, smoothness);
                    ChartDrawer.DrawEmptyCricle(vh, pos, symbolSize, tickness, color, toColor, backgroundColor, smoothness);
                }
                else
                {
                    ChartDrawer.DrawEmptyCricle(vh, pos, symbolSize, tickness, color, toColor, backgroundColor, smoothness);
                }
                break;

            case SerieSymbolType.Rect:
                if (gap > 0)
                {
                    ChartDrawer.DrawPolygon(vh, pos, symbolSize + gap, backgroundColor);
                    ChartDrawer.DrawPolygon(vh, pos, symbolSize, color, toColor);
                }
                else
                {
                    //ChartDrawer.DrawPolygon(vh, pos, symbolSize, color, toColor);
                    ChartDrawer.DrawRoundRectangle(vh, pos, symbolSize, symbolSize, color, 0, cornerRadius);
                }
                break;

            case SerieSymbolType.Triangle:
                if (gap > 0)
                {
                    ChartDrawer.DrawTriangle(vh, pos, symbolSize + gap, backgroundColor);
                    ChartDrawer.DrawTriangle(vh, pos, symbolSize, color, toColor);
                }
                else
                {
                    ChartDrawer.DrawTriangle(vh, pos, symbolSize, color, toColor);
                }
                break;

            case SerieSymbolType.Diamond:
                if (gap > 0)
                {
                    ChartDrawer.DrawDiamond(vh, pos, symbolSize + gap, backgroundColor);
                    ChartDrawer.DrawDiamond(vh, pos, symbolSize, color, toColor);
                }
                else
                {
                    ChartDrawer.DrawDiamond(vh, pos, symbolSize, color, toColor);
                }
                break;
            }
        }
Ejemplo n.º 7
0
        protected void DrawVisualMap(VertexHelper vh)
        {
            if (!m_VisualMap.enable || !m_VisualMap.show)
            {
                return;
            }
            var centerPos = m_VisualMap.location.GetPosition(chartWidth, chartHeight);

            var pos1       = Vector3.zero;
            var pos2       = Vector3.zero;
            var dir        = Vector3.zero;
            var halfWid    = m_VisualMap.itemWidth / 2;
            var halfHig    = m_VisualMap.itemHeight / 2;
            var xRadius    = 0f;
            var yRadius    = 0f;
            var splitNum   = m_VisualMap.rtInRange.Count;
            var splitWid   = m_VisualMap.itemHeight / (splitNum - 1);
            var isVertical = false;
            var colors     = m_VisualMap.rtInRange;
            var triangeLen = m_Settings.visualMapTriangeLen;

            switch (m_VisualMap.orient)
            {
            case Orient.Horizonal:
                pos1       = centerPos + Vector3.left * halfHig;
                pos2       = centerPos + Vector3.right * halfHig;
                dir        = Vector3.right;
                xRadius    = splitWid / 2;
                yRadius    = halfWid;
                isVertical = false;
                if (m_VisualMap.calculable)
                {
                    var p0    = pos1 + Vector3.right * m_VisualMap.rangeMinHeight;
                    var p1    = p0 + Vector3.up * halfWid;
                    var p2    = p0 + Vector3.up * (halfWid + triangeLen);
                    var p3    = p2 + Vector3.left * triangeLen;
                    var color = m_VisualMap.GetColor(m_VisualMap.rangeMin);
                    ChartDrawer.DrawTriangle(vh, p1, p2, p3, color);
                    p0    = pos1 + Vector3.right * m_VisualMap.rangeMaxHeight;
                    p1    = p0 + Vector3.up * halfWid;
                    p2    = p0 + Vector3.up * (halfWid + triangeLen);
                    p3    = p2 + Vector3.right * triangeLen;
                    color = m_VisualMap.GetColor(m_VisualMap.rangeMax);
                    ChartDrawer.DrawTriangle(vh, p1, p2, p3, color);
                }
                break;

            case Orient.Vertical:
                pos1       = centerPos + Vector3.down * halfHig;
                pos2       = centerPos + Vector3.up * halfHig;
                dir        = Vector3.up;
                xRadius    = halfWid;
                yRadius    = splitWid / 2;
                isVertical = true;
                if (m_VisualMap.calculable)
                {
                    var p0    = pos1 + Vector3.up * m_VisualMap.rangeMinHeight;
                    var p1    = p0 + Vector3.right * halfWid;
                    var p2    = p0 + Vector3.right * (halfWid + triangeLen);
                    var p3    = p2 + Vector3.down * triangeLen;
                    var color = m_VisualMap.GetColor(m_VisualMap.rangeMin);
                    ChartDrawer.DrawTriangle(vh, p1, p2, p3, color);
                    p0    = pos1 + Vector3.up * m_VisualMap.rangeMaxHeight;
                    p1    = p0 + Vector3.right * halfWid;
                    p2    = p0 + Vector3.right * (halfWid + triangeLen);
                    p3    = p2 + Vector3.up * triangeLen;
                    color = m_VisualMap.GetColor(m_VisualMap.rangeMax);
                    ChartDrawer.DrawTriangle(vh, p1, p2, p3, color);
                }
                break;
            }
            if (m_VisualMap.calculable && (m_VisualMap.rangeMin > m_VisualMap.min ||
                                           m_VisualMap.rangeMax < m_VisualMap.max))
            {
                var rangeMin = m_VisualMap.rangeMin;
                var rangeMax = m_VisualMap.rangeMax;
                var diff     = (m_VisualMap.max - m_VisualMap.min) / (splitNum - 1);
                for (int i = 1; i < splitNum; i++)
                {
                    var splitMin = m_VisualMap.min + (i - 1) * diff;
                    var splitMax = splitMin + diff;
                    if (rangeMin > splitMax || rangeMax < splitMin)
                    {
                        continue;
                    }
                    else if (rangeMin <= splitMin && rangeMax >= splitMax)
                    {
                        var splitPos   = pos1 + dir * (i - 1 + 0.5f) * splitWid;
                        var startColor = colors[i - 1];
                        var toColor    = colors[i];
                        ChartDrawer.DrawPolygon(vh, splitPos, xRadius, yRadius, startColor, toColor, isVertical);
                    }
                    else if (rangeMin > splitMin && rangeMax >= splitMax)
                    {
                        var p0          = pos1 + dir * m_VisualMap.rangeMinHeight;
                        var splitMaxPos = pos1 + dir * i * splitWid;
                        var splitPos    = p0 + (splitMaxPos - p0) / 2;
                        var startColor  = m_VisualMap.GetColor(m_VisualMap.rangeMin);
                        var toColor     = colors[i];
                        var yRadius1    = Vector3.Distance(p0, splitMaxPos) / 2;
                        if (m_VisualMap.orient == Orient.Vertical)
                        {
                            ChartDrawer.DrawPolygon(vh, splitPos, xRadius, yRadius1, startColor, toColor, isVertical);
                        }
                        else
                        {
                            ChartDrawer.DrawPolygon(vh, splitPos, yRadius1, yRadius, startColor, toColor, isVertical);
                        }
                    }
                    else if (rangeMax < splitMax && rangeMin <= splitMin)
                    {
                        var p0          = pos1 + dir * m_VisualMap.rangeMaxHeight;
                        var splitMinPos = pos1 + dir * (i - 1) * splitWid;
                        var splitPos    = splitMinPos + (p0 - splitMinPos) / 2;
                        var startColor  = colors[i - 1];
                        var toColor     = m_VisualMap.GetColor(m_VisualMap.rangeMax);
                        var yRadius1    = Vector3.Distance(p0, splitMinPos) / 2;
                        if (m_VisualMap.orient == Orient.Vertical)
                        {
                            ChartDrawer.DrawPolygon(vh, splitPos, xRadius, yRadius1, startColor, toColor, isVertical);
                        }
                        else
                        {
                            ChartDrawer.DrawPolygon(vh, splitPos, yRadius1, yRadius, startColor, toColor, isVertical);
                        }
                    }
                    else
                    {
                        var p0         = pos1 + dir * m_VisualMap.rangeMinHeight;
                        var p1         = pos1 + dir * m_VisualMap.rangeMaxHeight;
                        var splitPos   = (p0 + p1) / 2;
                        var startColor = m_VisualMap.GetColor(m_VisualMap.rangeMin);
                        var toColor    = m_VisualMap.GetColor(m_VisualMap.rangeMax);
                        var yRadius1   = Vector3.Distance(p0, p1) / 2;
                        if (m_VisualMap.orient == Orient.Vertical)
                        {
                            ChartDrawer.DrawPolygon(vh, splitPos, xRadius, yRadius1, startColor, toColor, isVertical);
                        }
                        else
                        {
                            ChartDrawer.DrawPolygon(vh, splitPos, yRadius1, yRadius, startColor, toColor, isVertical);
                        }
                    }
                }
            }
            else
            {
                for (int i = 1; i < splitNum; i++)
                {
                    var splitPos   = pos1 + dir * (i - 1 + 0.5f) * splitWid;
                    var startColor = colors[i - 1];
                    var toColor    = colors[i];
                    ChartDrawer.DrawPolygon(vh, splitPos, xRadius, yRadius, startColor, toColor, isVertical);
                }
            }

            if (m_VisualMap.rangeMin > m_VisualMap.min)
            {
                var p0 = pos1 + dir * m_VisualMap.rangeMinHeight;
                ChartDrawer.DrawPolygon(vh, pos1, p0, m_VisualMap.itemWidth / 2, m_ThemeInfo.visualMapBackgroundColor);
            }
            if (m_VisualMap.rangeMax < m_VisualMap.max)
            {
                var p1 = pos1 + dir * m_VisualMap.rangeMaxHeight;
                ChartDrawer.DrawPolygon(vh, p1, pos2, m_VisualMap.itemWidth / 2, m_ThemeInfo.visualMapBackgroundColor);
            }

            if (m_VisualMap.hoverLink)
            {
                if (m_VisualMap.rtSelectedIndex >= 0)
                {
                    var p0 = pos1 + dir * m_VisualMap.rangeMinHeight;
                    var p1 = pos1 + dir * m_VisualMap.rangeMaxHeight;

                    if (m_VisualMap.orient == Orient.Vertical)
                    {
                        var p2 = new Vector3(centerPos.x + halfWid, Mathf.Clamp(pointerPos.y + (triangeLen / 2), p0.y, p1.y));
                        var p3 = new Vector3(centerPos.x + halfWid, Mathf.Clamp(pointerPos.y - (triangeLen / 2), p0.y, p1.y));
                        var p4 = new Vector3(centerPos.x + halfWid + triangeLen / 2, pointerPos.y);
                        ChartDrawer.DrawTriangle(vh, p2, p3, p4, colors[m_VisualMap.rtSelectedIndex]);
                    }
                    else
                    {
                        var p2 = new Vector3(Mathf.Clamp(pointerPos.x + (triangeLen / 2), p0.x, p1.x), centerPos.y + halfWid);
                        var p3 = new Vector3(Mathf.Clamp(pointerPos.x - (triangeLen / 2), p0.x, p1.x), centerPos.y + halfWid);
                        var p4 = new Vector3(pointerPos.x, centerPos.y + halfWid + triangeLen / 2);
                        ChartDrawer.DrawTriangle(vh, p2, p3, p4, colors[m_VisualMap.rtSelectedIndex]);
                    }
                }
                else if (m_Tooltip.show && m_Tooltip.xValues[0] >= 0 && m_Tooltip.yValues[0] >= 0)
                {
                    // var p0 = pos1 + dir * m_VisualMap.rangeMinHeight;
                    // var p1 = pos1 + dir * m_VisualMap.rangeMaxHeight;
                    // if (m_VisualMap.orient == Orient.Vertical)
                    // {
                    //     var p2 = new Vector3(centerPos.x + halfWid, Mathf.Clamp(pointerPos.y + (triangeLen / 2), p0.y, p1.y));
                    //     var p3 = new Vector3(centerPos.x + halfWid, Mathf.Clamp(pointerPos.y - (triangeLen / 2), p0.y, p1.y));
                    //     var p4 = new Vector3(centerPos.x + halfWid + triangeLen / 2, pointerPos.y);
                    //     ChartDrawer.DrawTriangle(vh, p2, p3, p4, colors[m_VisualMap.rtSelectedIndex]);
                    // }
                    // else
                    // {
                    //     var p2 = new Vector3(Mathf.Clamp(pointerPos.x + (triangeLen / 2), p0.x, p1.x), centerPos.y + halfWid);
                    //     var p3 = new Vector3(Mathf.Clamp(pointerPos.x - (triangeLen / 2), p0.x, p1.x), centerPos.y + halfWid);
                    //     var p4 = new Vector3(pointerPos.x, centerPos.y + halfWid + triangeLen / 2);
                    //     ChartDrawer.DrawTriangle(vh, p2, p3, p4, colors[m_VisualMap.rtSelectedIndex]);
                    // }
                }
            }
        }
Ejemplo n.º 8
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();
            }
        }