Exemple #1
0
 private static void ImportItemStyleColor(ItemStyle itemStyle, List <Color32> colorList)
 {
     itemStyle.color           = colorList[0];
     itemStyle.toColor         = colorList[1];
     itemStyle.toColor2        = colorList[2];//没有toColor2的版本可以注释掉改行
     itemStyle.backgroundColor = colorList[3];
     itemStyle.borderColor     = colorList[4];
 }
 private void DrawCenter(VertexHelper vh, Serie serie, ItemStyle itemStyle, float insideRadius)
 {
     if (!ChartHelper.IsClearColor(itemStyle.centerColor))
     {
         var radius = insideRadius - itemStyle.centerGap;
         ChartDrawer.DrawCricle(vh, serie.runtimeCenterPos, radius, itemStyle.centerColor, m_Settings.cicleSmoothness);
     }
 }
 public static bool IsNeedCorner(ItemStyle itemStyle)
 {
     if (itemStyle.cornerRadius == null)
     {
         return(false);
     }
     foreach (var value in itemStyle.cornerRadius)
     {
         if (value != 0)
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #4
0
        internal static Color32 GetItemStyleGradientColor(ItemStyle itemStyle, Vector3 pos, CoordinateChart chart, Axis axis, Color32 defaultColor)
        {
            var min   = axis.runtimeMinValue;
            var max   = axis.runtimeMaxValue;
            var value = min + (pos.x - chart.coordinateX) / chart.coordinateWidth * (max - min);
            var rate  = (value - min) / (max - min);
            var color = itemStyle.GetGradientColor(rate, defaultColor);

            if (ChartHelper.IsClearColor(color))
            {
                return(defaultColor);
            }
            else
            {
                return(color);
            }
        }
Exemple #5
0
        public static Color32 GetItemStyleGradientColor(ItemStyle itemStyle, Vector3 pos, CoordinateChart chart,
                                                        Axis axis, Color32 defaultColor)
        {
            var min   = axis.runtimeMinValue;
            var max   = axis.runtimeMaxValue;
            var grid  = chart.GetAxisGridOrDefault(axis);
            var value = min + (pos.x - grid.runtimeX) / grid.runtimeWidth * (max - min);
            var rate  = (value - min) / (max - min);
            var color = itemStyle.GetGradientColor((float)rate, defaultColor);

            if (ChartHelper.IsClearColor(color))
            {
                return(defaultColor);
            }
            else
            {
                return(color);
            }
        }
        private void DrawZebraBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
                                  bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
                                  Vector3 prb, bool isYAxis, Grid grid)
        {
            var areaColor = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight);

            DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid);
            if (isYAxis)
            {
                plt = (plb + plt) / 2;
                prt = (prt + prb) / 2;
                Internal_CheckClipAndDrawZebraLine(vh, plt, prt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap,
                                                   areaColor, serie.clip, grid);
            }
            else
            {
                plb = (prb + plb) / 2;
                plt = (plt + prt) / 2;
                Internal_CheckClipAndDrawZebraLine(vh, plb, plt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap,
                                                   areaColor, serie.clip, grid);
            }
        }
