예제 #1
0
        public void Update(GraphChartBase graphChart)
        {
            if (graphChart == null || points == null || points.Count == 0)
            {
                return;
            }
            if (index >= points.Count)
            {
                return;
            }
            float leapTime = totalTime / (float)points.Count;

            next -= Time.deltaTime;
            if (next <= 0)
            {
                int totalLeaps = (int)(Time.deltaTime / (leapTime));

                for (int i = 0; i < totalLeaps && index < points.Count; i++)
                {
                    DoubleVector2 point = points[index];
                    graphChart.DataSource.AddPointToCategoryRealtime(category, point.x, point.y, leapTime);
                    ++index;
                }
                next = leapTime;
            }
        }
예제 #2
0
    void Start()
    {
        GraphChartBase graph = GetComponent <GraphChartBase>();

        if (graph != null)
        {
            graph.HorizontalValueToStringMap[0.0] = "Zero"; // example of how to set custom axis strings
            graph.DataSource.StartBatch();
            graph.DataSource.ClearCategory("Player 1");
            graph.DataSource.ClearAndMakeBezierCurve("Player 2");

            for (int i = 0; i < 5; i++)
            {
                graph.DataSource.AddPointToCategory("Player 1", i, Random.value * 10f + 20f);
                if (i == 0)
                {
                    graph.DataSource.SetCurveInitialPoint("Player 2", i, Random.value * 10f + 10f);
                }
                else
                {
                    graph.DataSource.AddLinearCurveToCategory("Player 2",
                                                              new DoubleVector2(i, Random.value * 10f + 10f));
                }
            }
            graph.DataSource.MakeCurveCategorySmooth("Player 2");
            graph.DataSource.EndBatch();
        }
    }
예제 #3
0
    void Start()
    {
        graph = GetComponent <GraphChartBase>();
        if (graph != null)
        {
            graph.DataSource.StartBatch();
            graph.DataSource.ClearCategory("Player 1");
            graph.DataSource.ClearAndMakeBezierCurve("Player 2");
            for (int i = 0; i < 30; i++)
            {
                graph.DataSource.AddPointToCategory("Player 1", Random.value * 10f, Random.value * 10f + 20f);
                if (i == 0)
                {
                    graph.DataSource.SetCurveInitialPoint("Player 2", 0f, Random.value * 10f + 10f);
                }
                else
                {
                    graph.DataSource.AddLinearCurveToCategory("Player 2",
                                                              new DoubleVector2(i * 10f / 30f, Random.value * 10f + 10f));
                }
            }

            graph.DataSource.MakeCurveCategorySmooth("Player 2");
            graph.DataSource.EndBatch();
        }
    }
예제 #4
0
    void Start()
    {
        GraphChartBase graph = GetComponent <GraphChartBase>();

        if (graph != null)
        {
            graph.DataSource.StartBatch();
            graph.DataSource.ClearAndMakeBezierCurve("Temperature");
            for (int i = 0; i < 30; i++)
            {
                if (i == 0)
                {
                    graph.DataSource.SetCurveInitialPoint("Temperature", DateTime.Now, UnityEngine.Random.value * 10f + 10f);
                }
                else
                {
                    graph.DataSource.AddLinearCurveToCategory("Temperature",
                                                              new DoubleVector2(ChartDateUtility.DateToValue(DateTime.Now) + i, UnityEngine.Random.value * 10f + 10f));
                }
            }

            graph.DataSource.MakeCurveCategorySmooth("Temperature");
            graph.DataSource.EndBatch();
        }
    }
예제 #5
0
    void LoadObjectArray(CategoryData data)
    {
        GraphChartBase graph  = GraphObject.GetComponent <GraphChartBase>();
        var            parent = mParser.GetObject(data.ParentObjectName);

        if (parent == null)
        {
            Debug.LogWarning("Object " + data.ParentObjectName + " does not exist in the document");
            return;
        }

        int length = mParser.GetArraySize(parent);

        try
        {
            for (int i = 0; i < length; i++)
            {
                object item      = mParser.GetItemObject(parent, i);
                double x         = ParseItem(mParser.GetChildObjectValue(item, data.XDataObjectName), data.XDateFormat);
                double y         = ParseItem(mParser.GetChildObjectValue(item, data.YDataObjectName), data.YDateFormat);
                double pointSize = -1;
                if (String.IsNullOrEmpty(data.SizeDataObjectName) == false)
                {
                    pointSize = double.Parse(mParser.GetChildObjectValue(item, data.SizeDataObjectName));
                }
                graph.DataSource.AddPointToCategory(data.Name, x, y, pointSize);
            }
        }
        catch (Exception e)
        {
            Debug.LogWarning("Data for category " + data.Name + " does not match the specified format. Ended with exception : " + e.ToString());
        }
    }
