private void InitRadarCoord(RadarCoord radar) { float txtHig = 20; radar.painter = chart.GetPainter(radar.index); radar.refreshComponent = delegate() { radar.UpdateRadarCenter(chart.chartPosition, chart.chartWidth, chart.chartHeight); var radarObject = ChartHelper.AddObject("Radar" + radar.index, chart.transform, chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); radar.gameObject = radarObject; radar.gameObject.hideFlags = chart.chartHideFlags; ChartHelper.HideAllObject(radarObject.transform, INDICATOR_TEXT); for (int i = 0; i < radar.indicatorList.Count; i++) { var indicator = radar.indicatorList[i]; var pos = radar.GetIndicatorPosition(i); var objName = INDICATOR_TEXT + "_" + i; var label = ChartHelper.AddChartLabel(objName, radarObject.transform, radar.axisName.labelStyle, chart.theme.common, radar.GetFormatterIndicatorContent(i), Color.clear, TextAnchor.MiddleCenter); label.SetActive(radar.indicator && radar.axisName.labelStyle.show); AxisHelper.AdjustCircleLabelPos(label, pos, radar.context.center, txtHig, radar.axisName.labelStyle.offset); } chart.RefreshBasePainter(); }; radar.refreshComponent.Invoke(); }
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; } }