Ejemplo n.º 1
0
    private IEnumerator StartShowCase(List <ElectionDataGrabber.DistrictData> districtsData)
    {
        barGraphDataSets = new List <BarGraphDataSet>();

        BarGraphDataSet benfordDataSet = new BarGraphDataSet();

        benfordDataSet.ListOfBars = new List <XYBarValues>();
        benfordDataSet.GroupName  = "სტანდარტული განაწილება";
        int ind = 0;

        foreach (var benfordsValue in BenfordsValues)
        {
            XYBarValues xyBarValues = new XYBarValues();
            xyBarValues.YValue = benfordsValue;
            ind++;
            xyBarValues.XValue = ind.ToString();
            benfordDataSet.ListOfBars.Add(xyBarValues);
        }
        barGraphDataSets.Add(benfordDataSet);

        foreach (var party in Parties)
        {
            // barGraphGenerator.res
            addPartyAgainstBenford(party, districtsData);
        }

        BarGraphGenerator.GeneratBarGraph(barGraphDataSets);
        yield break;
    }
Ejemplo n.º 2
0
    public void ShowStatsFromGivenPlayer(AllUsers allUsers, int givenUserId)
    {
        var specificUser = GetSpecificUser(allUsers, givenUserId);

        Debug.Log("-----------");
        GameData mockedGameData;

        for (int i = 0; i < exampleDataSet.Count; i++)
        {
            var gameDataTypeIndex = i;
            mockedGameData = GetMockedGameDataByIndex(gameDataTypeIndex);
            var currentGameData = GetCurrentGameData(specificUser, mockedGameData);

            var barIndex = 0;    // 0 = winrate, 1 = games played
            var winRate  = GetWinrate(currentGameData);
            exampleDataSet[gameDataTypeIndex].ListOfBars[barIndex].YValue = winRate;

            barIndex = 1;    // 0 = winrate, 1 = games played
            var playedAmount = GetTotalPlayed(currentGameData);
            exampleDataSet[gameDataTypeIndex].ListOfBars[barIndex].YValue = playedAmount;
        }

        if (exampleDataSet.Count == 0)
        {
            Debug.LogError("ExampleDataSet is Empty!");
            return;
        }
        barGraphGenerator.GeneratBarGraph(exampleDataSet);
    }
Ejemplo n.º 3
0
    public void CreateGraphFromData(List <XYBarValues> listXY, string parametro, Color sColor)
    {
        barGraphGenerator = GetComponent <BarGraphGenerator>();
        DestroyBefore();
        //Color color = new Color(UnityEngine.Random.Range(0F, 1F), UnityEngine.Random.Range(0, 1F), UnityEngine.Random.Range(0, 1F));
        BarGraphDataSet barHum = new BarGraphDataSet(parametro, sColor, listXY);

        sensorDataSet.Add(barHum);
        barGraphGenerator.GeneratBarGraph(sensorDataSet);
    }
Ejemplo n.º 4
0
    void Start()
    {
        barGraphGenerator = GetComponent <BarGraphGenerator>();


        //if the exampleDataSet list is empty then return.
        if (exampleDataSet.Count == 0)
        {
            Debug.LogError("ExampleDataSet is Empty!");
            return;
        }
        barGraphGenerator.GeneratBarGraph(exampleDataSet);
    }
Ejemplo n.º 5
0
    public void updateBarYear(int year)
    {
        int idx = 0;

        for (int i = 0; i < _yearList.Length; i++)
        {
            if (_yearList[i] == year)
            {
                idx = i;
                break;
            }
        }

        _barGraphGenerator.GeneratBarGraph(appDataSet[idx]);
    }
Ejemplo n.º 6
0
    // Start is called before the first frame update
    void Start()
    {
        TextAsset raw = Resources.Load(@"Data") as TextAsset;

        _parser = new ImmigrationDataParser(raw);

        _barGraphGenerator = GetComponent <BarGraphGenerator>();

        foreach (int year in _yearList)
        {
            appDataSet.Add(_parser.GetBarData(year));
        }

        //if the exampleDataSet list is empty then return.
        if (appDataSet.Count == 0)
        {
            Debug.LogError("ExampleDataSet is Empty!");
            return;
        }

        _barGraphGenerator.GeneratBarGraph(appDataSet[appDataSet.Count - 1]);
    }
