示例#1
0
    ///<summary>Instantiates emptyGraphPrefab (pie graph) and initializes it.</summary>
    void InitializeGraph()
    {
        GameObject graphGO = base.InstantiateGraph();

        graph = graphGO.GetComponent <WMG_Pie_Graph> ();
        graph.Init();
    }
    void Hello()
    {
        pieGraph = transform.Find("PieGraphData").GetComponent <WMG_Pie_Graph>();

        pieGraph.Init();

        pieGraph.resizeEnabled = true;

        pieGraph.explodeLength = 1.1f;         //饼块分离程度为0,意思为不分离

        pieGraph.useDoughnut = true;           //中间掏空

        pieGraph.doughnutPercentage = 0.4f;    //掏空大小

        pieGraph.autoCenter = true;            //自动居中

        pieGraph.autoCenterMinPadding = 41.4f; //自动居中后插孔填充背景

        pieGraph.bgCircleOffset = 4.7f;

        pieGraph.sliceLabelType = WMG_Enums.labelTypes.Labels_Percents; //显示标题和百分比

        pieGraph.sortBy = WMG_Pie_Graph.sortMethod.None;                //摆放顺序

        //调整标签
        pieGraph.sliceLabelExplodeLength = 35;

        pieGraph.sliceLabelFontSize = 15;

        pieGraph.numberDecimalsInPercents = 1;

        pieGraph.sliceLabelColor = new Color32(73, 181, 255, 255);
    }
示例#3
0
    // Use this for initialization
    void Start()
    {
        GameObject graphGO = GameObject.Instantiate(emptyPiePrefab);

        graphGO.transform.SetParent(this.transform, false);
        pieGraph = graphGO.GetComponent <WMG_Pie_Graph>();

        pieGraph.Init(); // Important this gets called before setting data
    }
    // Use this for initialization
    void Start()
    {
        GameObject graphGO = GameObject.Instantiate(emptyPiePrefab);

        graphGO.transform.SetParent(this.transform, false);
        pieGraph = graphGO.GetComponent <WMG_Pie_Graph>();

        pieGraph.Init();         // Important this gets called before setting data

        pieGraph.sliceValues.SetList(testData);
        pieGraph.sliceLabels.SetList(testStrings);
    }
示例#5
0
    // Use this for initialization
    void Start()
    {
        GameObject pieGraphObj = Instantiate <WMG_Pie_Graph>(pieGraphPrefab).gameObject;

        pieGraphObj.transform.SetParent(GameObject.Find("Canvas").transform, worldPositionStays: false);
        pieGraphObj.GetComponent <RectTransform>().sizeDelta     = pieGraphObj.transform.parent.GetComponent <RectTransform>().rect.size *0.3f; //全屏
        pieGraphObj.GetComponent <RectTransform>().localPosition = new Vector2(-604.6f, 119f);
        WMG_Pie_Graph pieGraph = pieGraphObj.GetComponent <WMG_Pie_Graph>();

        pieGraph.Init();

        //Debug.Log(pieGraph.gameObject.name);
        WMG_List <float> pieValues = new WMG_List <float>()
        {
            60f, 80f, 75f, 90f, 100f, 85f, 95f
        };
        WMG_List <string> pieLabels = new WMG_List <string>()
        {
            "One", "Two", "Three", "Four", "Five", "Six", "Seven"
        };
        WMG_List <Color> pieColor = new WMG_List <Color>()
        {
            Color.red, Color.yellow, Color.green, Color.blue, Color.cyan, Color.black
        };

        //pieGraph.resizeEnabled = true;

        ///////pieGraph.sliceValues = pieValues;  Debug.Log("草泥马有几个:" + pieGraph.sliceValues.Count);
        ////////pieGraph.sliceLabels = pieLabels;  //不能直接改变量,要用内置函数去改
        ////////pieGraph.sliceColors = pieColor;
        pieGraph.sliceValues.SetList(pieValues);
        pieGraph.sliceLabels.SetList(pieLabels);
        pieGraph.sliceColors.SetList(pieColor);

        pieGraph.sliceLabelExplodeLength = -10f;
        pieGraph.autoCenter = false;
        //pieGraph.autoCenterMinPadding = 10f;
        //pieGraph.bgCircleOffset = 80f;
        pieGraph.sortBy        = WMG_Pie_Graph.sortMethod.None;
        pieGraph.explodeLength = 1f;
        //pieGraph.explodeSymmetrical = false;
        pieGraph.sliceLabelFontSize       = 10;
        pieGraph.numberDecimalsInPercents = 1;


        pieGraph.interactivityEnabled        = true;
        pieGraph.WMG_Pie_Slice_Click        += SliceClickEvent;
        pieGraph.WMG_Pie_Legend_Entry_Click += SliceLegendEntryClickEvent;
        pieGraph.WMG_Pie_Slice_MouseEnter   += TooltipLegendLinkMouseEnter;

        //pieGraph.Refresh();
    }
