var district = AUTH.user.area;
var userType = AUTH.user.userType;
var industry = AUTH.user.industry;
var win = null;
//窗口大小变化时延时刷新图表大小
$(window).resize(function () {
var width = $(window).width();
$('#chartdiv').width(width - 150);
winResize();
});
function winResize() {
var width = $(window).width();
var height = $(window).height();
var left = (width - 900) / 2;
var top = 80;
$('.panel.window').css({
'left': left + 'px'
});
$('.window-shadow').css({
'left': left + 'px'
});
}
$(document).ready(function () {
win = $('#win').dialog({
title: '企业负荷详情',
width: 900,
height: 400,
closed: true,
cache: false,
modal: true
});
//设置root账号大小
if (G.is_root != 1) {
$("#show1").hide();
$("#show2").hide();
$("#show3").hide();
$("#show4").hide();
$("#detail1").width(260);
}
setDate();
getIndustry();
showIndustry2(industry);
initArea();
getArea2();
getArea3();
getMapMessage();
getDetail();
$("#btnQuery").on('click', function () {
query();
});
$(".maxbox>div").each(function (i) {
$(this).bind('click', function () {
showCompanyFluctuationLoad(this);
});
});
});
function transform(data) {
if (data) {
var transformData = [];
$.each(data, function (i, n) {
if (n['y'] == -9999) {
n['y'] = null;
}
if (new Date(n['x']).getMinutes() % 10 == 0) {
transformData.push(n);
}
});
return transformData;
}
return data;
}
function query() {
var city = getCity();
var industry = '',
industry2 = '';
try {
industry = $("#industry").combobox('getValue');
} catch (err) {
industry = '';
}
try {
industry2 = $("#industry2").combobox('getValue');
} catch (err) {
industry2 = '';
}
var date1 = $("#date1").datebox('getValue').replace(/-/g, "");
var date2 = $("#date2").datebox('getValue').replace(/-/g, "");
var date3 = $("#date3").datebox('getValue').replace(/-/g, "");
var first = $("#date1").datebox('getValue');
var second = $("#date2").datebox('getValue');
var third = $("#date3").datebox('getValue');
$("#firstDate").html(first);
$("#secondDate").html(second);
if (!time && !city) {
return;
}
ajax({
url: '/web/flucatuationLoad/getFlucatuationLoad.json',
type: 'POST',
dataType: 'JSON',
beforeSend: function () {
$("#chartdiv").mask('数据加载中....');
},
data: {
city: city,
date1: date1,
date2: date2,
date3: date3,
industry: industry,
industry2: industry2
},
success: function (data) {
$("#chartdiv").unmask();
if (data['status'] == 1) {
data = data['data'];
var today = {};
var yesterday = {};
var beforeday = {};
today['name'] = first;
yesterday['name'] = second;
beforeday['name'] = third;
today['data'] = {};
yesterday['data'] = {};
beforeday['data'] = {};
if (null == data) {
showDayChart([today, yesterday, beforeday], {
title: {
text: "单位:(万千瓦)"
}
}, "");
setMaxBox(false, '', '', false, '', '', date1, date2);
return;
}
chatData = data['chatData'];
today['data'] = transform(chatData['date1']);
yesterday['data'] = transform(chatData['date2']);
beforeday['data'] = transform(chatData['date3']);
showDayChart([today, yesterday, beforeday], {
title: {
text: "单位:(万千瓦)"
}
}, "");
maxData = data['maxData'];
todayMaxData = maxData['date1'];
yesterdayMaxData = maxData['date2'];
todayBoundState = todayMaxData['boundState'];
var todayP = null;
var todayGetTime = null;
if (todayMaxData['p'] != null && todayMaxData['p'] != "") {
todayP = todayMaxData['p'];
}
if (todayMaxData['getTime'] != null && todayMaxData['getTime'] != "") {
todayGetTime = String(todayMaxData['getTime']);
}
yesterdayBoundState = todayMaxData['boundState'];
var yesterdayP = null;
var yesterdayGetTime = null;
if (yesterdayMaxData['p'] != null && yesterdayMaxData['p'] != "") {
yesterdayP = yesterdayMaxData['p'];
}
if (yesterdayMaxData['getTime'] != null && yesterdayMaxData['getTime'] != "") {
yesterdayGetTime = String(yesterdayMaxData['getTime']);
}
setMaxBox(todayBoundState, todayP, todayGetTime, yesterdayBoundState, yesterdayP, yesterdayGetTime, date1, date2);
setInfoMap(data);
}
},
error: function () {
$("#chartdiv").unmask();
layer.msg(' 服务存在异常,请稍后再试!', {
icon: 2
});
}
});
}
function setInfoMap(data) {
$('#infoMap').empty();
if (_.has(data, 'infoMap')) {
_.each(data['infoMap'], function (item, index) {
var date = index;
var one = $('
[' + date + '] 最大负荷:' + item.max + ', 最小负荷:' + item.min + ', 平均负荷:' + item.avg + '
');
$('#infoMap').append(one);
});
}
}
function getCity() {
var area2, area3;
try {
area2 = $("#area2").combobox('getValue');
} catch (err) {
}
try {
area3 = $("#area3").combobox('getValue');
} catch (err) {
}
var city;
if ("" != area3 && undefined != area3) {
city = area3;
} else if ("" != area2 && undefined != area2) {
city = area2;
} else {
city = '640000';
}
return city;
}
//企业负荷详情弹窗
function showCompanyFluctuationLoad(obj) {
var text = $(".maxbox>.today dl:eq(0)").find('dd').html();
if (text == "") {
return;
}
win.dialog('open');
var city = getCity();
var industry = $("#industry").combobox('getValue');
var industry2 = $("#industry2").combobox('getValue');
var time = $(obj).find("input").val();
$("#win p").remove();
$("#content tr").remove();
$("#content").append('' + '| 企业名称 | ' + '负荷波动值(万千瓦) | ' + '地址 |
');
$("#content").append('| 数据加载中...... |
');
if (null == time || "" == time) {
return;
}
ajax({
url: '/web/flucatuationLoad/getCompanyFlucatuationLoadDetail.json',
type: 'POST',
data: {
city: city,
industry: industry,
industry2: industry2,
time: time
},
dataType: 'JSON',
success: function (data) {
$("#content tr").remove();
$("#content").append('' + '| 企业名称 | ' + '负荷波动值(万千瓦) | ' + '地址 |
');
if (data['status'] == 1) {
var html;
var host = jQuery.parseJSON(AUTH.site.config).platform['01200009'] + '.' + AUTH.site.domain;
host = "http://" + host;
if (undefined === data['data'] || data['data'].length <= 0) {
$("#win").append('没有数据
');
} else {
$.each(data['data'], function (i, n) {
var content = "";
if (i % 2 !== 0) {
content += "| " + n['companyName'] + " | "
content += "" + n['p'] + " | ";
content += "" + n['address'] + " | ";
} else {
content += " " + n['companyName'] + " | "
content += "" + n['p'] + " | ";
content += "" + n['address'] + " | ";
}
content += "
";
html += content;
})
$("#content").append(html);
}
}
}
});
}
//最大值设置
function setMaxBox(todayBoundState, todayP, todayGetTime, yesterdayBoundState, yesterdayP, yesterdayGetTime, date1, date2) {
//拼日期时间
var t1 = todayGetTime.replace(/:/g, "");
var t2 = yesterdayGetTime.replace(/:/g, "");
$(".todayTime").attr("value", date1 + t1);
$(".yesterdayTime").attr("value", date2 + t2);
if (true == todayBoundState) {
$(".maxbox>.today dl:eq(0)").find('dd').html("" + todayP + "万千瓦" + "");
} else {
$(".maxbox>.today dl:eq(0)").find('dd').html("" == todayP ? "-" : todayP + "万千瓦");
}
//$(".maxbox>.today dl:eq(1)").find('dd').html("" == todayGetTime ? "-" : todayGetTime.substring(8,10)+":"+todayGetTime.substring(10,12)+":"+todayGetTime.substring(12,14));
$(".maxbox>.today dl:eq(1)").find('dd').html(todayGetTime);
if (true == yesterdayBoundState) {
$(".maxbox>.yesterday dl:eq(0)").find('dd').html("" + yesterdayP + "万千瓦" + "");
} else {
$(".maxbox>.yesterday dl:eq(0)").find('dd').html(null == yesterdayP ? "-" : yesterdayP + "万千瓦");
}
//$(".maxbox>.yesterday dl:eq(1)").find('dd').html(null == yesterdayGetTime ? "-" : yesterdayGetTime.substring(8,10)+":"+yesterdayGetTime.substring(10,12)+":"+yesterdayGetTime.substring(12,14));
$(".maxbox>.yesterday dl:eq(1)").find('dd').html(yesterdayGetTime);
}
function setDate() {
var current = new Date();
var today = new Date(current.getFullYear(), current.getMonth(), current.getDate()).format("yyyy-MM-dd");
var yesterday = new Date(current.getFullYear(), current.getMonth(), current.getDate() - 1).format("yyyy-MM-dd");
var beforeday = new Date(current.getFullYear(), current.getMonth(), current.getDate() - 2).format("yyyy-MM-dd");
$("#date1").datebox('setValue', today);
$("#date2").datebox('setValue', yesterday);
$("#date3").datebox('setValue', beforeday);
}
//饼图加载
function pieChartBuild(project, pieData) {
$('#' + project).highcharts({
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
colors: ['#ED561B', '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4'],
tooltip: {
pointFormat: ' {point.percentage:.1f}%({point.y})'
},
title: {
text: ''
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
size: 160,
dataLabels: {
enabled: false,
format: '{point.name}: {point.percentage:.1f} %',
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
}
},
showInLegend: true
}
},
series: [{
type: 'pie',
// name: pieData.seriesName,
data: pieData
}]
});
}
var mapType;
function getDetail() {
var provinceName = $("#currentProName").val();
var cityName = $("#currentCName").val();
var districtName = $("#currentDisName").val();
ajax({
url: '/web/platformAnalyse/getDetail.json',
type: 'POST',
dataType: 'JSON',
data: {
provinceName: provinceName,
cityName: cityName,
districtName: districtName
},
success: function (data) {
if (data['status'] == 1) {
data = data['data'];
if (null != data['city'] && "" != data['city']) {
$("#title").html(data['city'] + "运行情况");
} else if (null != data['province'] && "" != data['province']) {
$("#title").html(data['province'] + "运行情况");
} else {
$("#title").html("全国运行情况");
}
$("#NotonlineCount").html("" + data['NotonlineCount'] + "");
$("#customer").html(data['customer']);
$("#totalCount").html(data['totalCount']);
$("#total").html(data['total'] + " 万千伏安");
var dataArr = [];
var arr1 = ['异常运行', data['NotonlineCount']];
var arr2 = ['在线', data['onlineCount']];
dataArr.push(arr1);
dataArr.push(arr2);
pieChartBuild("container1", dataArr);
}
}
});
}
function initDialog(flag) {
var provinceName = $("#currentProName").val();
var cityName = $("#currentCName").val();
var districtName = $("#currentDisName").val();
$("#content tr").remove();
$("#content").append('' + '| 企业名称 | ' + '负荷波动值(万千瓦) | ' + '地址 |
');
$("#content").append('| 数据加载中...... |
');
ajax({
url: '/web/platformAnalyse/getCompanyDetail.json',
type: 'POST',
data: {
provinceName: provinceName,
cityName: cityName,
districtName: districtName
},
dataType: 'JSON',
success: function (data) {
$("#content tr").remove();
$("#content").append('' + '| 企业名称 | ' + '监测点总数 | ' + '当前运行异常数 | ' + '连续三月运行异常数 | ' + '服务公司名称 |
');
if (data['status'] == 1) {
var host = jQuery.parseJSON(AUTH.site.config).platform['01200009'] + '.' + AUTH.site.domain;
host = "http://" + host;
var html;
$.each(data['data'], function (i, n) {
var content = "";
if (i % 2 !== 0) {
content += "| " + n['companyName'] + " | "
content += "" + n['totalCount'] + " | ";
content += "" + n['notOnlineCount'] + " | ";
content += "" + n['threeMonthNotOnlineCount'] + " | ";
content += " " + n['serviceCompany'] + " | ";
} else {
content += " " + n['companyName'] + " | "
content += "" + n['totalCount'] + " | ";
content += "" + n['notOnlineCount'] + " | ";
content += "" + n['threeMonthNotOnlineCount'] + " | ";
content += " " + n['serviceCompany'] + " | ";
}
content += "
";
html += content;
})
$("#content").append(html);
}
}
});
}
function showCompanyDetail() {
win.dialog('open');
initDialog();
}
function getCityDetail() {
var provinceName = $("#currentProName").val();
var cityName = $("#currentCName").val();
var districtName = $("#currentDisName").val();
ajax({
url: '/web/platformAnalyse/getCityDetail.json',
type: 'POST',
dataType: 'JSON',
data: {
provinceName: provinceName,
cityName: cityName,
districtName: districtName
},
success: function (data) {
if (data['status'] == 1) {
$("#cityContainer").css("display", "");
if (null != districtName && "" != districtName) {
$("#title1").html(districtName + "运行情况");
} else if (null != cityName && "" != cityName) {
$("#title1").html(cityName + "运行情况");
} else if (null != provinceName && "" != provinceName) {
$("#title1").html(provinceName + "运行情况");
}
data = data['data'];
$("#NotonlineCount1").html("" + data['NotonlineCount'] + "");
$("#customer1").html(data['customer']);
$("#totalCount1").html(data['totalCount']);
$("#total1").html(data['total'] + " 万千伏安");
var dataArr = [];
var arr1 = ['异常运行', data['NotonlineCount']];
var arr2 = ['在线', data['onlineCount']];
dataArr.push(arr1);
dataArr.push(arr2);
pieChartBuild("container2", dataArr);
}
}
});
}
function getMapMessage() {
var provinceName = $("#currentProName").val();
var cityName = $("#currentCName").val();
ajax({
url: '/web/platformAnalyse/getMapMessage.json',
type: 'POST',
dataType: 'JSON',
data: {
provinceName: provinceName,
cityName: cityName
},
success: function (data) {
if (data['status'] == 1) {
data = data['data'];
if (null != data['district'] && '' != data['district']) {
var district;
var dataArr = data['dataArr'];
for (var pos in dataArr) {
if (dataArr[pos]['name'] == data['district'])
district = [{
name: data['district'],
value: dataArr[pos]['value'],
selected: true
}]
}
loadAreaMap(district, data['max'], data['min'], data['city']);
} else if (null != data['city'] && '' != data['city']) {
loadCityMap(data['dataArr'], data['max'], data['min'], data['city']);
} else if (null != data['province'] && '' != data['province']) {
loadProvinceMap(data['dataArr'], data['max'], data['min'], data['province']);
} else {
loadChinaMap(data['dataArr'], data['max'], data['min']);
}
}
}
});
}
function initArea() {
//initOneArea('#area1');
initOneArea('#area2');
initOneArea('#area3');
}
function initOneArea(el) {
var arr = [{
"id": "",
"title": "请选择",
"selected": "true"
}];
h = arr.length * 24;
$(el).combobox({
data: arr,
valueField: 'id',
textField: 'title',
width: 80,
panelHeight: h
});
}
function getArea1() {
ajax({
url: '/web/area/getComboxData.json',
type: 'POST',
dataType: 'JSON',
success: function (data) {
if (data['status'] == 1) {
if (data['data'].length === 1) {
data['data'][0].selected = 'true'
}
var h = data['data'].length * 24;
h = h > 240 ? 240 : h;
$("#area1").combobox({
data: data['data'],
valueField: 'id',
textField: 'title',
width: 80,
panelHeight: h,
onChange: function () {
getArea2();
query();
}
});
query();
}
}
});
}
function getArea2() {
//var parentId = $("#area1").combobox('getValue');
ajax({
url: '/web/platformAnalyse/getArea.json',
// url: '/web/area/getComboxData.json',
type: 'POST',
dataType: 'JSON',
/*data: {
parentId: parentId,
},*/
success: function (data) {
if (data['status'] == 1) {
var list = data['data'];
var h = list.length * 24;
h = h > 240 ? 240 : h;
area = data['data'];
$("#area2").combobox({
data: list,
valueField: 'value',
textField: 'text',
width: 80,
panelHeight: h,
onChange: function () {
getArea3();
query();
}
});
}
}
});
}
function getArea3() {
var parentId = $("#area2").combobox('getValue');
ajax({
url: '/web/area/getComboxData.json',
type: 'POST',
dataType: 'JSON',
data: {
parentId: parentId,
},
success: function (data) {
if (data['status'] == 1) {
var list = data['data'];
list.unshift({
"id": "",
"title": "请选择",
"selected": "true"
});
var h = list.length * 24;
h = h > 240 ? 240 : h;
$("#area3").combobox({
data: list,
valueField: 'id',
textField: 'title',
width: 80,
panelHeight: h,
onChange: function () {
query();
}
});
}
}
});
}
function getIndustry() {
ajax({
url: '/web/industry/getTopIndustryComboData.json',
data: {
id: -1
},
type: 'POST',
dataType: 'JSON',
success: function (data) {
var industryData = [{
'value': "",
'text': "全部",
"selected": "true"
}];
$.each(data, function (i, n) {
var json = {};
json['value'] = n['id'];
json['text'] = n['title'];
industryData.push(json);
});
init_industry(industryData);
}
});
}
function init_industry(industryData) {
var h = industryData.length * 24;
h = h > 240 ? 240 : h;
$("#industry").combobox({
data: industryData,
valueField: 'value',
textField: 'text',
width: 80,
panelHeight: h,
onSelect: function (rec) {
showIndustry2(rec.value);
query();
}
});
};
function showIndustry2(id) {
if (null == id || '' == id) {
var industry2Data = [{
"value": "",
"text": "请选择",
"selected": "true"
}];
init_industry2(industry2Data);
return;
}
ajax({
url: '/web/industry/getIndustryComboDataByParent.json?industryCode=' + id,
success: function (data) {
var industryData2 = [{
"value": "",
"text": "请选择",
"selected": "true"
}];
for (var i = 0; i < data.length; i++) {
var json = {};
json['value'] = data[i].id;
json['text'] = data[i].title;
if (district == data[i].id) {
json['selected'] = 'true';
}
industryData2.push(json);
}
init_industry2(industryData2);
}
});
}
function init_industry2(industryData2) {
var h = industryData2.length * 24;
h = h > 240 ? 240 : h;
$("#industry2").combobox({
data: industryData2,
valueField: 'value',
textField: 'text',
width: 80,
panelHeight: h,
onChange: function () {
query();
}
});
};
var myChart, ecConfig, zrEvent;
var clickCount = 0;
var clickTimer;
//加载中国地图
function loadChinaMap(dataArr, max, min) {
mapType = 'china';
// 路径配置
require.config({
paths: {
echarts: 'http://static.vbdsm.com/js/lib/echarts/build/dist'
}
});
// 使用
require(
['echarts', 'echarts/chart/map'], // 使用柱状图就加载bar模块,按需加载
function (ec) {
// 基于准备好的dom,初始化echarts图表
myChart = ec.init(document.getElementById('main'));
var curIndx = 0;
var mapType = [];
var mapGeoData = require('echarts/util/mapData/params');
for (var city in cityMap) {
mapType.push(city);
// 自定义扩展图表类型
mapGeoData.params[city] = {
getGeoJson: (function (c) {
var geoJsonName = cityMap[c];
return function (callback) {
$.getJSON('../js/geoJson/china-main-city/' + geoJsonName + '.jsonp', callback);
}
})(city)
}
}
ecConfig = require('echarts/config');
zrEvent = require('zrender/tool/event');
myChart.on(ecConfig.EVENT.CLICK, function (param) {
$("#currentProName").val(param.name);
clickCount += 1;
if (null != clickTimer) {
return;
}
clickTimer = window.setInterval(function () {
clearInterval(clickTimer);
clickTimer = null;
var doClick = function () {
getCityDetail();
};
var doDBClick = function () {
$("#cityContainer").css("display", "none");
getMapMessage();
getDetail();
};
if (clickCount == 1) {
//单击的逻辑
doClick();
} else if (clickCount % 2 == 0) {
//双击的逻辑
doDBClick();
}
clickCount = 0;
}, 300);
});
option = {
tooltip: {
trigger: 'item',
formatter: '{b}'
},
dataRange: {
min: min,
max: max,
realtime: false,
text: ['高', '低'], // 文本,默认为数值文本
calculable: true,
color: ['#d44f47', '#de7e39', '#e49a37', '#d9c224', '#84d653', '#47d077', '#50c38b', '#40ace4', '#3c9ef1']
},
series: [{
name: "china",
type: 'map',
mapType: "china",
selectedMode: 'single',
itemStyle: {
normal: {
label: {
show: true
},
areaStyle: {
color: '#3c9ef1'
}
},
emphasis: {
label: {
show: true
}
}
},
data: dataArr
}]
};
// 为echarts对象加载数据
myChart.setOption(option);
});
};
//加载省地图
function loadProvinceMap(dataArr, max, min, provinceName) {
mapType = 'province';
// 路径配置
require.config({
paths: {
echarts: 'http://static.vbdsm.com/js/lib/echarts/build/dist'
}
});
// 使用
require(
['echarts', 'echarts/chart/map'], // 使用柱状图就加载bar模块,按需加载
function (ec) {
// 基于准备好的dom,初始化echarts图表
myChart = ec.init(document.getElementById('main'));
var curIndx = 0;
var mapType = [];
var mapGeoData = require('echarts/util/mapData/params');
for (var city in cityMap) {
mapType.push(city);
// 自定义扩展图表类型
mapGeoData.params[city] = {
getGeoJson: (function (c) {
var geoJsonName = cityMap[c];
return function (callback) {
$.getJSON('../js/geoJson/china-main-city/' + geoJsonName + '.jsonp', callback);
}
})(city)
}
}
ecConfig = require('echarts/config');
zrEvent = require('zrender/tool/event');
myChart.on(ecConfig.EVENT.CLICK, function (param) {
$("#currentCName").val(param.name);
clickCount += 1;
if (null != clickTimer) {
return;
}
clickTimer = window.setInterval(function () {
clearInterval(clickTimer);
clickTimer = null;
var doClick = function () {
getCityDetail();
};
var doDBClick = function () {
$("#cityContainer").css("display", "none");
getMapMessage();
getDetail();
};
if (clickCount == 1) {
//单击的逻辑
doClick();
} else if (clickCount % 2 == 0) {
//双击的逻辑
doDBClick();
}
clickCount = 0;
}, 300);
});
option = {
tooltip: {
trigger: 'item',
formatter: '{b}'
},
dataRange: {
min: min,
max: max,
realtime: false,
text: ['高', '低'], // 文本,默认为数值文本
calculable: true,
color: ['#d44f47', '#de7e39', '#e49a37', '#d9c224', '#84d653', '#47d077', '#50c38b', '#40ace4', '#3c9ef1']
},
toolbox: {
show: true,
feature: {
selfButtons: { //自定义按钮 danielinbiti,这里增加,selfbuttons可以随便取名字
show: true, //是否显示
title: '返回', //鼠标移动上去显示的文字
icon: 'http://static.vbdsm.com/js/lib/easyui/themes/icons/back.png', //图标
option: {},
onclick: function (option) { //点击事件,这里的option1是chart的option信息
$("#currentProName").val("");
$("#currentCName").val("");
$("#currentDisName").val("");
$("#cityContainer").css("display", "none");
getMapMessage();
getDetail();
}
}
}
},
series: [{
name: provinceName,
type: 'map',
mapType: provinceName,
selectedMode: 'single',
itemStyle: {
normal: {
label: {
show: true
},
areaStyle: {
color: '#3c9ef1'
}
},
emphasis: {
label: {
show: true
}
}
},
data: dataArr
}]
};
// 为echarts对象加载数据
myChart.setOption(option);
});
}
//加载地市地图
function loadCityMap(dataArr, max, min, cityName) {
mapType = 'city';
// 路径配置
require.config({
paths: {
echarts: 'http://static.vbdsm.com/js/lib/echarts/build/dist'
}
});
// 使用
require(
['echarts', 'echarts/chart/map'], // 使用柱状图就加载bar模块,按需加载
function (ec) {
// 基于准备好的dom,初始化echarts图表
myChart = ec.init(document.getElementById('main'));
var curIndx = 0;
var mapType = [];
var mapGeoData = require('echarts/util/mapData/params');
for (var city in cityMap) {
mapType.push(city);
// 自定义扩展图表类型
mapGeoData.params[city] = {
getGeoJson: (function (c) {
var geoJsonName = cityMap[c];
return function (callback) {
$.getJSON('../js/geoJson/china-main-city/' + geoJsonName + '.jsonp', callback);
}
})(city)
}
}
ecConfig = require('echarts/config');
zrEvent = require('zrender/tool/event');
myChart.on(ecConfig.EVENT.CLICK, function (param) {
$("#currentDisName").val(param.name);
clickCount += 1;
if (null != clickTimer) {
return;
}
clickTimer = window.setInterval(function () {
clearInterval(clickTimer);
clickTimer = null;
var doClick = function () {
getCityDetail();
};
var doDBClick = function () {
$("#currentProName").val("");
$("#currentCName").val("");
$("#currentDisName").val("");
$("#cityContainer").css("display", "none");
getMapMessage();
getDetail();
};
if (clickCount == 1) {
//单击的逻辑
doClick();
} else if (clickCount % 2 == 0) {
//双击的逻辑
doDBClick();
}
clickCount = 0;
}, 300);
});
option = {
tooltip: {
trigger: 'item',
formatter: '{b}'
},
dataRange: {
min: min,
max: max,
realtime: false,
text: ['高', '低'], // 文本,默认为数值文本
calculable: true,
color: ['#d44f47', '#de7e39', '#e49a37', '#d9c224', '#84d653', '#47d077', '#50c38b', '#40ace4', '#3c9ef1']
},
toolbox: {
show: true,
feature: {
selfButtons: { //自定义按钮 danielinbiti,这里增加,selfbuttons可以随便取名字
show: true, //是否显示
title: '返回', //鼠标移动上去显示的文字
icon: 'http://static.vbdsm.com/js/lib/easyui/themes/icons/back.png', //图标
option: {},
onclick: function (option) { //点击事件,这里的option1是chart的option信息
$("#currentCName").val("");
$("#currentDisName").val("");
$("#cityContainer").css("display", "none");
getMapMessage();
getDetail();
}
}
}
},
series: [{
name: cityName,
type: 'map',
mapType: cityName,
selectedMode: 'single',
itemStyle: {
normal: {
label: {
show: true
},
areaStyle: {
color: '#3c9ef1'
}
},
emphasis: {
label: {
show: true
}
}
},
data: dataArr
}]
};
// 为echarts对象加载数据
myChart.setOption(option);
});
}
//加载地市地图
function loadAreaMap(dataArr, max, min, cityName) {
mapType = 'city';
// 路径配置
require.config({
paths: {
echarts: 'http://static.vbdsm.com/js/lib/echarts/build/dist'
}
});
// 使用
require(
['echarts', 'echarts/chart/map'], // 使用柱状图就加载bar模块,按需加载
function (ec) {
// 基于准备好的dom,初始化echarts图表
myChart = ec.init(document.getElementById('main'));
var curIndx = 0;
var mapType = [];
var mapGeoData = require('echarts/util/mapData/params');
for (var city in cityMap) {
mapType.push(city);
// 自定义扩展图表类型
mapGeoData.params[city] = {
getGeoJson: (function (c) {
var geoJsonName = cityMap[c];
return function (callback) {
$.getJSON('../js/geoJson/china-main-city/' + geoJsonName + '.jsonp', callback);
}
})(city)
}
}
ecConfig = require('echarts/config');
zrEvent = require('zrender/tool/event');
option = {
tooltip: {
trigger: 'item',
formatter: '{b}'
},
dataRange: {
min: min,
max: max,
realtime: false,
text: ['高', '低'], // 文本,默认为数值文本
calculable: true,
color: ['#d44f47', '#de7e39', '#e49a37', '#d9c224', '#84d653', '#47d077', '#50c38b', '#40ace4', '#3c9ef1']
},
toolbox: {
show: false,
feature: {
selfButtons: { //自定义按钮 danielinbiti,这里增加,selfbuttons可以随便取名字
show: true, //是否显示
title: '返回', //鼠标移动上去显示的文字
icon: 'http://static.vbdsm.com/js/lib/easyui/themes/icons/back.png', //图标
option: {},
onclick: function (option) { //点击事件,这里的option1是chart的option信息
$("#currentCName").val("");
$("#currentDisName").val("");
$("#cityContainer").css("display", "none");
getMapMessage();
getDetail();
}
}
}
},
series: [{
name: cityName,
type: 'map',
mapType: cityName,
selectedMode: 'single',
itemStyle: {
normal: {
label: {
show: true
},
areaStyle: {
color: '#3c9ef1'
}
},
emphasis: {
label: {
show: true
}
}
},
data: dataArr
}]
};
// 为echarts对象加载数据
myChart.setOption(option);
});
}
function showDayChart(series, yAxis, title) {
$('#chartdiv').highcharts({
title: {
text: title,
x: -20
},
xAxis: {
type: "datetime",
tickInterval: 3 * 3600 * 1000,
gridLineWidth: 1, // 默认是0,即在图上没有纵轴间隔线
// 自定义x刻度上显示的时间格式,根据间隔大小,以下面预设的小时/分钟/日的格式来显示
dateTimeLabelFormats: {
hour: '%H:%M',
day: "00:00"
}
},
yAxis: yAxis,
tooltip: {
crosshairs: {
width: 1,
color: 'gray'
},
headerFormat: '时间:{point.key}
',
pointFormat: '{series.name}: {point.y}
',
valueDecimals: 2, // 数据值保留小数位数
xDateFormat: '%H:%M',
shared: true
},
legend: {
borderWidth: 0
},
plotOptions: {
column: {
dataLabels: {
enabled: false,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
}
},
series: {
connectNulls: true
}
},
series: series
});
}
//扩展Date的format方法
Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1,
"d+": this.getDate(),
"h+": this.getHours(),
"m+": this.getMinutes(),
"s+": this.getSeconds(),
"q+": Math.floor((this.getMonth() + 3) / 3),
"S": this.getMilliseconds()
}
if (/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
for (var k in o) {
if (new RegExp("(" + k + ")").test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
}
}
return format;
}