示例#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 FillGraph()
 {
     Graph.DataSource.ClearCategory("Category1");
     for (int i = 0; i < Bar.DataSource.TotalCategories; i++)
     {
         string categoryName = Bar.DataSource.GetCategoryName(i);
         for (int j = 0; j < Bar.DataSource.TotalGroups; j++)
         {
             string  groupName = Bar.DataSource.GetGroupName(j);
             Vector3 position;
             Bar.GetBarTrackPosition(categoryName, groupName, out position);          // find the position of the top of the bar chart
             double x, y;
             Graph.PointToClient(position, out x, out y);                             // convert it to graph coordinates
             Graph.DataSource.AddPointToCategory("Category1", x, Random.value * 10f); // drop the y value and set your own value
         }
     }
 }