unity smartchart的曲线图插件的使用

插件效果:


下面是代码的使用: 

    public Text fengXianQuShi_biaoTi;  //风险趋势标题

    //下面是自定义的y轴文本,图表自带的y轴文本总是居中对齐,不好控制
    public Text fengXianQuShi_Yaxis01;
    public Text fengXianQuShi_Yaxis02;
    public Text fengXianQuShi_Yaxis03;
    public Text fengXianQuShi_Yaxis04;
    public Text fengXianQuShi_Yaxis05;

    //下面是自定义的x轴文本,图表自带的x轴,总是显示一些数值
    public List<Text> fengXianQuShiList;
 IEnumerator updateFengXianQuShi()
    {
        while (true)
        {
            int value = Random.Range(2, 4);
            yield return new WaitForSeconds(value);

            WWW www = new WWW("");
            yield return  www;
            if (www.isDone && www.error == null)
            {

                left_Lit nn = JsonMapper.ToObject<left_Lit>(www.text);
                if(nn.data.max_value <= 500)
                {
                    sc.maxYValue =  500;   //设置图表Y轴的最大值
                }
                else if (nn.data.max_value <=1000)
                {
                    sc.maxYValue =  1000;
                }
                else if (nn.data.max_value <= 5000)
                {
                    sc.maxYValue =  5000;
                }
                else if (nn.data.max_value <= 10000)
                {
                    sc.maxYValue =  10000;
                }
                else if (nn.data.max_value <= 50000)
                {
                    sc.maxYValue =  50000;
                }else  if (nn.data.max_value <= 100000)
                {
                    sc.maxYValue = 100000;
                }
                else
                {
                    sc.maxYValue = 200000;
                }

                fengXianQuShi_Yaxis01.text = sc.maxYValue / 4 * 0 + "";
                fengXianQuShi_Yaxis02.text = sc.maxYValue / 4 * 1 + "";
                fengXianQuShi_Yaxis03.text = sc.maxYValue / 4 * 2 + "";
                fengXianQuShi_Yaxis04.text = sc.maxYValue / 4 * 3 + "";
                fengXianQuShi_Yaxis05.text = sc.maxYValue / 4 * 4 + "";

                if (nn.data.name.Count > 0) //说明有数据
                {
                    Vector2 [] shuzu= new Vector2[nn.data.name.Count];
                    print(shuzu.Length);
                    for (int ii=0;ii< nn.data.name.Count; ii++)
                    {
                        shuzu[ii] = new Vector2(ii * 25, nn.data.total[ii]);
                        fengXianQuShiList[ii].text = nn.data.name[ii];
                    }
                    sc.chartData[0].data = shuzu;                  
                    fengXianQuShi_biaoTi.text = nn.title;  //设置自定义的图表标题
                }
            }
            
            sc.SetupValues(true);
            sc.UpdateChart();
        }
    }

下面是监视器面板的设置:

 

QQ技术交流群:386476712

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值