示例#1
0
        protected override void DrawChart(VertexHelper vh)
        {
            base.DrawChart(vh);
            UpdatePieCenter();
            float totalDegree = 360;
            float startDegree = 0;
            float dataTotal   = GetDataTotal();
            float dataMax     = GetDataMax();

            angleList.Clear();
            for (int i = 0; i < seriesList.Count; i++)
            {
                if (!legend.IsShowSeries(i))
                {
                    angleList.Add(0);
                    continue;
                }
                float value    = seriesList[i].DataList[0];
                float degree   = totalDegree * value / dataTotal;
                float toDegree = startDegree + degree;

                float outSideRadius = pieInfo.outsideRadiusDynamic ?
                                      pieInfo.insideRadius + (pieRadius - pieInfo.insideRadius) * value / dataMax :
                                      pieRadius;
                if (tooltip.show && tooltip.DataIndex == i + 1)
                {
                    outSideRadius += pieInfo.tooltipExtraRadius;
                }
                ChartUtils.DrawDoughnut(vh, pieCenter, pieInfo.insideRadius,
                                        outSideRadius, startDegree, toDegree, themeInfo.GetColor(i));
                angleList.Add(toDegree);
                startDegree = toDegree;
            }
        }
示例#2
0
        protected override void OnPopulateMesh(VertexHelper vh)
        {
            if (dataList == null)
            {
                return;
            }

            base.OnPopulateMesh(vh);
            UpdatePieCenter();

            float totalDegree = 360;
            float startDegree = 0;
            float dataTotal   = GetDataTotal();
            float dataMax     = GetDataMax();

            for (int i = 0; i < dataList.Count; i++)
            {
                if (!legend.IsShowSeries(i))
                {
                    continue;
                }
                float value    = dataList[i].value;
                float degree   = totalDegree * value / dataTotal;
                float toDegree = startDegree + degree;

                float outSideRadius = pieInfo.outsideRadiusDynamic ?
                                      pieInfo.insideRadius + (pieRadius - pieInfo.insideRadius) * value / dataMax :
                                      pieRadius;
                ChartUtils.DrawDoughnut(vh, new Vector3(pieCenterX, pieCenterY), pieInfo.insideRadius,
                                        outSideRadius, startDegree, toDegree, themeInfo.GetColor(i));
                startDegree = toDegree;
            }
        }
示例#3
0
        private void DrawCricleRadar(VertexHelper vh)
        {
            float   insideRadius = 0, outsideRadius = 0;
            float   block        = radarInfo.radius / radarInfo.splitNumber;
            int     indicatorNum = radarInfo.indicatorList.Count;
            Vector3 p            = new Vector3(radarCenterX, radarCenterY);
            Vector3 p1;
            float   angle = 2 * Mathf.PI / indicatorNum;

            for (int i = 0; i < radarInfo.splitNumber; i++)
            {
                Color color = radarInfo.backgroundColorList[i % radarInfo.backgroundColorList.Count];
                outsideRadius = insideRadius + block;
                ChartUtils.DrawDoughnut(vh, p, insideRadius, outsideRadius, 0, 360, color);
                ChartUtils.DrawCicleNotFill(vh, p, outsideRadius, radarInfo.lineTickness,
                                            radarInfo.lineColor);
                insideRadius = outsideRadius;
            }
            for (int j = 0; j <= indicatorNum; j++)
            {
                float currAngle = j * angle;
                p1 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
                                 p.y + outsideRadius * Mathf.Cos(currAngle));
                ChartUtils.DrawLine(vh, p, p1, radarInfo.lineTickness / 2, radarInfo.lineColor);
            }
        }
