예제 #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);
            }
        }
예제 #2
0
        private void DrawLinePoint(VertexHelper vh, Serie serie)
        {
            if (!serie.show || serie.IsPerformanceMode())
            {
                return;
            }

            if (m_SerieGrid == null)
            {
                return;
            }

            var count               = serie.context.dataPoints.Count;
            var clip                = SeriesHelper.IsAnyClipSerie(chart.series);
            var theme               = chart.theme;
            var interacting         = false;
            var lineArrow           = serie.lineArrow;
            var visualMap           = chart.GetVisualMapOfSerie(serie);
            var isVisualMapGradient = VisualMapHelper.IsNeedLineGradient(visualMap);

            Axis axis;
            Axis relativedAxis;
            var  isY = chart.GetSerieGridCoordAxis(serie, out axis, out relativedAxis);

            for (int i = 0; i < count; i++)
            {
                var serieData = serie.GetSerieData(i);
                if (serieData == null)
                {
                    continue;
                }
                if (serieData.context.isClip)
                {
                    continue;
                }

                var symbol = SerieHelper.GetSerieSymbol(serie, serieData);

                if (!symbol.show || !symbol.ShowSymbol(i, count))
                {
                    continue;
                }

                var pos = serie.context.dataPoints[i];
                if (lineArrow != null && lineArrow.show)
                {
                    if (lineArrow.position == LineArrow.Position.Start && i == 0)
                    {
                        continue;
                    }
                    if (lineArrow.position == LineArrow.Position.End && i == count - 1)
                    {
                        continue;
                    }
                }

                if (ChartHelper.IsIngore(pos))
                {
                    continue;
                }

                var highlight  = serie.data[i].context.highlight || serie.highlight;
                var symbolSize = highlight ?
                                 theme.serie.lineSymbolSelectedSize :
                                 theme.serie.lineSymbolSize;
                if (!serieData.interact.TryGetValue(ref symbolSize, ref interacting))
                {
                    symbolSize = highlight ?
                                 symbol.GetSelectedSize(serieData.data, symbolSize) :
                                 symbol.GetSize(serieData.data, symbolSize);
                    serieData.interact.SetValue(ref interacting, symbolSize);
                    symbolSize = serie.animation.GetSysmbolSize(symbolSize);
                }
                var symbolColor      = SerieHelper.GetItemColor(serie, serieData, theme, serie.index, highlight);
                var symbolToColor    = SerieHelper.GetItemToColor(serie, serieData, theme, serie.index, highlight);
                var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, serie.index, highlight, false);

                if (isVisualMapGradient)
                {
                    symbolColor   = VisualMapHelper.GetLineGradientColor(visualMap, pos, m_SerieGrid, axis, relativedAxis, symbolColor);
                    symbolToColor = symbolColor;
                }
                var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, highlight);
                var borderColor  = SerieHelper.GetSymbolBorderColor(serie, serieData, theme, highlight);
                var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
                chart.DrawClipSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
                                     symbolColor, symbolToColor, symbolEmptyColor, borderColor, symbol.gap, clip, cornerRadius, m_SerieGrid,
                                     i > 0 ? serie.context.dataPoints[i - 1] : m_SerieGrid.context.position);
            }
            if (interacting)
            {
                if (SeriesHelper.IsStack(chart.series))
                {
                    chart.RefreshTopPainter();
                }
                else
                {
                    chart.RefreshPainter(serie);
                }
            }
        }
예제 #3
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;
                }
            }
        }