Ejemplo n.º 1
0
        /// <summary>
        /// 给定的线段和Grid边界的交点
        /// </summary>
        /// <param name="sp"></param>
        /// <param name="ep"></param>
        /// <returns></returns>
        public bool BoundaryPoint(Vector3 sp, Vector3 ep, ref Vector3 point)
        {
            if (Contains(sp) && Contains(ep))
            {
                point = ep;
                return(false);
            }
            var lb = new Vector3(context.x, context.y);
            var lt = new Vector3(context.x, context.y + context.height);
            var rt = new Vector3(context.x + context.width, context.y + context.height);
            var rb = new Vector3(context.x + context.width, context.y);

            if (UGLHelper.GetIntersection(sp, ep, rb, rt, ref point))
            {
                return(true);
            }
            if (UGLHelper.GetIntersection(sp, ep, lt, rt, ref point))
            {
                return(true);
            }
            if (UGLHelper.GetIntersection(sp, ep, lb, rb, ref point))
            {
                return(true);
            }
            if (UGLHelper.GetIntersection(sp, ep, lb, lt, ref point))
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        private static void UpdateSmoothLineDrawPoints(Serie serie, Settings setting, bool isY)
        {
            var   points     = serie.context.dataPoints;
            float smoothness = setting.lineSmoothness;

            for (int i = 0; i < points.Count - 1; i++)
            {
                var sp     = points[i];
                var ep     = points[i + 1];
                var lsp    = i > 0 ? points[i - 1] : sp;
                var nep    = i < points.Count - 2 ? points[i + 2] : ep;
                var ignore = serie.context.dataIgnores[i];
                if (isY)
                {
                    UGLHelper.GetBezierListVertical(ref s_CurvesPosList, sp, ep, smoothness, setting.lineSmoothStyle);
                }
                else
                {
                    UGLHelper.GetBezierList(ref s_CurvesPosList, sp, ep, lsp, nep, smoothness, setting.lineSmoothStyle, true);
                }

                for (int j = 1; j < s_CurvesPosList.Count; j++)
                {
                    serie.context.drawPoints.Add(new PointInfo(s_CurvesPosList[j], ignore));
                }
            }
        }
Ejemplo n.º 3
0
        public static bool GetAnimationPosition(AnimationStyle animation, bool isY, Vector3 lp, Vector3 cp, float progress, ref Vector3 ip)
        {
            if (animation.context.type == AnimationType.AlongPath)
            {
                var dist = Vector3.Distance(lp, cp);
                var rate = (dist - animation.context.currentPathDistance + animation.GetCurrDetail()) / dist;
                ip = Vector3.Lerp(lp, cp, rate);
                return(true);
            }
            else
            {
                var startPos = isY ? new Vector3(-10000, progress) : new Vector3(progress, -10000);
                var endPos   = isY ? new Vector3(10000, progress) : new Vector3(progress, 10000);

                return(UGLHelper.GetIntersection(lp, cp, startPos, endPos, ref ip));
            }
        }
Ejemplo n.º 4
0
 public bool IsInPolygon(Vector2 p)
 {
     return(UGLHelper.IsPointInPolygon(p, m_PolygonPoints));
 }
Ejemplo n.º 5
0
        private void DrawParallelSerie(VertexHelper vh, Parallel serie)
        {
            if (!serie.show)
            {
                return;
            }
            if (serie.animation.HasFadeOut())
            {
                return;
            }

            var parallel = chart.GetChartComponent <ParallelCoord>(serie.parallelIndex);

            if (parallel == null)
            {
                return;
            }

            var axisCount = parallel.context.parallelAxes.Count;

            if (axisCount <= 0)
            {
                return;
            }

            var animationIndex = serie.animation.GetCurrIndex();
            var isHorizonal    = parallel.orient == Orient.Horizonal;
            var lineColor      = SerieHelper.GetLineColor(serie, null, chart.theme, serie.context.colorIndex, false);
            var lineWidth      = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth);

            float currDetailProgress = !isHorizonal ?
                                       parallel.context.x :
                                       parallel.context.y;

            float totalDetailProgress = !isHorizonal ?
                                        parallel.context.x + parallel.context.width :
                                        parallel.context.y + parallel.context.height;

            serie.animation.InitProgress(currDetailProgress, totalDetailProgress);

            serie.context.dataPoints.Clear();
            serie.containerIndex       = parallel.index;
            serie.containterInstanceId = parallel.instanceId;

            var currProgress = serie.animation.GetCurrDetail();
            var isSmooth     = serie.lineType == LineType.Smooth;

            foreach (var serieData in serie.data)
            {
                m_Points.Clear();
                var count = Mathf.Min(axisCount, serieData.data.Count);
                var lp    = Vector3.zero;
                for (int i = 0; i < count; i++)
                {
                    if (animationIndex >= 0 && i > animationIndex)
                    {
                        continue;
                    }
                    var pos = GetPos(parallel, i, serieData.data[i], isHorizonal);
                    if (!isHorizonal)
                    {
                        if (isSmooth)
                        {
                            m_Points.Add(pos);
                        }
                        else if (pos.x <= currProgress)
                        {
                            m_Points.Add(pos);
                        }
                        else
                        {
                            var currProgressStart = new Vector3(currProgress, parallel.context.y - 50);
                            var currProgressEnd   = new Vector3(currProgress, parallel.context.y + parallel.context.height + 50);
                            var intersectionPos   = Vector3.zero;

                            if (UGLHelper.GetIntersection(lp, pos, currProgressStart, currProgressEnd, ref intersectionPos))
                            {
                                m_Points.Add(intersectionPos);
                            }
                            else
                            {
                                m_Points.Add(pos);
                            }
                            break;
                        }
                    }
                    else
                    {
                        if (isSmooth)
                        {
                            m_Points.Add(pos);
                        }
                        else if (pos.y <= currProgress)
                        {
                            m_Points.Add(pos);
                        }
                        else
                        {
                            var currProgressStart = new Vector3(parallel.context.x - 50, currProgress);
                            var currProgressEnd   = new Vector3(parallel.context.x + parallel.context.width + 50, currProgress);
                            var intersectionPos   = Vector3.zero;

                            if (UGLHelper.GetIntersection(lp, pos, currProgressStart, currProgressEnd, ref intersectionPos))
                            {
                                m_Points.Add(intersectionPos);
                            }
                            else
                            {
                                m_Points.Add(pos);
                            }
                            break;
                        }
                    }
                    lp = pos;
                }
                if (isSmooth)
                {
                    UGL.DrawCurves(vh, m_Points, lineWidth, lineColor, chart.settings.lineSmoothness, currProgress, isHorizonal);
                }
                else
                {
                    UGL.DrawLine(vh, m_Points, lineWidth, lineColor, isSmooth);
                }
            }
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(totalDetailProgress - currDetailProgress);
                chart.RefreshPainter(serie);
            }
        }
        private void DrawPolarLine(VertexHelper vh, Serie serie)
        {
            var datas = serie.data;

            if (datas.Count <= 0)
            {
                return;
            }

            m_SeriePolar = chart.GetChartComponent <PolarCoord>(serie.polarIndex);
            if (m_SeriePolar == null)
            {
                return;
            }

            var m_AngleAxis  = ComponentHelper.GetAngleAxis(chart.components, m_SeriePolar.index);
            var m_RadiusAxis = ComponentHelper.GetRadiusAxis(chart.components, m_SeriePolar.index);

            if (m_AngleAxis == null || m_RadiusAxis == null)
            {
                return;
            }

            var startAngle = m_AngleAxis.startAngle;
            var radius     = m_SeriePolar.context.radius;

            var min                 = m_RadiusAxis.context.minValue;
            var max                 = m_RadiusAxis.context.maxValue;
            var firstSerieData      = datas[0];
            var lp                  = GetPolarPos(m_SeriePolar, m_AngleAxis, firstSerieData, min, max, radius);
            var cp                  = Vector3.zero;
            var lineColor           = SerieHelper.GetLineColor(serie, null, chart.theme, serie.index, serie.highlight);
            var lineWidth           = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth);
            var currDetailProgress  = 0f;
            var totalDetailProgress = datas.Count;

            serie.animation.InitProgress(currDetailProgress, totalDetailProgress);

            var  ltp = Vector3.zero;
            var  lbp = Vector3.zero;
            var  ntp = Vector3.zero;
            var  nbp = Vector3.zero;
            var  itp = Vector3.zero;
            var  ibp = Vector3.zero;
            var  clp = Vector3.zero;
            var  crp = Vector3.zero;
            bool bitp = true, bibp = true;

            for (int i = 1; i < datas.Count; i++)
            {
                if (serie.animation.CheckDetailBreak(i))
                {
                    break;
                }

                var serieData = datas[i];

                cp = GetPolarPos(m_SeriePolar, m_AngleAxis, datas[i], min, max, radius);
                var np = i == datas.Count - 1 ? cp :
                         GetPolarPos(m_SeriePolar, m_AngleAxis, datas[i + 1], min, max, radius);

                UGLHelper.GetLinePoints(lp, cp, np, lineWidth,
                                        ref ltp, ref lbp,
                                        ref ntp, ref nbp,
                                        ref itp, ref ibp,
                                        ref clp, ref crp,
                                        ref bitp, ref bibp, i);

                if (i == 1)
                {
                    UGL.AddVertToVertexHelper(vh, ltp, lbp, lineColor, false);
                }

                if (bitp == bibp)
                {
                    if (bitp)
                    {
                        UGL.AddVertToVertexHelper(vh, itp, ibp, lineColor, true);
                    }
                    else
                    {
                        UGL.AddVertToVertexHelper(vh, ltp, clp, lineColor, true);
                        UGL.AddVertToVertexHelper(vh, ltp, crp, lineColor, true);
                    }
                }
                else
                {
                    if (bitp)
                    {
                        UGL.AddVertToVertexHelper(vh, itp, clp, lineColor, true);
                        UGL.AddVertToVertexHelper(vh, itp, crp, lineColor, true);
                    }
                    else if (bibp)
                    {
                        UGL.AddVertToVertexHelper(vh, clp, ibp, lineColor, true);
                        UGL.AddVertToVertexHelper(vh, crp, ibp, lineColor, true);
                    }
                }
                lp = cp;
            }

            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(totalDetailProgress);
                serie.animation.CheckSymbol(serie.symbol.GetSize(null, chart.theme.serie.lineSymbolSize));
                chart.RefreshChart();
            }
        }
