Example #1
0
        protected void DrawXBarSerie(VertexHelper vh, Serie serie, int colorIndex, ref List <float> seriesHig)
        {
            if (!IsActive(serie.index))
            {
                return;
            }
            if (serie.animation.HasFadeOut())
            {
                return;
            }
            var showData = serie.GetDataList(m_DataZoom);
            var yAxis    = m_YAxises[serie.axisIndex];
            var xAxis    = m_XAxises[serie.axisIndex];

            if (!xAxis.show)
            {
                xAxis = m_XAxises[(serie.axisIndex + 1) % m_XAxises.Count];
            }

            float categoryWidth = AxisHelper.GetDataWidth(xAxis, m_CoordinateWidth, showData.Count, m_DataZoom);
            float barGap        = GetBarGap();
            float totalBarWidth = GetBarTotalWidth(categoryWidth, barGap);
            float barWidth      = serie.GetBarWidth(categoryWidth);
            float offset        = (categoryWidth - totalBarWidth) / 2;
            float barGapWidth   = barWidth + barWidth * barGap;
            float space         = serie.barGap == -1 ? offset : offset + m_BarLastOffset;
            int   maxCount      = serie.maxShow > 0 ?
                                  (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
                : showData.Count;

            if (seriesHig.Count < serie.minShow)
            {
                for (int i = 0; i < serie.minShow; i++)
                {
                    seriesHig.Add(0);
                }
            }

            var   isPercentStack     = SeriesHelper.IsPercentStack(m_Series, serie.stack, SerieType.Bar);
            bool  dataChanging       = false;
            float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
            float yMinValue          = yAxis.GetCurrMinValue(dataChangeDuration);
            float yMaxValue          = yAxis.GetCurrMaxValue(dataChangeDuration);

            for (int i = serie.minShow; i < maxCount; i++)
            {
                if (i >= seriesHig.Count)
                {
                    seriesHig.Add(0);
                }
                var serieData = showData[i];
                if (serie.IsIgnoreValue(serieData.GetData(1)))
                {
                    serie.dataPoints.Add(Vector3.zero);
                    continue;
                }
                var highlight = (m_Tooltip.show && m_Tooltip.IsSelected(i)) ||
                                serie.data[i].highlighted ||
                                serie.highlighted;
                var   itemStyle   = SerieHelper.GetItemStyle(serie, serieData, highlight);
                float value       = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse);
                float borderWidth = value == 0 ? 0 : itemStyle.runtimeBorderWidth;
                if (serieData.IsDataChanged())
                {
                    dataChanging = true;
                }
                float pX    = m_CoordinateX + i * categoryWidth;
                float zeroY = m_CoordinateY + yAxis.runtimeZeroYOffset;
                if (!xAxis.boundaryGap)
                {
                    pX -= categoryWidth / 2;
                }
                float axisLineWidth = (value < 0 ? -1 : 1) * xAxis.axisLine.width;
                float pY            = seriesHig[i] + zeroY + axisLineWidth;

                var barHig     = 0f;
                var valueTotal = 0f;
                if (isPercentStack)
                {
                    valueTotal    = GetSameStackTotalValue(serie.stack, i);
                    barHig        = valueTotal != 0 ? (value / valueTotal * m_CoordinateHeight) : 0;
                    seriesHig[i] += barHig;
                }
                else
                {
                    valueTotal = yMaxValue - yMinValue;
                    if (valueTotal != 0)
                    {
                        barHig = (yMinValue > 0 ? value - yMinValue : value)
                                 / valueTotal * m_CoordinateHeight;
                    }
                    seriesHig[i] += barHig;
                }
                float   currHig = CheckAnimation(serie, i, barHig);
                Vector3 plb, plt, prt, prb, top;
                if (value < 0)
                {
                    plb = new Vector3(pX + space + borderWidth, pY - borderWidth);
                    plt = new Vector3(pX + space + borderWidth, pY + currHig + borderWidth - axisLineWidth);
                    prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig + borderWidth - axisLineWidth);
                    prb = new Vector3(pX + space + barWidth - borderWidth, pY - borderWidth);
                }
                else
                {
                    plb = new Vector3(pX + space + borderWidth, pY + borderWidth);
                    plt = new Vector3(pX + space + borderWidth, pY + currHig - borderWidth - axisLineWidth);
                    prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig - borderWidth - axisLineWidth);
                    prb = new Vector3(pX + space + barWidth - borderWidth, pY + borderWidth);
                }
                top = new Vector3(pX + space + barWidth / 2, pY + currHig - borderWidth);
                if (serie.clip)
                {
                    plb = ClampInCoordinate(plb);
                    plt = ClampInCoordinate(plt);
                    prt = ClampInCoordinate(prt);
                    prb = ClampInCoordinate(prb);
                    top = ClampInCoordinate(top);
                }
                serie.dataPoints.Add(top);
                if (serie.show)
                {
                    switch (serie.barType)
                    {
                    case BarType.Normal:
                        DrawNormalBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
                                      pX, pY, plb, plt, prt, prb, false);
                        break;

                    case BarType.Zebra:
                        DrawZebraBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
                                     pX, pY, plb, plt, prt, prb, false);
                        break;

                    case BarType.Capsule:
                        DrawCapsuleBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
                                       pX, pY, plb, plt, prt, prb, false);
                        break;
                    }
                }
            }
            if (dataChanging)
            {
                RefreshChart();
            }
            if (!SeriesHelper.IsStack(m_Series, serie.stack, SerieType.Bar))
            {
                m_BarLastOffset += barGapWidth;
            }
        }
        protected void DrawYBarSerie(VertexHelper vh, Serie serie, int colorIndex)
        {
            if (!IsActive(serie.name))
            {
                return;
            }
            if (serie.animation.HasFadeOut())
            {
                return;
            }
            var   xAxis         = m_XAxes[serie.xAxisIndex];
            var   yAxis         = m_YAxes[serie.yAxisIndex];
            var   grid          = GetSerieGridOrDefault(serie);
            var   showData      = serie.GetDataList(dataZoom);
            float categoryWidth = AxisHelper.GetDataWidth(yAxis, grid.runtimeHeight, showData.Count, dataZoom);
            float barGap        = Internal_GetBarGap(SerieType.Bar);
            float totalBarWidth = Internal_GetBarTotalWidth(categoryWidth, barGap, SerieType.Bar);
            float barWidth      = serie.GetBarWidth(categoryWidth);
            float offset        = (categoryWidth - totalBarWidth) / 2;
            float barGapWidth   = barWidth + barWidth * barGap;
            float space         = serie.barGap == -1 ? offset : offset + Internal_GetBarIndex(serie, SerieType.Bar) * barGapWidth;
            var   isStack       = SeriesHelper.IsStack(m_Series, serie.stack, SerieType.Bar);

            m_StackSerieData.Clear();
            if (isStack)
            {
                SeriesHelper.UpdateStackDataList(m_Series, serie, dataZoom, m_StackSerieData);
            }

            int maxCount = serie.maxShow > 0 ?
                           (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
                : showData.Count;
            var   isPercentStack     = SeriesHelper.IsPercentStack(m_Series, serie.stack, SerieType.Bar);
            bool  dataChanging       = false;
            float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
            float xMinValue          = xAxis.GetCurrMinValue(dataChangeDuration);
            float xMaxValue          = xAxis.GetCurrMaxValue(dataChangeDuration);
            var   isAllBarEnd        = true;

            for (int i = serie.minShow; i < maxCount; i++)
            {
                var serieData = showData[i];
                if (serie.IsIgnoreValue(serieData))
                {
                    serie.dataPoints.Add(Vector3.zero);
                    continue;
                }
                var highlight = (tooltip.show && tooltip.IsSelected(i)) ||
                                serie.data[i].highlighted ||
                                serie.highlighted;
                var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight);

                serieData.canShowLabel = true;
                float value       = showData[i].GetCurrData(1, dataChangeDuration, xAxis.inverse, xMinValue, xMaxValue);
                float borderWidth = value == 0 ? 0 : itemStyle.runtimeBorderWidth;
                if (showData[i].IsDataChanged())
                {
                    dataChanging = true;
                }
                float axisLineWidth = value == 0 ? 0
                    : ((value < 0 ? -1 : 1) * yAxis.axisLine.GetWidth(m_Theme.axis.lineWidth));

                float pY = grid.runtimeY + i * categoryWidth;
                if (!yAxis.boundaryGap)
                {
                    pY -= categoryWidth / 2;
                }
                float pX = grid.runtimeX + xAxis.runtimeZeroXOffset + axisLineWidth;
                if (isStack)
                {
                    for (int n = 0; n < m_StackSerieData.Count - 1; n++)
                    {
                        pX += m_StackSerieData[n][i].runtimeStackHig;
                    }
                }

                var barHig     = 0f;
                var valueTotal = 0f;
                if (isPercentStack)
                {
                    valueTotal = Internal_GetBarSameStackTotalValue(serie.stack, i, SerieType.Bar);
                    barHig     = valueTotal != 0 ? (value / valueTotal * grid.runtimeWidth) : 0;
                }
                else
                {
                    if (yAxis.IsLog())
                    {
                        int   minIndex = xAxis.runtimeMinLogIndex;
                        float nowIndex = xAxis.GetLogValue(value);
                        barHig = (nowIndex - minIndex) / xAxis.splitNumber * grid.runtimeWidth;
                    }
                    else
                    {
                        valueTotal = xMaxValue - xMinValue;
                        if (valueTotal != 0)
                        {
                            barHig = (xMinValue > 0 ? value - xMinValue : value)
                                     / valueTotal * grid.runtimeWidth;
                        }
                    }
                }
                serieData.runtimeStackHig = barHig;
                var   isBarEnd = false;
                float currHig  = Internal_CheckBarAnimation(serie, i, barHig, out isBarEnd);
                if (!isBarEnd)
                {
                    isAllBarEnd = false;
                }
                Vector3 plt, prt, prb, plb, top;
                if (value < 0)
                {
                    plt = new Vector3(pX - borderWidth, pY + space + barWidth - borderWidth);
                    prt = new Vector3(pX + currHig + borderWidth, pY + space + barWidth - borderWidth);
                    prb = new Vector3(pX + currHig + borderWidth, pY + space + borderWidth);
                    plb = new Vector3(pX - borderWidth, pY + space + borderWidth);
                }
                else
                {
                    plt = new Vector3(pX + borderWidth, pY + space + barWidth - borderWidth);
                    prt = new Vector3(pX + currHig - borderWidth, pY + space + barWidth - borderWidth);
                    prb = new Vector3(pX + currHig - borderWidth, pY + space + borderWidth);
                    plb = new Vector3(pX + borderWidth, pY + space + borderWidth);
                }
                top = new Vector3(pX + currHig - borderWidth, pY + space + barWidth / 2);
                if (serie.clip)
                {
                    plt = ClampInGrid(grid, plt);
                    prt = ClampInGrid(grid, prt);
                    prb = ClampInGrid(grid, prb);
                    plb = ClampInGrid(grid, plb);
                    top = ClampInGrid(grid, top);
                }
                serie.dataPoints.Add(top);
                if (serie.show)
                {
                    switch (serie.barType)
                    {
                    case BarType.Normal:
                        DrawNormalBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
                                      pX, pY, plb, plt, prt, prb, true, grid);
                        break;

                    case BarType.Zebra:
                        DrawZebraBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
                                     pX, pY, plb, plt, prt, prb, true, grid);
                        break;

                    case BarType.Capsule:
                        DrawCapsuleBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
                                       pX, pY, plb, plt, prt, prb, true, grid);
                        break;
                    }
                }
            }
            if (isAllBarEnd)
            {
                serie.animation.AllBarEnd();
            }
            if (dataChanging)
            {
                RefreshPainter(serie);
            }
        }
        private void InitRadiusAxis(RadiusAxis axis)
        {
            var m_Polar = GetPolar(axis.index);

            if (m_Polars == null)
            {
                return;
            }
            var m_AngleAxis = GetAngleAxis(m_Polar.index);

            if (m_AngleAxis == null)
            {
                return;
            }
            PolarHelper.UpdatePolarCenter(m_Polar, m_ChartPosition, m_ChartWidth, m_ChartHeight);
            axis.axisLabelTextList.Clear();
            var radius  = m_Polar.runtimeRadius;
            var objName = "axis_radius" + axis.index;
            var axisObj = ChartHelper.AddObject(objName, transform, graphAnchorMin,
                                                graphAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));

            axisObj.transform.localPosition = Vector3.zero;
            axisObj.SetActive(axis.show && axis.axisLabel.show);
            axisObj.hideFlags = chartHideFlags;
            ChartHelper.HideAllObject(axisObj);
            var textStyle   = axis.axisLabel.textStyle;
            var splitNumber = AxisHelper.GetSplitNumber(axis, radius, null);
            var totalWidth  = 0f;
            var startAngle  = m_AngleAxis.runtimeStartAngle;
            var cenPos      = m_Polar.runtimeCenterPos;
            var txtHig      = textStyle.GetFontSize(m_Theme.axis) + 2;
            var dire        = ChartHelper.GetDire(startAngle, true).normalized;
            var tickWidth   = axis.axisTick.GetLength(m_Theme.radiusAxis.tickWidth);
            var tickVetor   = ChartHelper.GetVertialDire(dire)
                              * (tickWidth + axis.axisLabel.margin);

            for (int i = 0; i < splitNumber; i++)
            {
                float labelWidth = AxisHelper.GetScaleWidth(axis, radius, i, null);
                bool  inside     = axis.axisLabel.inside;
                var   txt        = ChartHelper.AddTextObject(objName + i, axisObj.transform, new Vector2(0.5f, 0.5f),
                                                             new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(labelWidth, txtHig), textStyle,
                                                             m_Theme.axis);
                if (i == 0)
                {
                    axis.axisLabel.SetRelatedText(txt, labelWidth);
                }
                var isPercentStack = SeriesHelper.IsPercentStack(m_Series, SerieType.Bar);
                var labelName      = AxisHelper.GetLabelName(axis, radius, i, axis.runtimeMinValue, axis.runtimeMaxValue,
                                                             null, isPercentStack);
                txt.SetAlignment(TextAnchor.MiddleCenter);
                txt.SetText(labelName);
                txt.SetActive(axis.show &&
                              (axis.axisLabel.interval == 0 || i % (axis.axisLabel.interval + 1) == 0));
                var pos = ChartHelper.GetPos(cenPos, totalWidth, startAngle, true) + tickVetor;
                txt.SetLocalPosition(pos);
                AxisHelper.AdjustRadiusAxisLabelPos(txt, pos, cenPos, txtHig, Vector3.zero);
                axis.axisLabelTextList.Add(txt);

                totalWidth += labelWidth;
            }
            if (tooltip.runtimeGameObject)
            {
                Vector2    privot      = new Vector2(0.5f, 1);
                var        labelParent = tooltip.runtimeGameObject.transform;
                var        labelName   = ChartCached.GetAxisTooltipLabel(objName);
                GameObject labelObj    = ChartHelper.AddTooltipLabel(labelName, labelParent, m_Theme, privot);
                axis.SetTooltipLabel(labelObj);
                axis.SetTooltipLabelColor(m_Theme.tooltip.labelBackgroundColor, m_Theme.tooltip.labelTextColor);
                axis.SetTooltipLabelActive(axis.show && tooltip.show && tooltip.type == Tooltip.Type.Corss);
            }
        }
        private void InitAngleAxis(AngleAxis axis)
        {
            var m_Polar = GetPolar(axis.polarIndex);

            if (m_Polars == null)
            {
                return;
            }
            PolarHelper.UpdatePolarCenter(m_Polar, m_ChartPosition, m_ChartWidth, m_ChartHeight);
            var radius = m_Polar.runtimeRadius;

            axis.axisLabelTextList.Clear();

            string objName = "axis_angle" + axis.index;
            var    axisObj = ChartHelper.AddObject(objName, transform, graphAnchorMin,
                                                   graphAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));

            axisObj.transform.localPosition = Vector3.zero;
            axisObj.SetActive(axis.show && axis.axisLabel.show);
            axisObj.hideFlags = chartHideFlags;
            ChartHelper.HideAllObject(axisObj);
            var splitNumber    = AxisHelper.GetSplitNumber(axis, radius, null);
            var totalAngle     = axis.runtimeStartAngle;
            var total          = 360;
            var cenPos         = m_Polar.runtimeCenterPos;
            var txtHig         = axis.axisLabel.textStyle.GetFontSize(m_Theme.axis) + 2;
            var margin         = axis.axisLabel.margin;
            var isCategory     = axis.IsCategory();
            var isPercentStack = SeriesHelper.IsPercentStack(m_Series, SerieType.Bar);

            for (int i = 0; i < splitNumber; i++)
            {
                float scaleAngle = AxisHelper.GetScaleWidth(axis, total, i, null);
                bool  inside     = axis.axisLabel.inside;
                var   txt        = ChartHelper.AddTextObject(objName + i, axisObj.transform, new Vector2(0.5f, 0.5f),
                                                             new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(scaleAngle, txtHig),
                                                             axis.axisLabel.textStyle, m_Theme.axis);
                txt.SetAlignment(TextAnchor.MiddleCenter);
                txt.SetText(AxisHelper.GetLabelName(axis, total, i, axis.runtimeMinValue, axis.runtimeMaxValue,
                                                    null, isPercentStack));
                txt.SetActive(axis.show && (axis.axisLabel.interval == 0 || i % (axis.axisLabel.interval + 1) == 0));
                var pos = ChartHelper.GetPos(cenPos, radius + margin,
                                             isCategory ? (totalAngle + scaleAngle / 2) : totalAngle, true);
                AxisHelper.AdjustCircleLabelPos(txt, pos, cenPos, txtHig, Vector3.zero);
                if (i == 0)
                {
                    axis.axisLabel.SetRelatedText(txt, scaleAngle);
                }
                axis.axisLabelTextList.Add(txt);

                totalAngle += scaleAngle;
            }
            if (tooltip.runtimeGameObject)
            {
                Vector2    privot      = new Vector2(0.5f, 0.5f);
                var        labelParent = tooltip.runtimeGameObject.transform;
                GameObject labelObj    = ChartHelper.AddTooltipLabel(ChartCached.GetAxisTooltipLabel(objName), labelParent,
                                                                     m_Theme, privot, privot, privot, new Vector2(10, txtHig));
                axis.SetTooltipLabel(labelObj);
                axis.SetTooltipLabelColor(m_Theme.tooltip.labelBackgroundColor, m_Theme.tooltip.labelTextColor);
                axis.SetTooltipLabelActive(axis.show && tooltip.show && tooltip.type == Tooltip.Type.Corss);
            }
        }
