'use strict';
app.controller('nxreportCtrl', ["$scope", "$rootScope", "$state", "$timeout", "$interval", "$http", "$cookieStore", "moment", "SweetAlert", "Restangular", "api_report_nx", "api_statistic", function ($scope, $rootScope, $state, $timeout, $interval, $http, $cookieStore, moment, SweetAlert, Restangular, api_report_nx, api_statistic) {
$scope.parameters = {};
$scope.hearderlist = [];
$scope.pielenddata = [];
$scope.piebodydata = [];
$scope.barlenddata = [];
$scope.barbodydata = [];
$scope.categryid = 2;
$scope.sum = 0;
$scope.startlist = {
id: 2,
label: "事件总数&分类统计报告",
title: "事件总数",
key: "incidentClassify",
selected: true
};
$scope.nowdata = moment(new Date()).format('YYYY/MM/DD HH:ss:mm');
//时间搜索
// $scope.starttimes = moment(new Date().getTime() - 86400000 * 7).format('YYYY-MM-DD'); //开始时间
// $scope.endtimes = moment(new Date().getTime() - 86400000).format('YYYY-MM-DD'); //结束时间
var weeks = new Date().getDay();
$scope.starttimes = moment(new Date().getTime() - 86400000 * (weeks + 6)).format('YYYY-MM-DD');
$scope.endtimes = moment(new Date().getTime() - 86400000 * (weeks)).format('YYYY-MM-DD');
$scope.changeForm = function (paramDateFrom) {
$scope.starttimes = moment(paramDateFrom).format('YYYY-MM-DD');
}
$scope.changeTo = function (paramDateTo) {
$scope.endtimes = moment(paramDateTo).format('YYYY-MM-DD');
}
$scope.parameters.paramDateFrom = $scope.starttimes;
$scope.parameters.paramDateTo = $scope.endtimes;
//高度
setInterval(function () {
if (document.getElementById("DIV3")) {
$scope.listheight = {
"min-height": document.getElementById("DIV3").scrollHeight - 20 + "px"
};
}
}, 1000)
var downPdf = document.getElementById("exportToPdf");
downPdf.onclick = function () {
html2canvas(
document.getElementById("export_content"), {
dpi: 172, //导出pdf清晰度
onrendered: function (canvas) {
var contentWidth = canvas.width;
var contentHeight = canvas.height;
//一页pdf显示html页面生成的canvas高度;
var pageHeight = contentWidth / 592.28 * 841.89;
//未生成pdf的html页面高度
var leftHeight = contentHeight;
//pdf页面偏移
var position = 0;
//html页面生成的canvas在pdf中图片的宽高(a4纸的尺寸[595.28,841.89])
var imgWidth = 595.28;
var imgHeight = 592.28 / contentWidth * contentHeight;
var pageData = canvas.toDataURL('image/jpeg', 1.0);
var pdf = new jsPDF('', 'pt', 'a4');
//有两个高度需要区分,一个是html页面的实际高度,和生成pdf的页面高度(841.89)
//当内容未超过pdf一页显示的范围,无需分页
if (leftHeight < pageHeight) {
pdf.addImage(pageData, 'JPEG', 0, 0, imgWidth, imgHeight);
} else {
while (leftHeight > 0) {
pdf.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight)
leftHeight -= pageHeight;
position -= 841.89;
//避免添加空白页
if (leftHeight > 0) {
pdf.addPage();
}
}
}
pdf.save('content.pdf');
},
//背景设为白色(默认为黑色)
background: "#fff"
})
}
//上周
$scope.week = function () {
$scope.searchstate = "week";
var weeks = new Date().getDay();
$scope.starttimes = moment(new Date().getTime() - 86400000 * (weeks + 6)).format('YYYY-MM-DD');
$scope.endtimes = moment(new Date().getTime() - 86400000 * (weeks)).format('YYYY-MM-DD');
$scope.parameters.paramDateFrom = $scope.starttimes;
$scope.parameters.paramDateTo = $scope.endtimes;
// $scope.parameters = parseDateParameter($scope.parameters);
$scope.mdxquery();
}
//上月
$scope.month = function () {
$scope.searchstate = "month";
$scope.starttimes = moment((new Date(moment().startOf('month'))).setMonth((new Date()).getMonth() - 1)).format('YYYY-MM-DD');
$scope.endtimes = moment((new Date(moment().startOf('month'))).setMonth((new Date()).getMonth()) - 86400000).format('YYYY-MM-DD');
$scope.parameters.paramDateFrom = $scope.starttimes;
$scope.parameters.paramDateTo = $scope.endtimes;
// $scope.parameters = parseDateParameter($scope.parameters);
$scope.mdxquery();
}
//上年
$scope.year = function () {
$scope.searchstate = "year";
$scope.starttimes = moment().startOf('year').format('YYYY-MM-DD');
$scope.endtimes = moment().format('YYYY-MM-DD');
$scope.parameters.paramDateFrom = $scope.starttimes;
$scope.parameters.paramDateTo = $scope.endtimes;
// $scope.parameters = parseDateParameter($scope.parameters);
$scope.mdxquery();
}
/**
*日历
*/
$scope.open = function ($event) {
$event.preventDefault();
$event.stopPropagation();
$scope.opened = !$scope.opened;
};
$scope.endOpen = function ($event) {
$event.preventDefault();
$event.stopPropagation();
$scope.startOpened = false;
$scope.endOpened = !$scope.endOpened;
};
$scope.startOpen = function ($event) {
$event.preventDefault();
$event.stopPropagation();
$scope.endOpened = false;
$scope.startOpened = !$scope.startOpened;
};
/***
* 导出
*/
$scope.exportData = function () {
// var modelData = $scope.startlist;
// $state.go('childpape', { starttime: $scope.parameters.paramDateFrom, endtime: $scope.parameters.paramDateTo, model: JSON.stringify(modelData) });
// api_report_nx.getPdf({ url: "http://localhost/#/childpape/2018-11-12/2018-11-18/%7B%22id%22:24,%22label%22:%22%E8%B5%84%E4%BA%A7%E5%9C%A8%E5%BA%93%E7%8A%B6%E6%80%81%E7%BB%9F%E8%AE%A1%E6%8A%A5%E5%91%8A%22,%22key%22:%22assetStatus%22,%22level%22:2,%22expanded%22:false,%22uid%22:%220.2409134734491598%22,%22parent_uid%22:%220.23149440146902256%22,%22children%22:%5B%5D,%22classes%22:%5B%22leaf%22%5D,%22selected%22:true%7D" }).then(function(response) {
// var downUrl = api_report_nx.getPdf({ url: "http://localhost/#/childpape/2018-11-12/2018-11-18/%7B%22id%22:24,%22label%22:%22%E8%B5%84%E4%BA%A7%E5%9C%A8%E5%BA%93%E7%8A%B6%E6%80%81%E7%BB%9F%E8%AE%A1%E6%8A%A5%E5%91%8A%22,%22key%22:%22assetStatus%22,%22level%22:2,%22expanded%22:false,%22uid%22:%220.2409134734491598%22,%22parent_uid%22:%220.23149440146902256%22,%22children%22:%5B%5D,%22classes%22:%5B%22leaf%22%5D,%22selected%22:true%7D" }).getRequestedUrl();
// var a = document.createElement('a');
// a.href = downUrl;
// a.target = '_blank';
// // a.download = filename;
// document.body.appendChild(a);
// a.click();
// });
$http({
url: api_report_nx.getPdf().getRequestedUrl(),
method: 'post',
data: {
url: "http://localhost/#/childpape/2018-11-12/2018-11-18/%7B%22id%22:24,%22label%22:%22%E8%B5%84%E4%BA%A7%E5%9C%A8%E5%BA%93%E7%8A%B6%E6%80%81%E7%BB%9F%E8%AE%A1%E6%8A%A5%E5%91%8A%22,%22key%22:%22assetStatus%22,%22level%22:2,%22expanded%22:false,%22uid%22:%220.2409134734491598%22,%22parent_uid%22:%220.23149440146902256%22,%22children%22:%5B%5D,%22classes%22:%5B%22leaf%22%5D,%22selected%22:true%7D"
},
headers: {
//'Content-type' : 'application/xls',
'Accept': '*/*'
},
responseType: 'arraybuffer'
}).success(function (data, status, headers, config) {
var file = new Blob([data], {
type: 'application/octet-stream'
});
//trick to download store a file having its URL
var fileURL = URL.createObjectURL(file);
var a = document.createElement('a');
a.href = fileURL;
// window.open(a.href);
a.target = '_blank';
// a.download = filename;
document.body.appendChild(a);
a.click();
}).error(function (data, status, headers, config) {
// console.log(data);
});
}
/**
* 时间搜索
*/
$scope.mdxquery = function () {
$scope.parameters.paramDateFrom = moment($scope.parameters.paramDateFrom).format('YYYY-MM-DD');
$scope.parameters.paramDateTo = moment($scope.parameters.paramDateTo).format('YYYY-MM-DD');
if ($scope.startlist.id == 2) {
incidentClassify()
} else if ($scope.startlist.id == 3) {
incidentHandler()
} else if ($scope.startlist.id == 6) {
problemClassify()
} else if ($scope.startlist.id == 7) {
problemHandler()
} else if ($scope.startlist.id == 12) {
changeClassify()
} else if ($scope.startlist.id == 13) {
changeHandler()
} else if ($scope.startlist.id == 16) {
releaseClassify()
} else if ($scope.startlist.id == 17) {
releaseHandler()
} else if ($scope.startlist.id == 22) {
assetClassify()
} else if ($scope.startlist.id == 24) {
assetStatus()
}
}
/**
* 树形列表
*/
$scope.my_tree = {};
$scope.my_data = [];
$scope.try_async_load = function () {
$scope.my_data = [{
id: 1,
label: "事件报表",
children: [{
id: 2,
label: "事件总数&分类统计报告",
title: "事件总数",
key: "incidentClassify",
selected: true,
}, {
id: 3,
label: "处理完事件占比",
tip1: "完成事件数量",
tip2: "事件占比",
key: "incidentHandler"
}]
},
{
id: 5,
label: "问题报表",
children: [{
id: 6,
label: "问题总数&分类统计报告",
title: "问题总数",
key: "problemClassify"
}, {
id: 7,
label: "处理人完成问题占比",
tip1: "完成问题数量",
tip2: "问题占比",
key: "problemHandler"
}]
}, {
id: 11,
label: "变更报表",
children: [{
id: 12,
label: "变更总数&分类统计报告",
title: "变更总数",
key: "changeClassify"
}, {
id: 13,
label: "处理人完成变更占比",
tip1: "完成变更数量",
tip2: "变更占比",
key: "changeHandler"
}]
}, {
id: 15,
label: "发布报表",
children: [{
id: 16,
label: "发布总数&分类统计报告",
title: "发布总数",
key: "releaseClassify"
}, {
id: 17,
label: "处理人完成发布占比",
tip1: "完成发布数量",
tip2: "发布占比",
key: "releaseHandler"
}]
},
{
id: 21,
label: "资产报表",
children: [{
id: 22,
label: "资产总金额&分类统计报告",
title: "资产总金额",
key: "assetClassify"
}, {
id: 24,
label: "资产总量统计报告",
title: "资产总量",
key: "assetStatus"
}]
}
];
$scope.my_tree = angular.copy($scope.my_data);
};
function convertListToTree(data, treeMap) {
var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
var root = null; //Initially set our loop to null
var parentNode = null;
//loop over data
for (var i = 0; i < data.length; i++) {
var datum = data[i];
//each node will have children, so let's give it a "children" poperty
datum.children = [];
//add an entry for this node to the map so that any future children can
//lookup the parent
idToNodeMap[datum.id] = datum;
//Does this node have a parent?
if (typeof datum.parent === "undefined" || datum.parent == null) {
//Doesn't look like it, so this node is the root of the tree
root = datum;
treeMap[datum.id] = root;
} else {
//This node has a parent, so let's look it up using the id
parentNode = idToNodeMap[datum.parent.id];
//We don't need this property, so let's delete it.
delete datum.parent;
//Let's add the current node as a child of the parent node.
parentNode.children.push(datum);
}
}
return root;
console.log(root)
}
function convertParentToChildList(data) {
var treeMap = {};
var list = [];
convertListToTree(data, treeMap);
angular.forEach(treeMap, function (item) {
list.push(item);
});
return list;
}
$scope.try_async_load();
$scope.my_tree_handler = function (branch) {
$scope.startlist = branch;
if (branch.id == 2) {
incidentClassify()
} else if (branch.id == 3) {
incidentHandler();
$scope.my_data[0].children[0].selected = false;
} else if (branch.id == 6) {
problemClassify()
$scope.my_data[0].children[0].selected = false;
} else if (branch.id == 7) {
problemHandler()
$scope.my_data[0].children[0].selected = false;
} else if (branch.id == 12) {
changeClassify()
$scope.my_data[0].children[0].selected = false;
} else if (branch.id == 13) {
changeHandler()
$scope.my_data[0].children[0].selected = false;
} else if (branch.id == 16) {
releaseClassify()
$scope.my_data[0].children[0].selected = false;
} else if (branch.id == 17) {
releaseHandler()
$scope.my_data[0].children[0].selected = false;
} else if (branch.id == 22) {
assetClassify()
$scope.my_data[0].children[0].selected = false;
} else if (branch.id == 24) {
assetStatus()
$scope.my_data[0].children[0].selected = false;
}
}
/***
* 故障现象总数
*/
// setTimeout(function() {
function incidentClassify() {
$scope.pielenddata = [];
$scope.piebodydata = [];
$scope.hearderlist = [{
name: "事件类别(三级)",
value: "type3"
}, {
name: "事件数量",
value: "num"
}, {
name: "所属类型(二级)",
value: "type2"
}, {
name: "所属类型(一级)",
value: "type1"
}, {
name: "占比",
value: "proportion"
}];
api_report_nx.fetchDataList("incidentClassify", {
"startTime": $scope.parameters.paramDateFrom,
"endTime": $scope.parameters.paramDateTo
}).then(function (response) {
if (response.code == 200) {
$scope.sum = response.sum;
$scope.rRows = response.incidentClassifyList;
angular.forEach(response.incidentClassify, function (item) {
$scope.pielenddata.push(item.type);
$scope.piebodydata.push({
"value": item.num,
"name": item.type,
"proportion": item.proportion
});
})
pieechart()
} else {
}
});
}
// setTimeout(function() {
incidentClassify()
// }, 500);
/**
* 处理事件占比
*/
function incidentHandler() {
$scope.barlenddata = [];
$scope.barbodydata = [];
$scope.hearderlist = [{
name: "处理人",
value: "name"
}, {
name: "完成事件数",
value: "num"
}, {
name: "占比",
value: "proportion"
}];
api_report_nx.fetchDataList("incidentHandler", {
"startTime": $scope.parameters.paramDateFrom,
"endTime": $scope.parameters.paramDateTo
}).then(function (response) {
if (response.code == 200) {
$scope.sum = response.sum;
$scope.rRows = response.incidentHandler;
angular.forEach(response.incidentHandler, function (item) {
$scope.barlenddata.push(item.name);
$scope.barbodydata.push({
"value": item.num,
"name": item.name,
"proportion": item.proportion
});
})
barechart()
} else {
}
});
}
// incidentHandler()
/**
* 问题总数
*/
function problemClassify() {
$scope.pielenddata = [];
$scope.piebodydata = [];
$scope.hearderlist = [{
name: "问题类别(三级)",
value: "type3"
}, {
name: "问题数量",
value: "num"
}, {
name: "所属类型(二级)",
value: "type2"
}, {
name: "所属类型(一级)",
value: "type1"
}, {
name: "占比",
value: "proportion"
}];
api_report_nx.fetchDataList("problemClassify", {
"startTime": $scope.parameters.paramDateFrom,
"endTime": $scope.parameters.paramDateTo
}).then(function (response) {
if (response.code == 200) {
$scope.sum = response.sum;
$scope.rRows = response.problemClassifyList;
angular.forEach(response.problemClassify, function (item) {
$scope.pielenddata.push(item.type);
$scope.piebodydata.push({
"value": item.num,
"name": item.type,
"proportion": item.proportion
});
})
pieechart()
} else {
}
});
}
/**
* 处理问题占比
*/
function problemHandler() {
$scope.barlenddata = [];
$scope.barbodydata = [];
$scope.hearderlist = [{
name: "主责人",
value: "name"
}, {
name: "完成问题数",
value: "num"
}, {
name: "占比",
value: "proportion"
}];
api_report_nx.fetchDataList("problemHandler", {
"startTime": $scope.parameters.paramDateFrom,
"endTime": $scope.parameters.paramDateTo
}).then(function (response) {
if (response.code == 200) {
$scope.sum = response.sum;
$scope.rRows = response.problemHandler;
angular.forEach(response.problemHandler, function (item) {
$scope.barlenddata.push(item.name);
$scope.barbodydata.push({
"value": item.num,
"name": item.name,
"proportion": item.proportion
});
})
barechart()
} else {
}
});
}
/**
* 变更总数
*/
function changeClassify() {
$scope.pielenddata = [];
$scope.piebodydata = [];
$scope.hearderlist = [{
name: "变更类别(三级)",
value: "type3"
}, {
name: "变更数量",
value: "num"
}, {
name: "所属类型(二级)",
value: "type2"
}, {
name: "所属类型(一级)",
value: "type1"
}, {
name: "占比",
value: "proportion"
}];
api_report_nx.fetchDataList("changeClassify", {
"startTime": $scope.parameters.paramDateFrom,
"endTime": $scope.parameters.paramDateTo
}).then(function (response) {
if (response.code == 200) {
$scope.sum = response.sum;
$scope.rRows = response.changeClassifyList;
angular.forEach(response.changeClassify, function (item) {
$scope.pielenddata.push(item.type);
$scope.piebodydata.push({
"value": item.num,
"name": item.type,
"proportion": item.proportion
});
})
pieechart()
} else {
}
});
}
/**
* 完成变更占比
*/
function changeHandler() {
$scope.barlenddata = [];
$scope.barbodydata = [];
$scope.hearderlist = [{
name: "主责人",
value: "name"
}, {
name: "完成变更数",
value: "num"
}, {
name: "占比",
value: "proportion"
}];
api_report_nx.fetchDataList("changeHandler", {
"startTime": $scope.parameters.paramDateFrom,
"endTime": $scope.parameters.paramDateTo
}).then(function (response) {
if (response.code == 200) {
$scope.sum = response.sum;
$scope.rRows = response.changeHandler;
angular.forEach(response.changeHandler, function (item) {
$scope.barlenddata.push(item.name);
$scope.barbodydata.push({
"value": item.num,
"name": item.name,
"proportion": item.proportion
});
})
barechart()
} else {
}
});
}
/**
* 发布总数
*/
function releaseClassify() {
$scope.pielenddata = [];
$scope.piebodydata = [];
api_report_nx.fetchDataList("releaseClassify", {
"startTime": $scope.parameters.paramDateFrom,
"endTime": $scope.parameters.paramDateTo
}).then(function (response) {
if (response.code == 200) {
$scope.sum = response.sum;
$scope.rRows = response.releaseClassifyList;
angular.forEach(response.releaseClassify, function (item) {
$scope.pielenddata.push(item.name);
$scope.piebodydata.push({
"value": item.num,
"name": item.name,
"proportion": item.proportion
});
})
pieechart()
} else {
}
});
}
/**
* 完成发布占比
*/
function releaseHandler() {
$scope.barlenddata = [];
$scope.barbodydata = [];
api_report_nx.fetchDataList("releaseHandler", {
"startTime": $scope.parameters.paramDateFrom,
"endTime": $scope.parameters.paramDateTo
}).then(function (response) {
if (response.code == 200) {
$scope.sum = response.sum;
$scope.rRows = response.releaseHandler;
angular.forEach(response.releaseHandler, function (item) {
$scope.barlenddata.push(item.name);
$scope.barbodydata.push({
"value": item.num,
"name": item.name,
"proportion": item.proportion
});
})
barechart()
} else {
}
});
}
/**
* 资产总额
*/
function assetClassify() {
$scope.pielenddata = [];
$scope.piebodydata = [];
$scope.hearderlist = [{
name: "资产类别(三级)",
value: "label3"
}, {
name: "资产金额",
value: "money"
}, {
name: "资产类别(二级)",
value: "label2"
}, {
name: "资产类别(一级)",
value: "label1"
}];
api_report_nx.fetchDataList("assetClassify", {
"startTime": $scope.parameters.paramDateFrom,
"endTime": $scope.parameters.paramDateTo
}).then(function (response) {
if (response.code == 200) {
$scope.sum = response.sumMoney;
$scope.summap = response.sum;
$scope.rRows = response.assetClassifyList;
angular.forEach(response.assetClassify, function (item) {
$scope.pielenddata.push(item.label);
$scope.piebodydata.push({
"value": item.money,
"name": item.label,
"proportion": item.proportion
});
})
pieechart()
} else {
}
});
}
/**
*资产在库
*/
$scope.summap = 0;
function assetStatus() {
$scope.pielenddata = [];
$scope.piebodydata = [];
$scope.hearderlist = [{
name: "资产类别(三级)",
value: "label3"
}, {
name: "数量",
value: "sum"
}, {
name: "资产类别(二级)",
value: "label2"
}, {
name: "资产类别(一级)",
value: "label1"
}];
api_report_nx.fetchDataList("assetStatus", {
"startTime": $scope.parameters.paramDateFrom,
"endTime": $scope.parameters.paramDateTo
}).then(function (response) {
// if (response.code == 200) {
$scope.sum = response.sum;
// $scope.summap = response.sum;
$scope.rRows = response.assetStatusList;
angular.forEach(response.assetStatus, function (item) {
$scope.pielenddata.push(item.state);
$scope.piebodydata.push({
"value": item.sum,
"name": item.state,
"proportion": item.proportion
});
})
pieechart()
// } else {
// }
});
}
/**
* 环形图
*/
function pieechart() {
var dom = document.getElementById("report");
var myChart = echarts.init(dom);
var app = {};
var option = null;
myChart.showLoading({
text: '数据加载中...',
color: '#c23531',
textColor: '#fff',
maskColor: 'rgba(255,255,255,0)',
zlevel: 0
});
myChart.hideLoading();
option = {
// title: [{
// text: [$scope.sum],
// x: '15%',
// y: '50%',
// textStyle: {
// fontSize: 42,
// fontWeight: 'normal',
// fontStyle: 'normal',
// color: '#005395',
// align: 'center',
// }
// },
// {
// text: $scope.startlist.title,
// x: '15%',
// y: '40%',
// textStyle: {
// fontSize: 16,
// fontWeight: 'normal',
// fontStyle: 'normal',
// align: "center",
// color: '#333'
// }
// }
// ],
title: {
subtext: [$scope.sum],
text: $scope.startlist.title,
itemGap: 3,
"x": '20%',
"y": '40%',
textAlign: "center",
"textStyle": {
"fontWeight": 'normal',
"fontSize": 18,
"color": '#333',
},
"subtextStyle": {
"fontWeight": 'normal',
"fontSize": 42,
"color": '#005395',
"lineHeight": 14
},
},
tooltip: {
"backgroundColor": "rgba(0,0,0,9)",
"textStyle": {
"fontSize": 12,
"color": '#f9f9f9',
},
trigger: 'item',
formatter: "{a}
{b}: {c} ({d}%)"
},
legend: {
orient: 'vertical',
x: '40%',
y: 'center',
itemGap: 20,
data: $scope.pielenddata,
formatter: function (param) {
for (var i = 0; i < $scope.pielenddata.length; i++) {
if ($scope.piebodydata[i].name == param) {
return ' ' + $scope.piebodydata[i].name + ' ' + $scope.piebodydata[i].value + ' ' + $scope.piebodydata[i].proportion;
}
}
}
},
series: [{
name: $scope.startlist.title,
type: 'pie',
radius: ['70%', '85%'],
center: ['20%', '50%'],
color: ['#315b7e', '#3370a1', '#1a3a53', '#61829d', '#8496A5', '#e6eef4', '#15598F', '#61829d', '#5F9FD1', '#7EAFD6'],
hoverAnimation: true,
label: {
normal: {
show: false,
position: 'center'
},
formatter: [
'{a|这段文本采用样式a}',
'{b|这段文本采用样式b}这段用默认样式{x|这段用样式x}'
].join('\n'),
rich: {
a: {
color: 'red',
lineHeight: 10
},
b: {
backgroundColor: {
image: 'xxx/xxx.jpg'
},
height: 40
},
x: {
fontSize: 18,
fontFamily: 'Microsoft YaHei',
borderColor: '#449933',
borderRadius: 4
},
}
},
labelLine: {
normal: {
show: false
}
},
data: $scope.piebodydata
}]
};
if (option && typeof option === "object") {
myChart.setOption(option, true);
myChart.hideLoading();
}
// ///
// var dom = document.getElementById("reportnext");
// var myChartn = echarts.init(dom);
// var app = {};
// var optionn = null;
// myChartn.showLoading({
// text: '数据加载中...',
// color: '#c23531',
// textColor: '#fff',
// maskColor: 'rgba(255,255,255,0)',
// zlevel: 0
// });
// myChartn.hideLoading();
// optionn = {
// title: [{
// text: [$scope.sum],
// x: 'center',
// y: '50%',
// textStyle: {
// fontSize: 42,
// fontWeight: 'normal',
// fontStyle: 'normal',
// color: '#005395',
// align: 'center',
// }
// },
// {
// text: $scope.startlist.title,
// x: 'center',
// y: '40%',
// textStyle: {
// fontSize: 16,
// fontWeight: 'normal',
// fontStyle: 'normal',
// align: "center",
// color: '#333'
// }
// }
// ],
// tooltip: {
// "backgroundColor": "rgba(0,0,0,9)",
// "textStyle": {
// "fontSize": 12,
// "color": '#f9f9f9',
// },
// trigger: 'item',
// formatter: "{a}
{b}: {c} ({d}%)"
// },
// legend: {
// orient: 'vertical',
// x: '90%',
// y: 'center',
// itemGap: 40,
// data: $scope.pielenddata,
// formatter: function(param) {
// for (var i = 0; i < $scope.pielenddata.length; i++) {
// if ($scope.piebodydata[i].name == param) {
// return ' ' + $scope.piebodydata[i].name + ' ' + $scope.piebodydata[i].value + ' ' + $scope.piebodydata[i].proportion;
// }
// }
// }
// },
// series: [{
// show: false,
// name: $scope.startlist.title,
// type: 'pie',
// radius: ['70%', '85%'],
// center: ['50%', '50%'],
// color: ['#315b7e', '#3370a1', '#1a3a53', '#61829d', '#8496A5', '#e6eef4', '#15598F', '#61829d', '#5F9FD1', '#7EAFD6'],
// hoverAnimation: true,
// label: {
// normal: {
// show: false,
// position: 'center'
// },
// formatter: [
// '{a|这段文本采用样式a}',
// '{b|这段文本采用样式b}这段用默认样式{x|这段用样式x}'
// ].join('\n'),
// rich: {
// a: {
// color: 'red',
// lineHeight: 10
// },
// b: {
// backgroundColor: {
// image: 'xxx/xxx.jpg'
// },
// height: 40
// },
// x: {
// fontSize: 18,
// fontFamily: 'Microsoft YaHei',
// borderColor: '#449933',
// borderRadius: 4
// },
// }
// },
// labelLine: {
// normal: {
// show: false
// }
// },
// data: $scope.piebodydata
// }]
// };
// if (optionn && typeof optionn === "object") {
// myChartn.setOption(optionn);
// myChartn.hideLoading();
// }
}
// }, 1000)
/***
* 柱状图
*/
function hardDisks(data) {
if ($scope.sum == 0) {
return 0;
} else {
}
return data / $scope.sum;
}
function barechart() {
var dom = document.getElementById("barreport");
var mybarChart = echarts.init(dom);
var app = {};
var optionbar = null;
mybarChart.showLoading({
text: '数据加载中...',
color: '#c23531',
textColor: '#fff',
maskColor: 'rgba(255,255,255,0)',
zlevel: 0
});
mybarChart.hideLoading();
optionbar = {
title: {
// text: '(件)故障数量',
x: '10',
y: '0',
textStyle: {
fontWeight: 'normal',
fontSize: 12,
color: "#56c9ff",
}
},
xAxis: {
axisTick: {
alignWithLabel: true
},
splitLine: {
show: false
},
splitArea: {
show: false
},
// data: XData,
data: $scope.barlenddata,
axisLine: {
lineStyle: {
color: '#eaeaea'
}
},
axisLabel: {
interval: 0,
formatter: function (value) {
return value.split("").join("\n");
},
// rotate: 45,
// margin: 2,
textStyle: {
color: '#999',
fontSize: 14,
}
},
},
// grid: { // 控制图的大小,调整下面这些值就可以,
// x: 40,
// x2: 100,
// y2: 150, // y2可以控制 X轴跟Zoom控件之间的间隔,避免以为倾斜后造成 label重叠到zoom上
// },
yAxis: {
axisTick: {
show: false
},
splitLine: {
show: false
},
splitArea: {
show: false
},
minInterval: 1,
axisLabel: {
show: true,
textStyle: {
color: '#999',
fontSize: 14,
}
},
axisLine: {
show: false,
lineStyle: {
color: '#eaeaea'
}
},
splitLine: {
lineStyle: {
color: "#eaeaea"
}
}
},
grid: {
left: 10,
top: 25,
bottom: 20,
right: 10,
containLabel: true
},
"tooltip": {
"trigger": "item",
"backgroundColor": "rgba(0,0,0,9)",
"textStyle": {
"fontSize": 12,
"color": '#f9f9f9',
},
formatter: function (data) {
return $scope.startlist.tip1 + ':' + data.value + '
' + $scope.startlist.tip2 + ':' + data.data.proportion;
},
},
series: {
type: "bar",
itemStyle: {
normal: {
color: function (params) {
// type = 'linear';
// var colorList = [
// '#005395'
// ];
return '#005395'
},
}
},
label: {
normal: {
show: true,
position: 'top',
textStyle: {
// color: '#56c9ff'
}
}
},
barWidth: 18,
// barWidth: '30%',
// data: yData
data: $scope.barbodydata
}
};
if (optionbar && typeof optionbar === "object") {
mybarChart.setOption(optionbar, true);
mybarChart.hideLoading();
}
}
}])