Ejemplo n.º 7
0
        public void DrawSerie(VertexHelper vh, Serie serie)
        {
            if (serie.type != SerieType.Ring)
            {
                return;
            }
            if (!serie.show || serie.animation.HasFadeOut())
            {
                return;
            }
            var data = serie.data;

            serie.animation.InitProgress(data.Count, serie.startAngle, serie.startAngle + 360);
            SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight);
            TitleStyleHelper.CheckTitle(serie, ref chart.m_ReinitTitle, ref m_UpdateTitleText);
            SerieLabelHelper.CheckLabel(serie, ref chart.m_ReinitLabel, ref m_UpdateLabelText);
            var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
            var ringWidth          = serie.runtimeOutsideRadius - serie.runtimeInsideRadius;
            var dataChanging       = false;

            for (int j = 0; j < data.Count; j++)
            {
                var serieData = data[j];
                if (!serieData.show)
                {
                    continue;
                }
                if (serieData.IsDataChanged())
                {
                    dataChanging = true;
                }
                var value         = serieData.GetFirstData(dataChangeDuration);
                var max           = serieData.GetLastData();
                var degree        = (float)(360 * value / max);
                var startDegree   = GetStartAngle(serie);
                var toDegree      = GetToAngle(serie, degree);
                var itemStyle     = SerieHelper.GetItemStyle(serie, serieData, serieData.highlighted);
                var itemColor     = SerieHelper.GetItemColor(serie, serieData, chart.theme, j, serieData.highlighted);
                var itemToColor   = SerieHelper.GetItemToColor(serie, serieData, chart.theme, j, serieData.highlighted);
                var outsideRadius = serie.runtimeOutsideRadius - j * (ringWidth + serie.ringGap);
                var insideRadius  = outsideRadius - ringWidth;
                var centerRadius  = (outsideRadius + insideRadius) / 2;
                var borderWidth   = itemStyle.borderWidth;
                var borderColor   = itemStyle.borderColor;
                var roundCap      = serie.roundCap && insideRadius > 0;

                serieData.runtimePieStartAngle    = serie.clockwise ? startDegree : toDegree;
                serieData.runtimePieToAngle       = serie.clockwise ? toDegree : startDegree;
                serieData.runtimePieInsideRadius  = insideRadius;
                serieData.runtimePieOutsideRadius = outsideRadius;
                if (itemStyle.backgroundColor.a != 0)
                {
                    UGL.DrawDoughnut(vh, serie.runtimeCenterPos, insideRadius, outsideRadius, itemStyle.backgroundColor,
                                     itemStyle.backgroundColor, Color.clear, 0, 360, borderWidth, borderColor, 0,
                                     chart.settings.cicleSmoothness, false, serie.clockwise);
                }
                var isGradient = !UGLHelper.IsValueEqualsColor(itemColor, itemToColor);
                if (isGradient)
                {
                    if (serie.clockwise)
                    {
                        itemToColor = Color.Lerp(itemColor, itemToColor, toDegree / (startDegree + 360));
                    }
                    else
                    {
                        itemToColor = Color.Lerp(itemToColor, itemColor, toDegree / (startDegree + 360));
                    }
                }
                UGL.DrawDoughnut(vh, serie.runtimeCenterPos, insideRadius, outsideRadius, itemColor, itemToColor,
                                 Color.clear, startDegree, toDegree, borderWidth, borderColor, 0, chart.settings.cicleSmoothness,
                                 roundCap, serie.clockwise);
                DrawCenter(vh, serie, serieData, insideRadius, j == data.Count - 1);
                UpateLabelPosition(serie, serieData, j, startDegree, toDegree, centerRadius);
            }
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(360);
                chart.RefreshChart();
            }
            if (dataChanging)
            {
                chart.RefreshChart();
            }
        }
