Example #1
0
        private void DrawYLineSerie(VertexHelper vh, int serieIndex, Serie serie, ref List <float> seriesHig)
        {
            if (!IsActive(serie.index))
            {
                return;
            }
            var     showData    = serie.GetDataList(m_DataZoom);
            Vector3 lp          = Vector3.zero;
            Vector3 np          = Vector3.zero;
            Vector3 nnp         = Vector3.zero;
            Color   lineColor   = serie.GetLineColor(m_ThemeInfo, serieIndex, false);
            Color   areaColor   = serie.GetAreaColor(m_ThemeInfo, serieIndex, false);
            Color   areaToColor = serie.GetAreaToColor(m_ThemeInfo, serieIndex, false);
            var     xAxis       = m_XAxises[serie.axisIndex];
            var     yAxis       = m_YAxises[serie.axisIndex];
            var     zeroPos     = new Vector3(coordinateX + xAxis.zeroXOffset, coordinateY);
            var     lastSerie   = m_Series.GetSerie(serieIndex - 1);
            var     isStack     = m_Series.IsStack(serie.stack, SerieType.Line);

            if (!yAxis.show)
            {
                yAxis = m_YAxises[(serie.axisIndex + 1) % m_YAxises.Count];
            }
            float scaleWid = yAxis.GetDataWidth(coordinateHig, m_DataZoom);
            float startY   = coordinateY + (yAxis.boundaryGap ? scaleWid / 2 : 0);
            int   maxCount = maxShowDataNumber > 0 ?
                             (maxShowDataNumber > showData.Count ? showData.Count : maxShowDataNumber)
                : showData.Count;

            if (seriesHig.Count < minShowDataNumber)
            {
                for (int i = 0; i < minShowDataNumber; i++)
                {
                    seriesHig.Add(0);
                }
            }
            for (int i = minShowDataNumber; i < maxCount; i++)
            {
                if (i >= seriesHig.Count)
                {
                    seriesHig.Add(0);
                }
                float value   = showData[i].data[1];
                float pY      = startY + i * scaleWid;
                float pX      = seriesHig[i] + coordinateX + yAxis.axisLine.width;
                float dataHig = (value - xAxis.minValue) / (xAxis.maxValue - xAxis.minValue) * coordinateWid;
                np = new Vector3(pX + dataHig, pY);
                serie.dataPoints.Add(np);
                seriesHig[i] += dataHig;
                lp            = np;
            }

            lp = serie.dataPoints[0];
            for (int i = 1; i < serie.dataPoints.Count; i++)
            {
                np = serie.dataPoints[i];
                serie.ClearSmoothList(i);
                switch (serie.lineType)
                {
                case LineType.Normal:
                    nnp = i < serie.dataPoints.Count - 1 ? serie.dataPoints[i + 1] : np;
                    DrawNormalLine(vh, serieIndex, serie, yAxis, lp, np, nnp, i, lineColor, areaColor, areaToColor, zeroPos);
                    break;

                case LineType.Smooth:
                    DrawSmoothLine(vh, serieIndex, serie, yAxis, lp, np, i, lineColor, areaColor, areaToColor, isStack, zeroPos);
                    break;

                case LineType.StepStart:
                case LineType.StepMiddle:
                case LineType.StepEnd:
                    DrawStepLine(vh, serieIndex, serie, yAxis, lp, np, i, lineColor, areaColor, zeroPos);
                    break;
                }
                lp = np;
            }
        }
Example #2
0
        private void DrawXLineSerie(VertexHelper vh, int serieIndex, Serie serie, ref List <float> seriesHig)
        {
            if (!IsActive(serie.index))
            {
                return;
            }
            var showData = serie.GetDataList(m_DataZoom);

            if (showData.Count <= 0)
            {
                return;
            }
            Color   lineColor = serie.GetLineColor(m_ThemeInfo, serieIndex, false);
            Color   areaColor = serie.GetAreaColor(m_ThemeInfo, serieIndex, false);
            Color   areaToColor = serie.GetAreaToColor(m_ThemeInfo, serieIndex, false);
            Vector3 lp = Vector3.zero, np = Vector3.zero, nnp = Vector3.zero;
            var     yAxis     = m_YAxises[serie.axisIndex];
            var     xAxis     = m_XAxises[serie.axisIndex];
            var     zeroPos   = new Vector3(coordinateX, coordinateY + yAxis.zeroYOffset);
            var     lastSerie = m_Series.GetSerie(serie.index - 1);
            var     isStack   = m_Series.IsStack(serie.stack, SerieType.Line);

            if (!xAxis.show)
            {
                xAxis = m_XAxises[(serie.axisIndex + 1) % m_XAxises.Count];
            }
            float scaleWid = xAxis.GetDataWidth(coordinateWid, m_DataZoom);
            float startX   = coordinateX + (xAxis.boundaryGap ? scaleWid / 2 : 0);
            int   maxCount = maxShowDataNumber > 0 ?
                             (maxShowDataNumber > showData.Count ? showData.Count : maxShowDataNumber)
                : showData.Count;

            if (seriesHig.Count < minShowDataNumber)
            {
                for (int i = 0; i < minShowDataNumber; i++)
                {
                    seriesHig.Add(0);
                }
            }
            for (int i = minShowDataNumber; i < maxCount; i++)
            {
                if (i >= seriesHig.Count)
                {
                    seriesHig.Add(0);
                }
                float yValue = showData[i].data[1];
                seriesHig[i] += GetDataPoint(xAxis, yAxis, showData, yValue, startX, i, scaleWid, seriesHig[i], ref np);
                serie.dataPoints.Add(np);
                lp = np;
            }
            if (serie.dataPoints.Count <= 0)
            {
                return;
            }
            lp = serie.dataPoints[0];
            for (int i = 1; i < serie.dataPoints.Count; i++)
            {
                np = serie.dataPoints[i];
                serie.ClearSmoothList(i);
                switch (serie.lineType)
                {
                case LineType.Normal:
                    nnp = i < serie.dataPoints.Count - 1 ? serie.dataPoints[i + 1] : np;
                    DrawNormalLine(vh, serieIndex, serie, xAxis, lp, np, nnp, i, lineColor, areaColor, areaToColor, zeroPos);
                    break;

                case LineType.Smooth:
                    DrawSmoothLine(vh, serieIndex, serie, xAxis, lp, np, i, lineColor, areaColor, areaToColor, isStack, zeroPos);
                    break;

                case LineType.StepStart:
                case LineType.StepMiddle:
                case LineType.StepEnd:
                    DrawStepLine(vh, serieIndex, serie, xAxis, lp, np, i, lineColor, areaColor, zeroPos);
                    break;
                }
                lp = np;
            }
        }