private void InitRadiusAxis(RadiusAxis axis)
        {
            var polar = chart.GetChartComponent <PolarCoord>(axis.index);

            if (polar == null)
            {
                return;
            }

            var angleAxis = ComponentHelper.GetAngleAxis(chart.components, polar.index);

            if (angleAxis == null)
            {
                return;
            }

            PolarHelper.UpdatePolarCenter(polar, chart.chartPosition, chart.chartWidth, chart.chartHeight);
            axis.context.labelObjectList.Clear();
            var radius  = polar.context.radius;
            var 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 && axis.axisLabel.show);
            axisObj.hideFlags = chart.chartHideFlags;
            ChartHelper.HideAllObject(axisObj);
            var textStyle   = axis.axisLabel.textStyle;
            var splitNumber = AxisHelper.GetScaleNumber(axis, radius, null);
            var totalWidth  = 0f;
            var txtHig      = textStyle.GetFontSize(chart.theme.axis) + 2;

            for (int i = 0; i < splitNumber; i++)
            {
                var labelWidth     = AxisHelper.GetScaleWidth(axis, radius, i + 1, null);
                var inside         = axis.axisLabel.inside;
                var isPercentStack = SeriesHelper.IsPercentStack <Bar>(chart.series);
                var labelName      = AxisHelper.GetLabelName(axis, radius, i, axis.context.minValue, axis.context.maxValue,
                                                             null, isPercentStack);
                var label = ChartHelper.AddAxisLabelObject(splitNumber, i, objName + i, axisObj.transform,
                                                           new Vector2(labelWidth, txtHig), axis, chart.theme.axis, labelName, Color.clear);

                if (i == 0)
                {
                    axis.axisLabel.SetRelatedText(label.text, labelWidth);
                }

                label.text.SetAlignment(textStyle.GetAlignment(TextAnchor.MiddleCenter));
                label.SetText(labelName);
                label.SetPosition(GetLabelPosition(polar, axis, angleAxis.context.startAngle, totalWidth));
                label.SetActive(true);
                label.SetTextActive(true);

                axis.context.labelObjectList.Add(label);

                totalWidth += labelWidth;
            }
        }
Пример #2
0
 /// <summary>
 /// 更新刻度标签文字
 /// </summary>
 /// <param name="dataZoom"></param>
 internal void UpdateLabelText(float coordinateWidth, DataZoom dataZoom, bool forcePercent)
 {
     for (int i = 0; i < context.labelObjectList.Count; i++)
     {
         if (context.labelObjectList[i] != null)
         {
             var text = AxisHelper.GetLabelName(this, coordinateWidth, i, context.minValue, context.maxValue, dataZoom, forcePercent);
             context.labelObjectList[i].SetText(text);
         }
     }
 }
Пример #3
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;
            }
        }