public static GameObject Get(string name, Transform parent, LabelStyle label, Color color,
                                     float iconWidth, float iconHeight, ThemeStyle theme)
        {
            GameObject element;

            if (m_Stack.Count == 0 || !Application.isPlaying)
            {
                element = CreateSerieLabel(name, parent, label, color, iconWidth, iconHeight, theme);
            }
            else
            {
                element = m_Stack.Pop();
                if (element == null)
                {
                    element = CreateSerieLabel(name, parent, label, color, iconWidth, iconHeight, theme);
                }
                m_ReleaseDic.Remove(element.GetInstanceID());
                element.name = name;
                element.transform.SetParent(parent);
                var text = new ChartText(element);
                text.SetColor(color);
                text.SetFontAndSizeAndStyle(label.textStyle, theme.common);
                ChartHelper.SetActive(element, true);
            }
            element.transform.localEulerAngles = new Vector3(0, 0, label.rotate);
            return(element);
        }
Esempio n. 2
0
 public void SetIconActive(bool flag)
 {
     isIconActive = flag;
     if (m_IconImage)
     {
         ChartHelper.SetActive(m_IconImage, flag);
     }
 }
Esempio n. 3
0
 public void SetActive(bool flag)
 {
     m_Active = flag && tooltip.showContent;
     ChartHelper.SetActive(gameObject, m_Active);
     if (!flag)
     {
         foreach (var item in m_Items)
         {
             item.gameObject.SetActive(false);
         }
     }
 }
        public void SetActive(bool flag)
        {
#if dUI_TextMeshPro
            //m_TMPText.gameObject.SetActive(flag);
            if (m_TMPText != null)
            {
                ChartHelper.SetActive(m_TMPText.gameObject, flag);
            }
#else
            //m_Text.gameObject.SetActive(flag);
            if (m_Text != null)
            {
                ChartHelper.SetActive(m_Text.gameObject, flag);
            }
#endif
        }
 public static void Release(GameObject element)
 {
     if (element == null)
     {
         return;
     }
     ChartHelper.SetActive(element, false);
     if (!Application.isPlaying)
     {
         return;
     }
     if (!m_ReleaseDic.ContainsKey(element.GetInstanceID()))
     {
         m_Stack.Push(element);
         m_ReleaseDic.Add(element.GetInstanceID(), true);
     }
 }
 public bool RemoveChartComponent(MainComponent component)
 {
     if (component == null)
     {
         return(false);
     }
     if (m_Components.Remove(component))
     {
         if (component.gameObject != null)
         {
             ChartHelper.SetActive(component.gameObject, false);
         }
         InitComponentHandlers();
         RefreshChart();
         return(true);
     }
     return(false);
 }
Esempio n. 7
0
        public static void SetLegendBackground(Legend legend, ImageStyle style)
        {
            var background = legend.context.background;

            if (background == null)
            {
                return;
            }
            ChartHelper.SetActive(background, style.show);
            if (!style.show)
            {
                return;
            }
            var rect = background.gameObject.GetComponent <RectTransform>();

            rect.localPosition = legend.context.center;
            rect.sizeDelta     = new Vector2(legend.context.width, legend.context.height);
            ChartHelper.SetBackground(background, style);
        }
        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. 9
0
        public bool SetText(string text)
        {
            if (m_TextRect == null || m_LabelText == null)
            {
                return(false);
            }

            if (text == null)
            {
                text = "";
            }
            if (!m_LabelText.GetText().Equals(text))
            {
                m_LabelText.SetText(text);
                if (m_AutoSize)
                {
                    var newSize = string.IsNullOrEmpty(text) ? Vector2.zero :
                                  new Vector2(m_LabelText.GetPreferredWidth(),
                                              m_LabelText.GetPreferredHeight());
                    var sizeChange = newSize.x != m_TextRect.sizeDelta.x || newSize.y != m_TextRect.sizeDelta.y;
                    this.m_Width  = newSize.x;
                    this.m_Height = newSize.y;
                    if (sizeChange)
                    {
                        m_TextRect.sizeDelta = newSize;
                        UpdateSize();
                        UpdatePadding();
                        AdjustIconPos();
                    }
                    return(sizeChange);
                }
                AdjustIconPos();
                if (m_HideIconIfTextEmpty && isIconActive)
                {
                    ChartHelper.SetActive(m_IconImage.gameObject, !string.IsNullOrEmpty(text));
                }
            }
            return(false);
        }
Esempio n. 10
0
        public void Update()
        {
            if (clickChartCount > 2)
            {
                m_ShowDebugInfo = !m_ShowDebugInfo;
                ChartHelper.SetActive(m_Label.transform, m_ShowDebugInfo);
                clickChartCount     = 0;
                m_LastCheckShowTime = Time.realtimeSinceStartup;
                return;
            }
            if (Time.realtimeSinceStartup - m_LastCheckShowTime > 0.5f)
            {
                m_LastCheckShowTime = Time.realtimeSinceStartup;
                clickChartCount     = 0;
            }
            if (!m_ShowDebugInfo || m_Label == null)
            {
                return;
            }

            m_FrameCount++;
            if (Time.realtimeSinceStartup - m_LastTime >= INTERVAL)
            {
                fps          = m_FrameCount / (Time.realtimeSinceStartup - m_LastTime);
                m_FrameCount = 0;
                m_LastTime   = Time.realtimeSinceStartup;
                if (m_LastRefreshCount == refreshCount)
                {
                    m_LastRefreshCount = 0;
                    refreshCount       = 0;
                }
                m_LastRefreshCount = refreshCount;
                if (m_FpsList.Count > MAXCACHE)
                {
                    m_FpsList.RemoveAt(0);
                }
                m_FpsList.Add(fps);
                avgFps = GetAvg(m_FpsList);
                if (m_Label != null)
                {
                    s_Sb.Length = 0;
                    s_Sb.AppendFormat("v{0}\n", XChartsMgr.version);
                    s_Sb.AppendFormat("fps : {0:f0} / {1:f0}\n", fps, avgFps);
                    s_Sb.AppendFormat("draw : {0}\n", refreshCount);

                    var dataCount = m_Chart.GetAllSerieDataCount();
                    SetValueWithKInfo(s_Sb, "data", dataCount);

                    var vertCount = 0;
                    foreach (var serie in m_Chart.series)
                    {
                        vertCount += serie.context.vertCount;
                    }

                    SetValueWithKInfo(s_Sb, "b-vert", m_Chart.m_BasePainterVertCount);
                    SetValueWithKInfo(s_Sb, "s-vert", vertCount);
                    SetValueWithKInfo(s_Sb, "t-vert", m_Chart.m_TopPainterVertCount, false);

                    m_Label.SetText(s_Sb.ToString());
                }
            }
        }
Esempio n. 11
0
 public void SetActive(bool flag)
 {
     ChartHelper.SetActive(gameObject, flag);
 }