示例#4
0
        private void DrawData(VertexHelper vh)
        {
            int     indicatorNum = radarInfo.indicatorList.Count;
            var     angle        = 2 * Mathf.PI / indicatorNum;
            var     p            = new Vector3(radarCenterX, radarCenterY);
            Vector3 startPoint   = Vector3.zero;
            Vector3 toPoint      = Vector3.zero;
            Vector3 firstPoint   = Vector3.zero;

            for (int i = 0; i < seriesList.Count; i++)
            {
                if (!legend.IsShowSeries(i))
                {
                    continue;
                }
                var dataList  = seriesList[i].dataList;
                var color     = themeInfo.GetColor(i);
                var areaColor = new Color(color.r, color.g, color.b, color.a * 0.7f);
                var max       = radarInfo.indicatorList[i].max > 0 ?
                                radarInfo.indicatorList[i].max :
                                GetMaxValue();
                List <Vector3> pointList = new List <Vector3>();
                for (int j = 0; j < dataList.Count; j++)
                {
                    var radius    = radarInfo.radius * dataList[j].value / max;
                    var currAngle = j * angle;
                    if (j == 0)
                    {
                        startPoint = new Vector3(p.x + radius * Mathf.Sin(currAngle),
                                                 p.y + radius * Mathf.Cos(currAngle));
                        firstPoint = startPoint;
                    }
                    else
                    {
                        toPoint = new Vector3(p.x + radius * Mathf.Sin(currAngle),
                                              p.y + radius * Mathf.Cos(currAngle));
                        if (radarInfo.area)
                        {
                            ChartUtils.DrawTriangle(vh, p, startPoint, toPoint, areaColor);
                        }
                        ChartUtils.DrawLine(vh, startPoint, toPoint, radarInfo.lineTickness, color);
                        startPoint = toPoint;
                    }
                    pointList.Add(startPoint);
                }
                if (radarInfo.area)
                {
                    ChartUtils.DrawTriangle(vh, p, startPoint, firstPoint, areaColor);
                }
                ChartUtils.DrawLine(vh, startPoint, firstPoint, radarInfo.lineTickness, color);
                foreach (var point in pointList)
                {
                    float radius = radarInfo.linePointSize - radarInfo.lineTickness * 2;

                    ChartUtils.DrawCricle(vh, point, radius, Color.white);
                    ChartUtils.DrawDoughnut(vh, point, radius, radarInfo.linePointSize, 0, 360, color);
                }
            }
        }
示例#5
0
        protected override void OnPopulateMesh(VertexHelper vh)
        {
            base.OnPopulateMesh(vh);
            UpdatePieCenter();
            float totalDegree = 360;
            float startDegree = 0;

            float degree   = totalDegree * progressInfo.progress / 100;
            float toDegree = startDegree + degree;

            ChartUtils.DrawDoughnut(vh, new Vector3(pieCenterX, pieCenterY), progressInfo.insideRadius,
                                    progressInfo.outsideRadius, startDegree, toDegree, progressInfo.progressColor);
            startDegree = toDegree;

            ChartUtils.DrawDoughnut(vh, new Vector3(pieCenterX, pieCenterY), progressInfo.insideRadius,
                                    progressInfo.outsideRadius, startDegree, totalDegree, progressInfo.backgroundColor);
        }