예제 #6
0
    void LoadVectorArray(CategoryData data)
    {
        GraphChartBase   graph      = GraphObject.GetComponent <GraphChartBase>();
        var              obj        = mParser.GetObject(data.DataObjectName);
        int              size       = mParser.GetArraySize(obj);
        VectorFormatData formatData = mVectorFormats[data.DataFormat];

        if (size < 0) // this is not an array , show warning
        {
            Debug.LogWarning("DataType " + data.DataType + " does not match category " + data.Name);
            return;
        }
        int itemLength = data.Skip + formatData.Length;

        try
        {
            for (int i = 0; i < size; i += itemLength)
            {
                double x         = ParseItem(mParser.GetItem(obj, i + formatData.X), data.XDateFormat);
                double y         = ParseItem(mParser.GetItem(obj, i + formatData.Y), data.YDateFormat);
                double pointSize = -1;
                if (formatData.Size >= 0)
                {
                    pointSize = double.Parse(mParser.GetItem(obj, i + formatData.Size));
                }
                graph.DataSource.AddPointToCategory(data.Name, x, y, pointSize);
            }
        }
        catch (Exception e)
        {
            Debug.LogWarning("Data for category " + data.Name + " does not match the specified format. Ended with exception : " + e.ToString());
        }
    }
예제 #7
0
    IEnumerator ClearAll()
    {
        yield return(new WaitForSeconds(5f));

        GraphChartBase graph = GetComponent <GraphChartBase>();

        graph.DataSource.Clear();
    }
예제 #8
0
 void Start()
 {
     graph = GetComponent <GraphChartBase>();
     //double x = 0f;
     //for (int i = 0; i < 250000; i++)    // initialize with random data
     //{
     //    mData.Add(new DoubleVector2(x, UnityEngine.Random.value));
     //    x += UnityEngine.Random.value * 10f;
     //}
     LoadPage(currentPagePosition); // load the page at position 0
 }
예제 #9
0
 // Update is called once per frame
 void Update()
 {
     graphChart = GetComponent <GraphChartBase>();
     if (graphChart == null)
     {
         return;
     }
     foreach (InnerAnimation anim in mAnimations.Values)
     {
         anim.Update(graphChart);
     }
 }
예제 #10
0
 void Start()
 {
     graph = GetComponent <GraphChartBase>();
     if (graph != null)
     {
         graph.DataSource.StartBatch();
         graph.DataSource.ClearCategory("MaxScore");
         graph.DataSource.ClearCategory("AvgScore");
         graph.DataSource.AddPointToCategory("MaxScore", 0, 0);
         graph.DataSource.AddPointToCategory("AvgScore", 0, 0);
         graph.DataSource.EndBatch();
     }
 }
예제 #11
0
 void Start()
 {
     try
     {
         graph          = GetComponent <GraphChartBase>();
         documentClient = new DocumentClient(new Uri(endpointString), authKeyString);
         //Task.Run(TestTableConnection);
     }
     catch (Exception e)
     {
         print("Some error occured: " + e.Message);
     }
 }
