예제 #1
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);
                        }
                    }
                }
            }
        }
예제 #2
0
        protected override void OnPopulateMesh(VertexHelper vh)
        {
            base.OnPopulateMesh(vh);

            if (yAxis.type == AxisType.category)
            {
                int   seriesCount = seriesList.Count;
                float scaleWid    = coordinateHig / (yAxis.splitNumber - 1);
                float barWid      = barInfo.barWid > 1 ? barInfo.barWid : scaleWid * barInfo.barWid;
                float offset      = (scaleWid - barWid * seriesCount - barInfo.space * (seriesCount - 1)) / 2;
                float max         = GetMaxValue();
                for (int j = 0; j < seriesCount; j++)
                {
                    if (!legend.IsShowSeries(j))
                    {
                        continue;
                    }
                    Series series     = seriesList[j];
                    Color  color      = legend.GetColor(j);
                    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];
                        float      pX   = zeroX + coordinate.tickness;
                        float      pY   = zeroY + i * coordinateHig / (yAxis.splitNumber - 1);
                        if (!yAxis.boundaryGap)
                        {
                            pY -= scaleWid / 2;
                        }
                        float   barHig = data.value / max * coordinateWid;
                        float   space  = offset + j * (barWid + barInfo.space);
                        Vector3 p1     = new Vector3(pX, pY + space + barWid);
                        Vector3 p2     = new Vector3(pX + barHig, pY + space + barWid);
                        Vector3 p3     = new Vector3(pX + barHig, pY + space);
                        Vector3 p4     = new Vector3(pX, pY + space);
                        ChartUtils.DrawPolygon(vh, p1, p2, p3, p4, color);
                    }
                }
            }
            else
            {
                int   seriesCount = seriesList.Count;
                float scaleWid    = coordinateWid / (xAxis.splitNumber - 1);
                float barWid      = barInfo.barWid > 1 ? barInfo.barWid : scaleWid * barInfo.barWid;
                float offset      = (scaleWid - barWid * seriesCount - barInfo.space * (seriesCount - 1)) / 2;
                float max         = GetMaxValue();
                for (int j = 0; j < seriesCount; j++)
                {
                    if (!legend.IsShowSeries(j))
                    {
                        continue;
                    }
                    Series series     = seriesList[j];
                    Color  color      = legend.GetColor(j);
                    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];
                        float      pX   = zeroX + i * coordinateWid / (xAxis.splitNumber - 1);
                        if (!xAxis.boundaryGap)
                        {
                            pX -= scaleWid / 2;
                        }
                        float   pY     = zeroY + coordinate.tickness;
                        float   barHig = data.value / max * coordinateHig;
                        float   space  = offset + j * (barWid + barInfo.space);
                        Vector3 p1     = new Vector3(pX + space, pY);
                        Vector3 p2     = new Vector3(pX + space, pY + barHig);
                        Vector3 p3     = new Vector3(pX + space + barWid, pY + barHig);
                        Vector3 p4     = new Vector3(pX + space + barWid, pY);
                        ChartUtils.DrawPolygon(vh, p1, p2, p3, p4, color);
                    }
                }
            }
        }