/**
* 柱状图
* @param data
*/
function getHighchartTjt2(data, id) {
var nameId = "chartDiv";
if (id != "" && id != undefined) {
nameId = id;
}
var length = data.color.length;
var colors = new Array([length]);
var series = [];
for (var i = 0; i < length; i++) {
colors[i] = '#' + data.color[i];
var type = data.type == '' || data.type == undefined ? '' : data.type[i];
series[i] = {
name : data.names[i],
data : data.yValue[i],
stack : type
};
}
Highcharts.setOptions({
lang: {
resetZoom: '重置',
printChart: '打印图表',
downloadJPEG: '导出JPEG图片',
downloadPDF: '导出PDF文件',
downloadPNG: '导出PNG图片',
downloadSVG: '导出SVG文件'
},
global: { useUTC: false } //不使用时区
});
var legend = true;
if (data.from == 'twfb') {
legend = false;
}
var allowDecimals = true; //Y轴是否显示小数
var spacingLeft = 0; //左边款距离
var spacingBottom = 0; //下部
var backgroundColor = ""; //背景色
var gridLineColor = "#C0C0C0"; //网格线颜色
if (data.from == "hkclient") {
legend = false;
backgroundColor = 'transparent';
allowDecimals = false;
spacingLeft = 0;
spacingBottom = -15;
gridLineColor = "#142c4c";
}
var chart = new Highcharts.Chart(nameId,{
chart: {
type: 'column',
spacingLeft : spacingLeft,
spacingBottom : spacingBottom,
backgroundColor : backgroundColor
},
colors: colors,
title: {
text: data.title
},
credits: false,
legend: {
enabled: legend
},
xAxis: {
categories: data.xValue
},
yAxis: {
allowDecimals: allowDecimals,
gridLineColor : gridLineColor,
min: 0,
title: {
text: data.ydw
}
},
tooltip: {
formatter: function() {
var str = '' + this.x + '
' + this.series.name + ': ' + this.y + data.ydw + '
' + '总计: ' + this.point.stackTotal + data.ydw;
if (this.point.extra != undefined) {
str += '
' + this.point.extra + '';
}
// 体重分布平均体重曲线特殊显示
if (data.from != '' && data.from != undefined && this.series.name == '平均体重') {
str = '' + this.point.extra + '';
}
// 有耳标的温度分布特殊显示
if (data.from == 'twfb') {
str = '总计:' + this.point.stackTotal + data.ydw + '
' + this.point.extra;
}
//体重增长分布
if (data.from == "tzzzfb") {
str = '' + this.x + '
' + '总计: ' + this.point.stackTotal + data.ydw + '
' + this.point.extra + '';
}
return str;
}
},
plotOptions: {
column: {
stacking: 'normal'
},
series: {
cursor: 'pointer',
events: {
click: function(e) {
if (data.from == "tzzzfb") {
getTzzzGtxxList(e.point.category);
}
if (data.from == "tzfb" && e.point.series.name != "平均体重") {
var yweb = $("#yweb").val();
if (yweb == 1 || yweb == "1") {
getTzfbGtxxList(e.point.category);
}
}
if (data.from == "twfb") {
var res = e.point.url.split("&");
getGtxxList($("#mcid").val(), $("#zsid").val(), $("#lqid").val(), "twfb", res[1].split("=")[1], res[2].split("=")[1], res[0].split("=")[1]);
}
if (data.from == "xscs_fwfb") {
getFwfbGtxxList(e.point.category);
}
}
}
}
},
series: series
});
}
/**
* 线状图
* @param data
*/
function getHighchartTjt(data, id) {
var nameId = "chartDiv";
if (id != "" && id != undefined) {
nameId = id;
}
var dateFormat = '%m-%d %H:%M:%S';
var length = data.color.length;
var colors = new Array([length]);
var series = [];
for (var i = 0; i < length; i++) {
colors[i] = '#' + data.color[i];
series[i] = {
name : data.names[i],
data : data.values[i]
};
}
if (data.dateFormat != '' && data.dateFormat != undefined) {
dateFormat = data.dateFormat;
}
Highcharts.setOptions({
lang: {
resetZoom: '重置',
printChart: '打印图表',
downloadJPEG: '导出JPEG图片',
downloadPDF: '导出PDF文件',
downloadPNG: '导出PNG图片',
downloadSVG: '导出SVG文件'
},
global: { useUTC: false } //不使用时区
});
var legend = {
enabled: true
}; //是否显示窗格
var allowDecimals = true; //Y轴是否显示小数
var spacingLeft = 0; //左边款距离
var backgroundColor = ""; //背景色
var gridLineColor = "#C0C0C0"; //网格线颜色
var title = {
text: data.title
};
if (data.from == "hkclient" || data.from == "hkclient_tjfx" || data.from == "hkclientSy") {
legend = {
enabled: false
};
if (data.from == "hkclient_tjfx") {
legend = {
layout: 'vertical',
align: 'left',
verticalAlign: 'top',
x: 150,
y: 100,
floating: true,
borderWidth: 1,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
};
}
backgroundColor = 'transparent';
if (data.from != "hkclientSy") {
allowDecimals = false;
}
spacingLeft = 0;
gridLineColor = "#142c4c";
title = {
text:data.title,
style:{
color: "#ffffff",
fontSize: "40px"
}
};
}
var chart = new Highcharts.Chart(nameId,{
chart: {
zoomType: 'x',
borderWidth: 0,
backgroundColor: backgroundColor,
spacingLeft : spacingLeft
},
colors: colors,
title: title,
xAxis: {
type: 'datetime',
minRange: 60 * 1000 * 60,
dateTimeLabelFormats: {
second: '%H:%M:%S',
minute: '%H:%M',
hour: '%H:%M',
day: '%m-%d',
month: '%m-%d',
week: '%m-%d',
year: '$Y'
}
},
yAxis: {
title: {
//text: '' + data.ydw + ''
text: ''
},
allowDecimals: allowDecimals,
gridLineColor: gridLineColor
},
legend: legend,
credits: {
enabled: false
},
plotOptions: {
line: {
turboThreshold: 0,
marker: {
radius: 2
},
lineWidth: 2,
states: {
hover: {
enabled: false,
lineWidth: 3
}
},
},
series: {
cursor: 'pointer',
events: {
click: function(e) {
// if (data.from == "qttzzz") {
// tzzzfb(e.point.x);
// }
if (data.from == "hkbj_gzxx") {
showGzxxList(e.point.x);
}
}
}
}
},
tooltip: {
formatter: function () {
var sj = Highcharts.dateFormat(dateFormat, this.x);
if (sj.indexOf("-") > -1) {
sj = "日期:" + sj;
} else {
sj = "时间:" + sj;
}
var str = sj + '
' + '' + this.series.name + ':' + this.y + data.ydw + '';
if (this.point.extra != undefined) {
str += '
' + this.point.extra + '';
}
if (data.from == "hkclient") {
str = '时间:' + Highcharts.dateFormat(dateFormat, this.x) + '
' + '' + this.series.name + ':' + this.y + data.ydw + '';
}
return str;
},
crosshairs: [ {
width: 2,
color: '#FF5B00',
dashStyle: 'shortdot'
}, {
width: 2,
color: '#FF5B00',
dashStyle: 'shortdot'
}]
},
series: series
});
}
/**
*
* @param mcid 牧场ID
* @param zsid 猪舍ID
* @param lqid 栏期ID
* @param gjz 关键字
* @param min 最小值
* @param max 最大值
* @param time 时间毫秒
*/
function getGtxxList(mcid, zsid, lqid, gjz, min, max, time, ebh) {
if (ebh == undefined || ebh == "" || ebh == "undefined") {
ebh = "000000000000000";
}
Dialogs.load('setGtxxList.htm', {"mcid" : mcid, "zsid" : zsid, "lqid" : lqid, "gjz" : gjz, "min" : min, "max" : max, "time" : time, "ebh" : ebh}, {
// 对话框基本配置选项
draggable: true, // 是否拖动
autosize: true, // 是否自适应大小
resizable: true, // 是否可以改变大小
maximizable: true, // 是否显示最大化最小化
autopos: 'fixed', // 窗口是否(自动剧中,fixed)页面 默认’fixed’
title: "个体信息列表", // 窗口标题
lightbox: false, // 窗口应用时是否禁用其他操作
width: 550, // 窗口宽度
height: 430, // 窗口高度
autocenter: true // 对话框窗体自动居中
});
}
/**
* 加载个体信息列表
* @param id
* @param param
* @param fgf
*/
function loadGtxxList(id, param, fgf) {
jQuery("#" + id).flexigrid({
url : 'getGtszList.htm',
dataType : 'json',
method : 'post',
params : [{
name : 'param',
value : param
}, {
name : 'fgf',
value : fgf
}],
title : '个体生长浏览',
usepager : true,
useRp : true,
rp : 10,
singleSelect : true,
hidehead : false,
showInputPage : true,
showSelectRp : false,
showTableToggleBtn : false,
width : '790',
height : '335',
nowrap : true,
resizable : false,
cache : false,// 清除缓存
colModel : [{
display : '行号',
name : 'hh',
width : 25,
sortable : false,
align : 'center',
process : function(col, record, d) {
jQuery(col).html(d + 1);
}
}, {
display : '动物耳标',
name : 'dweb',
width : 95,
sortable : true,
align : 'center',
process : function(col, record, d) {
jQuery(col).html("" + record.dweb + "");
}
}, {
display : '当前体重(Kg)',
name : 'dqtz',
width : 65,
sortable : false,
align : 'center'
}, {
display : '体重增长(g)',
name : 'tzzz',
width : 65,
sortable : false,
align : 'center'
}, {
display : '注册体重(Kg)',
name : 'rltz',
width : 70,
sortable : false,
align : 'center'
}, {
display : '当前温度(℃)',
name : 'dqwd',
width : 70,
sortable : false,
align : 'center'
}, {
display : '入栏日期',
name : 'rlsj',
width : 65,
sortable : false,
align : 'center'
}, {
display : '全程温度',
name : '',
width : 55,
sortable : false,
align : 'center',
process : function(col, record, d) {
jQuery(col).addClass('s');
jQuery(col).html(record.qcwd);
}
}, {
display : '体重变化',
name : '',
width : 55,
sortable : false,
align : 'center',
process : function(col, record, d) {
jQuery(col).addClass('s');
jQuery(col).html(record.tzbh);
}
}, {
display : '体重增长',
name : '',
width : 55,
sortable : false,
align : 'center',
process : function(col, record, d) {
jQuery(col).addClass('s');
jQuery(col).html(record.zztjt);
}
}, {
display : '颜色标识',
name : '',
width : 45,
sortable : false,
align : 'center',
process : function(col, record, d) {
var html = selectYsbz(record.lqid, record.dweb, record.ysbz);
jQuery(col).html(html);
}
}, {
display : '是否异常',
name : '',
width : 45,
sortable : false,
align : 'center',
process : function(col, record, d) {
var html = selectSfyc(record.lqid, record.dweb, record.sfyc);
jQuery(col).html(html);
}
}]
});
}
/**
* 个体信息颜色标识下拉框
*/
function selectYsbz(lqid, dweb, ysbz) {
var html = "";
return html;
}
/**
* 颜色标识变更
*/
function getYsbzChange(lqid, dweb, ysbz) {
if (lqid != "" && dweb != "") {
jQuery.ajax({
url: "setYsbz.htm",
dataType: "json",
type: "post",
async: false,
data : {"lqid" : lqid, "dweb" : dweb, "ysbz" : ysbz},
success: function(data){
if (data.returnCode == 0) {
$("#ysbz" + dweb).val("0");
alert("颜色标识变更失败");
}
}
});
}
}
/**
* 个体信息
* @param dweb
*/
function showGtxx(dweb, param, fgf, tjt) {
param += fgf + '{name : tjt,value : ' + tjt + '}';
param += fgf + '{name : dweb,value : ' + dweb + '}';
var params = [{
name : 'param',
value : param
}, {
name : 'fgf',
value : fgf
}];
huimv.loadPage("gtszDiv", "getGtxxtjt.htm", params);
$("#gtszDiv").show();
$("#gtszTable").hide();
}
/**
* 是否异常下拉框
*/
function selectSfyc(lqid, dweb, sfyc) {
var html = "";
return html;
}
/**
* 是否异常变更
*/
function getSfycChange(lqid, dweb, sfyc) {
var oldSfyc = 1 - sfyc;
var sfycmc = sfyc == '0' ? "正常" : "异常";
if (lqid != "" && dweb != "") {
Dialogs.alert("确定变更为" + sfycmc + "?", {
title : '提示信息',
width : 250,
height : 80,
top : 150,
button : {
ok : ['确定',function(){
this.close();
jQuery.ajax({
url: "setSfyc.htm",
dataType: "json",
type: "post",
async: false,
data : {"lqid" : lqid, "dweb" : dweb, "sfyc" : sfyc},
success: function(data){
if (data.returnCode > 0) {
alert("操作成功");
} else {
$("#sfyc" + dweb).val(oldSfyc);
alert("操作失败");
}
}
});
}],
cancel : ['取消',function(){
this.close();
$("#sfyc" + dweb).val(oldSfyc);
}]
}
});
}
}