private void GetStartEndPos(Axis xAxis, Axis yAxis, GridCoord grid, double value, ref Vector3 sp, ref Vector3 ep)
 {
     if (xAxis.IsCategory())
     {
         var pY = AxisHelper.GetAxisPosition(grid, yAxis, value);
         sp = new Vector3(grid.context.x, pY);
         ep = new Vector3(grid.context.x + grid.context.width, pY);
     }
     else
     {
         var pX = AxisHelper.GetAxisPosition(grid, xAxis, value);
         sp = new Vector3(pX, grid.context.y);
         ep = new Vector3(pX, grid.context.y + grid.context.height);
     }
 }
Ejemplo n.º 2
0
 private Vector3 GetPosition(Axis xAxis, Axis yAxis, GridCoord grid, double value, bool start)
 {
     if (yAxis.IsCategory())
     {
         var pX = AxisHelper.GetAxisPosition(grid, xAxis, value);
         return(start ?
                new Vector3(pX, grid.context.y + grid.context.height) :
                new Vector3(pX, grid.context.y));
     }
     else
     {
         var pY = AxisHelper.GetAxisPosition(grid, yAxis, value);
         return(start ?
                new Vector3(grid.context.x, pY + grid.context.height) :
                new Vector3(grid.context.x + grid.context.width, pY));
     }
 }
Ejemplo n.º 3
0
        private Vector3 GetPosition(MarkAreaData data, Serie serie, DataZoom dataZoom, XAxis xAxis, YAxis yAxis,
                                    GridCoord grid, List <SerieData> showData, bool start)
        {
            var pos = Vector3.zero;

            switch (data.type)
            {
            case MarkAreaType.Min:
                data.runtimeValue = SerieHelper.GetMinData(serie, data.dimension, dataZoom);
                return(GetPosition(xAxis, yAxis, grid, data.runtimeValue, start));

            case MarkAreaType.Max:
                data.runtimeValue = SerieHelper.GetMaxData(serie, data.dimension, dataZoom);
                return(GetPosition(xAxis, yAxis, grid, data.runtimeValue, start));

            case MarkAreaType.Average:
                data.runtimeValue = SerieHelper.GetAverageData(serie, data.dimension, dataZoom);
                return(GetPosition(xAxis, yAxis, grid, data.runtimeValue, start));

            case MarkAreaType.Median:
                data.runtimeValue = SerieHelper.GetMedianData(serie, data.dimension, dataZoom);
                return(GetPosition(xAxis, yAxis, grid, data.runtimeValue, start));

            case MarkAreaType.None:
                if (data.xPosition != 0 || data.yPosition != 0)
                {
                    var pX = grid.context.x + data.xPosition;
                    var pY = grid.context.y + data.yPosition;
                    return(new Vector3(pX, pY));
                }
                else if (data.yValue != 0)
                {
                    data.runtimeValue = data.yValue;
                    if (yAxis.IsCategory())
                    {
                        var pY = AxisHelper.GetAxisPosition(grid, yAxis, data.yValue, showData.Count, dataZoom);
                        return(start ?
                               new Vector3(grid.context.x, pY) :
                               new Vector3(grid.context.x + grid.context.width, pY));
                    }
                    else
                    {
                        return(GetPosition(xAxis, yAxis, grid, data.runtimeValue, start));
                    }
                }
                else
                {
                    data.runtimeValue = data.xValue;
                    if (xAxis.IsCategory())
                    {
                        var pX = AxisHelper.GetAxisPosition(grid, xAxis, data.xValue, showData.Count, dataZoom);
                        return(start ? new Vector3(pX, grid.context.y + grid.context.height) :
                               new Vector3(pX, grid.context.y));
                    }
                    else
                    {
                        return(GetPosition(xAxis, yAxis, grid, data.xValue, start));
                    }
                }

            default:
                break;
            }
            return(pos);
        }
        private void DrawMarkLine(VertexHelper vh, MarkLine markLine)
        {
            var serie = chart.GetSerie(markLine.serieIndex);

            if (!serie.show || !markLine.show)
            {
                return;
            }
            if (markLine.data.Count == 0)
            {
                return;
            }
            var yAxis      = chart.GetChartComponent <YAxis>(serie.yAxisIndex);
            var xAxis      = chart.GetChartComponent <XAxis>(serie.xAxisIndex);
            var grid       = chart.GetChartComponent <GridCoord>(xAxis.gridIndex);
            var dataZoom   = chart.GetDataZoomOfAxis(xAxis);
            var animation  = markLine.animation;
            var showData   = serie.GetDataList(dataZoom);
            var sp         = Vector3.zero;
            var ep         = Vector3.zero;
            var colorIndex = chart.GetLegendRealShowNameIndex(serie.serieName);
            var serieColor = SerieHelper.GetLineColor(serie, null, chart.theme, colorIndex, false);

            animation.InitProgress(0, 1f);
            ResetTempMarkLineGroupData(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 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.context.x + data.xPosition;
                        sp = new Vector3(pX, grid.context.y);
                        ep = new Vector3(pX, grid.context.y + grid.context.height);
                    }
                    else if (data.yPosition != 0)
                    {
                        data.runtimeValue = data.yPosition;
                        var pY = grid.context.y + data.yPosition;
                        sp = new Vector3(grid.context.x, pY);
                        ep = new Vector3(grid.context.x + grid.context.width, 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.context.x, pY);
                            ep = new Vector3(grid.context.x + grid.context.width, 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.context.y);
                            ep = new Vector3(pX, grid.context.y + grid.context.height);
                        }
                        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();
            }
        }
 private float GetAxisPosition(GridCoord grid, Axis axis, DataZoom dataZoom, int dataCount, double value)
 {
     return(AxisHelper.GetAxisPosition(grid, axis, value, dataCount, dataZoom));
 }