예제 #1
0
        private void DrawSerieData(VertexHelper vh, Grid grid, Serie serie, SerieData serieData, int colorIndex,
                                   float pX, float pY, float space, float barWidth, bool isTime, float minValue, float maxValue,
                                   float xCategoryWidth)
        {
            var xStart       = 0f;
            var xEnd         = 0f;
            var xActualStart = 0f;
            var xActualEnd   = 0f;
            var start        = (int)serieData.GetData(0);
            var end          = (int)serieData.GetData(1);
            var actualStart  = (int)serieData.GetData(2);
            var actualEnd    = (int)serieData.GetData(3);
            var enableActual = actualStart > 0 && actualEnd > 0;

            if (isTime)
            {
                var valueTotal = maxValue - minValue;
                xStart = pX + (start - minValue) / valueTotal * grid.runtimeWidth;
                xEnd   = pX + (end - minValue) / valueTotal * grid.runtimeWidth;
                if (enableActual)
                {
                    xActualStart = pX + (actualStart - minValue) / valueTotal * grid.runtimeWidth;
                    xActualEnd   = pX + (actualEnd - minValue) / valueTotal * grid.runtimeWidth;
                }
            }
            else
            {
                xStart = pX + start * xCategoryWidth;
                xEnd   = pX + end * xCategoryWidth;
                if (enableActual)
                {
                    xActualStart = pX + actualStart * xCategoryWidth;
                    xActualEnd   = pX + actualEnd * xCategoryWidth;
                }
            }
            var highlight = (serieData != null && serieData.highlighted) ||
                            serie.highlighted;
            var itemStyle   = SerieHelper.GetItemStyle(serie, serieData, highlight);
            var color       = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight);
            var borderWidth = itemStyle.borderWidth;

            var rect = DrawGanttBar(vh, grid, serie, serieData, itemStyle, color, pY, pY, space, barWidth, xStart,
                                    xEnd);

            if (enableActual)
            {
                var defaultActualColor = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, true);
                var actualColor        = SerieHelper.GetItemColor0(serie, serieData, m_Theme, highlight, defaultActualColor);
                var rect2 = DrawGanttBar(vh, grid, serie, serieData, itemStyle, actualColor, pY, pY, space, barWidth,
                                         xActualStart, xActualEnd);
                var rect3X     = Mathf.Min(rect.x, rect2.x);
                var rect3Width = Mathf.Max(rect.x + rect.width, rect2.x + rect2.width) - rect3X;
                var rect3      = new Rect(rect3X, rect.y, rect3Width, rect.height);
                serie.dataPoints.Add(rect3.center);
                serieData.runtimePosition = rect3.center;
                serieData.labelPosition   = rect3.center;
                serieData.runtimeRect     = rect3;
            }
            else
            {
                serie.dataPoints.Add(rect.center);
                serieData.runtimePosition = rect.center;
                serieData.labelPosition   = rect.center;
                serieData.runtimeRect     = rect;
            }
        }