123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939 |
- '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} <br/>{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);
- 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} <br/>{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 + '<br />' + $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);
- mybarChart.hideLoading();
- }
- }
- }])
|