private void UpdateAxisPointerDataIndex(Serie serie, XAxis xAxis, YAxis yAxis, GridCoord grid, bool isTriggerAxis)
 {
     serie.context.pointerAxisDataIndexs.Clear();
     if (yAxis.IsCategory())
     {
         if (isTriggerAxis)
         {
             serie.context.pointerEnter = true;
             serie.context.pointerAxisDataIndexs.Add((int)yAxis.context.pointerValue);
             yAxis.context.axisTooltipValue = yAxis.context.pointerValue;
         }
     }
     else if (yAxis.IsTime())
     {
         serie.context.pointerEnter = true;
         if (isTriggerAxis)
         {
             GetSerieDataIndexByAxis(serie, yAxis, grid);
         }
         else
         {
             GetSerieDataIndexByItem(serie, yAxis, grid);
         }
     }
     else if (xAxis.IsCategory())
     {
         if (isTriggerAxis)
         {
             serie.context.pointerEnter = true;
             serie.context.pointerAxisDataIndexs.Add(serie.context.dataZoomStartIndex + (int)xAxis.context.pointerValue);
             xAxis.context.axisTooltipValue = xAxis.context.pointerValue;
         }
     }
     else
     {
         serie.context.pointerEnter = true;
         if (isTriggerAxis)
         {
             GetSerieDataIndexByAxis(serie, xAxis, grid);
         }
         else
         {
             GetSerieDataIndexByItem(serie, xAxis, grid);
         }
     }
 }
 public static float GetYAxisOnZeroOffset(List <MainComponent> components, YAxis axis)
 {
     if (!axis.axisLine.onZero)
     {
         return(0);
     }
     foreach (var component in components)
     {
         if (component is XAxis)
         {
             var xAxis = component as XAxis;
             if (xAxis.IsValue() && xAxis.gridIndex == axis.gridIndex)
             {
                 return(xAxis.context.offset);
             }
         }
     }
     return(0);
 }
Exemplo 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);
        }