コード例 #1
0
        private Vector3 GetLabelPosition(PolarCoord polar, Axis axis, float startAngle, float totalWidth)
        {
            var cenPos     = polar.context.center;
            var dire       = ChartHelper.GetDire(startAngle, true).normalized;
            var tickLength = axis.axisTick.GetLength(chart.theme.axis.tickLength);
            var tickVector = ChartHelper.GetVertialDire(dire) *
                             (tickLength + axis.axisLabel.distance);

            return(ChartHelper.GetPos(cenPos, totalWidth, startAngle, true) + tickVector);
        }
コード例 #2
0
        private void DrawPolarIndicator(VertexHelper vh, Tooltip tooltip, PolarCoord m_Polar)
        {
            if (tooltip.context.angle < 0)
            {
                return;
            }
            var theme        = chart.theme;
            var m_AngleAxis  = ComponentHelper.GetAngleAxis(chart.components, m_Polar.index);
            var lineColor    = TooltipHelper.GetLineColor(tooltip, theme);
            var lineType     = tooltip.lineStyle.GetType(theme.tooltip.lineType);
            var lineWidth    = tooltip.lineStyle.GetWidth(theme.tooltip.lineWidth);
            var cenPos       = m_Polar.context.center;
            var radius       = m_Polar.context.radius;
            var sp           = m_Polar.context.center;
            var tooltipAngle = m_AngleAxis.GetValueAngle(tooltip.context.angle);

            var ep = ChartHelper.GetPos(sp, radius, tooltipAngle, true);

            switch (tooltip.type)
            {
            case Tooltip.Type.Corss:
                ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, sp, ep, lineColor);
                var dist = Vector2.Distance(chart.pointerPos, cenPos);
                if (dist > radius)
                {
                    dist = radius;
                }
                var outsideRaidus = dist + tooltip.lineStyle.GetWidth(theme.tooltip.lineWidth) * 2;
                UGL.DrawDoughnut(vh, cenPos, dist, outsideRaidus, lineColor, Color.clear);
                break;

            case Tooltip.Type.Line:
                ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, sp, ep, lineColor);
                break;

            case Tooltip.Type.Shadow:
                UGL.DrawSector(vh, cenPos, radius, lineColor, tooltipAngle - 2, tooltipAngle + 2, chart.settings.cicleSmoothness);
                break;
            }
        }
コード例 #3
0
        private Vector3 GetPolarPos(PolarCoord m_Polar, AngleAxis m_AngleAxis, SerieData serieData, double min,
                                    double max, float polarRadius)
        {
            var angle = 0f;

            if (!m_AngleAxis.clockwise)
            {
                angle = m_AngleAxis.GetValueAngle((float)serieData.GetData(1));
            }
            else
            {
                angle = m_AngleAxis.GetValueAngle((float)serieData.GetData(1));
            }

            var value  = serieData.GetData(0);
            var radius = (float)((value - min) / (max - min) * polarRadius);

            angle = (angle + 360) % 360;
            serieData.context.angle    = angle;
            serieData.context.position = ChartHelper.GetPos(m_Polar.context.center, radius, angle, true);

            return(serieData.context.position);
        }
コード例 #4
0
        public static void UpdatePolarCenter(PolarCoord polar, Vector3 chartPosition, float chartWidth, float chartHeight)
        {
            if (polar.center.Length < 2)
            {
                return;
            }
            var centerX = polar.center[0] <= 1 ? chartWidth * polar.center[0] : polar.center[0];
            var centerY = polar.center[1] <= 1 ? chartHeight * polar.center[1] : polar.center[1];

            polar.context.center = chartPosition + new Vector3(centerX, centerY);
            if (polar.radius <= 0)
            {
                polar.context.radius = 0;
            }
            else if (polar.radius <= 1)
            {
                polar.context.radius = Mathf.Min(chartWidth, chartHeight) * polar.radius;
            }
            else
            {
                polar.context.radius = polar.radius;
            }
        }
