Exemplo n.º 1
0
        protected override void CheckTootipArea(Vector2 local, bool isActivedOther)
        {
            base.CheckTootipArea(local, isActivedOther);
            if (isActivedOther)
            {
                return;
            }
            tooltip.ClearSerieDataIndex();
            bool selected = false;

            foreach (var serie in m_Series.list)
            {
                if (!serie.show)
                {
                    continue;
                }
                if (serie.type != SerieType.Scatter && serie.type != SerieType.EffectScatter)
                {
                    continue;
                }
                bool refresh   = false;
                var  dataCount = serie.data.Count;
                for (int j = 0; j < serie.data.Count; j++)
                {
                    var serieData = serie.data[j];
                    var symbol    = SerieHelper.GetSerieSymbol(serie, serieData);
                    if (!symbol.ShowSymbol(j, dataCount))
                    {
                        continue;
                    }
                    var dist = Vector3.Distance(local, serieData.runtimePosition);
                    if (dist <= symbol.GetSize(serieData.data, m_Theme.serie.scatterSymbolSize))
                    {
                        serieData.selected = true;
                        tooltip.AddSerieDataIndex(serie.index, j);
                        selected = true;
                    }
                    else
                    {
                        serieData.selected = false;
                    }
                }
                if (refresh)
                {
                    RefreshChart();
                }
            }
            if (selected)
            {
                tooltip.UpdateContentPos(local + tooltip.offset);
                UpdateTooltip();
            }
            else if (tooltip.IsActive())
            {
                tooltip.SetActive(false);
                RefreshChart();
            }
        }
Exemplo n.º 2
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);
         }
     }
 }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
        protected void DrawScatterSerie(VertexHelper vh, int colorIndex, Serie serie)
        {
            if (serie.animation.HasFadeOut())
            {
                return;
            }
            if (!serie.show)
            {
                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 symbol    = SerieHelper.GetSerieSymbol(serie, serieData);
                if (!symbol.ShowSymbol(n, maxCount))
                {
                    continue;
                }
                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, xAxis.inverse);
                float yValue       = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse);
                if (serieData.IsDataChanged())
                {
                    dataChanging = true;
                }
                float pX       = m_CoordinateX + xAxis.axisLine.width;
                float pY       = m_CoordinateY + yAxis.axisLine.width;
                float xDataHig = (xValue - xAxis.runtimeMinValue) / (xAxis.runtimeMaxValue - xAxis.runtimeMinValue) * m_CoordinateWidth;
                float yDataHig = (yValue - yAxis.runtimeMinValue) / (yAxis.runtimeMaxValue - yAxis.runtimeMinValue) * m_CoordinateHeight;
                var   pos      = new Vector3(pX + xDataHig, pY + yDataHig);
                serie.dataPoints.Add(pos);
                serieData.runtimePosition = pos;
                var   datas      = serie.data[n].data;
                float symbolSize = 0;
                if (serie.highlighted || serieData.highlighted)
                {
                    symbolSize = symbol.GetSelectedSize(datas);
                }
                else
                {
                    symbolSize = symbol.GetSize(datas);
                }
                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 = (symbolSize - nowSize) / symbolSize;
                        DrawSymbol(vh, symbol.type, nowSize, symbolBorder, pos, color, toColor, symbol.gap, cornerRadius);
                    }
                    RefreshChart();
                }
                else
                {
                    DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos, color, toColor, symbol.gap, cornerRadius);
                }
            }
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(1);
                m_IsPlayingAnimation = true;
                RefreshChart();
            }
            if (dataChanging)
            {
                RefreshChart();
            }
        }