Esempio n. 1
0
    IEnumerator UpdateXAxisModels()
    {
        xAxisPoints = model.selectedDataNames.Count;

        while (xAxisModels.Count != xAxisPoints)
        {
            int diff = xAxisModels.Count - xAxisPoints;
            if (diff > 0)
            {
                xAxisModels[0].Delete();
                graphNumberModels[0].Delete();
            }
            else
            {
                //Initiate Models
                AxisNumberModel  mod      = new AxisNumberModel();
                GraphNumberModel graphMod = new GraphNumberModel();
                xAxisModels.Add(mod);
                graphNumberModels.Add(graphMod);

                //Set variables
                graphMod.width = 20;

                //Initialize Controllers
                Controller.Instantiate <AxisNumberController>(xAxisNumber, mod, xAxisParent);
                Controller.Instantiate <GraphNumberController>(graphNumber, graphMod, graphParent);
            }

            yield return(null);
        }
        UpdateXAxisLabels(model.selectedDataNames, xAxisModels, graphNumberModels);
    }
Esempio n. 2
0
    IEnumerator UpdateYAxisModels()
    {
        while (yAxisModels.Count != yAxisPoints)
        {
            int diff = yAxisModels.Count - yAxisPoints;
            if (diff > 0)
            {
                yAxisModels[0].Delete();
            }
            else
            {
                //Initiate Models
                AxisNumberModel mod = new AxisNumberModel();
                yAxisModels.Add(mod);

                //Initialize Controllers
                Controller.Instantiate <AxisNumberController>(yAxisNumber, mod, yAxisParent);
            }

            yield return(null);
        }
        UpdateYAxisLabels(yDataPoints, yAxisModels);
    }
Esempio n. 3
0
    protected override void OnInitialize()
    {
        //Find GameObjects
        ToggleGroup[] toggleGroups = gameObject.GetComponentsInChildren <ToggleGroup>();
        dataNameGroup       = toggleGroups[0];
        dataPreferenceGroup = toggleGroups[1];

        //Set GameObjects
        yAxisModels       = new ModelRefs <AxisNumberModel>();
        xAxisModels       = new ModelRefs <AxisNumberModel>();
        graphNumberModels = new ModelRefs <GraphNumberModel>();

        //Reset Scale++
        transform.localScale = Vector3.one;

        title.text = "Bar Graph";

        //MessageListeners
        Message.AddListener <ToggleMessage>(OnToggleMessage);

        //CreateYAxis
        CalculateMaxYValue();


        foreach (int num in yDataPoints)
        {
            //Initiate Models
            AxisNumberModel mod = new AxisNumberModel();
            yAxisModels.Add(mod);

            //Set variables

            mod.numberText = num.ToString();

            //Initialize Controllers
            Controller.Instantiate <AxisNumberController>(yAxisNumber, mod, yAxisParent);
        }

        //Create XAxis
        foreach (int i in model.selectedDataNames)
        {
            float num = model.data[i, model.selectedDataPreference];
            xAxisPoints++;

            //Initiate Models
            AxisNumberModel  mod      = new AxisNumberModel();
            GraphNumberModel graphMod = new GraphNumberModel();
            xAxisModels.Add(mod);
            graphNumberModels.Add(graphMod);

            //Set variables
            mod.numberText = "--";

            graphMod.height    = num;
            graphMod.maxHeight = maxYValue;
            graphMod.width     = 20;
            graphMod.label     = num.ToString();

            //Initialize Controllers
            Controller.Instantiate <AxisNumberController>(xAxisNumber, mod, xAxisParent);
            Controller.Instantiate <GraphNumberController>(graphNumber, graphMod, graphParent);
        }

        //Create Toggle Buttons for the Toggle Group Data Names

        CreateToggleGroup("Data Names", model.dataNames, dataNameGroup.transform, false);
        CreateToggleGroup("Data Prefs", model.dataPrefs, dataPreferenceGroup.transform);

        title.text = model.title;
    }