echarts -- 动态绑定data中的数据

来源:互联网 发布:数据库2002 编辑:程序博客网 时间:2024/06/07 23:28

echarts 中 data 的数据一般为 JSON 数组,所有数据格式为 JSON 或JSON 数组的在得到后台的数据之后都可以自行拼接为呈现的数据。
所以:

forceOption = {            title : {                text : 'title',                x : 'center',                y : '0',                textStyle : {                    fontWeight : 'normal',                }            },            tooltip : {},            animationDurationUpdate : 1500,            animationEasingUpdate : 'quinticInOut',            textStyle : {                color : '#000'            },            series : [ {                type : 'graph',                tooltip : {                    backgroundColor : 'skyblue',                //                      formatter: "{b} <br/>{a} : {c} h "                },                layout : 'none',                symbolSize : 10,                roam : true,                label : {                    normal : {                        show : true                    }                },                edgeSymbol : [ 'circle', 'arrow' ],                edgeSymbolSize : [ 4, 10 ],                edgeLabel : {                    normal : {                        textStyle : {                            fontSize : 12                        },}                },                //手动填充的Data,可以为JSON、JSON数组或返回其中之一的方法,但是格式要求                data : getDataToFoce(),                links : getLinkToFoce(),                lineStyle : {                    normal : {                        opacity : 0.9,                        width : 2,                        curveness : 0.2                    }                }            } ]        };var forceChart = echarts.init(document.getElementById('forchart'));        forceChart.setOption(forceOption);
原创粉丝点击