Example #5
0
 private float GetAxisPosition(Grid grid, Axis axis, DataZoom dataZoom, int dataCount, double value)
 {
     return(AxisHelper.GetAxisPosition(grid, axis, value, dataCount, dataZoom));
 }
Example #6
0
        protected void DrawCandlestickSerie(VertexHelper vh, int colorIndex, Serie serie)
        {
            if (!IsActive(serie.index))
            {
                return;
            }
            if (serie.animation.HasFadeOut())
            {
                return;
            }
            var   showData      = serie.GetDataList(dataZoom);
            var   yAxis         = m_YAxes[serie.yAxisIndex];
            var   xAxis         = m_XAxes[serie.xAxisIndex];
            var   grid          = GetSerieGridOrDefault(serie);
            float categoryWidth = AxisHelper.GetDataWidth(xAxis, grid.runtimeWidth, showData.Count, dataZoom);
            float barWidth      = serie.GetBarWidth(categoryWidth);
            float space         = (categoryWidth - barWidth) / 2;
            int   maxCount      = serie.maxShow > 0
                ? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
                : showData.Count;

            bool  dataChanging       = false;
            float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
            float yMinValue          = yAxis.GetCurrMinValue(dataChangeDuration);
            float yMaxValue          = yAxis.GetCurrMaxValue(dataChangeDuration);
            var   isAllBarEnd        = true;
            var   isYAxis            = false;

            for (int i = serie.minShow; i < maxCount; i++)
            {
                var serieData = showData[i];
                if (serie.IsIgnoreValue(serieData.GetData(1)))
                {
                    serie.dataPoints.Add(Vector3.zero);
                    continue;
                }
                var highlight = (tooltip.show && tooltip.IsSelected(i)) ||
                                serie.data[i].highlighted ||
                                serie.highlighted;
                var itemStyle   = SerieHelper.GetItemStyle(serie, serieData, highlight);
                var open        = serieData.GetCurrData(0, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
                var close       = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
                var lowest      = serieData.GetCurrData(2, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
                var heighest    = serieData.GetCurrData(3, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
                var isRise      = close > open;
                var borderWidth = open == 0 ? 0f
                    : (itemStyle.runtimeBorderWidth == 0 ? m_Theme.serie.candlestickBorderWidth
                    : itemStyle.runtimeBorderWidth);
                if (serieData.IsDataChanged())
                {
                    dataChanging = true;
                }
                float pX    = grid.runtimeX + i * categoryWidth;
                float zeroY = grid.runtimeY + yAxis.runtimeZeroYOffset;
                if (!xAxis.boundaryGap)
                {
                    pX -= categoryWidth / 2;
                }
                float pY         = zeroY;
                var   barHig     = 0f;
                var   valueTotal = yMaxValue - yMinValue;
                var   minCut     = (yMinValue > 0 ? yMinValue : 0);
                if (valueTotal != 0)
                {
                    barHig = (close - open) / valueTotal * grid.runtimeHeight;
                    pY    += (open - minCut) / valueTotal * grid.runtimeHeight;
                }
                serieData.runtimeStackHig = barHig;
                var   isBarEnd = false;
                float currHig  = CheckAnimation(serie, i, barHig, out isBarEnd);
                if (!isBarEnd)
                {
                    isAllBarEnd = false;
                }
                Vector3 plb, plt, prt, prb, top;

                plb = new Vector3(pX + space + borderWidth, pY + borderWidth);
                plt = new Vector3(pX + space + borderWidth, pY + currHig - borderWidth);
                prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig - borderWidth);
                prb = new Vector3(pX + space + barWidth - borderWidth, pY + borderWidth);
                top = new Vector3(pX + space + barWidth / 2, pY + currHig - borderWidth);
                if (serie.clip)
                {
                    plb = ClampInGrid(grid, plb);
                    plt = ClampInGrid(grid, plt);
                    prt = ClampInGrid(grid, prt);
                    prb = ClampInGrid(grid, prb);
                    top = ClampInGrid(grid, top);
                }
                serie.dataPoints.Add(top);
                var areaColor = isRise
                    ? itemStyle.GetColor(m_Theme.serie.candlestickColor)
                    : itemStyle.GetColor0(m_Theme.serie.candlestickColor0);
                var borderColor = isRise
                    ? itemStyle.GetBorderColor(m_Theme.serie.candlestickBorderColor)
                    : itemStyle.GetBorderColor0(m_Theme.serie.candlestickBorderColor0);
                var itemWidth      = Mathf.Abs(prt.x - plb.x);
                var itemHeight     = Mathf.Abs(plt.y - prb.y);
                var center         = new Vector3((plb.x + prt.x) / 2, (plt.y + prb.y) / 2);
                var lowPos         = new Vector3(center.x, zeroY + (lowest - minCut) / valueTotal * grid.runtimeHeight);
                var heighPos       = new Vector3(center.x, zeroY + (heighest - minCut) / valueTotal * grid.runtimeHeight);
                var openCenterPos  = new Vector3(center.x, prb.y);
                var closeCenterPos = new Vector3(center.x, prt.y);
                if (barWidth > 2f * borderWidth)
                {
                    if (itemWidth > 0 && itemHeight > 0)
                    {
                        if (ItemStyleHelper.IsNeedCorner(itemStyle))
                        {
                            UGL.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, areaColor, 0,
                                                   itemStyle.cornerRadius, isYAxis, 0.5f);
                        }
                        else
                        {
                            CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, areaColor, areaColor,
                                                    serie.clip, grid);
                        }
                        UGL.DrawBorder(vh, center, itemWidth, itemHeight, 2 * borderWidth, borderColor, 0,
                                       itemStyle.cornerRadius, isYAxis, 0.5f);
                    }
                }
                else
                {
                    UGL.DrawLine(vh, openCenterPos, closeCenterPos, Mathf.Max(borderWidth, barWidth / 2), borderColor);
                }
                if (isRise)
                {
                    UGL.DrawLine(vh, openCenterPos, lowPos, borderWidth, borderColor);
                    UGL.DrawLine(vh, closeCenterPos, heighPos, borderWidth, borderColor);
                }
                else
                {
                    UGL.DrawLine(vh, closeCenterPos, lowPos, borderWidth, borderColor);
                    UGL.DrawLine(vh, openCenterPos, heighPos, borderWidth, borderColor);
                }
            }
            if (isAllBarEnd)
            {
                serie.animation.AllBarEnd();
            }
            if (dataChanging)
            {
                RefreshPainter(serie);
            }
        }
