zoukankan      html  css  js  c++  java
  • js的json转换

    静态页面是:

     data:[{
                        value:2.5,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    },{
                        value:2.5,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    },{
                        value:2.5,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    },{
                        value:2.5,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    },{
                        value:2.5,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    },{
                        value:2.5,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    },{
                        value:1.5,
                        itemStyle:{
                          normal:{color:'#ec3434'}    
                        }
                    },{
                        value:2.5,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    },{
                        value:2.5,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    },{
                        value:2.6,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    },{
                        value:2.6,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    },{
                        value:2.6,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    },{
                        value:2.6,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    },{
                        value:2.6,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    },{
                        value:2.6,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    },{
                        value:2.6,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    },{
                        value:3.0,
                        itemStyle:{
                          normal:{color:'#f2df0b'}    
                        }
                    },{
                        value:2.5,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    },{
                        value:2.5,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    },{
                        value:2.5,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    },{
                        value:2.5,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    },{
                        value:2.5,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    },{
                        value:2.5,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    },{
                        value:2.5,
                        itemStyle:{
                          normal:{color:'#4a90e2'}    
                        }
                    }]

    这不是一维数组,不能在js中

    var xTotal = new Array();

    可以转换成json即可

    //共有多少节电池
            //拼接成X轴
            //拼接成Y轴
            var xTotal = new Array();
            var yTotal = new Array();
            for(var i=0;i<result.data.length;i++){
                xTotal.push((i+1));
                
                var ytemp = "{value:"+result.data[i].bettervol+",itemStyle:{normal:{color:'#4a90e2'}}}";
                
                yTotal.push(eval('(' + ytemp + ')'));         --------------关键点
            }
  • 相关阅读:
    C++中的friend函数详细解析(一)
    【图像处理算法】 直方图均衡化
    可降水量W:空中水文学名词初集(4)
    excel\docx
    WebService学习总结
    C#深入学习笔记Lock
    事件Event深入总结
    C#泛型委托与Lambda总结
    SQLServer事务与锁的基础概念总结
    委托Delegate深入总结
  • 原文地址:https://www.cnblogs.com/zrui-xyu/p/5543352.html
Copyright © 2011-2022 走看看