void Awake()
 {
     chart = gameObject.GetComponent <BarChart>();
     chart.ClearData();
     for (int i = 0; i < 5; i++)
     {
         chart.AddYAxisData("y" + i);
         chart.AddData(0, Random.Range(0, 200));
     }
 }
Пример #2
0
 void Awake()
 {
     fpsChart  = transform.Find("fps/FpsChart").gameObject.GetComponent <LineChart>();
     lineChart = transform.Find("charts/LineChart").gameObject.GetComponent <LineChart>();
     barChart  = transform.Find("charts/BarChart").gameObject.GetComponent <BarChart>();
     fpsText   = transform.Find("settings/txtFps").gameObject.GetComponent <Text>();
     fpsChart.ClearData();
     lineChart.ClearData();
     barChart.ClearData();
     InitCharts();
 }
Пример #3
0
    private void Start()
    {
        chart = transform.GetComponent <BarChart>();
        if (maunul)
        {
            t_n = staticname.i_name;
        }
        else
        {
            t_n = FindObjectOfType <User_Info>().user_name;
        }
        string path_1 = "Assets/Local_DataBase/Students/" + t_n + "/Total_score_list";

        rank = new Dictionary <string, float>();
        rank.Add("A-H", 0);
        rank.Add("B-List", 0);
        rank.Add("C_List", 0);
        rank.Add("A-List", 0);
        if (File.Exists(path_1))
        {
            StreamReader mysecondReader = new StreamReader(path_1);
            while (!mysecondReader.EndOfStream)
            {
                string[] input = mysecondReader.ReadLine().Split(' ');
                Debug.Log(input[0] + " " + input[1]);
                if (!rank.ContainsKey(input[0]))
                {
                    rank.Add(input[0], float.Parse(input[1]));
                }
                else
                {
                    if (rank[input[0]] - float.Parse(input[1]) < 0.000000001)
                    {
                        rank[input[0]] = float.Parse(input[1]);
                    }
                }
            }
        }

        chart.ClearData();
        chart.AddXAxisData("A-H");
        chart.AddXAxisData("B-List");
        chart.AddXAxisData("C-List");
        chart.AddXAxisData("A_List");
        foreach (var temp in rank)
        {
            chart.AddData(0, temp.Value, temp.Key);
        }
        //chart.ClearData();
        //chart.AddData(0, 10, "value1");
        //chart.AddData(0, 10, "value2");
    }
Пример #4
0
    private void Start()
    {
        chart = transform.GetComponent <BarChart>();
        chart.SetSize(250, 200);
        t_n = FindObjectOfType <User_Info>().user_name;
        string       path     = "Assets/Local_DataBase/Teachers/" + t_n + "/Student_List";
        StreamReader myReader = new StreamReader(path);

        rank = new Dictionary <int, int>();
        while (!myReader.EndOfStream)
        {
            string student = myReader.ReadLine();
            // Reading the score.
            string path_1 = "Assets/Local_DataBase/Students/" + student + "/Total_score_list";
            if (!File.Exists(path_1))
            {
                if (rank.ContainsKey(0))
                {
                    rank[0]++;
                }
                else
                {
                    rank.Add(0, 1);
                }
                continue;
            }
            //use hashmap to prevent duplicates.
            Dictionary <string, float> score_list = new Dictionary <string, float>();
            StreamReader mysecondReader           = new StreamReader(path_1);
            while (!mysecondReader.EndOfStream)
            {
                string[] input = mysecondReader.ReadLine().Split(' ');
                if (!score_list.ContainsKey(input[0]))
                {
                    score_list.Add(input[0], float.Parse(input[1]));
                }
                else
                {
                    if (score_list[input[0]] - float.Parse(input[1]) < 0.000000001)
                    {
                        score_list[input[0]] = float.Parse(input[1]);
                    }
                }
            }
            double total_score = 0;
            //add the score for each course.
            foreach (var kvp in score_list)
            {
                total_score += score_list[kvp.Key];
            }
            total_score /= num_coruses;
            //Debug.Log(total_score + "   " + student);
            if (rank.ContainsKey((int)total_score))
            {
                rank[(int)total_score]++;
            }
            else
            {
                rank.Add((int)total_score, 1);
            }
        }
        chart.ClearData();
        foreach (var temp in rank)
        {
            chart.AddXAxisData(temp.Key.ToString());
            //chart.AddXAxisData("B-List");
            //chart.AddXAxisData("C-List");
            //chart.AddXAxisData("A-List");
            chart.AddData(0, temp.Value, temp.Key.ToString());
            //chart.AddData(temp.Key.ToString(),120);
        }
        //chart.ClearData();
        //chart.AddData(0, 10, "value1");
        //chart.AddData(0, 10, "value2");
    }