예제 #12
0
    public void ApplyData(string text)
    {
        GraphChartBase graph = GraphObject.GetComponent <GraphChartBase>();

        if (Format == DocumentFormat.JSON)
        {
            mParser = new JsonParser(text);
        }
        else
        {
            mParser = new XMLParser(text);
        }

        LoadCategoryVisualStyle(graph);
        EnsureCreateDataTypes();
        if (mCategoryVisualStyle.Length == 0)
        {
            Debug.LogWarning("no visual styles defeind for GraphDataFiller, aborting");
            return;
        }

        if (mCategoryVisualStyle.Length < Categories.Length)
        {
            Debug.LogWarning("not enough visual styles in GraphDataFiller");
        }


        graph.DataSource.StartBatch();
        for (int i = 0; i < Categories.Length; i++)
        {
            var cat = Categories[i];
            if (cat.Enabled == false)
            {
                continue;
            }
            int    visualIndex = Math.Min(i, mCategoryVisualStyle.Length - 1);
            object visualStyle = mCategoryVisualStyle[visualIndex];

            if (graph.DataSource.HasCategory(cat.Name))
            {
                graph.DataSource.RemoveCategory(cat.Name);
            }
            graph.DataSource.AddCategory(cat.Name, null, 0, new MaterialTiling(), null, false, null, 0);
            graph.DataSource.RestoreCategory(cat.Name, visualStyle); // set the visual style of the category to the one in the prefab
            var loader = mLoaders[cat.DataType];                     // find the loader based on the data type
            loader(cat);                                             // load the category data
        }
        graph.DataSource.EndBatch();
    }
예제 #13
0
 public void Update(GraphChartBase graphChart)
 {
     if (graphChart == null || points == null || points.Count == 0)
     {
         return;
     }
     if (index >= points.Count)
     {
         return;
     }
     next -= Time.deltaTime;
     if (next <= 0)
     {
         next = totalTime / (float)points.Count;
         Vector2 point = points[index];
         graphChart.DataSource.AddPointToCategoryRealtime(category, point.x, point.y, next);
         ++index;
     }
 }
예제 #14
0
    void LoadArrayForEachElement(CategoryData data)
    {
        GraphChartBase graph = GraphObject.GetComponent <GraphChartBase>();

        if (mParser.SetPathRelativeTo(data.ParentObjectName) == false)
        {
            Debug.LogWarning("Object " + data.ParentObjectName + " does not exist in the document");
            return;
        }
        var    xObj    = mParser.GetObject(data.XDataObjectName);
        var    yObj    = mParser.GetObject(data.YDataObjectName);
        object sizeObj = null;

        if (String.IsNullOrEmpty(data.SizeDataObjectName) == false)
        {
            sizeObj = mParser.GetObject(data.SizeDataObjectName);
        }
        int length = Math.Min(mParser.GetArraySize(xObj), mParser.GetArraySize(yObj));

        if (sizeObj != null)
        {
            length = Math.Min(length, mParser.GetArraySize(sizeObj));
        }
        try
        {
            for (int i = 0; i < length; i++)
            {
                double x         = ParseItem(mParser.GetItem(xObj, i), data.XDateFormat);
                double y         = ParseItem(mParser.GetItem(yObj, i), data.YDateFormat);
                double pointSize = -1;
                if (sizeObj != null)
                {
                    pointSize = double.Parse(mParser.GetItem(sizeObj, i));
                }
                graph.DataSource.AddPointToCategory(data.Name, x, y, pointSize);
            }
        }
        catch (Exception e)
        {
            Debug.LogWarning("Data for category " + data.Name + " does not match the specified format. Ended with exception : " + e.ToString());
        }
    }
예제 #15
0
    void LoadCategoryVisualStyle(GraphChartBase graph)
    {
        var prefab = CategoryPrefab;

        if (prefab == null)
        {
            if (graph is GraphChart)
            {
                prefab = ((GameObject)Resources.Load("Chart And Graph/DefualtGraphCategoryStyle2D")).GetComponent <GraphChartBase>();
            }
            else
            {
                prefab = ((GameObject)Resources.Load("Chart And Graph/DefualtGraphCategoryStyle3D")).GetComponent <GraphChartBase>(); // load default
            }
        }
        if (prefab == null)
        {
            Debug.LogError("missing resources for graph and chart, please reimport the package");
        }
        else
        {
            mCategoryVisualStyle = prefab.DataSource.StoreAllCategoriesinOrder();
        }
    }