Ejemplo n.º 8
0
        private void UpdateSerieContext()
        {
            var needCheck = m_LegendEnter ||
                            (chart.isPointerInChart && (m_RadarCoord != null && m_RadarCoord.IsPointerEnter()));
            var needInteract = false;
            var needHideAll  = false;

            if (!needCheck)
            {
                if (m_LastCheckContextFlag == needCheck)
                {
                    return;
                }
                needHideAll = true;
            }
            m_LastCheckContextFlag             = needCheck;
            serie.context.pointerEnter         = false;
            serie.context.pointerItemDataIndex = -1;
            var areaStyle = serie.areaStyle;

            switch (serie.radarType)
            {
            case RadarType.Multiple:
                for (int i = 0; i < serie.data.Count; i++)
                {
                    var serieData = serie.data[i];
                    serieData.index = i;
                    var symbol     = SerieHelper.GetSerieSymbol(serie, serieData);
                    var symbolSize = symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
                    if (needHideAll || m_LegendEnter)
                    {
                        serieData.context.highlight = needHideAll ? false : true;
                        serieData.interact.SetValue(ref needInteract, symbolSize, serieData.context.highlight);
                    }
                    else
                    {
                        serieData.context.highlight = false;
                        foreach (var pos in serieData.context.dataPoints)
                        {
                            if (Vector3.Distance(chart.pointerPos, pos) < symbolSize * 2)
                            {
                                serie.context.pointerEnter         = true;
                                serie.context.pointerItemDataIndex = i;
                                serieData.context.highlight        = true;
                                break;
                            }
                        }
                        if (!serieData.context.highlight && areaStyle != null)
                        {
                            var center     = m_RadarCoord.context.center;
                            var dataPoints = serieData.context.dataPoints;
                            for (int n = 0; n < dataPoints.Count; n++)
                            {
                                var p1 = dataPoints[n];
                                var p2 = n >= dataPoints.Count - 1 ? dataPoints[0] : dataPoints[n + 1];
                                if (UGLHelper.IsPointInTriangle(p1, center, p2, chart.pointerPos))
                                {
                                    serie.context.pointerEnter         = true;
                                    serie.context.pointerItemDataIndex = i;
                                    serieData.context.highlight        = true;
                                    break;
                                }
                            }
                        }
                        serieData.interact.SetValue(ref needInteract, symbolSize, serieData.context.highlight);
                    }
                }
                break;

            case RadarType.Single:
                for (int i = 0; i < serie.data.Count; i++)
                {
                    var serieData = serie.data[i];
                    serieData.index = i;
                    if (Vector3.Distance(chart.pointerPos, serieData.context.position) < serie.symbol.size * 2)
                    {
                        serie.context.pointerEnter         = true;
                        serie.context.pointerItemDataIndex = i;
                        return;
                    }
                }
                if (!serie.context.pointerEnter && areaStyle != null)
                {
                    var center     = m_RadarCoord.context.center;
                    var dataPoints = serie.data;
                    for (int n = 0; n < dataPoints.Count; n++)
                    {
                        var p1 = dataPoints[n];
                        var p2 = n >= dataPoints.Count - 1 ? dataPoints[0] : dataPoints[n + 1];
                        if (UGLHelper.IsPointInTriangle(p1.context.position, center, p2.context.position, chart.pointerPos))
                        {
                            serie.context.pointerEnter         = true;
                            serie.context.pointerItemDataIndex = n;
                            p1.context.highlight = true;
                            break;
                        }
                    }
                }
                break;
            }
            if (needInteract)
            {
                chart.RefreshPainter(serie);
            }
        }
