コード例 #1
0
        private void DrawLineArrow(VertexHelper vh, Serie serie)
        {
            if (!serie.show || serie.lineArrow == null || !serie.lineArrow.show)
            {
                return;
            }

            if (serie.context.dataPoints.Count < 2)
            {
                return;
            }

            var lineColor  = SerieHelper.GetLineColor(serie, null, chart.theme, serie.index, false);
            var startPos   = Vector3.zero;
            var arrowPos   = Vector3.zero;
            var lineArrow  = serie.lineArrow.arrow;
            var dataPoints = serie.context.drawPoints;

            switch (serie.lineArrow.position)
            {
            case LineArrow.Position.End:
                if (dataPoints.Count < 3)
                {
                    startPos = dataPoints[dataPoints.Count - 2].position;
                    arrowPos = dataPoints[dataPoints.Count - 1].position;
                }
                else
                {
                    startPos = dataPoints[dataPoints.Count - 3].position;
                    arrowPos = dataPoints[dataPoints.Count - 2].position;
                }
                UGL.DrawArrow(vh, startPos, arrowPos, lineArrow.width, lineArrow.height,
                              lineArrow.offset, lineArrow.dent, lineArrow.GetColor(lineColor));

                break;

            case LineArrow.Position.Start:
                startPos = dataPoints[1].position;
                arrowPos = dataPoints[0].position;
                UGL.DrawArrow(vh, startPos, arrowPos, lineArrow.width, lineArrow.height,
                              lineArrow.offset, lineArrow.dent, lineArrow.GetColor(lineColor));

                break;
            }
        }
コード例 #2
0
        private void DrawMarkArea(VertexHelper vh, MarkArea markArea)
        {
            if (!markArea.show)
            {
                return;
            }
            var serie = chart.GetSerie(markArea.serieIndex);

            if (serie == null || !serie.show || !markArea.show)
            {
                return;
            }

            UpdateRuntimeData(markArea);

            var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName);
            var serieColor = SerieHelper.GetLineColor(serie, null, chart.theme, colorIndex, false);
            var areaColor  = markArea.itemStyle.GetColor(serieColor);

            UGL.DrawRectangle(vh, markArea.runtimeRect, areaColor, areaColor);
        }
コード例 #3
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);
            }
        }
コード例 #4
0
        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();
            }
        }
コード例 #5
0
        private void DrawMarkLine(VertexHelper vh, MarkLine markLine)
        {
            var serie = chart.GetSerie(markLine.serieIndex);

            if (!serie.show || !markLine.show)
            {
                return;
            }
            if (markLine.data.Count == 0)
            {
                return;
            }
            var yAxis      = chart.GetChartComponent <YAxis>(serie.yAxisIndex);
            var xAxis      = chart.GetChartComponent <XAxis>(serie.xAxisIndex);
            var grid       = chart.GetChartComponent <GridCoord>(xAxis.gridIndex);
            var dataZoom   = chart.GetDataZoomOfAxis(xAxis);
            var animation  = markLine.animation;
            var showData   = serie.GetDataList(dataZoom);
            var sp         = Vector3.zero;
            var ep         = Vector3.zero;
            var colorIndex = chart.GetLegendRealShowNameIndex(serie.serieName);
            var serieColor = SerieHelper.GetLineColor(serie, null, chart.theme, colorIndex, false);

            animation.InitProgress(0, 1f);
            ResetTempMarkLineGroupData(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 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.context.x + data.xPosition;
                        sp = new Vector3(pX, grid.context.y);
                        ep = new Vector3(pX, grid.context.y + grid.context.height);
                    }
                    else if (data.yPosition != 0)
                    {
                        data.runtimeValue = data.yPosition;
                        var pY = grid.context.y + data.yPosition;
                        sp = new Vector3(grid.context.x, pY);
                        ep = new Vector3(grid.context.x + grid.context.width, 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.context.x, pY);
                            ep = new Vector3(grid.context.x + grid.context.width, 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.context.y);
                            ep = new Vector3(pX, grid.context.y + grid.context.height);
                        }
                        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();
            }
        }