Exemple #7
0
        internal Color GetPointerColor(ThemeInfo theme, int serieIndex, float angle, ItemStyle itemStyle)
        {
            Color color;

            if (itemStyle.color != Color.clear)
            {
                color    = itemStyle.color;
                color.a *= itemStyle.opacity;
                return(color);
            }
            for (int i = 0; i < runtimeStageAngle.Count; i++)
            {
                if (angle < runtimeStageAngle[i])
                {
                    color    = axisLine.stageColor[i].color;
                    color.a *= itemStyle.opacity;
                    return(color);
                }
            }
            color    = theme.GetColor(serieIndex);
            color.a *= itemStyle.opacity;
            return(color);
        }
        private void DrawBarBackground(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle,
                                       int colorIndex, bool highlight, float pX, float pY, float space, float barWidth, bool isYAxis, Grid grid)
        {
            var color = SerieHelper.GetItemBackgroundColor(serie, serieData, m_Theme, colorIndex, highlight, false);

            if (ChartHelper.IsClearColor(color))
            {
                return;
            }
            if (isYAxis)
            {
                var     axis      = m_YAxes[serie.yAxisIndex];
                var     axisWidth = axis.axisLine.GetWidth(m_Theme.axis.lineWidth);
                Vector3 plt       = new Vector3(grid.runtimeX + axisWidth, pY + space + barWidth);
                Vector3 prt       = new Vector3(grid.runtimeX + axisWidth + grid.runtimeWidth, pY + space + barWidth);
                Vector3 prb       = new Vector3(grid.runtimeX + axisWidth + grid.runtimeWidth, pY + space);
                Vector3 plb       = new Vector3(grid.runtimeX + axisWidth, pY + space);
                if (serie.barType == BarType.Capsule)
                {
                    var radius = barWidth / 2;
                    var diff   = Vector3.right * radius;
                    var pcl    = (plt + plb) / 2 + diff;
                    var pcr    = (prt + prb) / 2 - diff;
                    Internal_CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, color, color, serie.clip, grid);
                    UGL.DrawSector(vh, pcl, radius, color, 180, 360);
                    UGL.DrawSector(vh, pcr, radius, color, 0, 180);
                    if (itemStyle.NeedShowBorder())
                    {
                        var borderWidth = itemStyle.borderWidth;
                        var borderColor = itemStyle.borderColor;
                        var smoothness  = settings.cicleSmoothness;
                        var inRadius    = radius - borderWidth;
                        var outRadius   = radius;
                        var p1          = plb + diff + Vector3.up * borderWidth / 2;
                        var p2          = prb - diff + Vector3.up * borderWidth / 2;
                        var p3          = plt + diff - Vector3.up * borderWidth / 2;
                        var p4          = prt - diff - Vector3.up * borderWidth / 2;
                        UGL.DrawLine(vh, p1, p2, borderWidth / 2, borderColor);
                        UGL.DrawLine(vh, p3, p4, borderWidth / 2, borderColor);
                        UGL.DrawDoughnut(vh, pcl, inRadius, outRadius, borderColor, ChartConst.clearColor32,
                                         180, 360, smoothness);
                        UGL.DrawDoughnut(vh, pcr, inRadius, outRadius, borderColor, ChartConst.clearColor32,
                                         0, 180, smoothness);
                    }
                }
                else
                {
                    Internal_CheckClipAndDrawPolygon(vh, ref plb, ref plt, ref prt, ref prb, color, color, serie.clip, grid);
                }
            }
            else
            {
                var     axis      = m_XAxes[serie.xAxisIndex];
                var     axisWidth = axis.axisLine.GetWidth(m_Theme.axis.lineWidth);
                Vector3 plb       = new Vector3(pX + space, grid.runtimeY + axisWidth);
                Vector3 plt       = new Vector3(pX + space, grid.runtimeY + grid.runtimeHeight + axisWidth);
                Vector3 prt       = new Vector3(pX + space + barWidth, grid.runtimeY + grid.runtimeHeight + axisWidth);
                Vector3 prb       = new Vector3(pX + space + barWidth, grid.runtimeY + axisWidth);
                if (serie.barType == BarType.Capsule)
                {
                    var radius = barWidth / 2;
                    var diff   = Vector3.up * radius;
                    var pct    = (plt + prt) / 2 - diff;
                    var pcb    = (plb + prb) / 2 + diff;
                    Internal_CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, color, color,
                                                     serie.clip, grid);
                    UGL.DrawSector(vh, pct, radius, color, 270, 450);
                    UGL.DrawSector(vh, pcb, radius, color, 90, 270);
                    if (itemStyle.NeedShowBorder())
                    {
                        var borderWidth = itemStyle.borderWidth;
                        var borderColor = itemStyle.borderColor;
                        var smoothness  = settings.cicleSmoothness;
                        var inRadius    = radius - borderWidth;
                        var outRadius   = radius;
                        var p1          = plb + diff + Vector3.right * borderWidth / 2;
                        var p2          = plt - diff + Vector3.right * borderWidth / 2;
                        var p3          = prb + diff - Vector3.right * borderWidth / 2;
                        var p4          = prt - diff - Vector3.right * borderWidth / 2;
                        UGL.DrawLine(vh, p1, p2, borderWidth / 2, borderColor);
                        UGL.DrawLine(vh, p3, p4, borderWidth / 2, borderColor);
                        UGL.DrawDoughnut(vh, pct, inRadius, outRadius, borderColor, ChartConst.clearColor32,
                                         270, 450, smoothness);
                        UGL.DrawDoughnut(vh, pcb, inRadius, outRadius, borderColor, ChartConst.clearColor32,
                                         90, 270, smoothness);
                    }
                }
                else
                {
                    Internal_CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, color, color, serie.clip, grid);
                }
            }
        }
        private void DrawCapsuleBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
                                    bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
                                    Vector3 prb, bool isYAxis, Grid grid)
        {
            var areaColor   = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight);
            var areaToColor = SerieHelper.GetItemToColor(serie, serieData, m_Theme, colorIndex, highlight);

            DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid);
            var borderWidth = itemStyle.runtimeBorderWidth;
            var radius      = barWidth / 2 - borderWidth;
            var isGradient  = !ChartHelper.IsValueEqualsColor(areaColor, areaToColor);

            if (isYAxis)
            {
                var diff = Vector3.right * radius;
                if (plt.x < prt.x)
                {
                    var pcl = (plt + plb) / 2 + diff;
                    var pcr = (prt + prb) / 2 - diff;
                    if (pcr.x > pcl.x)
                    {
                        if (isGradient)
                        {
                            var barLen         = prt.x - plt.x;
                            var rectStartColor = Color32.Lerp(areaColor, areaToColor, radius / barLen);
                            var rectEndColor   = Color32.Lerp(areaColor, areaToColor, (barLen - radius) / barLen);
                            Internal_CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, rectStartColor,
                                                             rectEndColor, serie.clip, grid);
                            UGL.DrawSector(vh, pcl, radius, areaColor, rectStartColor, 180, 360, 1, isYAxis);
                            UGL.DrawSector(vh, pcr, radius, rectEndColor, areaToColor, 0, 180, 1, isYAxis);
                        }
                        else
                        {
                            Internal_CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, areaColor,
                                                             areaToColor, serie.clip, grid);
                            UGL.DrawSector(vh, pcl, radius, areaColor, 180, 360);
                            UGL.DrawSector(vh, pcr, radius, areaToColor, 0, 180);
                        }
                    }
                }
                else if (plt.x > prt.x)
                {
                    var pcl = (plt + plb) / 2 - diff;
                    var pcr = (prt + prb) / 2 + diff;
                    if (pcr.x < pcl.x)
                    {
                        if (isGradient)
                        {
                            var barLen         = plt.x - prt.x;
                            var rectStartColor = Color32.Lerp(areaColor, areaToColor, radius / barLen);
                            var rectEndColor   = Color32.Lerp(areaColor, areaToColor, (barLen - radius) / barLen);
                            Internal_CheckClipAndDrawPolygon(vh, plb - diff, plt - diff, prt + diff, prb + diff, rectStartColor,
                                                             rectEndColor, serie.clip, grid);
                            UGL.DrawSector(vh, pcl, radius, rectStartColor, areaColor, 0, 180, 1, isYAxis);
                            UGL.DrawSector(vh, pcr, radius, areaToColor, rectEndColor, 180, 360, 1, isYAxis);
                        }
                        else
                        {
                            Internal_CheckClipAndDrawPolygon(vh, plb - diff, plt - diff, prt + diff, prb + diff, areaColor,
                                                             areaToColor, serie.clip, grid);
                            UGL.DrawSector(vh, pcl, radius, areaColor, 0, 180);
                            UGL.DrawSector(vh, pcr, radius, areaToColor, 180, 360);
                        }
                    }
                }
            }
            else
            {
                var diff = Vector3.up * radius;
                if (plt.y > plb.y)
                {
                    var pct = (plt + prt) / 2 - diff;
                    var pcb = (plb + prb) / 2 + diff;
                    if (pct.y > pcb.y)
                    {
                        if (isGradient)
                        {
                            var barLen         = plt.y - plb.y;
                            var rectStartColor = Color32.Lerp(areaColor, areaToColor, radius / barLen);
                            var rectEndColor   = Color32.Lerp(areaColor, areaToColor, (barLen - radius) / barLen);
                            Internal_CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, rectStartColor,
                                                             rectEndColor, serie.clip, grid);
                            UGL.DrawSector(vh, pct, radius, rectEndColor, areaToColor, 270, 450, 1, isYAxis);
                            UGL.DrawSector(vh, pcb, radius, rectStartColor, areaColor, 90, 270, 1, isYAxis);
                        }
                        else
                        {
                            Internal_CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, areaColor,
                                                             areaToColor, serie.clip, grid);
                            UGL.DrawSector(vh, pct, radius, areaToColor, 270, 450);
                            UGL.DrawSector(vh, pcb, radius, areaColor, 90, 270);
                        }
                    }
                }
                else if (plt.y < plb.y)
                {
                    var pct = (plt + prt) / 2 + diff;
                    var pcb = (plb + prb) / 2 - diff;
                    if (pct.y < pcb.y)
                    {
                        if (isGradient)
                        {
                            var barLen         = plb.y - plt.y;
                            var rectStartColor = Color32.Lerp(areaColor, areaToColor, radius / barLen);
                            var rectEndColor   = Color32.Lerp(areaColor, areaToColor, (barLen - radius) / barLen);
                            Internal_CheckClipAndDrawPolygon(vh, prb - diff, plb - diff, plt + diff, prt + diff, rectStartColor,
                                                             rectEndColor, serie.clip, grid);
                            UGL.DrawSector(vh, pct, radius, rectEndColor, areaToColor, 90, 270, 1, isYAxis);
                            UGL.DrawSector(vh, pcb, radius, rectStartColor, areaColor, 270, 450, 1, isYAxis);
                        }
                        else
                        {
                            Internal_CheckClipAndDrawPolygon(vh, prb - diff, plb - diff, plt + diff, prt + diff, areaColor,
                                                             areaToColor, serie.clip, grid);
                            UGL.DrawSector(vh, pct, radius, areaToColor, 90, 270);
                            UGL.DrawSector(vh, pcb, radius, areaColor, 270, 450);
                        }
                    }
                }
            }
        }
        private void DrawNormalBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
                                   bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
                                   Vector3 prb, bool isYAxis, Grid grid)
        {
            var areaColor   = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight);
            var areaToColor = SerieHelper.GetItemToColor(serie, serieData, m_Theme, colorIndex, highlight);

            DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid);
            var borderWidth = itemStyle.runtimeBorderWidth;

            if (isYAxis)
            {
                if (serie.clip)
                {
                    prb = ClampInGrid(grid, prb);
                    plb = ClampInGrid(grid, plb);
                    plt = ClampInGrid(grid, plt);
                    prt = ClampInGrid(grid, prt);
                }
                var itemWidth  = Mathf.Abs(prb.x - plt.x);
                var itemHeight = Mathf.Abs(prt.y - plb.y);
                var center     = new Vector3((plt.x + prb.x) / 2, (prt.y + plb.y) / 2);
                if (itemWidth > 0 && itemHeight > 0)
                {
                    if (ItemStyleHelper.IsNeedCorner(itemStyle))
                    {
                        UGL.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, areaToColor, 0,
                                               itemStyle.cornerRadius, isYAxis);
                    }
                    else
                    {
                        Internal_CheckClipAndDrawPolygon(vh, plb, plt, prt, prb, areaColor, areaToColor, serie.clip, grid);
                    }
                    UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, itemStyle.borderColor,
                                   itemStyle.borderToColor, 0, itemStyle.cornerRadius, isYAxis);
                }
            }
            else
            {
                if (serie.clip)
                {
                    prb = ClampInGrid(grid, prb);
                    plb = ClampInGrid(grid, plb);
                    plt = ClampInGrid(grid, plt);
                    prt = ClampInGrid(grid, prt);
                }
                var itemWidth  = Mathf.Abs(prt.x - plb.x);
                var itemHeight = Mathf.Abs(plt.y - prb.y);
                var center     = new Vector3((plb.x + prt.x) / 2, (plt.y + prb.y) / 2);
                if (itemWidth > 0 && itemHeight > 0)
                {
                    if (ItemStyleHelper.IsNeedCorner(itemStyle))
                    {
                        UGL.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, areaToColor, 0,
                                               itemStyle.cornerRadius, isYAxis);
                    }
                    else
                    {
                        Internal_CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, areaColor, areaToColor,
                                                         serie.clip, grid);
                    }
                    UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, itemStyle.borderColor,
                                   itemStyle.borderToColor, 0, itemStyle.cornerRadius, isYAxis);
                }
            }
        }
