예제 #1
0
 public override void SetDefaultValue()
 {
     m_ItemStyle         = new ItemStyle();
     m_ItemStyle.opacity = 0.6f;
     m_Label             = new LabelStyle();
     m_Label.show        = true;
 }
예제 #2
0
        public static Color32 GetItemColor0(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight, Color32 defaultColor)
        {
            if (serie == null)
            {
                return(ChartConst.clearColor32);
            }

            ItemStyle itemStyle = null;

            if (highlight)
            {
                itemStyle = GetItemStyleEmphasis(serie, serieData);
            }
            if (itemStyle == null)
            {
                itemStyle = GetItemStyle(serie, serieData);
            }

            var color = ChartHelper.IsClearColor(itemStyle.color0) ?
                        defaultColor :
                        itemStyle.color0;

            if (highlight)
            {
                color = ChartHelper.GetHighlightColor(color);
            }

            ChartHelper.SetColorOpacity(ref color, itemStyle.opacity);
            return(color);
        }
예제 #3
0
        public static Color32 GetItemColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight, bool opacity = true)
        {
            if (serie == null)
            {
                return(ChartConst.clearColor32);
            }

            ItemStyle itemStyle = null;

            if (highlight)
            {
                itemStyle = GetItemStyleEmphasis(serie, serieData);
            }
            if (itemStyle == null)
            {
                itemStyle = GetItemStyle(serie, serieData);
            }

            var color = ChartHelper.IsClearColor(itemStyle.color) ?
                        theme.GetColor(index) :
                        itemStyle.color;

            if (highlight)
            {
                color = ChartHelper.GetHighlightColor(color);
            }
            if (opacity)
            {
                ChartHelper.SetColorOpacity(ref color, itemStyle.opacity);
            }
            return(color);
        }
예제 #4
0
        private void DrawZebraBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
                                  bool highlight, float gap, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
                                  Vector3 prb, bool isYAxis, GridCoord grid, Axis axis, Color32 barColor, Color32 barToColor)
        {
            var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, colorIndex, highlight, false);

            if (!ChartHelper.IsClearColor(backgroundColor))
            {
                UGL.DrawRoundRectangle(vh, serieData.context.backgroundRect, backgroundColor, backgroundColor, 0,
                                       null, isYAxis, chart.settings.cicleSmoothness, false);
            }
            if (isYAxis)
            {
                plt = (plb + plt) / 2;
                prt = (prt + prb) / 2;
                chart.DrawClipZebraLine(vh, plt, prt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap,
                                        barColor, barToColor, serie.clip, grid, grid.context.width);
            }
            else
            {
                plb = (prb + plb) / 2;
                plt = (plt + prt) / 2;
                chart.DrawClipZebraLine(vh, plb, plt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap,
                                        barColor, barToColor, serie.clip, grid, grid.context.height);
            }
        }
예제 #5
0
 private void DrawPieCenter(VertexHelper vh, Serie serie, ItemStyle itemStyle, float insideRadius)
 {
     if (!ChartHelper.IsClearColor(itemStyle.centerColor))
     {
         var radius = insideRadius - itemStyle.centerGap;
         UGL.DrawCricle(vh, serie.context.center, radius, itemStyle.centerColor, chart.settings.cicleSmoothness);
     }
 }
        public static Color32 GetItemStyleGradientColor(ItemStyle itemStyle, Vector3 pos, BaseChart chart,
                                                        Axis axis, Color32 defaultColor)
        {
            var min   = axis.context.minValue;
            var max   = axis.context.maxValue;
            var grid  = chart.GetChartComponent <GridCoord>(axis.gridIndex);
            var value = min + (pos.x - grid.context.x) / grid.context.width * (max - min);
            var rate  = (value - min) / (max - min);
            var color = itemStyle.GetGradientColor((float)rate, defaultColor);

            if (ChartHelper.IsClearColor(color))
            {
                return(defaultColor);
            }
            else
            {
                return(color);
            }
        }
예제 #7
0
        private void DrawNormalBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
                                   bool highlight, float gap, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
                                   Vector3 prb, bool isYAxis, GridCoord grid, Color32 areaColor, Color32 areaToColor)
        {
            var borderWidth = itemStyle.runtimeBorderWidth;

            if (isYAxis)
            {
                if (serie.clip)
                {
                    prb = chart.ClampInGrid(grid, prb);
                    plb = chart.ClampInGrid(grid, plb);
                    plt = chart.ClampInGrid(grid, plt);
                    prt = chart.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)
                {
                    var invert = center.x < plb.x;
                    if (itemStyle.IsNeedCorner())
                    {
                        UGL.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, areaToColor, 0,
                                               itemStyle.cornerRadius, isYAxis, chart.settings.cicleSmoothness, invert);
                    }
                    else
                    {
                        chart.DrawClipPolygon(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, chart.settings.cicleSmoothness, invert);
                }
            }
            else
            {
                if (serie.clip)
                {
                    prb = chart.ClampInGrid(grid, prb);
                    plb = chart.ClampInGrid(grid, plb);
                    plt = chart.ClampInGrid(grid, plt);
                    prt = chart.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)
                {
                    var invert = center.y < plb.y;
                    if (itemStyle.IsNeedCorner())
                    {
                        UGL.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, areaToColor, 0,
                                               itemStyle.cornerRadius, isYAxis, chart.settings.cicleSmoothness, invert);
                    }
                    else
                    {
                        chart.DrawClipPolygon(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, chart.settings.cicleSmoothness, invert);
                }
            }
        }
예제 #8
0
        private void DrawNormalBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
                                   bool highlight, float gap, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
                                   Vector3 prb, bool isYAxis, GridCoord grid, Axis axis, Color32 areaColor, Color32 areaToColor, double value)
        {
            var borderWidth     = itemStyle.runtimeBorderWidth;
            var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, colorIndex, highlight, false);
            var cornerRadius    = serie.barType == BarType.Capsule && !itemStyle.IsNeedCorner() ?
                                  m_CapusleDefaultCornerRadius :
                                  itemStyle.cornerRadius;
            var invert = value < 0;

            if (!ChartHelper.IsClearColor(backgroundColor))
            {
                UGL.DrawRoundRectangle(vh, serieData.context.backgroundRect, backgroundColor, backgroundColor, 0,
                                       cornerRadius, isYAxis, chart.settings.cicleSmoothness, invert);
            }
            UGL.DrawRoundRectangle(vh, serieData.context.rect, areaColor, areaToColor, 0,
                                   cornerRadius, isYAxis, chart.settings.cicleSmoothness, invert);
            if (serie.barType == BarType.Capsule)
            {
                UGL.DrawBorder(vh, serieData.context.backgroundRect, borderWidth, itemStyle.borderColor,
                               0, cornerRadius, isYAxis, chart.settings.cicleSmoothness, invert, -borderWidth);
            }
            else
            {
                UGL.DrawBorder(vh, serieData.context.rect, borderWidth, itemStyle.borderColor,
                               0, cornerRadius, isYAxis, chart.settings.cicleSmoothness, invert, itemStyle.borderGap);
            }
        }