示例#6
0
        protected override void DrawChart(VertexHelper vh)
        {
            base.DrawChart(vh);
            int   seriesCount = seriesList.Count;
            float max         = GetMaxValue();
            float scaleWid    = xAxis.GetSplitWidth(coordinateWid);

            for (int j = 0; j < seriesCount; j++)
            {
                if (!legend.IsShowSeries(j))
                {
                    continue;
                }
                Series  series         = seriesList[j];
                Color32 color          = themeInfo.GetColor(j);
                Vector3 lp             = Vector3.zero;
                Vector3 np             = Vector3.zero;
                float   startX         = zeroX + (xAxis.boundaryGap ? scaleWid / 2 : 0);
                int     showDataNumber = series.showDataNumber;
                int     startIndex     = 0;
                if (series.showDataNumber > 0 && series.DataList.Count > series.showDataNumber)
                {
                    startIndex = series.DataList.Count - series.showDataNumber;
                }
                for (int i = startIndex; i < series.DataList.Count; i++)
                {
                    float value = series.DataList[i];

                    np = new Vector3(startX + i * scaleWid, zeroY + value * coordinateHig / max);
                    if (i > 0)
                    {
                        if (lineInfo.smooth)
                        {
                            var     list = ChartUtils.GetBezierList(lp, np, lineInfo.smoothStyle);
                            Vector3 start, to;
                            start = list[0];
                            for (int k = 1; k < list.Length; k++)
                            {
                                to = list[k];
                                ChartUtils.DrawLine(vh, start, to, lineInfo.tickness, color);
                                start = to;
                            }
                        }
                        else
                        {
                            ChartUtils.DrawLine(vh, lp, np, lineInfo.tickness, color);
                            if (lineInfo.area)
                            {
                                ChartUtils.DrawPolygon(vh, lp, np, new Vector3(np.x, zeroY),
                                                       new Vector3(lp.x, zeroY), color);
                            }
                        }
                    }
                    lp = np;
                }
                // draw point
                if (lineInfo.showPoint)
                {
                    for (int i = 0; i < series.DataList.Count; i++)
                    {
                        float value = series.DataList[i];

                        Vector3 p = new Vector3(startX + i * scaleWid,
                                                zeroY + value * coordinateHig / max);
                        float pointWid = lineInfo.pointWid;
                        if (tooltip.show && i == tooltip.DataIndex - 1)
                        {
                            pointWid = pointWid * 1.8f;
                        }
                        if (theme == Theme.Dark)
                        {
                            ChartUtils.DrawCricle(vh, p, pointWid, color,
                                                  (int)lineInfo.pointWid * 5);
                        }
                        else
                        {
                            ChartUtils.DrawCricle(vh, p, pointWid, Color.white);
                            ChartUtils.DrawDoughnut(vh, p, pointWid - lineInfo.tickness,
                                                    pointWid, 0, 360, color);
                        }
                    }
                }
            }
            //draw tooltip line
            if (tooltip.show && tooltip.DataIndex > 0)
            {
                float   splitWid = coordinateWid / (xAxis.GetSplitNumber() - 1);
                float   px       = zeroX + (tooltip.DataIndex - 1) * splitWid + (xAxis.boundaryGap ? splitWid / 2 : 0);
                Vector2 sp       = new Vector2(px, zeroY);
                Vector2 ep       = new Vector2(px, zeroY + coordinateHig);
                ChartUtils.DrawLine(vh, sp, ep, coordinate.tickness, themeInfo.tooltipFlagAreaColor);
            }
        }
示例#7
0
        void DrawLineChart(VertexHelper vh)
        {
            if (Mode == ChartMode.Bar)
            {
                return;
            }
            int seriesCount = seriesList.Count;

            Vector2 v2  = GetMaxAndMinValue();
            float   max = v2.x - v2.y;
            //float max = GetMaxValue();

            float minValue = v2.y;

            float scaleWid = xAxis.GetDataWidth(coordinateWid);
            int   num      = Mode == ChartMode.Mixed?1:0;

            for (int j = num; j < seriesCount; j++)
            {
                if (!legend.IsShowSeries(j))
                {
                    continue;
                }
                Series  series         = seriesList[j];
                Color32 color          = themeInfo.GetColor(j);
                Vector3 lp             = Vector3.zero;
                Vector3 np             = Vector3.zero;
                float   startX         = zeroX + (xAxis.boundaryGap ? scaleWid / 2 : 0);
                int     showDataNumber = series.showDataNumber;
                int     startIndex     = 0;
                if (series.showDataNumber > 0 && series.DataList.Count > series.showDataNumber)
                {
                    startIndex = series.DataList.Count - series.showDataNumber;
                }
                for (int i = startIndex; i < series.DataList.Count; i++)
                {
                    float value = series.DataList[i];

                    np = new Vector3(startX + i * scaleWid, zeroY + (value - minValue) * coordinateHig / max);
                    if (i > 0)
                    {
                        if (lineInfo.smooth)
                        {
                            var     list = ChartUtils.GetBezierList(lp, np, lineInfo.smoothStyle);
                            Vector3 start, to;
                            start = list[0];
                            for (int k = 1; k < list.Length; k++)
                            {
                                to = list[k];
                                ChartUtils.DrawLine(vh, start, to, lineInfo.tickness, color);
                                start = to;
                            }
                        }
                        else
                        {
                            ChartUtils.DrawLine(vh, lp, np, lineInfo.tickness, color);
                            if (lineInfo.area)
                            {
                                ChartUtils.DrawPolygon(vh, lp, np, new Vector3(np.x, zeroY),
                                                       new Vector3(lp.x, zeroY), color);
                            }
                        }
                    }
                    lp = np;
                }
                // draw point
                if (lineInfo.showPoint)
                {
                    for (int i = num; i < series.DataList.Count; i++)
                    {
                        float value = series.DataList[i];

                        Vector3 p = new Vector3(startX + i * scaleWid,
                                                zeroY + (value - minValue) * coordinateHig / max);
                        float pointWid = lineInfo.pointWid;
                        if (tooltip.show && i == tooltip.DataIndex - 1)
                        {
                            pointWid = pointWid * 1.8f;
                        }
                        if (theme == Theme.Dark)
                        {
                            ChartUtils.DrawCricle(vh, p, pointWid, color,
                                                  (int)lineInfo.pointWid * 5);
                        }
                        else
                        {
                            ChartUtils.DrawCricle(vh, p, pointWid, Color.white);
                            ChartUtils.DrawDoughnut(vh, p, pointWid - lineInfo.tickness,
                                                    pointWid, 0, 360, color);
                        }
                    }
                }
            }
        }