Ejemplo n.º 7
0
    void Start()
    {
        barGraphGenerator = GetComponent <BarGraphGenerator>();


        //if the exampleDataSet list is empty then return.
        if (exampleDataSet.Count == 0)
        {
            Debug.LogError("ExampleDataSet is Empty!");
            return;
        }

        if (useCode)
        {
            //Borra los datos introducidos desde el inspector
            exampleDataSet.Clear();

            //Creo un nuevo conjunto de datos
            BarGraphDataSet example = new BarGraphDataSet();
            //Asigno el color y el nombre
            example.barColor  = Color.blue;
            example.GroupName = "Grupo de prueba Casos Activos";
            //Voy a configurar varios paises
            example.ListOfBars = new List <XYBarValues>();
            //Primer país
            XYBarValues xySpain = new XYBarValues();
            xySpain.XValue = "España";
            xySpain.YValue = 100.0f;  //Cantidad de contagiados
                                      //Añade el país al conjunto de datos
            example.ListOfBars.Add(xySpain);

            //Otro país repite los pasos con otros datos.
            XYBarValues xyItaly = new XYBarValues();
            xyItaly.XValue = "Italy";
            xyItaly.YValue = 250.0f;  //Cantidad de contagiados
            example.ListOfBars.Add(xyItaly);

            //Añade el conjunto de datos a mostrar
            exampleDataSet.Add(example);


            example = new BarGraphDataSet();
            //Asigno el color y el nombre
            example.barColor  = Color.green;
            example.GroupName = "Grupo de prueba Recuperados";
            //Voy a configurar varios paises
            example.ListOfBars = new List <XYBarValues>();
            //Primer país
            xySpain        = new XYBarValues();
            xySpain.XValue = "España";
            xySpain.YValue = 1200.0f;  //Cantidad de contagiados
                                       //Añade el país al conjunto de datos
            example.ListOfBars.Add(xySpain);

            //Otro país repite los pasos con otros datos.
            xyItaly        = new XYBarValues();
            xyItaly.XValue = "Italy";
            xyItaly.YValue = 2500.0f;  //Cantidad de contagiados
            example.ListOfBars.Add(xyItaly);
            exampleDataSet.Add(example);
        }

        //Generar la gráfica
        barGraphGenerator.GeneratBarGraph(exampleDataSet);
    }
