var selectOrg = ""; $(function(){ changeView('u451_','全部'); getReal(); //工机具 getTools(); // 找到具有id "u455" 的元素 var u455Element = document.getElementById('u455'); // 添加点击事件监听器 u455Element.addEventListener('click', function() { location.reload(); // 刷新页面 }); var u456Element = document.getElementById('u456'); // 添加点击事件监听器 u456Element.addEventListener('click', function() { // 在点击事件处理函数中使用window.open方法打开新页面 window.open('http://140.210.209.102:19994/hnbcscreen/login.html?userName='+localStorage.getItem("userName")+"&passWord="+localStorage.getItem("passWord"), '_blank'); // 替换'your_custom_page_url'为您自定义页面的URL // window.open('http://192.168.0.14:19994/hnbcscreen/login.html?userName='+localStorage.getItem("userName")+"&passWord="+localStorage.getItem("passWord"), '_blank'); // 替换'your_custom_page_url'为您自定义页面的URL // window.open('http://127.0.0.1:19994/hnbcscreen/login.html?userName='+localStorage.getItem("userName")+"&passWord="+localStorage.getItem("passWord"), '_blank'); // 替换'your_custom_page_url'为您自定义页面的URL }); }); function getTools() { $.ajax({ type: 'POST', async: true, // 默认异步true,false表示同步 url: czl_ht_url + "/dataIndex/getTool",// 请求地址 dataType: 'json', // 服务器返回数据类型 data: {}, //获取提交的表单字段 success: function (data) { data = JSON.parse(data.data); let bar = data.bar; let line = data.line; let allNum = parseInt(bar.dataKey); let valNum = parseInt(bar.dataValue); $("#Tools-garden-present").text(allNum); $("#Tools-garden-number").text(valNum); //设备工机具环形图 getToolsName(allNum,valNum); let proName = []; let nums = []; for(var i=0;i `${data.value.toFixed(2)}%` }, emphasis: { show: true } }, labelLine: { normal: { show: false } }, data: [{ name: '满足率', value: percentage, label: { normal: { fontSize: 18, color: '#585F6E', fontWeight: 'bolder' } }, itemStyle: { normal: { color: '#36cf93', shadowColor: 'rgba(34,192,245,0.8)', shadowBlur: 10 } } }, { name: '未满足率', value: 100 - percentage, label: { normal: { show: false, fontSize: 0 } }, itemStyle: { normal: { color: '#f0f0f0' }, emphasis: { color: '#f0f0f0' } }, hoverAnimation: false }] }] } myChart.setOption(option); } //设备工机具环形图 function getToolsName(total, present) { let myChart = echarts.init(document.getElementById('Tools-garden')); // 随机生成占比数据 const percentage = (present / total) * 100; // // 圆心角的一半 // const angle = PI * val / 50 / 2; // // 渐变起点 // const pointStart = [ // 0.5 - 0.5 * cos(angle) * sin(angle), // 0.5 + 0.5 * cos(angle) * cos(angle) // ]; // // 渐变终点 // const pointEnd = [ // 0.5 - 0.5 * sin(angle), // 0.5 + 0.5 * cos(angle) // ]; option = { series: [{ name: '占比', type: 'pie', startAngle: 270, // 环图起始位置:正下发 radius: ['50%', '60%'], avoidLabelOverlap: false, label: { normal: { show: true, position: 'center', formatter: ({ data }) => `${data.value.toFixed(2)}%` }, emphasis: { show: true } }, labelLine: { normal: { show: false } }, data: [{ name: '满足率', value: percentage, label: { normal: { fontSize: 18, color: '#585F6E', fontWeight: 'bolder' } }, itemStyle: { normal: { color: '#36cf93', shadowColor: 'rgba(34,192,245,0.8)', shadowBlur: 10 } } }, { name: '未满足率', value: 100 - percentage, label: { normal: { show: false, fontSize: 0 } }, itemStyle: { normal: { color: '#f0f0f0' }, emphasis: { color: '#f0f0f0' } }, hoverAnimation: false }] }] } myChart.setOption(option); } //实名制柱状图 function getRealNames(proName,nums) { let myChart = echarts.init(document.getElementById('Real-name-post')); let nameList = proName; let dataList = nums; let fontSize = '12'; let option = { backgroundColor: 'transparent', tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' }, backgroundColor: 'rgba(0, 0, 0, 0.63)', //设置背景颜色 textStyle: { color: '#fff', // fontFamily: 'Alibaba PuHuiTi R' }, borderColor: "rgba(255,255,255, .5)", }, legend: { show: false, data: ['考勤数'], align: 'left', right: 10, textStyle: { color: "#000", fontSize: fontSize }, itemWidth: 10, itemHeight: 10, itemGap: 35 }, dataZoom: [{ type: 'inside', zoomOnMouseWheel: false, moveOnMouseMove: true, moveOnMouseWheel: true, startValue: 0, endValue: 5, orient: 'vertical', }], grid: { top: '1%', left: '50%', right: '0%', bottom: '3%', // containLabel: true }, xAxis: [{ type: 'value', axisLine: { show: false, lineStyle: { color: "#063374", width: 1, type: "solid" } }, axisTick: { show: false, }, axisLabel: { show: false, textStyle: { color: "#00c7ff", } }, splitLine: { show: false, lineStyle: { color: "#063374", } }, }], yAxis: [{ type: 'category', axisLabel: { show: true, textStyle: { color: '#000', fontSize: fontSize, // fontFamily: 'Alibaba PuHuiTi R' } }, axisTick: { show: false, }, axisLine: { show: false, lineStyle: { color: "#00c7ff", width: 1, type: "solid" }, }, splitLine: { show: false, lineStyle: { color: "#063374", } }, data: nameList, }], series: [{ name: '考勤数', type: 'bar', data: dataList, barWidth: 14, //柱子宽度 barGap: 1, //柱子之间间距 itemStyle: { normal: { color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{ offset: 0, color: '#0BCCFE' }, { offset: 1, color: '#1E3AFF' }]), opacity: 1, } }, label: { normal: { show: true, relative: 'right', formatter: '{c}', textStyle: { color: '#fff', fontSize: fontSize, // fontFamily: 'Alibaba PuHuiTi R' } } }, }] }; // myChart.setOption(option, true); // myChart.on('mousemove', stop); // myChart.on('globalout', goMove); myChart.setOption(option,true); } //设备工机具柱状图 function getToolsNames(proName,nums) { let myChart = echarts.init(document.getElementById('Tools-post')); // var charts = { // 按顺序排列从大到小 // cityList: proName, // cityData: nums // } // var top10CityList = charts.cityList // var top10CityData = charts.cityData // var color = ['#36cf93', '#ffa94c', '#4bced0'] // var color1 = ['#409eff', '#f2c1f5', '#4aa4ff'] // // let lineY = [] // let lineT = [] // for (var i = 0; i < charts.cityList.length; i++) { // var x = i // if (x > 1) { // x = 2 // } // var data = { // name: charts.cityList[i], // color: color[x], // value: top10CityData[i], // barGap: '-100%', // itemStyle: { // normal: { // show: true, // color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{ // offset: 0, // color: color[x] // }, { // offset: 1, // color: color1[x] // }], false), // barBorderRadius: 10 // }, // emphasis: { // shadowBlur: 15, // shadowColor: 'rgba(0, 0, 0, 0.1)' // } // } // } // var data1 = { // value: top10CityData[0], // itemStyle: { // color: '#ffffff', // barBorderRadius: 10 // } // } // lineY.push(data) // lineT.push(data1) // } // // option = { // backgroundColor: '#ffffff', // title: { // show: false // }, // tooltip: { // trigger: 'item', // formatter: (p) => { // if (p.seriesName === 'total') { // return '' // } // return `${p.name}
${p.value}` // } // }, // grid: { // borderWidth: 0, // top: '10%', // left: '5%', // right: '15%', // bottom: '3%' // }, // color: color, // yAxis: [{ // type: 'category', // inverse: true, // axisTick: { // show: false // }, // axisLine: { // show: false // }, // axisLabel: { // show: false, // inside: false // }, // data: top10CityList // }, { // type: 'category', // axisLine: { // show: false // }, // axisTick: { // show: false // }, // axisLabel: { // show: true, // inside: false, // verticalAlign: 'bottom', // lineHeight: '40', // textStyle: { // color: '#b3ccf8', // fontSize: '14', // fontFamily: 'PingFangSC-Regular' // }, // formatter: function(val) { // return `${val}` // } // }, // splitArea: { // show: false // }, // splitLine: { // show: false // }, // data: top10CityData // }], // xAxis: { // type: 'value', // axisTick: { // show: false // }, // axisLine: { // show: false // }, // splitLine: { // show: false // }, // axisLabel: { // show: false // } // }, // series: [{ // name: 'total', // type: 'bar', // zlevel: 1, // barGap: '-100%', // barWidth: '10px', // data: lineT, // legendHoverLink: false // }, { // name: 'bar', // type: 'bar', // zlevel: 2, // barWidth: '10px', // data: lineY, // label: { // normal: { // color: '#0051de', // show: true, // position: [0, '-24px'], // textStyle: { // fontSize: 16 // }, // formatter: function(a) { // let num = '' // let str = '' // if (a.dataIndex + 1 < 10) { // num = '0' + (a.dataIndex + 1); // } else { // num = (a.dataIndex + 1); // } // if (a.dataIndex === 0) { // str = `{color4|${a.name}}` // } else if (a.dataIndex === 1) { // str = `{color4|${a.name}}` // } else { // str = `{color4|${a.name}}` // } // return str; // }, // rich: { // color4: { // color: '#000000' // } // } // } // } // }], // } let nameList = proName; let dataList = nums; let fontSize = '12'; let option = { backgroundColor: 'transparent', tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' }, backgroundColor: 'rgba(0, 0, 0, 0.63)', //设置背景颜色 textStyle: { color: '#fff', // fontFamily: 'Alibaba PuHuiTi R' }, borderColor: "rgba(255,255,255, .5)", }, legend: { show: false, data: ['使用数'], align: 'left', right: 10, textStyle: { color: "#000", fontSize: fontSize }, itemWidth: 10, itemHeight: 10, itemGap: 35 }, dataZoom: [{ type: 'inside', zoomOnMouseWheel: false, moveOnMouseMove: true, moveOnMouseWheel: true, startValue: 0, endValue: 5, orient: 'vertical', }], grid: { top: '1%', left: '50%', right: '0%', bottom: '3%', // containLabel: true }, xAxis: [{ type: 'value', axisLine: { show: false, lineStyle: { color: "#063374", width: 1, type: "solid" } }, axisTick: { show: false, }, axisLabel: { show: false, textStyle: { color: "#00c7ff", } }, splitLine: { show: false, lineStyle: { color: "#063374", } }, }], yAxis: [{ type: 'category', axisLabel: { show: true, textStyle: { color: '#000', fontSize: fontSize, // fontFamily: 'Alibaba PuHuiTi R' } }, axisTick: { show: false, }, axisLine: { show: false, lineStyle: { color: "#00c7ff", width: 1, type: "solid" }, }, splitLine: { show: false, lineStyle: { color: "#063374", } }, data: nameList, }], series: [{ name: '工器具数', type: 'bar', data: dataList, barWidth: 14, //柱子宽度 barGap: 1, //柱子之间间距 itemStyle: { normal: { color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{ offset: 0, color: '#0BCCFE' }, { offset: 1, color: '#1E3AFF' }]), opacity: 1, } }, label: { normal: { show: true, relative: 'right', formatter: '{c}', textStyle: { color: '#fff', fontSize: fontSize, // fontFamily: 'Alibaba PuHuiTi R' } } }, }] }; myChart.setOption(option); } //闲置率Echarts function idleEcharts(color, data, name) { const { random, PI, cos, sin } = Math; // 随机生成占比数据 //const val = random() * 100; const val = (name/data )* 100; // 圆心角的一半 const angle = PI * val / 50 / 2; // 渐变起点 const pointStart = [ 0.5 - 0.5 * cos(angle) * sin(angle), 0.5 + 0.5 * cos(angle) * cos(angle) ]; // 渐变终点 const pointEnd = [ 0.5 - 0.5 * sin(angle), 0.5 + 0.5 * cos(angle) ]; option = { series: [{ name: '占比', type: 'pie', startAngle: 270, // 环图起始位置:正下发 radius: ['54%', '70%'], avoidLabelOverlap: false, label: { normal: { show: true, position: 'center', formatter: ({ data }) => `${data.value.toFixed(0)}%` }, emphasis: { show: true } }, labelLine: { normal: { show: false } }, data: [{ name: '满足率', value: val, label: { normal: { fontSize: 14, color: '#999999', fontWeight: 'bolder' } }, itemStyle: { normal: { color: color } } }, { name: '未满足率', value: 100 - val, label: { normal: { show: false, fontSize: 0 } }, itemStyle: { normal: { color: '#f0f0f0' }, emphasis: { color: '#f0f0f0' } }, hoverAnimation: false }] }] } }