Exemplo n.º 1
0
        private static void AddLineVertToVertexHelper(VertexHelper vh, Vector3 tp, Vector3 bp,
                                                      Color32 lineColor, bool visualMapGradient, bool lineStyleGradient, VisualMap visualMap,
                                                      LineStyle lineStyle, GridCoord grid, Axis axis, Axis relativedAxis, bool needTriangle,
                                                      bool lastIgnore, bool ignore)
        {
            if (lastIgnore && needTriangle)
            {
                UGL.AddVertToVertexHelper(vh, tp, bp, ColorUtil.clearColor32, true);
            }

            if (visualMapGradient)
            {
                var color1 = VisualMapHelper.GetLineGradientColor(visualMap, tp, grid, axis, relativedAxis, lineColor);
                var color2 = VisualMapHelper.GetLineGradientColor(visualMap, bp, grid, axis, relativedAxis, lineColor);
                UGL.AddVertToVertexHelper(vh, tp, bp, color1, color2, needTriangle);
            }
            else if (lineStyleGradient)
            {
                var color1 = VisualMapHelper.GetLineStyleGradientColor(lineStyle, tp, grid, axis, lineColor);
                var color2 = VisualMapHelper.GetLineStyleGradientColor(lineStyle, bp, grid, axis, lineColor);
                UGL.AddVertToVertexHelper(vh, tp, bp, color1, color2, needTriangle);
            }
            else
            {
                UGL.AddVertToVertexHelper(vh, tp, bp, lineColor, needTriangle);
            }
            if (lastIgnore && !needTriangle)
            {
                UGL.AddVertToVertexHelper(vh, tp, bp, ColorUtil.clearColor32, false);
            }
            if (ignore && needTriangle)
            {
                UGL.AddVertToVertexHelper(vh, tp, bp, ColorUtil.clearColor32, false);
            }
        }
Exemplo n.º 2
0
        private static void AddVertToVertexHelperWithLerpColor(VertexHelper vh, Vector3 tp, Vector3 bp,
                                                               Color32 color, Color32 toColor, bool isY, float min, float max, bool needTriangle)
        {
            var range  = max - min;
            var color1 = Color32.Lerp(color, toColor, ((isY ? tp.x : tp.y) - min) / range);
            var color2 = Color32.Lerp(color, toColor, ((isY ? bp.x : bp.y) - min) / range);

            UGL.AddVertToVertexHelper(vh, tp, bp, color1, color2, needTriangle);
        }
        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();
            }
        }
Exemplo n.º 4
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;
                }
            }
        }
Exemplo n.º 5
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;
                }
            }
        }