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 () {
}
}
Graph_Maker 饼图
最新推荐文章于 2024-09-11 09:55:02 发布