|
本帖最后由 技术小白 于 2016-12-21 21:03 编辑
我写的js代码,请帮忙看看
define(function(require){
var $ = require("jquery");
var justep = require("$UI/system/lib/justep");
var Baas = require("$UI/system/lib/base/baas");
var Model = function(){
this.callParent();
};
var a;
var leiM = wwa ;[img][/img]
Model.prototype.modelLoad = function(event) {
var moR1 = new Date().format('yyyy-MM-dd');
var moR2 = moR1+" "+"00:00" ;
document.getElementById("input1").value = moR2;
this.comp("dateData").setValue("startDate", moR2);
this.comp("dateData").setValue("endDate", new Date());
// var foodData = this.comp("baasData1");//数据源
// var sql = "DT BETWEEN '2016-11-18 00:00:00' AND '2016-11-19 00:00:00'";
// foodData.setFilter("RunningPar",sql);//过滤条件
// foodData.refreshData();
e(this);
};
Model.prototype.button7Click = function(event){
//e(this);
};
Model.prototype.baasData1CustomRefresh = function(event){
var data = event.source;
Baas.sendRequest({
"url" : "/SYCEMS/SYCEMS", // servlet请求地址
"action" : "queryRunningPar", // action
"params" :{ // action对应的参数
"columns" : Baas.getDataColumns(data),
"limit" : event.limit,
"offset" : event.offset
},
"success" : function(resultData) { //请求成功后的回调函数
var append = event.options && event.options.append;
a = resultData;
//console.log(a);
data.loadData(resultData, append);
}
});
};
Date.prototype.format = function(format) {
var o = {
"M+": this.getMonth() + 1,
"d+": this.getDate(),
"h+": this.getHours(),
"m+": this.getMinutes(),
"s+": this.getSeconds(),
"q+": Math.floor((this.getMonth() + 3) / 3),
"S": this.getMilliseconds()
};
if (/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
for (var k in o) {
if (new RegExp("(" + k + ")").test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
}
}
return format;
};
function e(wm){
var GDline1 = new Object;
GDline1.a = a ;
GDline1.SeriesData = [];//数据数组
GDline1.dataRow1 = [];//一号线的数据
GDline1.xAisxRow = [];//x轴坐标数据
GDline1.visablelable = true;//是否可见
GDline1.tempData = 0;
GDline1.dateStr = [];//临时中间变量
function echar(a, b) {//函数两个参数,a为数据源可以为json,b为可选参数,当b为1时,清空看echarts里面的值
/* a = eval(a);*/
a=a.a;
a=a.rows;
if (b == 1) {
GDline1.dateStr.length = 0;
GDline1.dataRow1.length = 0;
GDline1.dataRow2.length = 0;
GDline1.xAisxRow.length = 0;
}
for (var i = 0 ; i < a.length ; i++) {
if ((a[leiM].value)===null) {
GDline1.tempData = 0;
}
else {
GDline1.tempData = a[leiM].value;//10000
}
var paramt1 = {
name: GDline1.dateStr,
value: GDline1.tempData
};
GDline1.dataRow1.push(paramt1);
GDline1.xAisxRow.push(GDline1.dateStr);
}
}
echar(GDline1,a);
//console.log(JSON.stringify(a));
option = {
grid:{
x:50,
y:65,
x2:30,
y2:30,
},
tooltip : {
trigger: 'axis'
},
toolbox: {
x: 'center',
top:'20%',
show : true,
feature : {
dataZoom : {
show : true,
title : {
dataZoom : '区域缩放',
dataZoomReset : '区域缩放后退'
}
},
mark : {show: false},
dataView : {show: false, readOnly: false},
magicType : {show: true, type: ['line', 'bar']},
restore : {show: true},
saveAsImage : {show: false}
}
},
calculable : false,
xAxis : [
{
name: '时间',
nameTextStyle: {
color: '#576B95',
fontSize: 8
},
splitLine: { //显示分界线
show: false
},
type : 'category',
boundaryGap : false,
data : GDline1.xAisxRow
}
],
yAxis : [
{
name: '温度(℃)',
nameTextStyle: {
color: '#576B95',
fontSize: 8
},
splitLine: { //显示分界线
show: false
},
type : 'value',
axisLabel : {
formatter: '{value}'
}
}
],
series : [
{
name:'最高气温',
type:'line',
data:GDline1.dataRow1,
markPoint : {
data : [
{type : 'max', name: '最大值'},
{type : 'min', name: '最小值'}
]
},
},
]
};
var myChart = echarts.init(wm.getElementByXid('main'));
myChart.setOption(option);
}
return Model;
}); |
-
|