コード例 #1
0
        private void DrawMarkLineSymbol(VertexHelper vh, SerieSymbol symbol, Serie serie, Grid grid, ChartTheme theme,
                                        Vector3 pos, Vector3 startPos, Color32 lineColor)
        {
            var symbolSize   = symbol.GetSize(null, theme.serie.lineSymbolSize);
            var tickness     = SerieHelper.GetSymbolBorder(serie, null, theme, false);
            var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, null, false);

            chart.Internal_CheckClipAndDrawSymbol(vh, symbol.type, symbolSize, tickness, pos, lineColor, lineColor,
                                                  symbol.gap, true, cornerRadius, grid, startPos);
        }
コード例 #2
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.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);
         }
     }
 }
コード例 #3
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);
         }
     }
 }
コード例 #4
0
        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();
            }
        }
コード例 #5
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();
            }
        }
コード例 #6
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);
            }
        }
コード例 #7
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();
            }
        }