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");
    }
Exemple #2
0
        void AddOneData()
        {
            lineChart.title.text = initCount + "数据";
            barChart.title.text  = initCount + "数据";
            timeNow = timeNow.AddSeconds(1);
            string category = timeNow.ToString("hh:mm:ss");
            float  xvalue   = Mathf.PI / 180 * initCount;
            float  yvalue   = 15 + Mathf.Sin(xvalue) * 2;

            lineChart.AddData(0, yvalue);
            lineChart.AddXAxisData(category);
            barChart.AddData(0, yvalue);
            barChart.AddXAxisData(category);
        }
Exemple #3
0
        IEnumerator AddSimpleBar()
        {
            chart = gameObject.GetComponent <BarChart>();
            if (chart == null)
            {
                chart = gameObject.AddComponent <BarChart>();
            }
            chart.title.text    = "BarChart - 柱状图";
            chart.title.subText = "普通柱状图";

            chart.yAxis0.minMaxType = Axis.AxisMinMaxType.Default;

            chart.RemoveData();
            serie = chart.AddSerie(SerieType.Bar, "Bar1");

            for (int i = 0; i < m_DataNum; i++)
            {
                chart.AddXAxisData("x" + (i + 1));
                chart.AddData(0, UnityEngine.Random.Range(30, 90));
            }
            yield return(new WaitForSeconds(1));
        }
Exemple #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");
    }