Graph_Maker 饼图

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_15267341/article/details/91047421
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class test01 : MonoBehaviour {
    public WMG_Pie_Graph pieGraph;
	// Use this for initialization
	void Start () {

        pieGraph.Init();


        WMG_List<float> pieValues = new WMG_List<float>() { 60f, 80f, 75f};
        WMG_List<string> pieLabels = new WMG_List<string>() { "xu", "hai", "tao" };
        WMG_List<Color> pieColor = new WMG_List<Color>() { Color.red, Color.yellow, Color.green };


        //pieGraph.resizeEnabled = true;
        pieGraph.sliceValues.SetList(pieValues);
        pieGraph.sliceLabels.SetList(pieLabels);
        pieGraph.sliceColors.SetList(pieColor);
        pieGraph.sortBy = WMG_Pie_Graph.sortMethod.Smallest_First;  //从小到大
        pieGraph.explodeLength = 0f;  //控制饼与饼之间的缝隙
        pieGraph.explodeSymmetrical = false;
        pieGraph.sliceLabelFontSize = 30;
        pieGraph.numberDecimalsInPercents = 2;   //百分比小数点的位数,2意为小数点保留2位


        pieGraph.interactivityEnabled = true;
        pieGraph.WMG_Pie_Slice_Click += SliceClickEvent;


        pieGraph.Refresh();
    }
    void SliceClickEvent(WMG_Pie_Graph pieGraph, WMG_Pie_Graph_Slice aSlice)
    {

        print(aSlice.objectToScale.name);
        if (aSlice.objectToLabel.GetComponent<Text>().text!="")
        {
           // float.Parse(aSlice.objectToLabel.GetComponent<Text>().text).ToString("F2");
        }
        print(aSlice.objectToLabel.GetComponent<Text>().text);
    }
    void SliceLegendEntryClickEvent(WMG_Pie_Graph pieGraph, WMG_Legend_Entry legendEntry)
    {

    }

	// Update is called once per frame
	void Update () {
		
	}
}

展开阅读全文

没有更多推荐了,返回首页