Esempio n. 1
0
        public static void AddPointToCategoryWithLabel(GraphChartBase chart, string category, double x, double y, double pointSize = -1, string xLabel = null, string yLabel = null)
        {
            DoubleVector3 item = new DoubleVector3(x, y, 0.0);

            chart.VectorValueToStringMap[item] = new KeyValuePair <string, string>(xLabel, yLabel);
            chart.DataSource.AddPointToCategory(category, x, y, pointSize);
        }
Esempio n. 2
0
 public void LoadGraphDataFromFile(string path, GraphChartBase graph)
 {
     try
     {
         using (StreamReader file = new StreamReader(path))
         {
             while (file.Peek() > 0)
             {
                 string catName = file.ReadLine();
                 if (graph.DataSource.HasCategory(catName) == false)
                 {
                     throw new Exception("category does not exist in the graph");
                 }
                 int count = int.Parse(file.ReadLine());
                 for (int i = 0; i < count; i++)
                 {
                     double x = double.Parse(file.ReadLine());
                     double y = double.Parse(file.ReadLine());
                     graph.DataSource.AddPointToCategory(catName, x, y);
                 }
             }
         }
     }
     catch (Exception)
     {
         throw new Exception("Invalid file format");
     }
 }
        public static void AddPointToCategoryWithLabelRealtime(GraphChartBase chart, string category, double x, double y, double slideTime = 0, double pointSize = -1, string xLabel = null, string yLabel = null)
        {
            bool          invalidate = false;
            DoubleVector3 item       = new DoubleVector3(x, y, 0.0);

            invalidate = chart.VectorValueToStringMap.Remove(item);
            chart.VectorValueToStringMap[item] = new KeyValuePair <string, string>(xLabel, yLabel);

            if (invalidate)
            {
                chart.ClearCache();
            }

            chart.DataSource.AddPointToCategoryRealtime(category, x, y, slideTime, pointSize);
        }
        void Start()
        {
            GraphChartBase graph = GetComponent <GraphChartBase>();

            if (graph != null)
            {
                graph.DataSource.StartBatch();
                graph.DataSource.ClearCategory("Player 1");
                graph.DataSource.ClearCategory("Player 2");
                for (int i = 0; i < 10; i++)
                {
                    graph.DataSource.AddPointToCategory("Player 1", Random.value * 10f, Random.value * 10f, Random.value * 3f);
                    graph.DataSource.AddPointToCategory("Player 2", Random.value * 10f, Random.value * 10f, Random.value * 3f);
                }
                graph.DataSource.EndBatch();
            }
        }
Esempio n. 5
0
        void Start()
        {
            GraphChartBase graph = GetComponent <GraphChartBase>();

            if (graph != null)
            {
                //      graph.DataSource.StartBatch();
                graph.DataSource.ClearCategory("Player 1");
                graph.DataSource.ClearCategory("Player 2");
                for (int i = 0; i < 10; i++)
                {
                    GraphData.AddPointToCategoryWithLabelRealtime(graph, "Player 1", Random.value * 10f, Random.value * 10f, 0f, Random.value * 3f, "A", "B");
//                    graph.DataSource.AddPointToCategory("Player 1", Random.value * 10f, Random.value * 10f, Random.value *3f);
                    //    graph.DataSource.AddPointToCategory("Player 2", Random.value * 10f, Random.value * 10f, Random.value *3f);
                }
                //        graph.DataSource.EndBatch();
            }
        }
Esempio n. 6
0
        public void SaveGraphDataToFile(string path, GraphChartBase graph)
        {
            IInternalGraphData data = (IInternalGraphData)graph;

            using (StreamWriter file = new StreamWriter(path))
            {
                foreach (var cat in data.Categories)
                {
                    file.WriteLine(cat.Name);
                    file.WriteLine(cat.Data.Count);
                    for (int i = 0; i < cat.Data.Count; i++)
                    {
                        DoubleVector3 item = cat.Data[i];
                        file.WriteLine(item.x);
                        file.WriteLine(item.y);
                    }
                }
            }
        }
Esempio n. 7
0
        public static void AddPointToCategoryWithLabel(GraphChartBase chart, string category, double x, double y, double pointSize = -1, string xLabel = null, string yLabel = null)
        {
            if (xLabel != null)
            {
                chart.HorizontalValueToStringMap[x] = xLabel;
            }
            else
            {
                chart.HorizontalValueToStringMap.Remove(x);
            }

            if (yLabel != null)
            {
                chart.VerticalValueToStringMap[y] = yLabel;
            }
            else
            {
                chart.VerticalValueToStringMap.Remove(y);
            }
            chart.DataSource.AddPointToCategory(category, x, y, pointSize);
        }
Esempio n. 8
0
        public static void AddPointToCategoryWithLabelRealtime(GraphChartBase chart, string category, double x, double y, double slideTime = 0, double pointSize = -1, string xLabel = null, string yLabel = null)
        {
            bool invalidate = false;

            invalidate = chart.HorizontalValueToStringMap.Remove(x);
            if (xLabel != null)
            {
                chart.HorizontalValueToStringMap[x] = xLabel;
            }

            invalidate |= chart.VerticalValueToStringMap.Remove(y);
            if (yLabel != null)
            {
                chart.VerticalValueToStringMap[y] = yLabel;
            }
            if (invalidate)
            {
                chart.ClearCache();
            }

            chart.DataSource.AddPointToCategoryRealtime(category, x, y, slideTime, pointSize);
        }
        bool RenameCategory(string oldName, string newName)
        {
            GraphChartBase graph = (GraphChartBase)serializedObject.targetObject;

            try
            {
                graph.DataSource.RenameCategory(oldName, newName);
            }
            catch (Exception)
            {
                return(false);
            }
            serializedObject.Update();
            if (graph.gameObject.activeInHierarchy)
            {
                graph.GenerateChart();
            }
            else
            {
                EditorUtility.SetDirty(graph);
            }
            return(true);
        }
Esempio n. 10
0
 public static void AddPointToCategoryWithLabel(GraphChartBase chart, string category, DateTime x, DateTime y, double pointSize = -1, string xLabel = null, string yLabel = null)
 {
     AddPointToCategoryWithLabel(chart, category, ChartDateUtility.DateToValue(x), ChartDateUtility.DateToValue(y), pointSize, xLabel, yLabel);
 }
 public static void AddPointToCategoryWithLabelRealtime(GraphChartBase chart, string category, double x, DateTime y, double slideTime = 0, double pointSize = -1, string xLabel = null, string yLabel = null)
 {
     AddPointToCategoryWithLabelRealtime(chart, category, x, ChartDateUtility.DateToValue(y), slideTime, pointSize, xLabel, yLabel);
 }