Ejemplo n.º 9
0
        private static void DrawSerieLineNormalArea(VertexHelper vh, Serie serie, bool isY,
                                                    float zero, float min, float max, Color32 areaColor, Color32 areaToColor,
                                                    VisualMap visualMap, Axis axis, Axis relativedAxis, GridCoord grid)
        {
            var points = serie.context.drawPoints;
            var count  = points.Count;

            if (count < 2)
            {
                return;
            }

            var isBreak             = false;
            var lp                  = Vector3.zero;
            var isVisualMapGradient = VisualMapHelper.IsNeedAreaGradient(visualMap);
            var areaLerp            = !ChartHelper.IsValueEqualsColor(areaColor, areaToColor);
            var zsp                 = isY ?
                                      new Vector3(zero, points[0].position.y) :
                                      new Vector3(points[0].position.x, zero);
            var zep = isY ?
                      new Vector3(zero, points[count - 1].position.y) :
                      new Vector3(points[count - 1].position.x, zero);

            var lastDataIsIgnore = false;

            for (int i = 0; i < points.Count; i++)
            {
                var tp       = points[i].position;
                var isIgnore = points[i].isIgnoreBreak;
                var color    = areaColor;
                var toColor  = areaToColor;
                var lerp     = areaLerp;

                if (serie.animation.CheckDetailBreak(tp, isY))
                {
                    isBreak = true;

                    var progress     = serie.animation.GetCurrDetail();
                    var ip           = Vector3.zero;
                    var axisStartPos = isY ? new Vector3(-10000, progress) : new Vector3(progress, -10000);
                    var axisEndPos   = isY ? new Vector3(10000, progress) : new Vector3(progress, 10000);

                    if (UGLHelper.GetIntersection(lp, tp, axisStartPos, axisEndPos, ref ip))
                    {
                        tp = ip;
                    }
                }
                var zp = isY ? new Vector3(zero, tp.y) : new Vector3(tp.x, zero);
                if (isVisualMapGradient)
                {
                    color   = VisualMapHelper.GetLineGradientColor(visualMap, zp, grid, axis, relativedAxis, areaColor);
                    toColor = VisualMapHelper.GetLineGradientColor(visualMap, tp, grid, axis, relativedAxis, areaToColor);
                    lerp    = true;
                }
                if (i > 0)
                {
                    if ((lp.y - zero > 0 && tp.y - zero < 0) || (lp.y - zero < 0 && tp.y - zero > 0))
                    {
                        var ip = Vector3.zero;
                        if (UGLHelper.GetIntersection(lp, tp, zsp, zep, ref ip))
                        {
                            if (lerp)
                            {
                                AddVertToVertexHelperWithLerpColor(vh, ip, ip, color, toColor, isY, min, max, i > 0);
                            }
                            else
                            {
                                if (lastDataIsIgnore)
                                {
                                    UGL.AddVertToVertexHelper(vh, ip, ip, ColorUtil.clearColor32, true);
                                }

                                UGL.AddVertToVertexHelper(vh, ip, ip, toColor, color, i > 0);

                                if (isIgnore)
                                {
                                    UGL.AddVertToVertexHelper(vh, ip, ip, ColorUtil.clearColor32, true);
                                }
                            }
                        }
                    }
                }

                if (lerp)
                {
                    AddVertToVertexHelperWithLerpColor(vh, tp, zp, color, toColor, isY, min, max, i > 0);
                }
                else
                {
                    if (lastDataIsIgnore)
                    {
                        UGL.AddVertToVertexHelper(vh, tp, zp, ColorUtil.clearColor32, true);
                    }

                    UGL.AddVertToVertexHelper(vh, tp, zp, toColor, color, i > 0);

                    if (isIgnore)
                    {
                        UGL.AddVertToVertexHelper(vh, tp, zp, ColorUtil.clearColor32, true);
                    }
                }
                lp = tp;
                lastDataIsIgnore = isIgnore;
                if (isBreak)
                {
                    break;
                }
            }
        }
