예제 #1
0
    // Start is called before the first frame update
    void Start()
    {
        string name1 = "test";
        string name2 = "test2";

        BarChart chart = GetComponent <BarChart>();

        chart.title.show = true;
        chart.title.text = "Bar Text";

        chart.tooltip.show = true;

        chart.legend.show = true;
        chart.legend.data.Clear();
        chart.legend.data.Add(name1);
        chart.legend.data.Add(name2);

        chart.xAxises[0].show = true;
        chart.xAxises[1].show = false;
        chart.yAxises[0].show = true;
        chart.yAxises[1].show = false;

        chart.xAxises[0].type = Axis.AxisType.Value;
        chart.yAxises[0].type = Axis.AxisType.Category;


        int[] data1 = { 10, 20, -30, 10, 50 };
        int[] data2 = { 50, 60, -10, 50, 10 };
        chart.xAxises[0].splitNumber = data1.Length;

        chart.RemoveData();

        for (int i = 0; i < data1.Length; i++)
        {
            chart.AddYAxisData(i.ToString());
        }

        chart.AddSerie(name1, SerieType.Line);
        chart.AddSerie(name2, SerieType.Line);

        foreach (int i in data1)
        {
            chart.AddData(name1, i);
        }

        foreach (int i in data2)
        {
            chart.AddData(name2, i);
        }

        chart.bar.inSameBar = true;
    }
예제 #2
0
        IEnumerator AddSimpleBar()
        {
            chart = gameObject.GetComponent <BarChart>();
            if (chart == null)
            {
                chart = gameObject.AddComponent <BarChart>();
            }
            chart.title.text    = "BarChart - 柱状图";
            chart.title.subText = "普通柱状图";

            chart.yAxis0.minMaxType = Axis.AxisMinMaxType.Default;

            chart.RemoveData();
            serie = chart.AddSerie(SerieType.Bar, "Bar1");

            for (int i = 0; i < m_DataNum; i++)
            {
                chart.AddXAxisData("x" + (i + 1));
                chart.AddData(0, UnityEngine.Random.Range(30, 90));
            }
            yield return(new WaitForSeconds(1));
        }