コード例 #1
0
        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);
        }
コード例 #2
0
 public override void OnSerieDataUpdate(int serieIndex)
 {
     if (m_LabelObject != null && FormatterHelper.NeedFormat(component.text))
     {
         m_LabelObject.SetText(GetTitleText(component));
     }
     if (m_SubLabelObject != null && FormatterHelper.NeedFormat(component.subText))
     {
         m_SubLabelObject.SetText(GetSubTitleText(component));
     }
 }
コード例 #3
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());
                }
            }
        }
コード例 #4
0
        public void Refresh()
        {
            if (tooltip == null)
            {
                return;
            }
            var data = tooltip.context.data;

            var titleActive = !string.IsNullOrEmpty(data.title);

            if (titleActive != title.gameObject.activeSelf)
            {
                title.gameObject.SetActive(titleActive);
            }
            title.SetText(data.title);

            m_ColumnMaxWidth.Clear();
            for (int i = 0; i < data.param.Count; i++)
            {
                var item  = GetItem(i);
                var param = data.param[i];
                if (param.columns.Count <= 0)
                {
                    item.gameObject.SetActive(false);
                    continue;
                }
                item.gameObject.SetActive(true);
                for (int j = 0; j < param.columns.Count; j++)
                {
                    var column = GetItemColumn(item, j);
                    column.SetActive(true);
                    column.SetText(param.columns[j]);

                    if (j == 0)
                    {
                        column.text.SetColor(param.color);
                    }

                    if (j >= m_ColumnMaxWidth.Count)
                    {
                        m_ColumnMaxWidth.Add(0);
                    }

                    var columnWidth = column.GetWidth();
                    if (m_ColumnMaxWidth[j] < columnWidth)
                    {
                        m_ColumnMaxWidth[j] = columnWidth;
                    }
                }
                for (int j = param.columns.Count; j < item.columns.Count; j++)
                {
                    item.columns[j].SetActive(false);
                }
            }
            for (int i = data.param.Count; i < m_Items.Count; i++)
            {
                m_Items[i].gameObject.SetActive(false);
            }
            ResetSize();
            // border.effectColor = data.param.Count == 1
            //     ? data.param[0].color
            //     : tooltip.borderColor;
            UpdatePosition(tooltip.context.pointer + tooltip.offset);
            tooltip.gameObject.transform.SetAsLastSibling();
        }