예제 #1
0
        private void InitAngleAxis(AngleAxis axis)
        {
            PolarHelper.UpdatePolarCenter(m_Polar, m_ChartPosition, m_ChartWidth, m_ChartHeight);
            var radius = m_Polar.runtimeRadius;

            axis.axisLabelTextList.Clear();

            string objName = "axis_angle";
            var    axisObj = ChartHelper.AddObject(objName, transform, chartAnchorMin,
                                                   chartAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));

            axisObj.transform.localPosition = Vector3.zero;
            axisObj.SetActive(axis.show && axis.axisLabel.show);
            axisObj.hideFlags = chartHideFlags;
            ChartHelper.HideAllObject(axisObj);
            var labelColor = ChartHelper.IsClearColor(axis.axisLabel.color) ?
                             (Color)m_ThemeInfo.axisTextColor :
                             axis.axisLabel.color;
            int   splitNumber = AxisHelper.GetSplitNumber(axis, radius, null);
            float totalAngle  = m_AngleAxis.runtimeStartAngle;
            var   total       = 360;
            var   cenPos      = m_Polar.runtimeCenterPos;
            var   txtHig      = m_AngleAxis.axisLabel.fontSize + 2;
            var   margin      = m_AngleAxis.axisLabel.margin;
            var   isCategory  = m_AngleAxis.IsCategory();

            for (int i = 0; i < splitNumber - 1; i++)
            {
                float scaleAngle = AxisHelper.GetScaleWidth(axis, total, i, null);
                bool  inside     = axis.axisLabel.inside;
                Text  txt        = ChartHelper.AddTextObject(objName + i, axisObj.transform,
                                                             m_ThemeInfo.font, labelColor, TextAnchor.MiddleCenter, new Vector2(0.5f, 0.5f),
                                                             new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(scaleAngle, txtHig),
                                                             axis.axisLabel.fontSize, axis.axisLabel.rotate, axis.axisLabel.fontStyle);
                if (i == 0)
                {
                    axis.axisLabel.SetRelatedText(txt, scaleAngle);
                }
                var isPercentStack = SeriesHelper.IsPercentStack(m_Series, SerieType.Bar);
                txt.text = AxisHelper.GetLabelName(axis, total, i, axis.runtimeMinValue, axis.runtimeMaxValue, null,
                                                   isPercentStack);
                txt.gameObject.SetActive(axis.show &&
                                         (axis.axisLabel.interval == 0 || i % (axis.axisLabel.interval + 1) == 0));
                var pos = ChartHelper.GetPos(cenPos, radius + margin, isCategory ? (totalAngle + scaleAngle / 2) : totalAngle, true);
                AxisHelper.AdjustCircleLabelPos(txt, pos, cenPos, txtHig, Vector3.zero);
                axis.axisLabelTextList.Add(txt);

                totalAngle += scaleAngle;
            }
            if (m_Tooltip.runtimeGameObject)
            {
                Vector2    privot      = new Vector2(0.5f, 0.5f);
                var        labelParent = m_Tooltip.runtimeGameObject.transform;
                GameObject labelObj    = ChartHelper.AddTooltipLabel(ChartCached.GetAxisTooltipLabel(objName), labelParent,
                                                                     m_ThemeInfo.font, privot, privot, privot, new Vector2(10, txtHig));
                axis.SetTooltipLabel(labelObj);
                axis.SetTooltipLabelColor(m_ThemeInfo.tooltipBackgroundColor, m_ThemeInfo.tooltipTextColor);
                axis.SetTooltipLabelActive(axis.show && m_Tooltip.show && m_Tooltip.type == Tooltip.Type.Corss);
            }
        }
예제 #2
0
        private void InitAngleAxis(AngleAxis axis)
        {
            var m_Polar = GetPolar(axis.polarIndex);

            if (m_Polars == null)
            {
                return;
            }
            PolarHelper.UpdatePolarCenter(m_Polar, m_ChartPosition, m_ChartWidth, m_ChartHeight);
            var radius = m_Polar.runtimeRadius;

            axis.runtimeAxisLabelList.Clear();

            string objName = "axis_angle" + axis.index;
            var    axisObj = ChartHelper.AddObject(objName, transform, graphAnchorMin,
                                                   graphAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));

            axisObj.transform.localPosition = Vector3.zero;
            axisObj.SetActive(axis.show);
            axisObj.hideFlags = chartHideFlags;
            ChartHelper.HideAllObject(axisObj);
            var splitNumber    = AxisHelper.GetSplitNumber(axis, radius, null);
            var totalAngle     = axis.runtimeStartAngle;
            var total          = 360;
            var cenPos         = m_Polar.runtimeCenterPos;
            var txtHig         = axis.axisLabel.textStyle.GetFontSize(m_Theme.axis) + 2;
            var margin         = axis.axisLabel.margin;
            var isCategory     = axis.IsCategory();
            var isPercentStack = SeriesHelper.IsPercentStack(m_Series, SerieType.Bar);

            for (int i = 0; i < splitNumber; i++)
            {
                float scaleAngle = AxisHelper.GetScaleWidth(axis, total, i, null);
                bool  inside     = axis.axisLabel.inside;
                var   labelName  = AxisHelper.GetLabelName(axis, total, i, axis.runtimeMinValue, axis.runtimeMaxValue,
                                                           null, isPercentStack);
                var label = ChartHelper.AddAxisLabelObject(splitNumber, i, objName + i, axisObj.transform, new Vector2(0.5f, 0.5f),
                                                           new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(scaleAngle, txtHig), axis,
                                                           theme.axis, labelName);
                label.label.SetAlignment(axis.axisLabel.textStyle.GetAlignment(TextAnchor.MiddleCenter));
                var pos = ChartHelper.GetPos(cenPos, radius + margin,
                                             isCategory ? (totalAngle + scaleAngle / 2) : totalAngle, true);
                AxisHelper.AdjustCircleLabelPos(label, pos, cenPos, txtHig, Vector3.zero);
                if (i == 0)
                {
                    axis.axisLabel.SetRelatedText(label.label, scaleAngle);
                }
                axis.runtimeAxisLabelList.Add(label);

                totalAngle += scaleAngle;
            }
            if (tooltip.runtimeGameObject)
            {
                Vector2    privot      = new Vector2(0.5f, 0.5f);
                var        labelParent = tooltip.runtimeGameObject.transform;
                GameObject labelObj    = ChartHelper.AddTooltipLabel(ChartCached.GetAxisTooltipLabel(objName), labelParent,
                                                                     m_Theme, privot, privot, privot, new Vector2(10, txtHig));
                axis.SetTooltipLabel(labelObj);
                axis.SetTooltipLabelColor(m_Theme.tooltip.labelBackgroundColor, m_Theme.tooltip.labelTextColor);
                axis.SetTooltipLabelActive(axis.show && tooltip.show && tooltip.type == Tooltip.Type.Corss);
            }
        }