コード例 #1
0
        private void InitTooltip(Tooltip tooltip)
        {
            tooltip.painter          = chart.m_PainterUpper;
            tooltip.refreshComponent = delegate()
            {
                var objName = ChartCached.GetComponentObjectName(tooltip);
                tooltip.gameObject = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
                                                           chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
                var tooltipObject = tooltip.gameObject;
                tooltipObject.transform.localPosition = Vector3.zero;
                tooltipObject.hideFlags = chart.chartHideFlags;
                var parent = tooltipObject.transform;
                ChartHelper.HideAllObject(tooltipObject.transform);

                tooltip.view = TooltipView.CreateView(tooltip, chart.theme, parent);
                tooltip.SetActive(false);

                m_LabelRoot = ChartHelper.AddObject("label", tooltip.gameObject.transform, chart.chartMinAnchor,
                                                    chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
                ChartHelper.HideAllObject(m_LabelRoot);
                m_IndicatorLabels.Clear();
                for (int i = 0; i < 2; i++)
                {
                    var labelName = "label_" + i;
                    var item      = ChartHelper.AddTooltipIndicatorLabel(component, labelName, m_LabelRoot.transform,
                                                                         chart.theme, TextAnchor.MiddleCenter);
                    item.SetActive(false);
                    m_IndicatorLabels.Add(item);
                }
            };
            tooltip.refreshComponent();
        }
コード例 #2
0
        public override void InitComponent()
        {
            var comment = component;

            comment.painter          = null;
            comment.refreshComponent = delegate()
            {
                var objName    = ChartCached.GetComponentObjectName(comment);
                var commentObj = ChartHelper.AddObject(objName,
                                                       chart.transform,
                                                       chart.chartMinAnchor,
                                                       chart.chartMaxAnchor,
                                                       chart.chartPivot,
                                                       chart.chartSizeDelta);

                commentObj.SetActive(comment.show);
                commentObj.hideFlags = chart.chartHideFlags;
                ChartHelper.HideAllObject(commentObj);
                for (int i = 0; i < comment.items.Count; i++)
                {
                    var item       = comment.items[i];
                    var labelStyle = comment.GetLabelStyle(i);
                    var label      = ChartHelper.AddChartLabel(s_CommentObjectName + i, commentObj.transform, labelStyle, chart.theme.common,
                                                               GetContent(item), Color.clear, TextAnchor.MiddleCenter);
                    label.SetActive(comment.show && item.show);
                    label.SetPosition(item.position + labelStyle.offset);
                }
            };
            comment.refreshComponent();
        }
コード例 #3
0
        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();
        }