Example #7
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();
            }
        }
        protected void DrawAxisSplit(VertexHelper vh, AxisTheme theme, DataZoom dataZoom,
                                     Orient orient, float startX, float startY, float axisLength, float splitLength, Axis relativedAxis = null)
        {
            Axis axis      = component;
            var  lineColor = axis.splitLine.GetColor(theme.splitLineColor);
            var  lineWidth = axis.splitLine.GetWidth(theme.lineWidth);
            var  lineType  = axis.splitLine.GetType(theme.splitLineType);

            var size = AxisHelper.GetScaleNumber(axis, axisLength, dataZoom);

            if (axis.IsTime())
            {
                size += 1;
                if (!ChartHelper.IsEquals(axis.GetLastLabelValue(), axis.context.maxValue))
                {
                    size += 1;
                }
            }

            var current = orient == Orient.Horizonal ?
                          startX :
                          startY;

            for (int i = 0; i < size; i++)
            {
                var scaleWidth = AxisHelper.GetScaleWidth(axis, axisLength, axis.IsTime() ? i : i + 1, dataZoom);

                if (axis.boundaryGap && axis.axisTick.alignWithLabel)
                {
                    current -= scaleWidth / 2;
                }

                if (axis.splitArea.show && i <= size - 1)
                {
                    if (orient == Orient.Horizonal)
                    {
                        UGL.DrawQuadrilateral(vh,
                                              new Vector2(current, startY),
                                              new Vector2(current, startY + splitLength),
                                              new Vector2(current + scaleWidth, startY + splitLength),
                                              new Vector2(current + scaleWidth, startY),
                                              axis.splitArea.GetColor(i, theme));
                    }
                    else
                    {
                        UGL.DrawQuadrilateral(vh,
                                              new Vector2(startX, current),
                                              new Vector2(startX + splitLength, current),
                                              new Vector2(startX + splitLength, current + scaleWidth),
                                              new Vector2(startX, current + scaleWidth),
                                              axis.splitArea.GetColor(i, theme));
                    }
                }
                if (axis.splitLine.show)
                {
                    if (axis.splitLine.NeedShow(i))
                    {
                        if (orient == Orient.Horizonal)
                        {
                            if (relativedAxis == null || !MathUtil.Approximately(current, GetAxisLineXOrY()))
                            {
                                ChartDrawer.DrawLineStyle(vh,
                                                          lineType,
                                                          lineWidth,
                                                          new Vector3(current, startY),
                                                          new Vector3(current, startY + splitLength),
                                                          lineColor);
                            }
                        }
                        else
                        {
                            if (relativedAxis == null || !MathUtil.Approximately(current, GetAxisLineXOrY()))
                            {
                                ChartDrawer.DrawLineStyle(vh,
                                                          lineType,
                                                          lineWidth,
                                                          new Vector3(startX, current),
                                                          new Vector3(startX + splitLength, current),
                                                          lineColor);
                            }
                        }
                    }
                }
                current += scaleWidth;
            }
        }
        internal static void DrawAxisTick(VertexHelper vh, Axis axis, AxisTheme theme, DataZoom dataZoom,
                                          Orient orient, float startX, float startY, float axisLength)
        {
            var lineWidth  = axis.axisLine.GetWidth(theme.lineWidth);
            var tickLength = axis.axisTick.GetLength(theme.tickLength);

            if (AxisHelper.NeedShowSplit(axis))
            {
                var size = AxisHelper.GetScaleNumber(axis, axisLength, dataZoom);

                var current = orient == Orient.Horizonal ?
                              startX :
                              startY;

                for (int i = 0; i < size; i++)
                {
                    var scaleWidth = AxisHelper.GetScaleWidth(axis, axisLength, i + 1, dataZoom);
                    if (i == 0 && (!axis.axisTick.showStartTick || axis.axisTick.alignWithLabel))
                    {
                        current += scaleWidth;
                        continue;
                    }
                    if (i == size - 1 && !axis.axisTick.showEndTick)
                    {
                        current += scaleWidth;
                        continue;
                    }
                    if (axis.axisTick.show)
                    {
                        if (orient == Orient.Horizonal)
                        {
                            float pX = axis.IsTime() ?
                                       (startX + axis.GetDistance(axis.GetLabelValue(i), axisLength)) :
                                       current;

                            if (axis.boundaryGap && axis.axisTick.alignWithLabel)
                            {
                                pX -= scaleWidth / 2;
                            }

                            var sY = 0f;
                            var eY = 0f;
                            if ((axis.axisTick.inside && axis.IsBottom()) ||
                                (!axis.axisTick.inside && axis.IsTop()))
                            {
                                sY = startY + lineWidth;
                                eY = sY + tickLength;
                            }
                            else
                            {
                                sY = startY - lineWidth;
                                eY = sY - tickLength;
                            }

                            UGL.DrawLine(vh, new Vector3(pX, sY), new Vector3(pX, eY),
                                         axis.axisTick.GetWidth(theme.tickWidth),
                                         axis.axisTick.GetColor(theme.tickColor));
                        }
                        else
                        {
                            float pY = axis.IsTime() ?
                                       (startY + axis.GetDistance(axis.GetLabelValue(i), axisLength)) :
                                       current;

                            if (axis.boundaryGap && axis.axisTick.alignWithLabel)
                            {
                                pY -= scaleWidth / 2;
                            }

                            var sX = 0f;
                            var eX = 0f;
                            if ((axis.axisTick.inside && axis.IsLeft()) ||
                                (!axis.axisTick.inside && axis.IsRight()))
                            {
                                sX = startX + lineWidth;
                                eX = sX + tickLength;
                            }
                            else
                            {
                                sX = startX - lineWidth;
                                eX = sX - tickLength;
                            }

                            UGL.DrawLine(vh, new Vector3(sX, pY), new Vector3(eX, pY),
                                         axis.axisTick.GetWidth(theme.tickWidth),
                                         axis.axisTick.GetColor(theme.tickColor));
                        }
                    }
                    current += scaleWidth;
                }
            }
            if (axis.show && axis.axisLine.show && axis.axisLine.showArrow)
            {
                var lineY     = startY + axis.offset;
                var inverse   = axis.IsValue() && axis.inverse;
                var axisArrow = axis.axisLine.arrow;
                if (orient == Orient.Horizonal)
                {
                    if (inverse)
                    {
                        var startPos = new Vector3(startX + axisLength, lineY);
                        var arrowPos = new Vector3(startX, lineY);
                        UGL.DrawArrow(vh, startPos, arrowPos, axisArrow.width, axisArrow.height,
                                      axisArrow.offset, axisArrow.dent,
                                      axisArrow.GetColor(axis.axisLine.GetColor(theme.lineColor)));
                    }
                    else
                    {
                        var arrowPosX = startX + axisLength + lineWidth;
                        var startPos  = new Vector3(startX, lineY);
                        var arrowPos  = new Vector3(arrowPosX, lineY);
                        UGL.DrawArrow(vh, startPos, arrowPos, axisArrow.width, axisArrow.height,
                                      axisArrow.offset, axisArrow.dent,
                                      axisArrow.GetColor(axis.axisLine.GetColor(theme.lineColor)));
                    }
                }
                else
                {
                    if (inverse)
                    {
                        var startPos = new Vector3(startX, startY + axisLength);
                        var arrowPos = new Vector3(startX, startY);
                        UGL.DrawArrow(vh, startPos, arrowPos, axisArrow.width, axisArrow.height,
                                      axisArrow.offset, axisArrow.dent,
                                      axisArrow.GetColor(axis.axisLine.GetColor(theme.lineColor)));
                    }
                    else
                    {
                        var startPos = new Vector3(startX, startY);
                        var arrowPos = new Vector3(startX, startY + axisLength + lineWidth);
                        UGL.DrawArrow(vh, startPos, arrowPos, axisArrow.width, axisArrow.height,
                                      axisArrow.offset, axisArrow.dent,
                                      axisArrow.GetColor(axis.axisLine.GetColor(theme.lineColor)));
                    }
                }
            }
        }
        protected void InitAxis(Axis relativedAxis, Orient orient,
                                float axisStartX, float axisStartY, float axisLength, float relativedLength)
        {
            Axis axis = component;

            chart.InitAxisRuntimeData(axis);

            var objName = ChartCached.GetComponentObjectName(axis);
            var axisObj = ChartHelper.AddObject(objName,
                                                chart.transform,
                                                chart.chartMinAnchor,
                                                chart.chartMaxAnchor,
                                                chart.chartPivot,
                                                chart.chartSizeDelta);

            axisObj.SetActive(axis.show);
            axisObj.hideFlags = chart.chartHideFlags;
            ChartHelper.HideAllObject(axisObj);

            axis.gameObject = axisObj;
            axis.context.labelObjectList.Clear();

            if (!axis.show)
            {
                return;
            }

            var axisLabelTextStyle = axis.axisLabel.textStyle;
            var dataZoom           = chart.GetDataZoomOfAxis(axis);
            var splitNumber        = AxisHelper.GetScaleNumber(axis, axisLength, dataZoom);
            var totalWidth         = 0f;
            var eachWidth          = AxisHelper.GetEachWidth(axis, axisLength, dataZoom);
            var gapWidth           = axis.boundaryGap ? eachWidth / 2 : 0;

            var textWidth = axis.axisLabel.width > 0 ?
                            axis.axisLabel.width :
                            (orient == Orient.Horizonal ?
                             AxisHelper.GetScaleWidth(axis, axisLength, 0, dataZoom) :
                             (axisStartX - chart.chartX)
                            );

            var textHeight = axis.axisLabel.height > 0 ?
                             axis.axisLabel.height :
                             20f;

            var isPercentStack   = SeriesHelper.IsPercentStack <Bar>(chart.series);
            var inside           = axis.axisLabel.inside;
            var defaultAlignment = orient == Orient.Horizonal ? TextAnchor.MiddleCenter :
                                   ((inside && axis.IsLeft()) || (!inside && axis.IsRight()) ?
                                    TextAnchor.MiddleLeft :
                                    TextAnchor.MiddleRight);

            if (axis.IsCategory() && axis.boundaryGap)
            {
                splitNumber -= 1;
            }

            for (int i = 0; i < splitNumber; i++)
            {
                var labelWidth = AxisHelper.GetScaleWidth(axis, axisLength, i + 1, dataZoom);
                var labelName  = AxisHelper.GetLabelName(axis, axisLength, i,
                                                         axis.context.minValue,
                                                         axis.context.maxValue,
                                                         dataZoom, isPercentStack);

                var label = ChartHelper.AddAxisLabelObject(splitNumber, i,
                                                           ChartCached.GetAxisLabelName(i),
                                                           axisObj.transform,
                                                           new Vector2(textWidth, textHeight),
                                                           axis, chart.theme.axis, labelName,
                                                           Color.clear,
                                                           defaultAlignment);

                if (i == 0)
                {
                    axis.axisLabel.SetRelatedText(label.text, labelWidth);
                }

                var pos = GetLabelPosition(totalWidth + gapWidth, i);
                label.SetPosition(pos);
                CheckValueLabelActive(axis, i, label, pos);

                axis.context.labelObjectList.Add(label);

                totalWidth += labelWidth;
            }
            if (axis.axisName.show)
            {
                ChartLabel label         = null;
                var        relativedDist = (relativedAxis == null ? 0 : relativedAxis.context.offset);
                var        zeroPos       = new Vector3(axisStartX, axisStartY + relativedDist);
                var        offset        = axis.axisName.labelStyle.offset;
                var        autoColor     = axis.axisLine.GetColor(chart.theme.axis.lineColor);
                if (orient == Orient.Horizonal)
                {
                    var grid = chart.GetChartComponent <GridCoord>(axis.gridIndex);
                    var posY = !axis.axisName.onZero && grid != null? grid.context.y : GetAxisLineXOrY() + offset.y;
                    switch (axis.axisName.labelStyle.position)
                    {
                    case LabelStyle.Position.Start:

                        label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
                                                          chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleRight);
                        label.SetActive(axis.axisName.labelStyle.show);
                        label.SetPosition(axis.position == Axis.AxisPosition.Top ?
                                          new Vector2(zeroPos.x - offset.x, axisStartY + relativedLength + offset.y + axis.offset) :
                                          new Vector2(zeroPos.x - offset.x, posY));
                        break;

                    case LabelStyle.Position.Middle:

                        label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
                                                          chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
                        label.SetActive(axis.axisName.labelStyle.show);
                        label.SetPosition(axis.position == Axis.AxisPosition.Top ?
                                          new Vector2(axisStartX + axisLength / 2 + offset.x, axisStartY + relativedLength - offset.y + axis.offset) :
                                          new Vector2(axisStartX + axisLength / 2 + offset.x, posY));
                        break;

                    default:

                        label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
                                                          chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleLeft);
                        label.SetActive(axis.axisName.labelStyle.show);
                        label.SetPosition(axis.position == Axis.AxisPosition.Top ?
                                          new Vector2(axisStartX + axisLength + offset.x, axisStartY + relativedLength + offset.y + axis.offset) :
                                          new Vector2(axisStartX + axisLength + offset.x, posY));
                        break;
                    }
                }
                else
                {
                    var grid = chart.GetChartComponent <GridCoord>(axis.gridIndex);
                    var posX = !axis.axisName.onZero && grid != null? grid.context.x : GetAxisLineXOrY() + offset.x;
                    switch (axis.axisName.labelStyle.position)
                    {
                    case LabelStyle.Position.Start:

                        label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
                                                          chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
                        label.SetActive(axis.axisName.labelStyle.show);
                        label.SetPosition(axis.position == Axis.AxisPosition.Right ?
                                          new Vector2(axisStartX + relativedLength + offset.x + axis.offset, axisStartY - offset.y) :
                                          new Vector2(posX, axisStartY - offset.y));
                        break;

                    case LabelStyle.Position.Middle:

                        label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
                                                          chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
                        label.SetActive(axis.axisName.labelStyle.show);
                        label.SetPosition(axis.position == Axis.AxisPosition.Right ?
                                          new Vector2(axisStartX + relativedLength - offset.x + axis.offset, axisStartY + axisLength / 2 + offset.y) :
                                          new Vector2(posX, axisStartY + axisLength / 2 + offset.y));
                        break;

                    default:
                        //LabelStyle.Position
                        label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
                                                          chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
                        label.SetActive(axis.axisName.labelStyle.show);
                        label.SetPosition(axis.position == Axis.AxisPosition.Right ?
                                          new Vector2(axisStartX + relativedLength + offset.x + axis.offset, axisStartY + axisLength + offset.y) :
                                          new Vector2(posX, axisStartY + axisLength + offset.y));
                        break;
                    }
                }
            }
        }
        protected virtual void UpdatePointerValue(Axis axis)
        {
            var grid = chart.GetChartComponent <GridCoord>(axis.gridIndex);

            if (grid == null)
            {
                return;
            }
            if (!grid.context.isPointerEnter)
            {
                axis.context.pointerValue = double.PositiveInfinity;
            }
            else
            {
                var lastPointerValue = axis.context.pointerValue;
                if (axis.IsCategory())
                {
                    var dataZoom  = chart.GetDataZoomOfAxis(axis);
                    var dataCount = chart.series.Count > 0 ? chart.series[0].GetDataList(dataZoom).Count : 0;
                    var local     = chart.pointerPos;
                    if (axis is YAxis)
                    {
                        float splitWid = AxisHelper.GetDataWidth(axis, grid.context.height, dataCount, dataZoom);
                        for (int j = 0; j < axis.GetDataCount(dataZoom); j++)
                        {
                            float pY = grid.context.y + j * splitWid;
                            if ((axis.boundaryGap && (local.y > pY && local.y <= pY + splitWid)) ||
                                (!axis.boundaryGap && (local.y > pY - splitWid / 2 && local.y <= pY + splitWid / 2)))
                            {
                                axis.context.pointerValue         = j;
                                axis.context.pointerLabelPosition = axis.GetLabelObjectPosition(j);
                                if (j != lastPointerValue)
                                {
                                    if (chart.onAxisPointerValueChanged != null)
                                    {
                                        chart.onAxisPointerValueChanged(axis, j);
                                    }
                                }
                                break;
                            }
                        }
                    }
                    else
                    {
                        float splitWid = AxisHelper.GetDataWidth(axis, grid.context.width, dataCount, dataZoom);
                        for (int j = 0; j < axis.GetDataCount(dataZoom); j++)
                        {
                            float pX = grid.context.x + j * splitWid;
                            if ((axis.boundaryGap && (local.x > pX && local.x <= pX + splitWid)) ||
                                (!axis.boundaryGap && (local.x > pX - splitWid / 2 && local.x <= pX + splitWid / 2)))
                            {
                                axis.context.pointerValue         = j;
                                axis.context.pointerLabelPosition = axis.GetLabelObjectPosition(j);
                                if (j != lastPointerValue)
                                {
                                    if (chart.onAxisPointerValueChanged != null)
                                    {
                                        chart.onAxisPointerValueChanged(axis, j);
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
                else
                {
                    if (axis is YAxis)
                    {
                        var yRate  = axis.context.minMaxRange / grid.context.height;
                        var yValue = yRate * (chart.pointerPos.y - grid.context.y - axis.context.offset);
                        if (axis.context.minValue > 0)
                        {
                            yValue += axis.context.minValue;
                        }

                        var labelX = axis.GetLabelObjectPosition(0).x;
                        axis.context.pointerValue         = yValue;
                        axis.context.pointerLabelPosition = new Vector3(labelX, chart.pointerPos.y);
                        if (yValue != lastPointerValue)
                        {
                            if (chart.onAxisPointerValueChanged != null)
                            {
                                chart.onAxisPointerValueChanged(axis, yValue);
                            }
                        }
                    }
                    else
                    {
                        var xRate  = axis.context.minMaxRange / grid.context.width;
                        var xValue = xRate * (chart.pointerPos.x - grid.context.x - axis.context.offset);
                        if (axis.context.minValue > 0)
                        {
                            xValue += axis.context.minValue;
                        }

                        var labelY = axis.GetLabelObjectPosition(0).y;
                        axis.context.pointerValue         = xValue;
                        axis.context.pointerLabelPosition = new Vector3(chart.pointerPos.x, labelY);
                        if (xValue != lastPointerValue)
                        {
                            if (chart.onAxisPointerValueChanged != null)
                            {
                                chart.onAxisPointerValueChanged(axis, xValue);
                            }
                        }
                    }
                }
            }
        }