コード例 #1
0
        void DisplayHistogram(ScrollView scrollView)
        {
            // Clear the scrollview
            scrollView.Clear();

            if (panel == null)
            {
                m_HistogramTitle.text = "Histogram - No Panel Selected";
            }
            else
            {
                Dictionary <string, long> histogramValue;
                histogramValue = m_Debugger.ComputeHistogram(m_SelectedEvents?.Select(x => x.eventBase).ToList() ?? m_Log.lines.Select(x => x.eventBase).ToList());
                if (histogramValue == null)
                {
                    return;
                }

                m_HistogramTitle.text = "Histogram - Element Count : " + histogramValue.Count;

                var childrenList = scrollView.Children().ToList();
                foreach (var child in childrenList)
                {
                    child.RemoveFromHierarchy();
                }

                long maxDuration = 0;
                foreach (var key in histogramValue.Keys)
                {
                    if (maxDuration < histogramValue[key])
                    {
                        maxDuration = histogramValue[key];
                    }
                }

                foreach (var key in histogramValue.Keys)
                {
                    AddHistogramEntry(scrollView, key, histogramValue[key], histogramValue[key] / (float)maxDuration);
                }
            }
        }