Ejemplo n.º 10
0
        internal static void DrawSerieLine(VertexHelper vh, ThemeStyle theme, Serie serie, VisualMap visualMap,
                                           GridCoord grid, Axis axis, Axis relativedAxis, float lineWidth)
        {
            if (!serie.lineStyle.show || serie.lineStyle.type == LineStyle.Type.None)
            {
                return;
            }

            var datas = serie.context.drawPoints;

            var dataCount = datas.Count;

            if (dataCount < 2)
            {
                return;
            }

            var ltp = Vector3.zero;
            var lbp = Vector3.zero;
            var ntp = Vector3.zero;
            var nbp = Vector3.zero;
            var itp = Vector3.zero;
            var ibp = Vector3.zero;
            var clp = Vector3.zero;
            var crp = Vector3.zero;

            var isBreak             = false;
            var isY                 = axis is YAxis;
            var isVisualMapGradient = VisualMapHelper.IsNeedLineGradient(visualMap);
            var isLineStyleGradient = serie.lineStyle.IsNeedGradient();

            //var highlight = serie.highlight || serie.context.pointerEnter;
            var lineColor = SerieHelper.GetLineColor(serie, null, theme, serie.context.colorIndex, false);

            var lastDataIsIgnore = datas[0].isIgnoreBreak;
            var smooth           = serie.lineType == LineType.Smooth;

            for (int i = 1; i < dataCount; i++)
            {
                var cdata    = datas[i];
                var isIgnore = cdata.isIgnoreBreak;

                var cp = cdata.position;
                var lp = datas[i - 1].position;

                var np = i == dataCount - 1 ? cp : datas[i + 1].position;
                if (serie.animation.CheckDetailBreak(cp, isY))
                {
                    isBreak = true;
                    var ip       = Vector3.zero;
                    var progress = serie.animation.GetCurrDetail();
                    if (AnimationStyleHelper.GetAnimationPosition(serie.animation, isY, lp, cp, progress, ref ip))
                    {
                        cp = np = ip;
                    }
                }
                serie.context.lineEndPostion = cp;
                serie.context.lineEndValue   = AxisHelper.GetAxisPositionValue(grid, relativedAxis, cp);
                lastDataIsIgnore             = isIgnore;
                var handled = false;
                if (!smooth)
                {
                    switch (serie.lineStyle.type)
                    {
                    case LineStyle.Type.Dashed:
                        UGL.DrawDashLine(vh, lp, cp, lineWidth, lineColor, lineColor, 0, 0);
                        handled = true;
                        break;

                    case LineStyle.Type.Dotted:
                        UGL.DrawDotLine(vh, lp, cp, lineWidth, lineColor, lineColor, 0, 0);
                        handled = true;
                        break;

                    case LineStyle.Type.DashDot:
                        UGL.DrawDashDotLine(vh, lp, cp, lineWidth, lineColor, 0, 0, 0);
                        handled = true;
                        break;

                    case LineStyle.Type.DashDotDot:
                        UGL.DrawDashDotDotLine(vh, lp, cp, lineWidth, lineColor, 0, 0, 0);
                        handled = true;
                        break;

                    case LineStyle.Type.None:
                        handled = true;
                        break;
                    }
                }
                if (handled)
                {
                    if (isBreak)
                    {
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
                bool bitp = true, bibp = true;
                UGLHelper.GetLinePoints(lp, cp, np, lineWidth,
                                        ref ltp, ref lbp,
                                        ref ntp, ref nbp,
                                        ref itp, ref ibp,
                                        ref clp, ref crp,
                                        ref bitp, ref bibp, i);
                if (i == 1)
                {
                    AddLineVertToVertexHelper(vh, ltp, lbp, lineColor, isVisualMapGradient, isLineStyleGradient,
                                              visualMap, serie.lineStyle, grid, axis, relativedAxis, false, lastDataIsIgnore, isIgnore);
                    if (dataCount == 2 || isBreak)
                    {
                        AddLineVertToVertexHelper(vh, clp, crp, lineColor, isVisualMapGradient, isLineStyleGradient,
                                                  visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
                        serie.context.lineEndPostion = cp;
                        serie.context.lineEndValue   = AxisHelper.GetAxisPositionValue(grid, relativedAxis, cp);
                        break;
                    }
                }

                if (bitp == bibp)
                {
                    if (bitp)
                    {
                        AddLineVertToVertexHelper(vh, itp, ibp, lineColor, isVisualMapGradient, isLineStyleGradient,
                                                  visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
                    }
                    else
                    {
                        AddLineVertToVertexHelper(vh, ltp, clp, lineColor, isVisualMapGradient, isLineStyleGradient,
                                                  visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
                        AddLineVertToVertexHelper(vh, ltp, crp, lineColor, isVisualMapGradient, isLineStyleGradient,
                                                  visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
                    }
                }
                else
                {
                    if (bitp)
                    {
                        AddLineVertToVertexHelper(vh, itp, clp, lineColor, isVisualMapGradient, isLineStyleGradient,
                                                  visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
                        AddLineVertToVertexHelper(vh, itp, crp, lineColor, isVisualMapGradient, isLineStyleGradient,
                                                  visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
                    }
                    else if (bibp)
                    {
                        AddLineVertToVertexHelper(vh, clp, ibp, lineColor, isVisualMapGradient, isLineStyleGradient,
                                                  visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
                        AddLineVertToVertexHelper(vh, crp, ibp, lineColor, isVisualMapGradient, isLineStyleGradient,
                                                  visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
                    }
                }

                if (isBreak)
                {
                    break;
                }
            }
        }
Ejemplo n.º 11
0
        private static void DrawSerieLineStackArea(VertexHelper vh, Serie serie, Serie lastStackSerie, bool isY,
                                                   float zero, float min, float max, Color32 color, Color32 toColor, VisualMap visualMap)
        {
            if (lastStackSerie == null)
            {
                return;
            }

            var upPoints   = serie.context.drawPoints;
            var downPoints = lastStackSerie.context.drawPoints;
            var upCount    = upPoints.Count;
            var downCount  = downPoints.Count;

            if (upCount <= 0 || downCount <= 0)
            {
                return;
            }

            var lerp = !ChartHelper.IsValueEqualsColor(color, toColor);
            var ltp  = upPoints[0].position;
            var lbp  = downPoints[0].position;

            if (lerp)
            {
                AddVertToVertexHelperWithLerpColor(vh, ltp, lbp, color, toColor, isY, min, max, false);
            }
            else
            {
                UGL.AddVertToVertexHelper(vh, ltp, lbp, color, false);
            }

            int u = 1, d = 1;
            var isBreakTop    = false;
            var isBreakBottom = false;

            while ((u < upCount || d < downCount))
            {
                var tp = u < upCount ? upPoints[u].position : upPoints[upCount - 1].position;
                var bp = d < downCount ? downPoints[d].position : downPoints[downCount - 1].position;

                var tnp = (u + 1) < upCount ? upPoints[u + 1].position : upPoints[upCount - 1].position;
                var bnp = (d + 1) < downCount ? downPoints[d + 1].position : downPoints[downCount - 1].position;

                if (serie.animation.CheckDetailBreak(tp, isY))
                {
                    isBreakTop = true;

                    var progress = serie.animation.GetCurrDetail();
                    var ip       = Vector3.zero;

                    if (UGLHelper.GetIntersection(ltp, tp,
                                                  new Vector3(progress, -10000),
                                                  new Vector3(progress, 10000), ref ip))
                    {
                        tp = ip;
                    }
                    else
                    {
                        tp = new Vector3(progress, tp.y);
                    }
                }
                if (serie.animation.CheckDetailBreak(bp, isY))
                {
                    isBreakBottom = true;

                    var progress = serie.animation.GetCurrDetail();
                    var ip       = Vector3.zero;

                    if (UGLHelper.GetIntersection(lbp, bp,
                                                  new Vector3(progress, -10000),
                                                  new Vector3(progress, 10000), ref ip))
                    {
                        bp = ip;
                    }
                    else
                    {
                        bp = new Vector3(progress, bp.y);
                    }
                }

                if (lerp)
                {
                    AddVertToVertexHelperWithLerpColor(vh, tp, bp, color, toColor, isY, min, max, true);
                }
                else
                {
                    UGL.AddVertToVertexHelper(vh, tp, bp, color, true);
                }
                u++;
                d++;
                if (bp.x < tp.x && bnp.x < tp.x)
                {
                    u--;
                }
                if (tp.x < bp.x && tnp.x < bp.x)
                {
                    d--;
                }

                ltp = tp;
                lbp = bp;
                if (isBreakTop && isBreakBottom)
                {
                    break;
                }
            }
        }