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; } }
private void DrawRadiusAxis(VertexHelper vh, RadiusAxis radiusAxis) { var polar = chart.GetChartComponent <PolarCoord>(radiusAxis.polarIndex); if (polar == null) { return; } var angleAxis = ComponentHelper.GetAngleAxis(chart.components, polar.index); if (angleAxis == null) { return; } var startAngle = angleAxis.context.startAngle; var radius = polar.context.radius; var cenPos = polar.context.center; var size = AxisHelper.GetScaleNumber(radiusAxis, radius, null); var totalWidth = 0f; var dire = ChartHelper.GetDire(startAngle, true).normalized; var tickWidth = radiusAxis.axisTick.GetWidth(chart.theme.axis.tickWidth); var tickLength = radiusAxis.axisTick.GetLength(chart.theme.axis.tickLength); var tickVetor = ChartHelper.GetVertialDire(dire) * tickLength; for (int i = 0; i <= size; i++) { var scaleWidth = AxisHelper.GetScaleWidth(radiusAxis, radius, i); var pos = ChartHelper.GetPos(cenPos, totalWidth + tickWidth, startAngle, true); if (radiusAxis.show && radiusAxis.splitLine.show) { var outsideRaidus = totalWidth + radiusAxis.splitLine.GetWidth(chart.theme.axis.splitLineWidth) * 2; var splitLineColor = radiusAxis.splitLine.GetColor(chart.theme.axis.splitLineColor); UGL.DrawDoughnut(vh, cenPos, totalWidth, outsideRaidus, splitLineColor, Color.clear); } if (radiusAxis.show && radiusAxis.axisTick.show) { if ((i == 0 && radiusAxis.axisTick.showStartTick) || (i == size && radiusAxis.axisTick.showEndTick) || (i > 0 && i < size)) { UGL.DrawLine(vh, pos, pos + tickVetor, tickWidth, chart.theme.axis.lineColor); } } totalWidth += scaleWidth; } if (radiusAxis.show && radiusAxis.axisLine.show) { var lineStartPos = polar.context.center - dire * tickWidth; var lineEndPos = polar.context.center + dire * (radius + tickWidth); var lineWidth = radiusAxis.axisLine.GetWidth(chart.theme.axis.lineWidth); UGL.DrawLine(vh, lineStartPos, lineEndPos, lineWidth, chart.theme.axis.lineColor); } }
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; } }
private void DrawAngleAxis(VertexHelper vh, AngleAxis angleAxis) { var polar = chart.GetChartComponent <PolarCoord>(angleAxis.polarIndex); var radius = polar.context.radius; var cenPos = polar.context.center; var total = 360; var size = AxisHelper.GetScaleNumber(angleAxis, total, null); var currAngle = angleAxis.context.startAngle; var tickWidth = angleAxis.axisTick.GetWidth(chart.theme.axis.tickWidth); var tickLength = angleAxis.axisTick.GetLength(chart.theme.axis.tickLength); var tickColor = angleAxis.axisTick.GetColor(chart.theme.axis.lineColor); var lineColor = angleAxis.axisLine.GetColor(chart.theme.axis.lineColor); var splitLineColor = angleAxis.splitLine.GetColor(chart.theme.axis.splitLineColor); for (int i = 1; i < size; i++) { var scaleWidth = AxisHelper.GetScaleWidth(angleAxis, total, i); var pos = ChartHelper.GetPos(cenPos, radius, currAngle, true); if (angleAxis.show && angleAxis.splitLine.show) { var lineWidth = angleAxis.splitLine.GetWidth(chart.theme.axis.splitLineWidth); UGL.DrawLine(vh, cenPos, pos, lineWidth, splitLineColor); } if (angleAxis.show && angleAxis.axisTick.show) { if ((i == 1 && angleAxis.axisTick.showStartTick) || (i == size - 1 && angleAxis.axisTick.showEndTick) || (i > 1 && i < size - 1)) { var tickY = radius + tickLength; var tickPos = ChartHelper.GetPos(cenPos, tickY, currAngle, true); UGL.DrawLine(vh, pos, tickPos, tickWidth, tickColor); } } currAngle += scaleWidth; } if (angleAxis.show && angleAxis.axisLine.show) { var lineWidth = angleAxis.axisLine.GetWidth(chart.theme.axis.lineWidth); var outsideRaidus = radius + lineWidth * 2; UGL.DrawDoughnut(vh, cenPos, radius, outsideRaidus, lineColor, Color.clear); } }