private void SetTooltipIndicatorLabel(Tooltip tooltip, Axis axis, ChartLabel label) { if (label == null) { return; } if (double.IsPositiveInfinity(axis.context.pointerValue)) { return; } label.SetActive(true); label.SetTextActive(true); label.SetPosition(axis.context.pointerLabelPosition); if (axis.IsCategory()) { label.SetText(axis.GetData((int)axis.context.pointerValue)); } else { label.SetText(axis.context.pointerValue.ToString("f2")); } var textColor = axis.axisLabel.textStyle.GetColor(chart.theme.axis.textColor); if (ChartHelper.IsClearColor(tooltip.indicatorLabelStyle.background.color)) { label.color = textColor; } else { label.color = tooltip.indicatorLabelStyle.background.color; } label.SetTextColor(Color.white); }
public override void InitComponent() { var title = component; title.painter = null; title.refreshComponent = delegate() { title.OnChanged(); var anchorMin = title.location.runtimeAnchorMin; var anchorMax = title.location.runtimeAnchorMax; var pivot = title.location.runtimePivot; var objName = ChartCached.GetComponentObjectName(title); var titleObject = ChartHelper.AddObject(objName, chart.transform, anchorMin, anchorMax, pivot, chart.chartSizeDelta); title.gameObject = titleObject; title.gameObject.transform.SetSiblingIndex(chart.m_PainterUpper.transform.GetSiblingIndex() + 1); anchorMin = title.location.runtimeAnchorMin; anchorMax = title.location.runtimeAnchorMax; pivot = title.location.runtimePivot; var fontSize = title.labelStyle.textStyle.GetFontSize(chart.theme.title); ChartHelper.UpdateRectTransform(titleObject, anchorMin, anchorMax, pivot, new Vector2(chart.chartWidth, chart.chartHeight)); var titlePosition = chart.GetTitlePosition(title); var subTitlePosition = -new Vector3(0, fontSize + title.itemGap, 0); titleObject.transform.localPosition = titlePosition; titleObject.hideFlags = chart.chartHideFlags; ChartHelper.HideAllObject(titleObject); m_LabelObject = ChartHelper.AddChartLabel(s_TitleObjectName, titleObject.transform, title.labelStyle, chart.theme.title, GetTitleText(title), Color.clear, title.location.runtimeTextAlignment); m_LabelObject.SetActive(title.show && title.labelStyle.show); m_SubLabelObject = ChartHelper.AddChartLabel(s_SubTitleObjectName, titleObject.transform, title.subLabelStyle, chart.theme.subTitle, GetSubTitleText(title), Color.clear, title.location.runtimeTextAlignment); m_SubLabelObject.SetActive(title.show && title.subLabelStyle.show); m_SubLabelObject.transform.localPosition = subTitlePosition + title.subLabelStyle.offset; }; title.refreshComponent(); }