示例#1
0
    void Redraw()
    {
        if (Chart == null)
        {
            return;
        }
        DoubleVector3 last;

        if (Chart.DataSource.GetLastPoint("Player 1", out last))
        {
            if (TrackLast == false)
            {
                last.y = yPosition;
            }
            Vector3    pos;
            DoubleRect rect = new DoubleRect(last.x - Chart.DataSource.HorizontalViewSize, last.y - lineThickness * 0.5f, Chart.DataSource.HorizontalViewSize, lineThickness);
            DoubleRect trimRect;

            if (Area != null)
            {
                Vector3 res;
                if (Chart.PointToWorldSpace(out res, rect.min.x, rect.min.y))
                {
                    res.y += lineThickness;
                    double x, y;
                    if (Chart.PointToClient(res, out x, out y))
                    {
                        double thick = Math.Abs(rect.min.y - y);
                        rect = new DoubleRect(last.x - Chart.DataSource.HorizontalViewSize, last.y - thick * 0.5f, Chart.DataSource.HorizontalViewSize, thick);
                    }
                }
                if (Chart.TrimRect(rect, out trimRect))      // if the rect is in display
                {
                    if (Area.gameObject.activeSelf == false) // we draw it
                    {
                        Area.gameObject.SetActive(true);
                    }
                    Chart.RectToCanvas(Area, trimRect);
                    //       Area.sizeDelta = new Vector2(Area.sizeDelta.x, lineThickness);
                }
                else
                {
                    if (Area.gameObject.activeSelf == true) // otherwise it is set as incative
                    {
                        Area.gameObject.SetActive(false);
                    }
                }
            }
        }
    }
示例#2
0
    void Redraw()
    {
        if (Chart == null)
        {
            return;
        }

        if (Chart.IsRectVisible(currentRect) == false)
        {
            double endX = (float)(Chart.HorizontalScrolling + Chart.DataSource.HorizontalViewSize);
            double x    = endX - 1f;
            double y    = (float)Chart.VerticalScrolling;
            double endY = (float)Chart.DataSource.GetMaxValue(1, false);
            currentRect = new DoubleRect(x, y, endX - x, endY - y);
        }

        DoubleRect trimRect;

        if (Chart.TrimRect(currentRect, out trimRect))
        {
            Chart.RectToCanvas(Area, trimRect);
        }


        DoubleVector3 last;

        if (Chart.DataSource.GetLastPoint("Player 1", out last))
        {
            Vector3 pos;
            if (Chart.PointToWorldSpace(out pos, last.x, last.y, "Player 1"))
            {
                if (LastPoint != null)
                {
                    LastPoint.transform.position = pos;
                }
            }
        }
    }