コード例 #6
0
        private void DrawSingleRadar(VertexHelper vh)
        {
            var radar = chart.GetChartComponent <RadarCoord>(serie.radarIndex);

            if (radar == null)
            {
                return;
            }

            var indicatorNum = radar.indicatorList.Count;
            var angle        = 2 * Mathf.PI / indicatorNum;
            var centerPos    = radar.context.center;

            serie.animation.InitProgress(0, 1);
            serie.context.dataPoints.Clear();
            if (!serie.show || serie.animation.HasFadeOut())
            {
                return;
            }
            var startPoint = Vector3.zero;
            var toPoint    = Vector3.zero;
            var firstPoint = Vector3.zero;
            var lastColor  = ColorUtil.clearColor32;
            var firstColor = ColorUtil.clearColor32;

            var rate               = serie.animation.GetCurrRate();
            var dataChanging       = false;
            var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
            var startIndex         = GetStartShowIndex(serie);
            var endIndex           = GetEndShowIndex(serie);

            SerieHelper.UpdateMinMaxData(serie, 1, radar.ceilRate);
            for (int j = 0; j < serie.data.Count; j++)
            {
                var serieData = serie.data[j];
                serieData.index = j;
                string dataName = serieData.name;

                if (!serieData.show)
                {
                    serieData.context.labelPosition = Vector3.zero;
                    continue;
                }
                var lineStyle   = SerieHelper.GetLineStyle(serie, serieData);
                var areaStyle   = SerieHelper.GetAreaStyle(serie, serieData);
                var isHighlight = serie.context.pointerEnter;
                var areaColor   = SerieHelper.GetAreaColor(serie, serieData, chart.theme, j, isHighlight);
                var areaToColor = SerieHelper.GetAreaToColor(serie, serieData, chart.theme, j, isHighlight);
                var lineColor   = SerieHelper.GetLineColor(serie, serieData, chart.theme, j, isHighlight);
                int dataCount   = radar.indicatorList.Count;
                var index       = serieData.index;
                var p           = radar.context.center;
                var max         = radar.GetIndicatorMax(index);
                var value       = serieData.GetCurrData(1, dataChangeDuration);
                if (serieData.IsDataChanged())
                {
                    dataChanging = true;
                }
                if (max == 0)
                {
                    max = serie.context.dataMax;
                }
                if (!radar.IsInIndicatorRange(j, serieData.GetData(1)))
                {
                    lineColor = radar.outRangeColor;
                }
                var radius = (float)(max < 0 ? radar.context.dataRadius - radar.context.dataRadius * value / max :
                                     radar.context.dataRadius * value / max);
                var currAngle = (index + (radar.positionType == RadarCoord.PositionType.Between ? 0.5f : 0)) * angle;
                radius *= rate;
                if (index == startIndex)
                {
                    startPoint = new Vector3(p.x + radius * Mathf.Sin(currAngle),
                                             p.y + radius * Mathf.Cos(currAngle));
                    firstPoint = startPoint;
                    lastColor  = lineColor;
                    firstColor = lineColor;
                }
                else
                {
                    toPoint = new Vector3(p.x + radius * Mathf.Sin(currAngle),
                                          p.y + radius * Mathf.Cos(currAngle));
                    if (areaStyle != null && areaStyle.show)
                    {
                        UGL.DrawTriangle(vh, startPoint, toPoint, p, areaColor, areaColor, areaToColor);
                    }
                    if (lineStyle.show)
                    {
                        if (radar.connectCenter)
                        {
                            ChartDrawer.DrawLineStyle(vh, lineStyle, startPoint, centerPos,
                                                      chart.theme.serie.lineWidth, LineStyle.Type.Solid, lastColor, lastColor);
                        }
                        ChartDrawer.DrawLineStyle(vh, lineStyle, startPoint, toPoint, chart.theme.serie.lineWidth,
                                                  LineStyle.Type.Solid, radar.lineGradient ? lastColor : lineColor, lineColor);
                    }
                    startPoint = toPoint;
                    lastColor  = lineColor;
                }
                serieData.context.position      = startPoint;
                serieData.context.labelPosition = startPoint;

                if (areaStyle != null && areaStyle.show && j == endIndex)
                {
                    UGL.DrawTriangle(vh, startPoint, firstPoint, centerPos, areaColor, areaColor, areaToColor);
                }
                if (lineStyle.show && j == endIndex)
                {
                    if (radar.connectCenter)
                    {
                        ChartDrawer.DrawLineStyle(vh, lineStyle, startPoint, centerPos,
                                                  chart.theme.serie.lineWidth, LineStyle.Type.Solid, lastColor, lastColor);
                    }
                    ChartDrawer.DrawLineStyle(vh, lineStyle, startPoint, firstPoint, chart.theme.serie.lineWidth,
                                              LineStyle.Type.Solid, lineColor, radar.lineGradient ? firstColor : lineColor);
                }
            }
            if (serie.symbol.show && serie.symbol.type != SymbolType.None)
            {
                for (int j = 0; j < serie.data.Count; j++)
                {
                    var serieData = serie.data[j];
                    if (!serieData.show)
                    {
                        continue;
                    }
                    var isHighlight = serie.highlight || serieData.context.highlight || serie.context.pointerEnter;
                    var serieIndex  = serieData.index;
                    var symbolSize  = isHighlight ?
                                      serie.symbol.GetSelectedSize(serieData.data, chart.theme.serie.lineSymbolSelectedSize) :
                                      serie.symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
                    var symbolColor      = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieIndex, isHighlight);
                    var symbolToColor    = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieIndex, isHighlight);
                    var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serieIndex, isHighlight, false);
                    var symbolBorder     = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight);
                    var borderColor      = SerieHelper.GetSymbolBorderColor(serie, serieData, chart.theme, isHighlight);
                    var cornerRadius     = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
                    if (!radar.IsInIndicatorRange(j, serieData.GetData(1)))
                    {
                        symbolColor   = radar.outRangeColor;
                        symbolToColor = radar.outRangeColor;
                    }
                    chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, serieData.context.labelPosition, symbolColor,
                                     symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius);
                }
            }
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(1);
                chart.RefreshPainter(serie);
            }
            if (dataChanging)
            {
                chart.RefreshPainter(serie);
            }
        }
