|
define(function(require) {
var $ = require("jquery");
var justep = require("$UI/system/lib/justep");
require("../Common/Echarts/echarts-all");
var Model = function() {
this.callParent();
};
Model.prototype.modelLoad = function(event){
var names=[];
this.comp().each(function(param) {
names.push(param.row.val('TRI_ID'));
});
// 渗水折线图
var myChart = echarts.init(this.getElementByXid('EchartOne'));
var optionOne = {
title : {
text : justep.Date.toString(new Date(), justep.Date.STANDART_FORMAT_SHOT)
},
tooltip : {
trigger: 'axis'
},
legend: {
data:['CO','SO2','CO2']
},
toolbox: {
show : true,
feature : {
// mark : {show: true},
// dataView : {show: true, readOnly: false},
// magicType : {show: true, type: ['bar','line']},
// restore : {show: true},
saveAsImage : {show: true}
}
},
calculable : true,
xAxis : [
{
type : 'category',
boundaryGap : false,
data : []
}
],
yAxis : [
{
type : 'value',
splitArea : {show : true}
}
],
series : [
{
name:'CO',
type:'line',
stack: '渗水点',
data:[]
},
{
name:'SO2',
type:'line',
stack: '湿度',
data:[]
},
{
name:'CO2',
type:'line',
stack: '温度',
data:[]
}
]
};
//加载数据
jQuery.ajax({
url:"url",
type:'get',
dataType:'json',
success:function(jsons){
var Item = function(){
return {
name:'',
type:'line',
itemStyle: {normal: {areaStyle: {type: 'default',opacity:isArea}}},
label: {normal: {show: isShowAllData,position: 'top'}},
markLine: {data: [{type: 'average', name: '平均值'}]},
data:[]
}
};
var legends = [];
var Series = [];
var json = jsons.
for(var i=0;i < json.length;i++){
var it = new Item();
it.name = json[i].name;
legends.push(json[i].name);
it.data = json[i].data;
Series.push(it);
}
option.xAxis[0].data = jsons.xcontent;
option.legend.data = legends;
option.series = Series; // 设置图表
myChart.setOption(option);// 重新加载图表
},
error:function(){
alert("数据加载失败!请检查数据链接是否正确");
}
});
myChart.setOption(optionOne);
|
|