Graph_Maker 饼图

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 () {
		
	}
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值