示例#8
0
        protected override void OnPopulateMesh(VertexHelper vh)
        {
            base.OnPopulateMesh(vh);
            int   seriesCount = seriesList.Count;
            float max         = GetMaxValue();
            float scaleWid    = coordinateWid / (xAxis.splitNumber - 1);

            for (int j = 0; j < seriesCount; j++)
            {
                if (!legend.IsShowSeries(j))
                {
                    continue;
                }
                Series  series         = seriesList[j];
                Color   color          = themeInfo.GetColor(j);
                Vector3 lp             = Vector3.zero;
                Vector3 np             = Vector3.zero;
                float   startX         = zeroX + (xAxis.boundaryGap ? scaleWid / 2 : 0);
                int     showDataNumber = series.showDataNumber;
                int     startIndex     = 0;
                if (series.showDataNumber > 0 && series.dataList.Count > series.showDataNumber)
                {
                    startIndex = series.dataList.Count - series.showDataNumber;
                }
                for (int i = startIndex; i < series.dataList.Count; i++)
                {
                    SeriesData data = series.dataList[i];

                    np = new Vector3(startX + i * scaleWid, zeroY + data.value * coordinateHig / max);
                    if (i > 0)
                    {
                        if (lineInfo.smooth)
                        {
                            var     list = ChartUtils.GetBezierList(lp, np, lineInfo.smoothStyle);
                            Vector3 start, to;
                            start = list[0];
                            for (int k = 1; k < list.Count; k++)
                            {
                                to = list[k];
                                ChartUtils.DrawLine(vh, start, to, lineInfo.tickness, color);
                                start = to;
                            }
                        }
                        else
                        {
                            ChartUtils.DrawLine(vh, lp, np, lineInfo.tickness, color);
                            if (lineInfo.area)
                            {
                                ChartUtils.DrawPolygon(vh, lp, np, new Vector3(np.x, zeroY),
                                                       new Vector3(lp.x, zeroY), color);
                            }
                        }
                    }
                    lp = np;
                }
                // draw point
                if (lineInfo.showPoint)
                {
                    for (int i = 0; i < series.dataList.Count; i++)
                    {
                        SeriesData data = series.dataList[i];

                        Vector3 p = new Vector3(startX + i * scaleWid,
                                                zeroY + data.value * coordinateHig / max);
                        if (theme == Theme.Dark)
                        {
                            ChartUtils.DrawCricle(vh, p, lineInfo.pointWid, color,
                                                  (int)lineInfo.pointWid * 5);
                        }
                        else
                        {
                            ChartUtils.DrawCricle(vh, p, lineInfo.pointWid, Color.white);
                            ChartUtils.DrawDoughnut(vh, p, lineInfo.pointWid - lineInfo.tickness,
                                                    lineInfo.pointWid, 0, 360, color);
                        }
                    }
                }
            }
        }