Exemple #11
0
        private void DrawCapsuleBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
                                    bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
                                    Vector3 prb, bool isYAxis)
        {
            Color areaColor   = SerieHelper.GetItemColor(serie, serieData, m_ThemeInfo, colorIndex, highlight);
            Color areaToColor = SerieHelper.GetItemToColor(serie, serieData, m_ThemeInfo, colorIndex, highlight);

            DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis);
            var borderWidth = itemStyle.runtimeBorderWidth;
            var radius      = barWidth / 2 - borderWidth;

            if (isYAxis)
            {
                var diff = Vector3.right * radius;
                if (plt.x < prt.x)
                {
                    var pcl = (plt + plb) / 2 + diff;
                    var pcr = (prt + prb) / 2 - diff;
                    if (pcr.x > pcl.x)
                    {
                        CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, areaColor, areaToColor, serie.clip);
                        ChartDrawer.DrawSector(vh, pcl, radius, areaColor, 180, 360);
                        ChartDrawer.DrawSector(vh, pcr, radius, areaToColor, 0, 180);
                    }
                }
                else if (plt.x > prt.x)
                {
                    var pcl = (plt + plb) / 2 - diff;
                    var pcr = (prt + prb) / 2 + diff;
                    if (pcr.x < pcl.x)
                    {
                        CheckClipAndDrawPolygon(vh, plb - diff, plt - diff, prt + diff, prb + diff, areaColor, areaToColor, serie.clip);
                        ChartDrawer.DrawSector(vh, pcl, radius, areaColor, 0, 180);
                        ChartDrawer.DrawSector(vh, pcr, radius, areaToColor, 180, 360);
                    }
                }
            }
            else
            {
                var diff = Vector3.up * radius;
                if (plt.y > plb.y)
                {
                    var pct = (plt + prt) / 2 - diff;
                    var pcb = (plb + prb) / 2 + diff;
                    if (pct.y > pcb.y)
                    {
                        CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, areaColor, areaToColor, serie.clip);
                        ChartDrawer.DrawSector(vh, pct, radius, areaToColor, 270, 450);
                        ChartDrawer.DrawSector(vh, pcb, radius, areaColor, 90, 270);
                    }
                }
                else if (plt.y < plb.y)
                {
                    var pct = (plt + prt) / 2 + diff;
                    var pcb = (plb + prb) / 2 - diff;
                    if (pct.y < pcb.y)
                    {
                        CheckClipAndDrawPolygon(vh, prb - diff, plb - diff, plt + diff, prt + diff, areaColor, areaToColor, serie.clip);
                        ChartDrawer.DrawSector(vh, pct, radius, areaToColor, 90, 270);
                        ChartDrawer.DrawSector(vh, pcb, radius, areaColor, 270, 450);
                    }
                }
            }
        }
        internal Color32 GetPointerColor(ChartTheme theme, int serieIndex, float angle, ItemStyle itemStyle)
        {
            Color32 color;

            if (!ChartHelper.IsClearColor(itemStyle.color))
            {
                return(itemStyle.GetColor());
            }
            for (int i = 0; i < runtimeStageAngle.Count; i++)
            {
                if (angle < runtimeStageAngle[i])
                {
                    color = axisLine.stageColor[i].color;
                    ChartHelper.SetColorOpacity(ref color, itemStyle.opacity);
                    return(color);
                }
            }
            color = theme.GetColor(serieIndex);
            ChartHelper.SetColorOpacity(ref color, itemStyle.opacity);
            return(color);
        }
