|
附件里是我的JS代码 和W文件 我需要怎样去将data的数据 加载到Echarts中,求大神指导,
define(function(require) {
var $ = require("jquery");
var justep = require("$UI/system/lib/justep");
require("$UI/demo/misc/echarts/dist/echarts-all");
var Model = function() {
this.callParent();
};
Model.prototype.modelLoad = function(event) {
var yaopinData = this.comp("yaopinData");
var yaopinxxData = this.comp("yaopinxxData");
var names = [];
yaopinxxData.each(function(param) {
names.push(param.row.val('wpmc'));
});
var myChart = echarts.init(this.getElementByXid('main'));
var option = {
title : {
text : justep.Date.toString(new Date(), justep.Date.STANDART_FORMAT_SHOT)
},
tooltip : {
trigger : 'axis'
},
toolbox : {
show : true,
feature : {
mark : {
show : true
},
dataView : {
show : true,
readOnly : false
},
magicType : {
show : true,
type : [ 'line', 'bar' ]
},
restore : {
show : true
},
saveAsImage : {
show : true
}
}
},
legend : {
top : 20,
// data : [ '阿莫西林胶囊', '999感冒灵颗粒', '双黄莲口服液', '维生素C' ]
data:[names]
},
grid : {
left : '3%',
right : '4%',
bottom : '3%',
containLabel : true
},
xAxis : {
type : 'category',
boundaryGap : false,
data : [ '周一', '周二', '周三', '周四', '周五', '周六', '周日' ]
},
yAxis : [ {
type : 'value',
name : '销售额',
min : 0,
max : 2000,
interval : 50,
axisLabel : {
formatter : '{value}件 '
}
}, {
type : 'value',
name : '销售量',
min : 0,
max : 4,
interval : 1,
axisLabel : {
formatter : '{value} 万'
}
} ],
series : [ {
name : '阿莫西林胶囊',
type : 'bar',
stack : '销售量',
data : [ 300, 500, 450, 300, 400, 300, 500 ]
}, {
name : '999感冒灵颗粒',
type : 'bar',
stack : '销售量',
data : [ 200, 300, 490, 300, 500, 200, 400 ]
}, {
name : '双黄莲口服液',
type : 'bar',
stack : '销售量',
data : [ 100, 500, 200, 310, 450, 350, 100 ]
}, {
name : '维生素C',
type : 'bar',
stack : '销售量',
data : [ 150, 250, 420, 350, 100, 150, 200 ]
}, {
name : '阿莫西林胶囊',
type : 'line',
stack : '销售额',
data : [ 1.2, 3.1, 4.3, 2, 4, 3, 2.5 ]
}, {
name : '999感冒灵颗粒',
type : 'line',
stack : '销售额',
data : [ 2.1, 1.1, 1.5, 2.5, 3, 2.5, 1.8 ]
}, {
name : '双黄莲口服液',
type : 'line',
stack : '销售额',
data : [ 0.5, 1, 2, 3, 2.5, 2, 3 ]
}, {
name : '维生素C',
type : 'line',
stack : '销售额',
data : [ 1, 2, 3, 4, 0.1, 1, 2 ]
}
]
};
// myChart.showLoading({
// text: '玩命加载中....'
// });
myChart.setOption(option);
};
return Model;
});
这是我尝试写的代码 但是显示不来
|
|