コード例 #7
0
        private void DrawMutipleRadar(VertexHelper vh)
        {
            if (!serie.show)
            {
                return;
            }
            m_RadarCoord = chart.GetChartComponent <RadarCoord>(serie.radarIndex);
            if (m_RadarCoord == null)
            {
                return;
            }

            serie.containerIndex       = m_RadarCoord.index;
            serie.containterInstanceId = m_RadarCoord.instanceId;

            var startPoint   = Vector3.zero;
            var toPoint      = Vector3.zero;
            var firstPoint   = Vector3.zero;
            var indicatorNum = m_RadarCoord.indicatorList.Count;
            var angle        = 2 * Mathf.PI / indicatorNum;
            var centerPos    = m_RadarCoord.context.center;

            serie.animation.InitProgress(0, 1);
            if (!serie.show || serie.animation.HasFadeOut())
            {
                return;
            }
            var rate               = serie.animation.GetCurrRate();
            var dataChanging       = false;
            var interacting        = false;
            var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();

            SerieHelper.GetAllMinMaxData(serie, m_RadarCoord.ceilRate);
            for (int j = 0; j < serie.data.Count; j++)
            {
                var    serieData = serie.data[j];
                string dataName  = serieData.name;
                if (!serieData.show)
                {
                    continue;
                }
                var lineStyle   = SerieHelper.GetLineStyle(serie, serieData);
                var areaStyle   = SerieHelper.GetAreaStyle(serie, serieData);
                var symbol      = SerieHelper.GetSerieSymbol(serie, serieData);
                var isHighlight = serieData.context.highlight;
                var colorIndex  = chart.GetLegendRealShowNameIndex(serieData.legendName);
                var areaColor   = SerieHelper.GetAreaColor(serie, serieData, chart.theme, colorIndex, isHighlight);
                var areaToColor = SerieHelper.GetAreaToColor(serie, serieData, chart.theme, colorIndex, isHighlight);
                var lineColor   = SerieHelper.GetLineColor(serie, serieData, chart.theme, colorIndex, isHighlight);
                var lineWidth   = lineStyle.GetWidth(chart.theme.serie.lineWidth);
                int dataCount   = m_RadarCoord.indicatorList.Count;
                serieData.context.dataPoints.Clear();
                for (int n = 0; n < dataCount; n++)
                {
                    if (n >= serieData.data.Count)
                    {
                        break;
                    }
                    var min   = m_RadarCoord.GetIndicatorMin(n);
                    var max   = m_RadarCoord.GetIndicatorMax(n);
                    var value = serieData.GetCurrData(n, dataChangeDuration);
                    if (serieData.IsDataChanged())
                    {
                        dataChanging = true;
                    }
                    if (max == 0)
                    {
                        if (serie.data.Count > 1)
                        {
                            SerieHelper.GetMinMaxData(serie, n, out min, out max);
                            min = ChartHelper.GetMinDivisibleValue(min, 0);
                            max = ChartHelper.GetMaxDivisibleValue(max, 0);
                            if (min > 0)
                            {
                                min = 0;
                            }
                        }
                        else
                        {
                            max = serie.context.dataMax;
                        }
                    }
                    var radius    = (float)(m_RadarCoord.context.dataRadius * (value - min) / (max - min));
                    var currAngle = (n + (m_RadarCoord.positionType == RadarCoord.PositionType.Between ? 0.5f : 0)) * angle;
                    radius *= rate;
                    if (n == 0)
                    {
                        startPoint = new Vector3(centerPos.x + radius * Mathf.Sin(currAngle),
                                                 centerPos.y + radius * Mathf.Cos(currAngle));
                        firstPoint = startPoint;
                    }
                    else
                    {
                        toPoint = new Vector3(centerPos.x + radius * Mathf.Sin(currAngle),
                                              centerPos.y + radius * Mathf.Cos(currAngle));
                        if (areaStyle != null && areaStyle.show)
                        {
                            UGL.DrawTriangle(vh, startPoint, toPoint, centerPos, areaColor, areaColor, areaToColor);
                        }
                        if (lineStyle.show)
                        {
                            ChartDrawer.DrawLineStyle(vh, lineStyle.type, lineWidth, startPoint, toPoint, lineColor);
                        }
                        startPoint = toPoint;
                    }
                    serieData.context.dataPoints.Add(startPoint);
                }
                if (areaStyle != null && areaStyle.show)
                {
                    UGL.DrawTriangle(vh, startPoint, firstPoint, centerPos, areaColor, areaColor, areaToColor);
                }
                if (lineStyle.show)
                {
                    ChartDrawer.DrawLineStyle(vh, lineStyle.type, lineWidth, startPoint, firstPoint, lineColor);
                }
                if (symbol.show && symbol.type != SymbolType.None)
                {
                    for (int m = 0; m < serieData.context.dataPoints.Count; m++)
                    {
                        var point      = serieData.context.dataPoints[m];
                        var symbolSize = isHighlight ?
                                         symbol.GetSelectedSize(null, chart.theme.serie.lineSymbolSelectedSize) :
                                         symbol.GetSize(null, chart.theme.serie.lineSymbolSize);
                        if (!serieData.interact.TryGetValue(ref symbolSize, ref interacting))
                        {
                            symbolSize = isHighlight ?
                                         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, chart.theme, j, isHighlight);
                        var symbolToColor    = SerieHelper.GetItemToColor(serie, serieData, chart.theme, j, isHighlight);
                        var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, j, isHighlight, false);
                        var symbolBorder     = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight);
                        var borderColor      = SerieHelper.GetSymbolBorderColor(serie, serieData, chart.theme, isHighlight);
                        var cornerRadius     = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
                        chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, point, symbolColor,
                                         symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius);
                    }
                }
            }
            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(1);
                chart.RefreshPainter(serie);
            }
            if (dataChanging || interacting)
            {
                chart.RefreshPainter(serie);
            }
        }
コード例 #8
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;
                }
            }
        }