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); } }
private void UpdateRuntimeValue() { foreach (var polar in m_Polars) { PolarHelper.UpdatePolarCenter(polar, m_ChartPosition, m_ChartWidth, m_ChartHeight); } foreach (var axis in m_AngleAxes) { axis.runtimeStartAngle = 90 - axis.startAngle; } }
private void UpdateRuntimeValue() { PolarHelper.UpdatePolarCenter(m_Polar, m_ChartPosition, m_ChartWidth, m_ChartHeight); m_AngleAxis.runtimeStartAngle = 90 - m_AngleAxis.startAngle; }
private void InitRadiusAxis(RadiusAxis axis) { var m_Polar = GetPolar(axis.index); if (m_Polars == null) { return; } var m_AngleAxis = GetAngleAxis(m_Polar.index); if (m_AngleAxis == null) { return; } PolarHelper.UpdatePolarCenter(m_Polar, m_ChartPosition, m_ChartWidth, m_ChartHeight); axis.axisLabelTextList.Clear(); var radius = m_Polar.runtimeRadius; var objName = "axis_radius" + axis.index; var axisObj = ChartHelper.AddObject(objName, transform, graphAnchorMin, graphAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight)); axisObj.transform.localPosition = Vector3.zero; axisObj.SetActive(axis.show && axis.axisLabel.show); axisObj.hideFlags = chartHideFlags; ChartHelper.HideAllObject(axisObj); var textStyle = axis.axisLabel.textStyle; var splitNumber = AxisHelper.GetSplitNumber(axis, radius, null); var totalWidth = 0f; var startAngle = m_AngleAxis.runtimeStartAngle; var cenPos = m_Polar.runtimeCenterPos; var txtHig = textStyle.GetFontSize(m_Theme.axis) + 2; var dire = ChartHelper.GetDire(startAngle, true).normalized; var tickWidth = axis.axisTick.GetLength(m_Theme.radiusAxis.tickWidth); var tickVetor = ChartHelper.GetVertialDire(dire) * (tickWidth + axis.axisLabel.margin); for (int i = 0; i < splitNumber; i++) { float labelWidth = AxisHelper.GetScaleWidth(axis, radius, i, null); bool inside = axis.axisLabel.inside; var txt = ChartHelper.AddTextObject(objName + i, axisObj.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(labelWidth, txtHig), textStyle, m_Theme.axis); if (i == 0) { axis.axisLabel.SetRelatedText(txt, labelWidth); } var isPercentStack = SeriesHelper.IsPercentStack(m_Series, SerieType.Bar); var labelName = AxisHelper.GetLabelName(axis, radius, i, axis.runtimeMinValue, axis.runtimeMaxValue, null, isPercentStack); txt.SetAlignment(TextAnchor.MiddleCenter); txt.SetText(labelName); txt.SetActive(axis.show && (axis.axisLabel.interval == 0 || i % (axis.axisLabel.interval + 1) == 0)); var pos = ChartHelper.GetPos(cenPos, totalWidth, startAngle, true) + tickVetor; txt.SetLocalPosition(pos); AxisHelper.AdjustRadiusAxisLabelPos(txt, pos, cenPos, txtHig, Vector3.zero); axis.axisLabelTextList.Add(txt); totalWidth += labelWidth; } if (tooltip.runtimeGameObject) { Vector2 privot = new Vector2(0.5f, 1); var labelParent = tooltip.runtimeGameObject.transform; var labelName = ChartCached.GetAxisTooltipLabel(objName); GameObject labelObj = ChartHelper.AddTooltipLabel(labelName, labelParent, m_Theme, privot); axis.SetTooltipLabel(labelObj); axis.SetTooltipLabelColor(m_Theme.tooltip.labelBackgroundColor, m_Theme.tooltip.labelTextColor); axis.SetTooltipLabelActive(axis.show && tooltip.show && tooltip.type == Tooltip.Type.Corss); } }
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); } }