示例#6
0
    public void UpdateGraph(List <string> names, IList <float> data, string newTitle)
    {
        pieGraph.Init();

        //List<int> values = new List<int>();
        //List<string>
        //foreach (KeyValuePair<string, int> pair in vandalEdits)
        //{
        //    vandalValues.Add((string)pair.Key + "," + (int)pair.Value);
        //    //vandalValues.Add((int)pair.Value + "," + (string)pair.Key);
        //}
        pieGraph.sliceValues.SetList(data);
        pieGraph.sliceLabels.SetList(names);
        //pieGraph.sliceColors.SetList(new List<Color>() { Color.blue, Color.red });
    }
	// Use this for initialization
	void Start () {
		GameObject graphGO = GameObject.Instantiate(pieGraphPrefab) as GameObject;
		graphGO.transform.SetParent(this.transform, false);
		graph = graphGO.GetComponent<WMG_Pie_Graph>();

		graph.Init(); // Call Init() to ensure things are initialized

		// lets create an interactive doughnut chart
		graph.interactivityEnabled = true;
		graph.useDoughnut = true;
		graph.doughnutPercentage = 0.5f;
		graph.explodeLength = 0;
		graph.WMG_Pie_Slice_Click += myPieSliceClickFunction;
		graph.WMG_Pie_Slice_MouseEnter += myPieSliceHoverFunction;
	}
    // Use this for initialization
    void Start()
    {
        GameObject graphGO = GameObject.Instantiate(pieGraphPrefab) as GameObject;

        graphGO.transform.SetParent(this.transform, false);
        graph = graphGO.GetComponent <WMG_Pie_Graph>();

        graph.Init();         // Call Init() to ensure things are initialized

        // lets create an interactive doughnut chart
        graph.interactivityEnabled      = true;
        graph.useDoughnut               = true;
        graph.doughnutPercentage        = 0.5f;
        graph.explodeLength             = 0;
        graph.WMG_Pie_Slice_Click      += myPieSliceClickFunction;
        graph.WMG_Pie_Slice_MouseEnter += myPieSliceHoverFunction;
    }
    void Hello()
    {
        //初始化
        pieGraphGF.Init();
        pieGraphCN.Init();
        pieGraphDW.Init();

        //使能
        pieGraphGF.resizeEnabled = true;
        pieGraphCN.resizeEnabled = true;
        pieGraphDW.resizeEnabled = true;

        //不裂缝
        pieGraphGF.explodeLength = 0;
        pieGraphCN.explodeLength = 0;
        pieGraphDW.explodeLength = 0;

        //不掏空
        pieGraphGF.useDoughnut = false;
        pieGraphCN.useDoughnut = false;
        pieGraphDW.useDoughnut = false;

        //自动居中
        pieGraphGF.autoCenter = true;
        pieGraphCN.autoCenter = true;
        pieGraphDW.autoCenter = true;

        //摆放顺序
        pieGraphGF.sortBy = WMG_Pie_Graph.sortMethod.None;
        pieGraphCN.sortBy = WMG_Pie_Graph.sortMethod.None;
        pieGraphDW.sortBy = WMG_Pie_Graph.sortMethod.None;

        //饼状图中百分比显示样式
        pieGraphGF.sliceLabelType = WMG_Enums.labelTypes.None;
        pieGraphCN.sliceLabelType = WMG_Enums.labelTypes.None;
        pieGraphDW.sliceLabelType = WMG_Enums.labelTypes.None;

        //饼状图大小
        pieGraphGF.autoCenterMinPadding = 9f;
        pieGraphCN.autoCenterMinPadding = 9f;
        pieGraphDW.autoCenterMinPadding = 9f;
        pieGraphGF.bgCircleOffset       = 1f;
        pieGraphCN.bgCircleOffset       = 1f;
        pieGraphDW.bgCircleOffset       = 1f;

        //设置饼状图名称
        sliceLabelsGF.Add("光伏");
        sliceLabelsGF.Add("光伏_");
        sliceLabelsCN.Add("储能");
        sliceLabelsCN.Add("储能_");
        sliceLabelsDW.Add("电网");
        sliceLabelsDW.Add("电网_");

        //设置饼状图颜色
        sliceColorsGF.Add(new Color32(84, 176, 241, 255));
        sliceColorsGF.Add(new Color32(43, 54, 84, 0));
        sliceColorsCN.Add(new Color32(121, 220, 248, 255));
        sliceColorsCN.Add(new Color32(43, 54, 84, 0));
        sliceColorsDW.Add(new Color32(84, 176, 241, 255));
        sliceColorsDW.Add(new Color32(43, 54, 84, 0));

        //赋值给最终显示
        pieGraphGF.sliceLabels.Clear();
        pieGraphCN.sliceLabels.Clear();
        pieGraphDW.sliceLabels.Clear();
        pieGraphGF.sliceColors.Clear();
        pieGraphCN.sliceColors.Clear();
        pieGraphDW.sliceColors.Clear();
        pieGraphGF.sliceLabels.SetList(sliceLabelsGF);
        pieGraphCN.sliceLabels.SetList(sliceLabelsCN);
        pieGraphDW.sliceLabels.SetList(sliceLabelsDW);
        pieGraphGF.sliceColors.SetList(sliceColorsGF);
        pieGraphCN.sliceColors.SetList(sliceColorsCN);
        pieGraphDW.sliceColors.SetList(sliceColorsDW);

        pieGraphGF.Refresh();
        pieGraphCN.Refresh();
        pieGraphDW.Refresh();
    }
        public override void Awake()
        {
            base.Awake();
            pie.Init();
            pie.interactivityEnabled = true;
            //pie.useDoughnut = true;
            pie.doughnutPercentage        = 0.5f;
            pie.explodeLength             = 0;
            pie.WMG_Pie_Slice_MouseEnter += (pieGraph, aSlice, hover) =>
            {
                //Debug.Log("Pie Slice Hover: " + pieGraph.sliceLabels[aSlice.sliceIndex]);
                if (hover)
                {
                    Vector3 newPos = pie.getPositionFromExplode(aSlice, 30);
                    WMG_Anim.animPosition(aSlice.gameObject, 1, Ease.OutQuad, newPos);
                }
                else
                {
                    Vector3 newPos = pie.getPositionFromExplode(aSlice, 0);
                    WMG_Anim.animPosition(aSlice.gameObject, 1, DG.Tweening.Ease.OutQuad, newPos);
                }
            };
            lookPie.onClick.AddListener(() =>
            {
                pie.gameObject.SetActive(true);
                bar.gameObject.SetActive(false);
                switch (dropdown.value)
                {
                case 0:
                    {
                        Department[] arr = Kernel.Current.Sql.LoadEntitys <Department>();
                        pie.sliceLabels.SetList(arr.Select(x => x.Name));
                        float[] farr = new float[arr.Length];
                        for (int i = 0; i < arr.Length; i++)
                        {
                            var l   = Kernel.Current.Sql.QueryWhere <Personnel>($"DepartmentID={arr[i].ID}").Length;
                            farr[i] = l;
                        }
                        Color[] colors = new Color[farr.Length];
                        for (int i = 0; i < colors.Length; i++)
                        {
                            colors[i] = new Color(Random.value, farr[i], Random.value);
                        }
                        pie.sliceColors.SetList(colors);
                        pie.sliceValues.SetList(farr);
                    }
                    break;

                case 1:
                    {
                        Title[] arr = Kernel.Current.Sql.LoadEntitys <Title>();
                        pie.sliceLabels.SetList(arr.Select(x => x.Name));
                        float[] farr = new float[arr.Length];
                        for (int i = 0; i < arr.Length; i++)
                        {
                            var l   = Kernel.Current.Sql.QueryWhere <Personnel>($"TitleID={arr[i].ID}").Length;
                            farr[i] = l;
                        }
                        Color[] colors = new Color[farr.Length];
                        for (int i = 0; i < colors.Length; i++)
                        {
                            colors[i] = new Color(Random.value, farr[i], Random.value);
                        }
                        pie.sliceColors.SetList(colors);
                        pie.sliceValues.SetList(farr);
                    }
                    break;

                case 2:
                    {
                        Position[] arr = Kernel.Current.Sql.LoadEntitys <Position>();
                        pie.sliceLabels.SetList(arr.Select(x => x.Name));
                        float[] farr = new float[arr.Length];
                        for (int i = 0; i < arr.Length; i++)
                        {
                            var l   = Kernel.Current.Sql.QueryWhere <Personnel>($"PositionID={arr[i].ID}").Length;
                            farr[i] = l;
                        }
                        Color[] colors = new Color[farr.Length];
                        for (int i = 0; i < colors.Length; i++)
                        {
                            colors[i] = new Color(Random.value, farr[i], Random.value);
                        }
                        pie.sliceColors.SetList(colors);
                        pie.sliceValues.SetList(farr);
                    }
                    break;

                default:
                    break;
                }
            });
            lookAxis.onClick.AddListener(() =>
            {
                pie.gameObject.SetActive(false);
                bar.gameObject.SetActive(true);
                switch (dropdown.value)
                {
                case 0:
                    {
                        Department[] arr = Kernel.Current.Sql.LoadEntitys <Department>();
                        float[] farr     = new float[arr.Length];
                        float count      = 0;
                        for (int i = 0; i < arr.Length; i++)
                        {
                            var l   = Kernel.Current.Sql.QueryWhere <Personnel>($"DepartmentID={arr[i].ID}").Length;
                            farr[i] = l;
                            count  += l;
                        }
                        bar.SetValues(arr.Select(x => x.Name).Zip(farr, (x, y) =>
                        {
                            return(new KeyValuePair <string, float>(x, y));
                        }).ToList(), count);
                    }
                    break;

                case 1:
                    {
                        Title[] arr  = Kernel.Current.Sql.LoadEntitys <Title>();
                        float[] farr = new float[arr.Length];
                        float count  = 0;
                        for (int i = 0; i < arr.Length; i++)
                        {
                            var l   = Kernel.Current.Sql.QueryWhere <Personnel>($"DepartmentID={arr[i].ID}").Length;
                            farr[i] = l;
                            count  += l;
                        }
                        bar.SetValues(arr.Select(x => x.Name).Zip(farr, (x, y) =>
                        {
                            return(new KeyValuePair <string, float>(x, y));
                        }).ToList(), count);
                    }
                    break;

                case 2:
                    {
                        Position[] arr = Kernel.Current.Sql.LoadEntitys <Position>();
                        float[] farr   = new float[arr.Length];
                        float count    = 0;
                        for (int i = 0; i < arr.Length; i++)
                        {
                            var wherelen = Kernel.Current.Sql.QueryWhere <Personnel>($"PositionID={arr[i].ID}").Length;
                            farr[i]      = wherelen;
                            count       += wherelen;
                        }
                        bar.SetValues(arr.Select(x => x.Name).Zip(farr, (x, y) =>
                        {
                            return(new KeyValuePair <string, float>(x, y));
                        }).ToList(), count);
                    }
                    break;

                default:
                    break;
                }
            });
        }