Exemple #13
0
        private void DrawBarBackground(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
                                       bool highlight, float pX, float pY, float space, float barWidth, bool isYAxis)
        {
            Color color = SerieHelper.GetItemBackgroundColor(serie, serieData, m_ThemeInfo, colorIndex, highlight, false);

            if (color == Color.clear)
            {
                return;
            }
            if (isYAxis)
            {
                var     axis      = m_YAxises[serie.axisIndex];
                var     axisWidth = axis.axisLine.width;
                Vector3 plt       = new Vector3(coordinateX + axisWidth, pY + space + barWidth);
                Vector3 prt       = new Vector3(coordinateX + axisWidth + coordinateWidth, pY + space + barWidth);
                Vector3 prb       = new Vector3(coordinateX + axisWidth + coordinateWidth, pY + space);
                Vector3 plb       = new Vector3(coordinateX + axisWidth, pY + space);
                if (serie.barType == BarType.Capsule)
                {
                    var radius = barWidth / 2;
                    var diff   = Vector3.right * radius;
                    var pcl    = (plt + plb) / 2 + diff;
                    var pcr    = (prt + prb) / 2 - diff;
                    CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, color, color, serie.clip);
                    ChartDrawer.DrawSector(vh, pcl, radius, color, 180, 360);
                    ChartDrawer.DrawSector(vh, pcr, radius, color, 0, 180);
                    if (itemStyle.NeedShowBorder())
                    {
                        var borderWidth = itemStyle.borderWidth;
                        var borderColor = itemStyle.borderColor;
                        var smoothness  = m_Settings.cicleSmoothness;
                        var inRadius    = radius - borderWidth;
                        var outRadius   = radius;
                        var p1          = plb + diff + Vector3.up * borderWidth / 2;
                        var p2          = prb - diff + Vector3.up * borderWidth / 2;
                        var p3          = plt + diff - Vector3.up * borderWidth / 2;
                        var p4          = prt - diff - Vector3.up * borderWidth / 2;
                        ChartDrawer.DrawLine(vh, p1, p2, borderWidth / 2, borderColor);
                        ChartDrawer.DrawLine(vh, p3, p4, borderWidth / 2, borderColor);
                        ChartDrawer.DrawDoughnut(vh, pcl, inRadius, outRadius, borderColor, Color.clear, 180, 360, smoothness);
                        ChartDrawer.DrawDoughnut(vh, pcr, inRadius, outRadius, borderColor, Color.clear, 0, 180, smoothness);
                    }
                }
                else
                {
                    CheckClipAndDrawPolygon(vh, ref plb, ref plt, ref prt, ref prb, color, color, serie.clip);
                }
            }
            else
            {
                var     axis      = m_XAxises[serie.axisIndex];
                var     axisWidth = axis.axisLine.width;
                Vector3 plb       = new Vector3(pX + space, coordinateY + axisWidth);
                Vector3 plt       = new Vector3(pX + space, coordinateY + coordinateHeight + axisWidth);
                Vector3 prt       = new Vector3(pX + space + barWidth, coordinateY + coordinateHeight + axisWidth);
                Vector3 prb       = new Vector3(pX + space + barWidth, coordinateY + axisWidth);
                if (serie.barType == BarType.Capsule)
                {
                    var radius = barWidth / 2;
                    var diff   = Vector3.up * radius;
                    var pct    = (plt + prt) / 2 - diff;
                    var pcb    = (plb + prb) / 2 + diff;
                    CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, color, color, serie.clip);
                    ChartDrawer.DrawSector(vh, pct, radius, color, 270, 450);
                    ChartDrawer.DrawSector(vh, pcb, radius, color, 90, 270);
                    if (itemStyle.NeedShowBorder())
                    {
                        var borderWidth = itemStyle.borderWidth;
                        var borderColor = itemStyle.borderColor;
                        var smoothness  = m_Settings.cicleSmoothness;
                        var inRadius    = radius - borderWidth;
                        var outRadius   = radius;
                        var p1          = plb + diff + Vector3.right * borderWidth / 2;
                        var p2          = plt - diff + Vector3.right * borderWidth / 2;
                        var p3          = prb + diff - Vector3.right * borderWidth / 2;
                        var p4          = prt - diff - Vector3.right * borderWidth / 2;
                        ChartDrawer.DrawLine(vh, p1, p2, borderWidth / 2, borderColor);
                        ChartDrawer.DrawLine(vh, p3, p4, borderWidth / 2, borderColor);
                        ChartDrawer.DrawDoughnut(vh, pct, inRadius, outRadius, borderColor, Color.clear, 270, 450, smoothness);
                        ChartDrawer.DrawDoughnut(vh, pcb, inRadius, outRadius, borderColor, Color.clear, 90, 270, smoothness);
                    }
                }
                else
                {
                    CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, color, color, serie.clip);
                }
            }
        }
