/**
* @Description 文件描述
* @Author zhangming
* @Date 2021-03-02 17:30:04
* @LastEditTime 2021-04-26 15:11:38
* @LastEditors zhangming
*/
var E_chart_school = [];
var school_name = GetQueryString('school_name')
var school_id = GetQueryString('school_id')
$(function () {
// 渲染年份列表 在nav.js中获取select_year
$('#select-year').append(select_year)
$('.select').on('click', '.placeholder', function (e) {
var parent = $(this).closest('.select');
if (!parent.hasClass('is-open')) {
parent.addClass('is-open');
$('.select.is-open').not(parent).removeClass('is-open');
} else {
parent.removeClass('is-open');
}
e.stopPropagation();
}).on('click', 'ul>li', function () {
var parent = $(this).closest('.select');
parent.removeClass('is-open').find('.placeholder').text($(this).text());
$(window).attr('location', "schoolIndex.html?year=" + $(this).text() + "&area_name=" + area_name + "&school_id=" + school_id + "&school_name=" + school_name);
let on_year = $(this).text();
echartSizeInfo(on_year);
});
var typeOfBe = 'small';
// $('#BExiaoxue').click(function (event) {
// $(this).addClass('active');
// $(this).siblings().removeClass('active');
// typeOfBe = 'small';
// echarts_2();
// })
// $('#BEchuzhong').click(function (event) {
// $(this).addClass('active');
// $(this).siblings().removeClass('active');
// typeOfBe = 'middle';
// echarts_2();
// })
// $('#BEgaozhong').click(function (event) {
// $(this).addClass('active');
// $(this).siblings().removeClass('active');
// typeOfBe = 'height';
// echarts_2();
// })
let schoolName = document.querySelector("h1");
var url = decodeURI(window.location.href);
var schoolIndex = url.split("&school_name=");
schoolName.innerHTML = school_name;
(function ($) {
$.getUrlParam = function (name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return null;
}
})(jQuery);
var schoolID = $.getUrlParam('school_id');
school_situation(config_now_year);
getTabBtn(config_now_year);
getTeacherProportion(config_now_year);
Teachers_and_students(config_now_year);
echarts_all(config_now_year);
$('h1').prepend(config_now_year)
function getTabBtn(year) {
$.post(config_serverIp + "dataex/report/QuerySimpleGP", JSON.stringify({
"access_token": "system_01##20200102030405##a6ce11eab94df48a6ce11eab",
"query": {
"query_id": "A076",
"query_param": [
year, schoolID
]
},
"query_cache": 0,
"query_count": [
"total"
],
"query_format": "json",
"query_group": [
"businesstype"
]
}), function (resport) {
var data = resport.result;
var indata = JSON.parse(data);
_html = "";
if (indata[0].schooltype === "小学") {
_html += ``
} else if (indata[0].schooltype === "初级中学") {
_html += ``;
typeOfBe = 'middle';
} else if (indata[0].schooltype === "九年一贯制学校") {
_html += ``
_html += ``
} else if (indata[0].schooltype === "高级中学") {
_html += ``;
typeOfBe = 'height';
} else if (indata[0].schooltype === "完全中学") {
_html += ``
_html += ``;
typeOfBe = 'middle';
} else if (indata[0].schooltype === "十二年一贯制") {
_html += ``
_html += ``
_html += ``
}
let tabBtn = document.querySelector(".tab");
tabBtn.innerHTML = _html;
echarts_1(config_now_year);
echarts_2(config_now_year);
echarts_3(config_now_year);
echarts_4(config_now_year);
echarts_5(config_now_year);
echarts_6(config_now_year);
// tab切换
$("body").delegate(".tabbtn", "click", function (e) {
$(this).addClass("active").siblings().removeClass("active");
if (e.target.innerHTML === "小学") {
typeOfBe = 'small';
} else if (e.target.innerHTML === "初中") {
typeOfBe = 'middle';
} else if (e.target.innerHTML === "高中") {
typeOfBe = 'height';
}
echarts_2(config_now_year);
echarts_all(config_now_year);
})
})
}
function echarts_1(year) {
$.post(config_serverIp + "dataex/report/QuerySimpleGP", JSON.stringify({
"access_token": "system_01##20200102030405##a6ce11eab94df48a6ce11eab",
"query": {
"query_id": "A062",
"query_param": [
year, schoolID
]
},
"query_cache": 0,
"query_count": [
"total"
],
"query_format": "json",
"query_group": [
"businesstype"
]
}), function (resport) {
var data = resport.result;
var indata = JSON.parse(data);
newData = dataMoreBar(indata)
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('echart1')); // 学校办学条件
E_chart_school.push(myChart);
option = {
title: {
text: '',
left: 'center',
textStyle: {
color: '#fff',
fontSize: '16'
}
},
legend: {
type: 'scroll',
orient: 'vertical',
right: 0,
top: '20%',
bottom: 20,
textStyle: {
color: 'rgba(255,255,255,.5)',
fontSize: '12',
},
},
tooltip: {
trigger: 'item'
},
series: [
{
type: 'pie',
radius: '70%',
center: ['40%', '50%'],
color: ['#168EFE', '#8882F7', '#FFA06C', '#FFDB65', '#2CD1C0', '#FF88A8'],
data: newData,
label: { show: false },
labelLine: { show: false },
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
},
animationDelay: function (idx) {
return idx * 100;
}
}
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
window.addEventListener("resize", function () {
myChart.resize();
});
}, 'json');
}
function echarts_2(year) {
$.post(config_serverIp + "dataex/report/QuerySimpleGP", JSON.stringify({
"access_token": "system_01##20200102030405##a6ce11eab94df48a6ce11eab",
"query": {
"query_id": "A060",
"query_param": [
year, schoolID
]
},
"query_cache": 0,
"query_count": [
"total"
],
"query_format": "json",
"query_group": [
"didgroup", "stage"
]
}), function (resport) {
var data = resport.result;
var newData = data ? JSON.parse(data) : [];
var x_axis = [];
var class_number = [];
console.log(newData, 'data')
newData.map((data, index) => {
if (data.stage === "小学" && typeOfBe === 'small') {
x_axis.push(data.didgroup);
class_number.push(data.total);
} else if (data.stage === "初中" && typeOfBe === 'middle') {
x_axis.push(data.didgroup);
class_number.push(data.total);
} else if (data.stage === "高中" && typeOfBe === 'height') {
x_axis.push(data.didgroup);
class_number.push(data.total);
}
})
// debugger
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('echart2')); // 班级情况
E_chart_school.push(myChart);
option = {
// backgroundColor: '#00265f',
tooltip: {
trigger: 'axis',
axisPointer: { type: 'shadow' }
},
grid: {
left: '0%',
top: '5%',
right: '0%',
bottom: '20%',
containLabel: true
},
xAxis: [{
type: 'category',
data: x_axis,
axisLine: {
show: true,
lineStyle: {
color: "rgba(255,255,255,.1)",
width: 1,
type: "solid"
},
},
axisTick: {
show: false,
},
axisLabel: {
interval: 0,
// rotate:50,
show: true,
splitNumber: 15,
textStyle: {
color: "rgba(255,255,255,.6)",
fontSize: '12',
},
},
}],
yAxis: [{
type: 'value',
axisLabel: {
//formatter: '{value} %'
show: true,
textStyle: {
color: "rgba(255,255,255,.6)",
fontSize: '12',
},
},
axisTick: {
show: false,
},
axisLine: {
show: true,
lineStyle: {
color: "rgba(255,255,255,.1 )",
width: 1,
type: "solid"
},
},
splitLine: {
lineStyle: {
color: "rgba(255,255,255,.1)",
type: 'dashed'
}
}
}],
series: [
{
type: 'bar',
data: class_number,
barWidth: '35%', //柱子宽度
// barGap: 1, //柱子之间间距
label: {
show: true,
position: 'top'
},
itemStyle: {
normal: {
color: '#FFA06C',
opacity: 1,
barBorderRadius: 5,
}
},
// animationDelay: function (idx) {
// return idx * 1000;
// }
}
],
// animationEasing: 'elasticOut',
// animationDelayUpdate: function (idx) {
// return idx * 5;
// }
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
window.addEventListener("resize", function () {
myChart.resize();
});
}, 'json')
}
function echarts_3(year) {
$.post(config_serverIp + "dataex/report/QuerySimpleGP", JSON.stringify({
"access_token": "system_01##20200102030405##a6ce11eab94df48a6ce11eab",
"query": {
"query_id": "A055",
"query_param": [
year, schoolID
]
},
"query_cache": 0,
"query_count": [
"total"
],
"query_format": "echarts",
"query_group": [
"didgroup", "stage"
]
}), function (resport) {
var data = resport.result;
var newData = JSON.parse(data);
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('echart3')); // 学生情况
E_chart_school.push(myChart);
option = {
// backgroundColor: '#00265f',
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
legend: {
data: newData.groups[1],
textStyle: {
color: '#fff'
}
},
grid: {
left: '0%',
top: '10%',
right: '0%',
bottom: '2%',
containLabel: true
},
xAxis: [{
type: 'category',
data: newData.groups[0],
axisLine: {
show: true,
lineStyle: {
color: "rgba(255,255,255,.1)",
width: 1,
type: "solid"
},
},
axisTick: {
show: false,
},
axisLabel: {
interval: 0,
// rotate:50,
show: true,
splitNumber: 15,
textStyle: {
color: "rgba(255,255,255,.6)",
fontSize: '12',
},
},
}],
yAxis: [{
type: 'value',
axisLabel: {
//formatter: '{value} %'
show: true,
textStyle: {
color: "rgba(255,255,255,.6)",
fontSize: '12',
},
},
axisTick: {
show: false,
},
axisLine: {
show: true,
lineStyle: {
color: "rgba(255,255,255,.1 )",
width: 1,
type: "solid"
},
},
splitLine: {
lineStyle: {
color: "rgba(255,255,255,.1)",
type: 'dashed'
}
}
}],
series: [
{
name: '小学',
type: 'bar',
data: newData.datas[0],
barWidth: '15%', //柱子宽度
// barGap: 1, //柱子之间间距
label: {
show: true,
position: 'top'
},
itemStyle: {
normal: {
color: '#8882F7',
opacity: 1,
barBorderRadius: 5,
}
}
},
{
name: '初中',
type: 'bar',
data: newData.datas[1],
barWidth: '15%', //柱子宽度
// barGap: 1, //柱子之间间距
label: {
show: true,
position: 'top'
},
itemStyle: {
normal: {
color: '#FFA06C',
opacity: 1,
barBorderRadius: 5,
}
}
},
{
name: '高中',
type: 'bar',
data: newData.datas[2],
barWidth: '15%', //柱子宽度
// barGap: 1, //柱子之间间距
label: {
show: true,
position: 'top'
},
itemStyle: {
normal: {
color: '#2CD1C0',
opacity: 1,
barBorderRadius: 5,
}
}
}
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
window.addEventListener("resize", function () {
myChart.resize();
});
}, 'json')
}
function echarts_4(year) {
$.post(config_serverIp + "dataex/report/QuerySimpleGP", JSON.stringify({
"access_token": "system_01##20200102030405##a6ce11eab94df48a6ce11eab",
"query": {
"query_id": "A056",
"query_param": [
year, schoolID
]
},
"query_cache": 0,
"query_count": [
"total"
],
"query_format": "json",
"query_group": [
"businesstype"
]
}), function (resport) {
var data = resport.result;
var indata = JSON.parse(data);
var girlNum = indata[0].nvno;
var allNum = indata[0].total;
var boyNum = Number(allNum) - Number(girlNum);
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('echart4')); // 师生男女比例
E_chart_school.push(myChart);
option = {
title: {
text: '',
left: 'center',
textStyle: {
color: '#fff',
fontSize: '16'
}
},
legend: {
top: '5%',
textStyle: {
color: 'rgba(255,255,255,.5)',
fontSize: '12',
},
},
tooltip: {
trigger: 'item'
},
series: [
{
type: 'pie',
radius: '70%',
center: ['50%', '65%'],
color: ['#168EFE', '#8882F7', '#FFA06C', '#FFDB65', '#2CD1C0', '#FF88A8'],
data: [
{ value: boyNum, name: '男' },
{ value: girlNum, name: '女' },
],
label: { show: false },
labelLine: { show: false },
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
},
animationDelay: function (idx) {
return idx * 100;
}
}
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
window.addEventListener("resize", function () {
myChart.resize();
});
}, 'json');
}
function echarts_5(year) {
$.post(config_serverIp + "dataex/report/QuerySimpleGP", JSON.stringify({
"access_token": "system_01##20200102030405##a6ce11eab94df48a6ce11eab",
"query": {
"query_id": "A061",
"query_param": [
year, schoolID
]
},
"query_cache": 0,
"query_count": [
"total"
],
"query_format": "json",
"query_group": [
"businesstype"
]
}), function (resport) {
var data = resport.result;
var indata = JSON.parse(data);
newData = dataMoreBar(indata)
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('echart5')); // 教师学历分布
E_chart_school.push(myChart);
option = {
title: {
text: '',
left: 'center',
textStyle: {
color: '#fff',
fontSize: '16'
}
},
legend: {
type: 'scroll',
orient: 'vertical',
right: 0,
top: '20%',
bottom: 20,
textStyle: {
color: 'rgba(255,255,255,.5)',
fontSize: '12',
},
},
tooltip: {
trigger: 'item'
},
series: [
{
type: 'pie',
radius: '70%',
center: ['40%', '50%'],
color: ['#168EFE', '#8882F7', '#FFA06C', '#FFDB65', '#2CD1C0', '#FF88A8'],
data: newData,
label: { show: false },
labelLine: { show: false },
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
},
animationDelay: function (idx) {
return idx * 100;
}
}
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
window.addEventListener("resize", function () {
myChart.resize();
});
}, 'json');
}
function echarts_6(year) {
$.post(config_serverIp + "dataex/report/QuerySimpleGP", JSON.stringify({
"access_token": "system_01##20200102030405##a6ce11eab94df48a6ce11eab",
"query": {
"query_id": "A056",
"query_param": [
year, schoolID
]
},
"query_cache": 0,
"query_count": [
"total"
],
"query_format": "json",
"query_group": [
"businesstype"
]
}), function (resport) {
var data = resport.result;
var indata = JSON.parse(data);
var girlNum = indata[1].nvno;
var allNum = indata[1].total;
var boyNum = Number(allNum) - Number(girlNum);
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('echart6')); // 师生男女比例(教师)
E_chart_school.push(myChart);
option = {
title: {
text: '',
left: 'center',
textStyle: {
color: '#fff',
fontSize: '16'
}
},
legend: {
top: '5%',
textStyle: {
color: 'rgba(255,255,255,.5)',
fontSize: '12',
},
},
tooltip: {
trigger: 'item'
},
series: [
{
type: 'pie',
radius: '70%',
center: ['50%', '65%'],
color: ['#168EFE', '#8882F7', '#FFA06C', '#FFDB65', '#2CD1C0', '#FF88A8'],
data: [
{ value: boyNum, name: '男' },
{ value: girlNum, name: '女' },
],
label: { show: false },
labelLine: { show: false },
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
},
animationDelay: function (idx) {
return idx * 100;
}
}
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
window.addEventListener("resize", function () {
myChart.resize();
});
}, 'json');
}
function getTeacherProportion(year) {
$.post(config_serverIp + "dataex/report/QuerySimpleGP", JSON.stringify({
"access_token": "system_01##20200102030405##a6ce11eab94df48a6ce11eab",
"query": {
"query_id": "A057",
"query_param": [
year, schoolID
]
},
"query_cache": 0,
"query_count": [
"studentno", "teacherno"
],
"query_format": "json",
"query_group": [
"stage"
]
}), function (resport) {
var data = resport.result;
var newData = JSON.parse(data);
if (newData[1] === undefined) {
$("#echart11").addClass("pie_css_one");
$("#echart11").removeClass("pie_css");
$("#echart12").removeClass("pie_css");
$("#echart13").removeClass("pie_css");
} else if (newData[2] === undefined) {
$("#echart11").addClass("pie_css_two");
$("#echart11").removeClass("pie_css");
$("#echart12").addClass("pie_css_two");
$("#echart12").removeClass("pie_css");
$("#echart13").removeClass("pie_css");
}
if (newData[0]) {
var teacherNum0 = Number(newData[0].teacherno);
var studentNum0 = Number(newData[0].studentno);
var studentP1 = (studentNum0 / teacherNum0).toFixed(2);
var stage = newData[0].stage;
echarts_11(studentP1, stage);
}
if (newData[1]) {
var teacherNum1 = Number(newData[1].teacherno);
var studentNum1 = Number(newData[1].studentno);
var studentP2 = (studentNum1 / teacherNum1).toFixed(2);
var stage = newData[1].stage;
echarts_12(studentP2, stage);
}
if (newData[2]) {
var teacherNum2 = Number(newData[2].teacherno);
var studentNum2 = Number(newData[2].studentno);
var studentP3 = (studentNum2 / teacherNum2).toFixed(2);
var stage = newData[2].stage;
echarts_13(studentP3, stage);
}
}, 'json');
}
function echarts_11(studentP1, stage) {
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('echart11'));
E_chart_school.push(myChart);
option = {
title: [{
text: stage,
left: 'center',
textStyle: {
color: '#fff',
fontSize: '16'
}
}],
tooltip: {
trigger: 'item',
formatter: "{a}
{b}: {c} ({d}%)",
position: function (p) { //其中p为当前鼠标的位置
return [p[0] + 10, p[1] - 10];
}
},
legend: {
top: '70%',
itemWidth: 10,
itemHeight: 10,
data: ['教师', '学生'],
textStyle: {
color: 'rgba(255,255,255,.5)',
fontSize: '12',
}
},
graphic: {
type: 'text',
left: 'center',
top: '38%',
style: {
text: `1:${studentP1}`,
textAlign: 'center',
fill: '#6EE3DA',
fontSize: '16'
}
},
series: [
{
name: stage,
type: 'pie',
center: ['50%', '40%'],
radius: ['40%', '60%'],
color: ['#168EFE', '#FFDB65'],
label: { show: false },
labelLine: { show: false },
data: [
{ value: 1, name: '教师' },
{ value: studentP1, name: '学生' },
],
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
},
}
}
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
window.addEventListener("resize", function () {
myChart.resize();
});
}
function echarts_12(studentP2, stage) {
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('echart12'));
E_chart_school.push(myChart);
option = {
title: [{
text: stage,
left: 'center',
textStyle: {
color: '#fff',
fontSize: '16'
}
}],
tooltip: {
trigger: 'item',
formatter: "{a}
{b}: {c} ({d}%)",
position: function (p) { //其中p为当前鼠标的位置
return [p[0] + 10, p[1] - 10];
}
},
legend: {
top: '70%',
itemWidth: 10,
itemHeight: 10,
data: ['教师', '学生'],
textStyle: {
color: 'rgba(255,255,255,.5)',
fontSize: '12',
}
},
graphic: {
type: 'text',
left: 'center',
top: '38%',
style: {
text: `1:${studentP2}`,
textAlign: 'center',
fill: '#6EE3DA',
fontSize: '16'
}
},
series: [
{
name: stage,
type: 'pie',
center: ['50%', '40%'],
radius: ['40%', '60%'],
color: ['#168EFE', '#FFDB65'],
label: { show: false },
labelLine: { show: false },
data: [
{ value: 1, name: '教师' },
{ value: studentP2, name: '学生' },
],
}
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
window.addEventListener("resize", function () {
myChart.resize();
});
}
function echarts_13(studentP3, stage) {
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('echart13'));
E_chart_school.push(myChart);
option = {
title: [{
text: stage,
left: 'center',
textStyle: {
color: '#fff',
fontSize: '16'
}
}],
tooltip: {
trigger: 'item',
formatter: "{a}
{b}: {c} ({d}%)",
position: function (p) { //其中p为当前鼠标的位置
return [p[0] + 10, p[1] - 10];
}
},
legend: {
top: '70%',
itemWidth: 10,
itemHeight: 10,
data: ['教师', '学生'],
textStyle: {
color: 'rgba(255,255,255,.5)',
fontSize: '12',
}
},
graphic: {
type: 'text',
left: 'center',
top: '38%',
style: {
text: `1:${studentP3}`,
textAlign: 'center',
fill: '#6EE3DA',
fontSize: '16'
}
},
series: [
{
name: stage,
type: 'pie',
center: ['50%', '40%'],
radius: ['40%', '60%'],
color: ['#168EFE', '#FFDB65'],
label: { show: false },
labelLine: { show: false },
data: [
{ value: 1, name: '教师' },
{ value: studentP3, name: '学生' },
],
}
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
window.addEventListener("resize", function () {
myChart.resize();
});
}
function school_situation(year) {
$.post(config_serverIp + "dataex/report/QuerySimpleGP", JSON.stringify({
"access_token": "system_01##20200102030405##a6ce11eab94df48a6ce11eab",
"query": {
"query_id": "A063",
"query_param": [
year, schoolID
]
},
"query_cache": 0,
"query_count": [
"total"
],
"query_format": "json",
"query_group": [
""
]
}), function (resport) {
var data = resport.result;
var newData = JSON.parse(data);
newData.map((item, index) => {
if (item.didgroup === "举办者") {
// 学校举办者
let schoolSponsor = document.querySelector("#school_sponsor");
schoolSponsor.innerHTML = `