void LoadValueArray(CategoryData data)
    {
        BarChart bar  = BarObject.GetComponent <BarChart>();
        var      obj  = mParser.GetObject(data.DataObjectName);
        int      size = mParser.GetArraySize(obj);

        if (size < 0) // this is not an array , show warning
        {
            Debug.LogWarning("DataType " + data.DataType + " does not match category " + data.Name);
            return;
        }
        try
        {
            for (int i = 0; i < size; i++)
            {
                double val   = ParseItem(mParser.GetItem(obj, i), null);
                string group = bar.DataSource.GetGroupName(i);
                bar.DataSource.SetValue(data.Name, group, val);
            }
        }
        catch (Exception e)
        {
            Debug.LogWarning("Data for category " + data.Name + " does not match the specified format. Ended with exception : " + e.ToString());
        }
    }
    void BarClicked(BarChart.BarEventArgs args)
    {
        var sel = bar.GetComponent <masterBarSelection>();

        if (sel != null)
        {
            sel.ToogleBar(args.Category, args.Group);
        }
    }
    void Start()
    {
        Content      = GameObject.Find("Content");
        BarChatSetts = GameObject.Find("BarChatSetts(Clone)");
        GraphClose   = GameObject.Find("GraphClose");
        barChart     = barChartObj.GetComponent <BarChart>();
        PopulateGrid   populate       = Content.GetComponent <PopulateGrid>();
        CanvasBarChart canvasBarChart = barChart.GetComponent <CanvasBarChart>();

        canvasBarChart.DataSource.ClearCategories();

        GraphClose.GetComponent <Button>().onClick.AddListener(() => CloseGraph());

        string TurbineHeight = "";

        barChart.DataSource.StartBatch();
        if (barChart != null)
        {
            List <string> list = new List <string>();
            for (int i = 0; i < populate.GeneratedPowerSet.Length / 5; i++)
            {
                if (populate.GeneratedPowerSet[i, 1] != 0)
                {
                    list.Add("Power of Turbine Height " + TurbineHeight + "- Row " + populate.GeneratedPowerSet[i, 0] + " : " + populate.GeneratedPowerSet[i, 1] + " | WindInput of " + "Turbine Height " + TurbineHeight + "- Row " + populate.GeneratedPowerSet[i, 0] + " : " + populate.GeneratedPowerSet[i, 2]);
                    TurbineHeight = populate.getTrubineHeight(Convert.ToInt32(populate.GeneratedPowerSet[i, 0])).ToString();
                    canvasBarChart.DataSource.AddCategory("T" + TurbineHeight + "-" + populate.GeneratedPowerSet[i, 0], MaterialList[UnityEngine.Random.Range(0, MaterialList.Length)]);

                    barChart.DataSource.SetValue("T" + TurbineHeight + "-" + populate.GeneratedPowerSet[i, 0], "Power", populate.GeneratedPowerSet[i, 1]);
                    barChart.DataSource.SetValue("T" + TurbineHeight + "-" + populate.GeneratedPowerSet[i, 0], "WInput", populate.GeneratedPowerSet[i, 2]);
                }
            }
            using (System.IO.StreamWriter file =
                       new System.IO.StreamWriter(@"D:\\PowerOutPutAndWindInput.txt"))
            {
                foreach (string line in list)
                {
                    // If the line doesn't contain the word 'Second', write the line to the file.
                    file.WriteLine(line);
                }
            }
        }
        barChart.DataSource.EndBatch();
    }
示例#4
0
    // Start is called before the first frame update

    void Start()
    {
        BarChart barChart = GetComponent <BarChart>();

        if (barChart != null)
        {
            for (int i = 0; i < categories.Length; i++)
            {
                Material pointMaterial = Resources.Load(string.Format("Materials/_pointaaa0"), typeof(Material)) as Material;
                Debug.Log(pointMaterial);
                Debug.Log("HERE");
                ChartDynamicMaterial CDM = new ChartDynamicMaterial(barMaterial);

                barChart.DataSource.AddCategory(categories[i], CDM);
                barChart.DataSource.SetValue(categories[i], "All", values[i]);
            }
            barChart.GetComponent <BarAnimation>().Animate();
        }
    }