Exemple #1
0
        private void InitAngleAxis(AngleAxis axis)
        {
            var polar = chart.GetChartComponent <PolarCoord>(axis.polarIndex);

            if (polar == null)
            {
                return;
            }
            PolarHelper.UpdatePolarCenter(polar, chart.chartPosition, chart.chartWidth, chart.chartHeight);
            var radius = polar.context.radius;

            axis.context.labelObjectList.Clear();
            axis.context.startAngle = 90 - axis.startAngle;

            string objName = component.GetType().Name + axis.index;
            var    axisObj = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
                                                   chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);

            axisObj.transform.localPosition = Vector3.zero;
            axisObj.SetActive(axis.show);
            axisObj.hideFlags = chart.chartHideFlags;
            ChartHelper.HideAllObject(axisObj);
            var splitNumber    = AxisHelper.GetSplitNumber(axis, radius, null);
            var totalAngle     = axis.context.startAngle;
            var total          = 360;
            var cenPos         = polar.context.center;
            var txtHig         = axis.axisLabel.textStyle.GetFontSize(chart.theme.axis) + 2;
            var margin         = axis.axisLabel.distance + axis.axisTick.GetLength(chart.theme.axis.tickLength);
            var isCategory     = axis.IsCategory();
            var isPercentStack = SeriesHelper.IsPercentStack <Bar>(chart.series);

            for (int i = 0; i < splitNumber; i++)
            {
                float scaleAngle = AxisHelper.GetScaleWidth(axis, total, i + 1, null);
                bool  inside     = axis.axisLabel.inside;
                var   labelName  = AxisHelper.GetLabelName(axis, total, i, axis.context.minValue, axis.context.maxValue,
                                                           null, isPercentStack);
                var label = ChartHelper.AddAxisLabelObject(splitNumber, i, objName + i, axisObj.transform,
                                                           new Vector2(scaleAngle, txtHig), axis,
                                                           chart.theme.axis, labelName, Color.clear);
                label.text.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.text, scaleAngle);
                }
                axis.context.labelObjectList.Add(label);

                totalAngle += scaleAngle;
            }
        }