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();
        }
Esempio n. 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();
        }
Esempio n. 3
0
        private static ChartLabel CreateViewItemColumn(int i, Transform parent, Tooltip tooltip, ComponentTheme theme)
        {
            var labelStyle = tooltip.GetContentLabelStyle(i);
            var label      = ChartHelper.AddChartLabel("column" + i, parent, labelStyle, theme,
                                                       "", Color.clear, TextAnchor.MiddleLeft);

            return(label);
        }
        private static GameObject CreateSerieLabel(string name, Transform parent, LabelStyle labelStyle, Color color,
                                                   float iconWidth, float iconHeight, ThemeStyle theme)
        {
            var label = ChartHelper.AddChartLabel(name, parent, labelStyle, theme.common,
                                                  "", color, TextAnchor.MiddleCenter);

            label.SetActive(labelStyle.show);
            return(label.gameObject);
        }
        internal static ChartLabel AddTooltipIndicatorLabel(Tooltip tooltip, string name, Transform parent,
                                                            ThemeStyle theme, TextAnchor alignment)
        {
            var label = ChartHelper.AddChartLabel(name, parent, tooltip.indicatorLabelStyle, theme.tooltip,
                                                  "", Color.clear, alignment);

            label.SetActive(tooltip.show && tooltip.indicatorLabelStyle.show);
            return(label);
        }
Esempio n. 6
0
 private void InitMarkArea(MarkArea markArea)
 {
     markArea.painter          = chart.m_PainterUpper;
     markArea.refreshComponent = delegate()
     {
         var label = ChartHelper.AddChartLabel("label", m_MarkLineLabelRoot.transform, markArea.label, chart.theme.axis,
                                               component.text, Color.clear, TextAnchor.MiddleCenter);
         UpdateRuntimeData(component);
         label.SetActive(markArea.label.show);
         label.SetPosition(component.runtimeLabelPosition);
         label.SetText(component.text);
         markArea.runtimeLabel = label;
     };
     markArea.refreshComponent();
 }
        private void InitMarkLineLabel(Serie serie, MarkLineData data, Color serieColor)
        {
            data.painter          = chart.m_PainterUpper;
            data.refreshComponent = delegate()
            {
                var textName = string.Format("markLine_{0}_{1}", serie.index, data.index);
                var content  = MarkLineHelper.GetFormatterContent(serie, data);
                var label    = ChartHelper.AddChartLabel(textName, m_MarkLineLabelRoot.transform, data.label, chart.theme.axis,
                                                         content, Color.clear, TextAnchor.MiddleCenter);

                label.SetIconActive(false);
                label.SetActive(data.label.show);
                label.SetPosition(MarkLineHelper.GetLabelPosition(data));
                data.runtimeLabel = label;
            };
            data.refreshComponent();
        }
Esempio n. 8
0
        public static TooltipView CreateView(Tooltip tooltip, ThemeStyle theme, Transform parent)
        {
            var view = new TooltipView();

            view.tooltip = tooltip;
            view.theme   = theme.tooltip;

            view.gameObject = ChartHelper.AddObject("view", parent, anchorMin, anchorMax, pivot, Vector3.zero);
            view.gameObject.transform.localPosition = Vector3.zero;
            view.transform = view.gameObject.transform;

            view.background        = ChartHelper.GetOrAddComponent <Image>(view.gameObject);
            view.background.sprite = tooltip.backgroundImage;
            view.background.type   = tooltip.backgroundType;
            view.background.color  = ChartHelper.IsClearColor(tooltip.backgroundColor) ?
                                     Color.white : tooltip.backgroundColor;

            view.border                 = ChartHelper.GetOrAddComponent <Outline>(view.gameObject);
            view.border.enabled         = tooltip.borderWidth > 0;
            view.border.useGraphicAlpha = false;
            view.border.effectColor     = tooltip.borderColor;
            view.border.effectDistance  = new Vector2(tooltip.borderWidth, -tooltip.borderWidth);

            view.layout = ChartHelper.GetOrAddComponent <VerticalLayoutGroup>(view.gameObject);
            view.layout.childControlHeight     = false;
            view.layout.childControlWidth      = false;
            view.layout.childForceExpandHeight = false;
            view.layout.childForceExpandWidth  = false;
            view.layout.padding = new RectOffset(tooltip.paddingLeftRight,
                                                 tooltip.paddingLeftRight,
                                                 tooltip.paddingTopBottom,
                                                 tooltip.paddingTopBottom);

            view.title = ChartHelper.AddChartLabel("title", view.gameObject.transform, tooltip.titleLabelStyle, theme.tooltip,
                                                   "", Color.clear, TextAnchor.MiddleLeft);

            var item = CreateViewItem(0, view.gameObject.transform, tooltip, theme.tooltip);

            view.m_Items.Add(item);

            view.Refresh();

            return(view);
        }