Ejemplo n.º 8
0
    void Start()
    {
        //if the list is empty, exit
        if (exchDataSet.Count == 0)
        {
            Debug.LogError("exchDataSet is Empty!");
            return;
        }

        barGraphGenerator = GetComponent <BarGraphGenerator>();

        var countries = new Dictionary <string, int>();

        countries.Add("Mexico", 0);
        countries.Add("India", 1);
        countries.Add("Hong Kong", 2);
        countries.Add("Denmark", 3);
        countries.Add("China", 4);
        countries.Add("Brazil", 5);
        countries.Add("Malaysia", 6);
        countries.Add("Australia", 7);
        countries.Add("Canada", 8);
        countries.Add("Euro", 9);
        countries.Add("Japan", 10);
        countries.Add("New Zealand", 11);
        countries.Add("Norway", 12);
        countries.Add("Singapore", 13);
        countries.Add("South Africa", 14);
        countries.Add("South Korea", 15);
        countries.Add("Sweden", 16);
        countries.Add("Switzerland", 17);
        countries.Add("Taiwan", 18);
        countries.Add("Thailand", 19);
        countries.Add("Venezuela", 20);

        var countriesStatus = new Dictionary <string, int>();

        countriesStatus.Add("Australia", 0);
        countriesStatus.Add("Brazil", 0);
        countriesStatus.Add("Canada", 0);
        countriesStatus.Add("China", 0);
        countriesStatus.Add("Denmark", 0);
        countriesStatus.Add("Euro", 0);
        countriesStatus.Add("Hong Kong", 0);
        countriesStatus.Add("India", 0);
        countriesStatus.Add("Japan", 0);
        countriesStatus.Add("Malaysia", 0);
        countriesStatus.Add("Mexico", 0);
        countriesStatus.Add("New Zealand", 0);
        countriesStatus.Add("Norway", 0);
        countriesStatus.Add("Singapore", 0);
        countriesStatus.Add("South Africa", 0);
        countriesStatus.Add("South Korea", 0);
        countriesStatus.Add("Sweden", 0);
        countriesStatus.Add("Switzerland", 0);
        countriesStatus.Add("Taiwan", 0);
        countriesStatus.Add("Thailand", 0);
        countriesStatus.Add("Venezuela", 0);

        String fileData;

#if UNITY_EDITOR
        fileData = File.ReadAllText(Application.dataPath + "/Resources/yearly_csv.csv");
#elif UNITY_STANDALONE
        fileData = File.ReadAllText(Application.dataPath + "\\Resources\\yearly_csv.csv");
#elif UNITY_WEBGL
        UnityWebRequest www = UnityWebRequest.Get(Application.dataPath + "/Resources/yearly_csv.csv");
        fileData = www.downloadHandler.text;
#endif

        fileData = fileData.Replace("Date,Country,Value", "").Trim();
        String[] lines = fileData.Split("\n"[0]);

        CultureInfo ci = (CultureInfo)CultureInfo.CurrentCulture.Clone();
        ci.NumberFormat.CurrencyDecimalSeparator = ".";

        foreach (String line in lines)
        {
            String[] lineData = (line.Trim()).Split(","[0]);

            int countryId = countries[lineData[1]];
            if (countryId == 0 || countryId < 10)
            {
                if (countriesStatus[lineData[1]] < 10)
                {
                    exchDataSet[countryId].GroupName = lineData[1];
                    exchDataSet[countryId].ListOfBars[countriesStatus[lineData[1]]].XValue = lineData[0];
                    exchDataSet[countryId].ListOfBars[countriesStatus[lineData[1]]].YValue = float.Parse(lineData[2], NumberStyles.Any, ci);
                    countriesStatus[lineData[1]]++;
                }
            }
        }

        barGraphGenerator.GeneratBarGraph(exchDataSet);
    }
    public void Winter()
    {
        if (exampleDataSet.Count != 0)
        {
            exampleDataSet.Clear();
        }

        barGraphGenerator = GetComponent <BarGraphGenerator>();

        currentCountry = StartScript.selectedCountry;

        string[] csvFileLines = myCSVFile.text.Split('\n');
        for (int i = 1; i < csvFileLines.Length - 1; i++)
        {
            string[] values = csvFileLines[i].Split(',');

            List <XYBarValues> slist = new List <XYBarValues>();

            if (values[0] == currentCountry)
            {
                BarGraphDataSet br = new BarGraphDataSet();

                XYBarValues gs = new XYBarValues();

                gs.XValue = "Gold";

                gs.YValue = float.Parse(values[7]);

                slist.Add(gs);

                XYBarValues ss = new XYBarValues();

                ss.XValue = "Silver";

                ss.YValue = float.Parse(values[8]);

                slist.Add(ss);

                XYBarValues bs = new XYBarValues();

                bs.XValue = "bronze";

                bs.YValue = float.Parse(values[9]);

                slist.Add(bs);

                br.GroupName = "Winter";

                br.ListOfBars = slist;

                br.barColor = Color.blue;

                exampleDataSet.Add(br);
            }
        }

        if (exampleDataSet.Count == 0)
        {
            //Debug.LogError("ExampleDataSet is Empty!");
            return;
        }
        barGraphGenerator.GeneratBarGraph(exampleDataSet);
    }
    public void AllSeasons()

    {
        if (exampleDataSet.Count != 0)
        {
            exampleDataSet.Clear();
        }

        barGraphGenerator = GetComponent <BarGraphGenerator>();

        currentCountry = StartScript.selectedCountry;

        //Debug.Log(" Selected Country " + currentCountry);

        string[] csvFileLines = myCSVFile.text.Split('\n');
        for (int i = 1; i < csvFileLines.Length - 1; i++)
        {
            string[] values = csvFileLines[i].Split(',');

            List <XYBarValues> slist = new List <XYBarValues>();

            List <XYBarValues> wlist = new List <XYBarValues>();

            if (values[0] == currentCountry)
            {
                BarGraphDataSet br = new BarGraphDataSet();

                XYBarValues gs = new XYBarValues();

                gs.XValue = "Gold";

                gs.YValue = float.Parse(values[4]);

                slist.Add(gs);

                XYBarValues ss = new XYBarValues();

                ss.XValue = "Silver";

                ss.YValue = float.Parse(values[5]);

                slist.Add(ss);

                XYBarValues bs = new XYBarValues();

                bs.XValue = "bronze";

                bs.YValue = float.Parse(values[6]);

                slist.Add(bs);

                br.GroupName = "Summer";

                br.ListOfBars = slist;

                br.barColor = Color.red;

                exampleDataSet.Add(br);

                BarGraphDataSet bw = new BarGraphDataSet();

                XYBarValues gw = new XYBarValues();

                gw.XValue = "Gold";

                gw.YValue = float.Parse(values[7]);

                wlist.Add(gw);

                XYBarValues sw = new XYBarValues();

                sw.XValue = "Silver";

                sw.YValue = float.Parse(values[8]);

                wlist.Add(sw);

                XYBarValues tw = new XYBarValues();

                tw.XValue = "bronze";

                tw.YValue = float.Parse(values[9]);

                wlist.Add(tw);

                bw.GroupName = "Winter";

                bw.ListOfBars = wlist;

                bw.barColor = Color.blue;

                exampleDataSet.Add(bw);
            }
        }

        //if the exampleDataSet list is empty then return.
        if (exampleDataSet.Count == 0)
        {
            //Debug.LogError("ExampleDataSet is Empty!");
            return;
        }
        barGraphGenerator.GeneratBarGraph(exampleDataSet);
    }