Beispiel #1
0
        private void DrawMarkLine(VertexHelper vh, Serie serie)
        {
            if (!serie.show || !serie.markLine.show)
            {
                return;
            }
            if (serie.markLine.data.Count == 0)
            {
                return;
            }
            var yAxis      = chart.GetSerieYAxisOrDefault(serie);
            var xAxis      = chart.GetSerieXAxisOrDefault(serie);
            var grid       = chart.GetSerieGridOrDefault(serie);
            var dataZoom   = DataZoomHelper.GetAxisRelatedDataZoom(xAxis, chart.dataZooms);
            var animation  = serie.markLine.animation;
            var showData   = serie.GetDataList(dataZoom);
            var sp         = Vector3.zero;
            var ep         = Vector3.zero;
            var colorIndex = chart.GetLegendRealShowNameIndex(serie.name);
            var serieColor = SerieHelper.GetLineColor(serie, chart.theme, colorIndex, false);

            animation.InitProgress(1, 0, 1f);
            ResetTempMarkLineGroupData(serie.markLine);
            if (m_TempGroupData.Count > 0)
            {
                foreach (var kv in m_TempGroupData)
                {
                    if (kv.Value.Count >= 2)
                    {
                        sp = GetSinglePos(xAxis, yAxis, grid, serie, dataZoom, kv.Value[0], showData.Count);
                        ep = GetSinglePos(xAxis, yAxis, grid, serie, dataZoom, kv.Value[1], showData.Count);
                        kv.Value[0].runtimeStartPosition = sp;
                        kv.Value[1].runtimeEndPosition   = ep;
                        DrawMakLineData(vh, kv.Value[0], animation, serie, grid, serieColor, sp, ep);
                    }
                }
            }
            foreach (var data in serie.markLine.data)
            {
                if (data.group != 0)
                {
                    continue;
                }
                switch (data.type)
                {
                case MarkLineType.Min:
                    data.runtimeValue = SerieHelper.GetMinData(serie, data.dimension, dataZoom);
                    GetStartEndPos(xAxis, yAxis, grid, data.runtimeValue, ref sp, ref ep);
                    break;

                case MarkLineType.Max:
                    data.runtimeValue = SerieHelper.GetMaxData(serie, data.dimension, dataZoom);
                    GetStartEndPos(xAxis, yAxis, grid, data.runtimeValue, ref sp, ref ep);
                    break;

                case MarkLineType.Average:
                    data.runtimeValue = SerieHelper.GetAverageData(serie, data.dimension, dataZoom);
                    GetStartEndPos(xAxis, yAxis, grid, data.runtimeValue, ref sp, ref ep);
                    break;

                case MarkLineType.Median:
                    data.runtimeValue = SerieHelper.GetMedianData(serie, data.dimension, dataZoom);
                    GetStartEndPos(xAxis, yAxis, grid, data.runtimeValue, ref sp, ref ep);
                    break;

                case MarkLineType.None:
                    if (data.xPosition != 0)
                    {
                        data.runtimeValue = data.xPosition;
                        var pX = grid.runtimeX + data.xPosition;
                        sp = new Vector3(pX, grid.runtimeY);
                        ep = new Vector3(pX, grid.runtimeY + grid.runtimeHeight);
                    }
                    else if (data.yPosition != 0)
                    {
                        data.runtimeValue = data.yPosition;
                        var pY = grid.runtimeY + data.yPosition;
                        sp = new Vector3(grid.runtimeX, pY);
                        ep = new Vector3(grid.runtimeX + grid.runtimeWidth, pY);
                    }
                    else if (data.yValue != 0)
                    {
                        data.runtimeValue = data.yValue;
                        if (yAxis.IsCategory())
                        {
                            var pY = AxisHelper.GetAxisPosition(grid, yAxis, data.yValue, showData.Count, dataZoom);
                            sp = new Vector3(grid.runtimeX, pY);
                            ep = new Vector3(grid.runtimeX + grid.runtimeWidth, pY);
                        }
                        else
                        {
                            GetStartEndPos(xAxis, yAxis, grid, data.yValue, ref sp, ref ep);
                        }
                    }
                    else
                    {
                        data.runtimeValue = data.xValue;
                        if (xAxis.IsCategory())
                        {
                            var pX = AxisHelper.GetAxisPosition(grid, xAxis, data.xValue, showData.Count, dataZoom);
                            sp = new Vector3(pX, grid.runtimeY);
                            ep = new Vector3(pX, grid.runtimeY + grid.runtimeHeight);
                        }
                        else
                        {
                            GetStartEndPos(xAxis, yAxis, grid, data.xValue, ref sp, ref ep);
                        }
                    }
                    break;

                default:
                    break;
                }
                data.runtimeStartPosition = sp;
                data.runtimeEndPosition   = ep;
                DrawMakLineData(vh, data, animation, serie, grid, serieColor, sp, ep);
            }
            if (!animation.IsFinish())
            {
                animation.CheckProgress(1f);
                chart.RefreshTopPainter();
            }
        }