Esempio n. 9
0
        public static LegendItem AddLegendItem(BaseChart chart, Legend legend, int i, string legendName, Transform parent,
                                               ThemeStyle theme, string content, Color itemColor, bool active, int legendIndex)
        {
            var objName       = i + "_" + legendName;
            var anchorMin     = new Vector2(0, 0.5f);
            var anchorMax     = new Vector2(0, 0.5f);
            var pivot         = new Vector2(0, 0.5f);
            var sizeDelta     = new Vector2(100, 30);
            var iconSizeDelta = new Vector2(legend.itemWidth, legend.itemHeight);
            var textStyle     = legend.labelStyle.textStyle;
            var contentColor  = GetContentColor(chart, legendIndex, legendName, legend, theme, active);

            var objAnchorMin = new Vector2(0, 1);
            var objAnchorMax = new Vector2(0, 1);
            var objPivot     = new Vector2(0, 1);
            var btnObj       = ChartHelper.AddObject(objName, parent, objAnchorMin, objAnchorMax, objPivot, sizeDelta);
            var iconObj      = ChartHelper.AddObject("icon", btnObj.transform, anchorMin, anchorMax, pivot, iconSizeDelta);
            var img          = ChartHelper.GetOrAddComponent <Image>(btnObj);

            img.color         = Color.clear;
            img.raycastTarget = true;
            ChartHelper.GetOrAddComponent <Button>(btnObj);
            ChartHelper.GetOrAddComponent <Image>(iconObj);

            var label = ChartHelper.AddChartLabel("content", btnObj.transform, legend.labelStyle, theme.legend,
                                                  content, contentColor, TextAnchor.MiddleLeft);

            label.SetActive(true);

            var item = new LegendItem();

            item.index      = i;
            item.name       = objName;
            item.legendName = legendName;
            item.SetObject(btnObj);
            item.SetIconSize(legend.itemWidth, legend.itemHeight);
            item.SetIconColor(itemColor);
            item.SetIconImage(legend.GetIcon(i));
            item.SetContentPosition(legend.labelStyle.offset);
            item.SetContent(content);
            //item.SetBackground(legend.background);
            return(item);
        }
Esempio n. 10
0
        private ChartLabel AddDebugInfoObject(string name, Transform parent, LabelStyle labelStyle,
                                              ThemeStyle theme)
        {
            var anchorMax = new Vector2(0, 1);
            var anchorMin = new Vector2(0, 1);
            var pivot     = new Vector2(0, 1);
            var sizeDelta = new Vector2(100, 100);

            var labelGameObject = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);

            labelGameObject.transform.SetAsLastSibling();
            labelGameObject.hideFlags = m_Chart.chartHideFlags;
            ChartHelper.SetActive(labelGameObject, m_ShowDebugInfo);

            var label = ChartHelper.AddChartLabel("info", labelGameObject.transform, labelStyle, theme.common,
                                                  "", Color.clear, TextAnchor.UpperLeft);

            label.SetActive(labelStyle.show);
            return(label);
        }
Esempio n. 11
0
        public override void InitComponent()
        {
            var dataZoom = component;

            dataZoom.painter          = chart.m_PainterUpper;
            dataZoom.refreshComponent = delegate()
            {
                var dataZoomObject = ChartHelper.AddObject(s_DefaultDataZoom + dataZoom.index, chart.transform,
                                                           chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
                dataZoom.gameObject      = dataZoomObject;
                dataZoomObject.hideFlags = chart.chartHideFlags;
                ChartHelper.HideAllObject(dataZoomObject);

                var startLabel = ChartHelper.AddChartLabel(s_DefaultDataZoom + "start", dataZoomObject.transform,
                                                           dataZoom.labelStyle, chart.theme.dataZoom, "", Color.clear, TextAnchor.MiddleRight);
                startLabel.gameObject.SetActive(true);

                var endLabel = ChartHelper.AddChartLabel(s_DefaultDataZoom + "end", dataZoomObject.transform,
                                                         dataZoom.labelStyle, chart.theme.dataZoom, "", Color.clear, TextAnchor.MiddleLeft);
                endLabel.gameObject.SetActive(true);

                dataZoom.SetStartLabel(startLabel);
                dataZoom.SetEndLabel(endLabel);
                dataZoom.SetLabelActive(false);

                foreach (var index in dataZoom.xAxisIndexs)
                {
                    var xAxis = chart.GetChartComponent <XAxis>(index);
                    if (xAxis != null)
                    {
                        xAxis.UpdateFilterData(dataZoom);
                    }
                }

                foreach (var serie in chart.series)
                {
                    SerieHelper.UpdateFilterData(serie, dataZoom);
                }
            };
            dataZoom.refreshComponent();
        }
Esempio n. 12
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();
        }