예제 #16
0
    public void UpdateGraphPoints()
    {
        scale     = transform.localScale.x;
        graph     = GetComponent <GraphChartBase>();
        graphMaxY = graph.HeightRatio;
        graphMaxX = graph.WidthRatio;


        if (graph != null)
        {
            //Debug.Log("yaiii");

            graph.DataSource.StartBatch();
            for (int i = 0; i < 1; i++)
            {
                string categoryName = gameManager.categoryNames[0];
                graph.DataSource.ClearCategory(categoryName);
            }


            //graph.DataSource.ClearCategory("Player 1");
            int count = 0;
            for (int i = 0; i < gameManager.categoryNames.Count; i++)
            {
                //if graph is selected add data
                if (gameManager.selectedMaps[i] == 1)
                {
                    string categoryName = gameManager.categoryNames[i];



                    graph.DataSource.ClearAndMakeBezierCurve(categoryName);

                    graph.DataSource.SetCategoryFill(categoryName, fillMaterials[count], false);



                    for (int j = 0; j < dataY[i].Count; j++)
                    {
                        if (j % skip == 0 || j == dataY[0].Count - 1)
                        {
                            if (j == 0)
                            {
                                graph.DataSource.SetCurveInitialPoint(categoryName, 0f, dataY[i][0]);
                            }
                            else
                            {
                                graph.DataSource.AddLinearCurveToCategory(categoryName, new DoubleVector2(j, dataY[i][j]));
                            }
                        }
                        graph.DataSource.MakeCurveCategorySmooth(categoryName);
                    }

                    count++;
                }
            }
            //Debug.Log("count: " + count);
            graph.DataSource.EndBatch();
        }
        SetupPoints();
    }
예제 #17
0
 void Start()
 {
     graph = GetComponent <GraphChartBase>();
     SetInitialData();
 }
예제 #18
0
    public void Animate(string category, List <DoubleVector2> points, float totalTime)
    {
        graphChart = GetComponent <GraphChartBase>();
        if (graphChart == null)
        {
            return;
        }
        if (points == null)
        {
            return;
        }
        if (points.Count == 0)
        {
            return;
        }
        InnerAnimation anim = new InnerAnimation();

        anim.maxX = float.MinValue;
        anim.maxY = float.MinValue;
        anim.minX = float.MaxValue;
        anim.minY = float.MaxValue;

        for (int i = 0; i < points.Count; ++i)
        {
            anim.maxX = Math.Max(points[i].x, anim.maxX);
            anim.maxY = Math.Max(points[i].y, anim.maxY);
            anim.minX = Math.Min(points[i].x, anim.minX);
            anim.minY = Math.Min(points[i].y, anim.minY);
        }

        if (ModifyRange)
        {
            double maxX = anim.maxX;
            double maxY = anim.maxY;
            double minX = anim.minX;
            double minY = anim.minY;
            foreach (InnerAnimation a in mAnimations.Values)
            {
                maxX = Math.Max(maxX, a.maxX);
                maxY = Math.Max(maxY, a.maxY);
                minX = Math.Min(minX, a.minX);
                minY = Math.Min(minY, a.minY);
            }
            IInternalGraphData g = graphChart.DataSource;
            maxX = (float)Math.Max(g.GetMaxValue(0, true), maxX);
            minX = (float)Math.Min(g.GetMinValue(0, true), minX);
            maxY = (float)Math.Max(g.GetMaxValue(1, true), maxY);
            minY = (float)Math.Min(g.GetMinValue(1, true), minY);

            if (IsValidDouble(maxX) && IsValidDouble(maxY) && IsValidDouble(minX) && IsValidDouble(minY))
            {
                graphChart.DataSource.StartBatch();
                graphChart.DataSource.AutomaticHorizontalView = false;
                graphChart.DataSource.AutomaticVerticallView  = false;
                graphChart.DataSource.HorizontalViewSize      = (maxX - minX);
                graphChart.DataSource.HorizontalViewOrigin    = minX;
                graphChart.DataSource.VerticalViewSize        = (maxY - minY);
                graphChart.DataSource.VerticalViewOrigin      = minY;
                graphChart.DataSource.EndBatch();
            }
        }

        anim.points    = points;
        anim.index     = 0;
        anim.next      = 0;
        anim.totalTime = totalTime;
        anim.category  = category;
        graphChart.DataSource.ClearCategory(category);
        mAnimations[category] = anim;
    }
예제 #19
0
 // Use this for initialization
 void Start()
 {
     graphChart = GetComponent <GraphChartBase>();
 }
