Exemplo n.º 1
0
        public void Assign(ChartSeriesViewData[] series, int firstFrame, int firstSelectableFrame)
        {
            this.series               = series;
            this.chartDomainOffset    = firstFrame;
            this.firstSelectableFrame = firstSelectableFrame;
            numSeries = series.Length;

            if (order == null || order.Length != numSeries)
            {
                order = new int[numSeries];
                for (int i = 0, count = order.Length; i < count; ++i)
                {
                    order[i] = order.Length - 1 - i;
                }
            }

            if (overlays == null || overlays.Length != numSeries)
            {
                overlays = new ChartSeriesViewData[numSeries];
            }
            if (dataAvailable == null && series.Length > 0 && series[0].xValues != null)
            {
                dataAvailable = new int[series[0].xValues.Length];
            }
        }
Exemplo n.º 2
0
        private void DrawChartItemLine(Rect r, ChartViewData cdata, int index)
        {
            ChartSeriesViewData chartSeriesViewData = cdata.series[index];

            if (chartSeriesViewData.enabled)
            {
                if (this.m_LineDrawingPoints == null || chartSeriesViewData.numDataPoints > this.m_LineDrawingPoints.Length)
                {
                    this.m_LineDrawingPoints = new Vector3[chartSeriesViewData.numDataPoints];
                }
                Vector2 dataDomain = cdata.GetDataDomain();
                float   num        = dataDomain.y - dataDomain.x;
                if (num > 0f)
                {
                    float num2 = 1f / num * r.width;
                    float num3 = (cdata.series[index].rangeAxis.sqrMagnitude != 0f) ? (1f / (cdata.series[index].rangeAxis.y - cdata.series[index].rangeAxis.x) * r.height) : 0f;
                    float num4 = r.y + r.height;
                    for (int i = 0; i < chartSeriesViewData.numDataPoints; i++)
                    {
                        this.m_LineDrawingPoints[i].Set((chartSeriesViewData.xValues[i] - dataDomain.x) * num2 + r.x, num4 - (chartSeriesViewData.yValues[i] - chartSeriesViewData.rangeAxis.x) * num3, 0f);
                    }
                    using (new Handles.DrawingScope(cdata.series[index].color))
                    {
                        Handles.DrawAAPolyLine(2f, chartSeriesViewData.numDataPoints, this.m_LineDrawingPoints);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void ConfigureChartSeries(int historySize, ProfilerCounterDescriptor[] counters)
        {
            var chartAreaColors = ProfilerColors.chartAreaColors;

            for (int i = 0; i < counters.Length; ++i)
            {
                var counter  = counters[i];
                var category = counter.CategoryName;
                m_Series[i] = new ChartSeriesViewData(counter.Name, category, historySize, chartAreaColors[i % chartAreaColors.Length]);
            }

            // Allocate dataAvailable array for chart.
            m_Data.dataAvailable = new int[historySize];
        }
Exemplo n.º 4
0
        private void DrawChartItemLine(Rect r, ChartViewData cdata, int index)
        {
            ChartSeriesViewData series = cdata.series[index];

            if (!series.enabled)
            {
                return;
            }

            if (m_LineDrawingPoints == null || series.numDataPoints > m_LineDrawingPoints.Length)
            {
                m_LineDrawingPoints = new Vector3[series.numDataPoints];
            }

            Vector2 domain     = cdata.GetDataDomain();
            float   domainSize = domain.y - domain.x;

            if (domainSize <= 0f)
            {
                return;
            }

            float domainScale = 1f / domainSize * r.width;
            float rangeScale  = cdata.series[index].rangeAxis.sqrMagnitude == 0f ?
                                0f : 1f / (cdata.series[index].rangeAxis.y - cdata.series[index].rangeAxis.x) * r.height;
            float rectBottom = r.y + r.height;

            for (int i = 0; i < series.numDataPoints; ++i)
            {
                float yValue = series.yValues[i] * series.yScale;
                m_LineDrawingPoints[i].Set(
                    (series.xValues[i] - domain.x) * domainScale + r.x,
                    rectBottom - (Mathf.Clamp(yValue, graphRange.x, graphRange.y) - series.rangeAxis.x) * rangeScale,
                    0f
                    );
            }

            using (new Handles.DrawingScope(cdata.series[index].color))
                Handles.DrawAAPolyLine(k_LineWidth, series.numDataPoints, m_LineDrawingPoints);
        }