Exemple #14
0
        private Rect DrawGanttBar(VertexHelper vh, Grid grid, Serie serie, SerieData serieData, ItemStyle itemStyle,
                                  Color32 color, float pX, float pY, float space, float barWidth, float xStart, float xEnd)
        {
            var borderWidth = itemStyle.borderWidth;
            var plb         = new Vector3(xStart + borderWidth, pY + space + borderWidth);
            var plt         = new Vector3(xStart + borderWidth, pY + space + barWidth - borderWidth);
            var prt         = new Vector3(xEnd - borderWidth, pY + space + barWidth - borderWidth);
            var prb         = new Vector3(xEnd - borderWidth, pY + space + borderWidth);
            var center      = new Vector3((plb.x + prt.x) / 2, (plt.y + prb.y) / 2);
            var itemWidth   = Mathf.Abs(prt.x - plb.x);
            var itemHeight  = Mathf.Abs(plt.y - prb.y);

            if (serie.clip)
            {
                plb    = ClampInGrid(grid, plb);
                plt    = ClampInGrid(grid, plt);
                prt    = ClampInGrid(grid, prt);
                prb    = ClampInGrid(grid, prb);
                center = ClampInGrid(grid, center);
            }
            if (ItemStyleHelper.IsNeedCorner(itemStyle))
            {
                UGL.DrawRoundRectangle(vh, center, itemWidth, itemHeight, color, color, 0,
                                       itemStyle.cornerRadius, true, 0.5f);
            }
            else
            {
                CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, color, color,
                                        serie.clip, grid);
            }
            if (borderWidth != 0)
            {
                UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, itemStyle.borderColor, 0,
                               itemStyle.cornerRadius, true, 0.5f);
            }
            return(new Rect(plb.x, plb.y, xEnd - xStart, barWidth));
        }
        private void DrawNormalBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
                                   bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
                                   Vector3 prb, bool isYAxis)
        {
            Color areaColor   = SerieHelper.GetItemColor(serie, serieData, m_ThemeInfo, colorIndex, highlight);
            Color areaToColor = SerieHelper.GetItemToColor(serie, serieData, m_ThemeInfo, colorIndex, highlight);

            DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis);
            var borderWidth = itemStyle.runtimeBorderWidth;

            if (isYAxis)
            {
                CheckClipAndDrawPolygon(vh, plb, plt, prt, prb, areaColor, areaToColor, serie.clip);
                if (borderWidth > 0)
                {
                    var borderColor = itemStyle.borderColor;
                    var itemWidth   = Mathf.Abs(prb.x - plt.x);
                    var itemHeight  = Mathf.Abs(prt.y - plb.y);
                    var center      = new Vector3((plt.x + prb.x) / 2, (prt.y + plb.y) / 2);
                    ChartDrawer.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, borderColor);
                }
            }
            else
            {
                CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, areaColor, areaToColor, serie.clip);
                if (borderWidth > 0)
                {
                    var borderColor = itemStyle.borderColor;
                    var itemWidth   = Mathf.Abs(prt.x - plb.x);
                    var itemHeight  = Mathf.Abs(plt.y - prb.y);
                    var center      = new Vector3((plb.x + prt.x) / 2, (plt.y + prb.y) / 2);
                    ChartDrawer.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, borderColor);
                }
            }
        }