예제 #20
0
 // Use this for initialization
 void Start()
 {
     timeGraph  = GetComponent <GraphChartBase>();
     httpClient = new HttpClient();
 }
예제 #21
0
    public void GetSensorData()
    {
        if (SensorType == "" || TimeFromNow == "")
        {
            return;
        }

        ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) {
            return(true);
        };

        timeGraph  = GetComponent <GraphChartBase>();
        httpClient = new HttpClient();

        httpClient.GetString(
            new Uri("https://bigdot.herokuapp.com/graph-data/time/" + SensorType + "/" + TimeFromNow),
            delegate(CI.HttpClient.HttpResponseMessage <string> res) {
            string category_1 = "Default1";
            string category_2 = "Default2";
            string category_3 = "Default3";

            timeGraph.DataSource.StartBatch();
            timeGraph.DataSource.ClearCategory(category_1);
            timeGraph.DataSource.ClearCategory(category_2);
            timeGraph.DataSource.ClearCategory(category_3);

            string[] miscSensorsArray = { "humidity", "temperature", "pressure" };

            if (miscSensorsArray.Contains(SensorType))
            {
                String[] rawData = res.Data.Replace("[", "").Replace("]", "").Split(new String[] { "," }, StringSplitOptions.None);
                int limit        = 50;
                if (rawData.Length <= limit)
                {
                    for (int index = 0; index < rawData.Length; index++)
                    {
                        timeGraph.DataSource.AddPointToCategory(category_1, index, float.Parse(rawData[index]));
                    }
                }
                else
                {
                    float[] rawValues = new float[limit];
                    for (int index = 0; index < rawData.Length; index++)
                    {
                        int normalIndex        = (int)Math.Floor((float)index / (float)rawData.Length * ((float)limit - 1f));
                        rawValues[normalIndex] = float.Parse(rawData[index]);
                    }

                    for (int index = 0; index < rawValues.Length; index++)
                    {
                        if (rawValues[index] != 0)
                        {
                            timeGraph.DataSource.AddPointToCategory(category_1, index, rawValues[index]);
                        }
                    }
                }
            }
            else
            {
                String[] rawData = res.Data.Replace("[", "").Replace("]", "").Split(new String[] { "," }, StringSplitOptions.None);
                int limit        = 50;
                if (rawData.Length <= limit)
                {
                    for (int index = 0; index < rawData.Length; index++)
                    {
                        timeGraph.DataSource.AddPointToCategory(category_1, index, float.Parse(rawData[index]));
                        timeGraph.DataSource.AddPointToCategory(category_2, index, float.Parse(rawData[index]));
                        timeGraph.DataSource.AddPointToCategory(category_3, index, float.Parse(rawData[index]));
                    }
                }
                else
                {
                    int[] rawValuesX = new int[limit];
                    int[] rawValuesY = new int[limit];
                    int[] rawValuesZ = new int[limit];
                    for (int index = 0; index < rawData.Length; index += 3)
                    {
                        int normalIndex         = (int)Math.Floor((float)index / (float)(rawData.Length / 3f) * ((float)limit / 3f - 1));
                        rawValuesX[normalIndex] = int.Parse(rawData[index]);
                        rawValuesY[normalIndex] = int.Parse(rawData[index + 1]);
                        rawValuesZ[normalIndex] = int.Parse(rawData[index + 2]);
                    }

                    for (int index = 0; index < limit; index++)
                    {
                        if (rawValuesX[index] != 0 && rawValuesY[index] != 0 && rawValuesZ[index] != 0)
                        {
                            timeGraph.DataSource.AddPointToCategory(category_1, index, rawValuesX[index]);
                            timeGraph.DataSource.AddPointToCategory(category_2, index, rawValuesY[index]);
                            timeGraph.DataSource.AddPointToCategory(category_3, index, rawValuesZ[index]);
                        }
                    }
                }
            }

            timeGraph.DataSource.EndBatch();
            //barChart.DataSource.AutomaticMaxValue = true;
        }
            );
    }
예제 #22
0
 public LargeDataFeed(string name)
 {
     this.Category = name;
     graph         = GetComponent <GraphChartBase>();
     //SetInitialData();
 }