コード例 #5
0
        private void DrawPolarLine(VertexHelper vh, Serie serie)
        {
            var datas = serie.data;

            if (datas.Count <= 0)
            {
                return;
            }

            m_SeriePolar = chart.GetChartComponent <PolarCoord>(serie.polarIndex);
            if (m_SeriePolar == null)
            {
                return;
            }

            var m_AngleAxis  = ComponentHelper.GetAngleAxis(chart.components, m_SeriePolar.index);
            var m_RadiusAxis = ComponentHelper.GetRadiusAxis(chart.components, m_SeriePolar.index);

            if (m_AngleAxis == null || m_RadiusAxis == null)
            {
                return;
            }

            var startAngle = m_AngleAxis.startAngle;
            var radius     = m_SeriePolar.context.radius;

            var min                 = m_RadiusAxis.context.minValue;
            var max                 = m_RadiusAxis.context.maxValue;
            var firstSerieData      = datas[0];
            var lp                  = GetPolarPos(m_SeriePolar, m_AngleAxis, firstSerieData, min, max, radius);
            var cp                  = Vector3.zero;
            var lineColor           = SerieHelper.GetLineColor(serie, null, chart.theme, serie.index, serie.highlight);
            var lineWidth           = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth);
            var currDetailProgress  = 0f;
            var totalDetailProgress = datas.Count;

            serie.animation.InitProgress(currDetailProgress, totalDetailProgress);

            var  ltp = Vector3.zero;
            var  lbp = Vector3.zero;
            var  ntp = Vector3.zero;
            var  nbp = Vector3.zero;
            var  itp = Vector3.zero;
            var  ibp = Vector3.zero;
            var  clp = Vector3.zero;
            var  crp = Vector3.zero;
            bool bitp = true, bibp = true;

            for (int i = 1; i < datas.Count; i++)
            {
                if (serie.animation.CheckDetailBreak(i))
                {
                    break;
                }

                var serieData = datas[i];

                cp = GetPolarPos(m_SeriePolar, m_AngleAxis, datas[i], min, max, radius);
                var np = i == datas.Count - 1 ? cp :
                         GetPolarPos(m_SeriePolar, m_AngleAxis, datas[i + 1], min, max, radius);

                UGLHelper.GetLinePoints(lp, cp, np, lineWidth,
                                        ref ltp, ref lbp,
                                        ref ntp, ref nbp,
                                        ref itp, ref ibp,
                                        ref clp, ref crp,
                                        ref bitp, ref bibp, i);

                if (i == 1)
                {
                    UGL.AddVertToVertexHelper(vh, ltp, lbp, lineColor, false);
                }

                if (bitp == bibp)
                {
                    if (bitp)
                    {
                        UGL.AddVertToVertexHelper(vh, itp, ibp, lineColor, true);
                    }
                    else
                    {
                        UGL.AddVertToVertexHelper(vh, ltp, clp, lineColor, true);
                        UGL.AddVertToVertexHelper(vh, ltp, crp, lineColor, true);
                    }
                }
                else
                {
                    if (bitp)
                    {
                        UGL.AddVertToVertexHelper(vh, itp, clp, lineColor, true);
                        UGL.AddVertToVertexHelper(vh, itp, crp, lineColor, true);
                    }
                    else if (bibp)
                    {
                        UGL.AddVertToVertexHelper(vh, clp, ibp, lineColor, true);
                        UGL.AddVertToVertexHelper(vh, crp, ibp, lineColor, true);
                    }
                }
                lp = cp;
            }

            if (!serie.animation.IsFinish())
            {
                serie.animation.CheckProgress(totalDetailProgress);
                serie.animation.CheckSymbol(serie.symbol.GetSize(null, chart.theme.serie.lineSymbolSize));
                chart.RefreshChart();
            }
        }