| | |
| | | $(function() { |
| | | loadMap(); |
| | | //getReallyData(); |
| | | //getRegulatoryUnitChartData("",""); |
| | | //bindEvent(); |
| | | }) |
| | | // 加载地图 |
| | | var countries = []; |
| | | var countriesOverlay = new T.D3Overlay(init,redraw); |
| | | var countriesOverlay1 = new T.D3Overlay(init1,redraw1); |
| | | function loadMap() { |
| | | let map = new T.Map('map_div'); |
| | | map.centerAndZoom(new T.LngLat(116.38, 39.9), 11); |
| | | |
| | | var control = new T.Control.Zoom(); |
| | | control.setPosition(T_ANCHOR_TOP_RIGHT); |
| | | map.addControl(control);// 添加缩放平移控件 |
| | | var scale = new T.Control.Scale();// 创建比例尺控件对象 |
| | | d3.json("/bjfw/js/custom/beijing.json", function (data) { |
| | | countries = data.features; |
| | | map.addOverLay(countriesOverlay) |
| | | countriesOverlay.bringToBack(); |
| | | map.addOverLay(countriesOverlay1) |
| | | countriesOverlay.bringToBack(); |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | function init(sel, transform) { |
| | | var upd = sel.selectAll('path.geojson').data(countries); |
| | | upd.enter() |
| | | .append('path') |
| | | .attr("class", "geojson") |
| | | .attr('stroke', 'grey') |
| | | .attr('fill', function (d, i) { |
| | | //return d3.hsl(Math.random() * 360, 0.9, 0.5) |
| | | return "transparent" |
| | | }) |
| | | .attr('fill-opacity', '0') |
| | | } |
| | | |
| | | function redraw(sel, transform) { |
| | | sel.selectAll('path.geojson').each( |
| | | function (d, i) { |
| | | d3.select(this).attr('d', transform.pathFromGeojson) |
| | | } |
| | | ) |
| | | } |
| | | |
| | | |
| | | function init1(sel, transform) { |
| | | var upd = sel.selectAll('path.geojson1').data(countries); |
| | | upd.enter() |
| | | .append('path') |
| | | .attr("class", "geojson1") |
| | | .attr('stroke', 'grey') |
| | | .attr('fill', function (d, i) { |
| | | return d3.hsl(Math.random() * 360, 0.9, 0.5) |
| | | }) |
| | | .attr('fill-opacity', '0.1') |
| | | } |
| | | |
| | | function redraw1(sel, transform) { |
| | | sel.selectAll('path.geojson1').each( |
| | | function (d, i) { |
| | | d3.select(this).attr('d', transform.pathFromGeojson) |
| | | } |
| | | ) |
| | | } |
| | | |
| | | // 获取数据库真实数据 |
| | | function getReallyData() { |
| | | let url = window.location.protocol + "//" + window.location.host + "/bjfw/geotdp/index/indexCollect"; |
| | | $.get(url,function(res){ |
| | | |
| | | }) |
| | | } |
| | | // 页面数据赋值 |
| | | function pageAssignment(reallyData) { |
| | | for ( let key in reallyData) { |
| | | let className = "." + key; |
| | | $(className).text(reallyData[key]); |
| | | } |
| | | } |
| | | |
| | | //查询监管单位项目统计图表数据 |
| | | function getRegulatoryUnitChartData(startTime,endTime){ |
| | | let url = window.location.protocol + "//" + window.location.host + "/bjfw/geotdp/index/indexProjectNumsCollect"; |
| | | $.get(url,{ |
| | | startTime: startTime, |
| | | endTime: endTime |
| | | },function(res){ |
| | | if(res.status && res.message === "操作成功"){ |
| | | let chartData = {}; |
| | | chartData.yData = res.result.map((item)=>{ |
| | | return item.fullName; |
| | | }) |
| | | chartData.xData = res.result.map((item)=>{ |
| | | return item.projectNums; |
| | | }) |
| | | loadRegulatoryUnitChart(chartData); |
| | | }else{ |
| | | $.modal.alertError("请求出错"); |
| | | } |
| | | |
| | | }) |
| | | } |
| | | |
| | | //加载监管单位项目统计图表 |
| | | function loadRegulatoryUnitChart(chartData){ |
| | | var myChart = echarts.init(document.getElementById('rank_chart')); |
| | | |
| | | let beginColor = "rgb(255,140,0,0.1)", |
| | | endColor = "rgb(255,140,0,1)", |
| | | endPix = ""; |
| | | //let endZom = 50; |
| | | |
| | | let option = { |
| | | title: { |
| | | show: false, |
| | | }, |
| | | dataZoom: [ |
| | | { |
| | | type: "inside", |
| | | start: 0, |
| | | // end: endZom, |
| | | orient: "vertical", |
| | | zoomOnMouseWheel: false, ////滚轮是否触发缩放 |
| | | }, |
| | | ], |
| | | tooltip: { |
| | | trigger: "axis", |
| | | axisPointer: { |
| | | type: "shadow", |
| | | }, |
| | | }, |
| | | legend: { |
| | | bottom: 20, |
| | | right: 0, |
| | | textStyle: { |
| | | color: "#666", |
| | | fontSize: 18, |
| | | }, |
| | | orient: "vertical", |
| | | }, |
| | | grid: { |
| | | borderWidth: 0, |
| | | top: "8%", |
| | | left: "1%", |
| | | right: "8%", |
| | | bottom: "2%", |
| | | }, |
| | | color: "#fff", |
| | | yAxis: [ |
| | | { |
| | | type: "category", |
| | | inverse: true, |
| | | axisLine: { |
| | | show: false, |
| | | }, |
| | | splitLine: { |
| | | show: false, |
| | | }, |
| | | axisTick: { |
| | | show: false, |
| | | }, |
| | | axisLabel: { |
| | | show: false, |
| | | }, |
| | | data: chartData.yData, |
| | | }, |
| | | ], |
| | | xAxis: { |
| | | type: "value", |
| | | axisTick: { |
| | | show: false, |
| | | }, |
| | | axisLine: { |
| | | show: false, |
| | | }, |
| | | splitLine: { |
| | | show: false, |
| | | }, |
| | | axisLabel: { |
| | | show: false, |
| | | }, |
| | | }, |
| | | series: [ |
| | | { |
| | | name: "累计", |
| | | type: "bar", |
| | | barWidth: "10px", |
| | | itemStyle: { |
| | | normal: { |
| | | show: true, |
| | | color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [ |
| | | { |
| | | offset: 0, |
| | | color: beginColor, |
| | | }, |
| | | { |
| | | offset: 1, |
| | | color: endColor, |
| | | }, |
| | | ]), |
| | | barBorderRadius: [0, 5, 5, 0], |
| | | }, |
| | | emphasis: { |
| | | shadowBlur: 15, |
| | | shadowColor: "rgba(0, 0, 0, 0.1)", |
| | | }, |
| | | }, |
| | | data: chartData.xData, |
| | | animationDuration: 1500, |
| | | label: { |
| | | normal: { |
| | | color: "black", |
| | | show: true, |
| | | position: "right", |
| | | fontSize: 18, |
| | | fontStyle: "italic", |
| | | formatter: function (para) { |
| | | return para.data + endPix; |
| | | }, |
| | | }, |
| | | }, |
| | | }, |
| | | { |
| | | type: "bar", |
| | | barGap: "0", |
| | | barWidth: 10, |
| | | animation: false, |
| | | itemStyle: { |
| | | color: "transparent", |
| | | }, |
| | | tooltip: { |
| | | show: false, |
| | | }, |
| | | label: { |
| | | show: true, |
| | | position: ["0", "-35"], |
| | | fontSize: 13, |
| | | color: "rgb(0,0,0,0.7)", |
| | | formatter: function (param) { |
| | | return param.dataIndex + 1 + " " + param.name; |
| | | }, |
| | | }, |
| | | data: chartData.xData, |
| | | }, |
| | | |
| | | ], |
| | | animationEasing: "cubicOut", |
| | | }; |
| | | |
| | | myChart.setOption(option); |
| | | } |
| | | |
| | | //绑定事件 |
| | | function bindEvent(){ |
| | | $(".statistic-btn .btn").on("click",function(){ |
| | | if(this.innerText === "总计"){ |
| | | getRegulatoryUnitChartData("",""); |
| | | }else if(this.innerText === "本年度"){ |
| | | let d = new Date(); |
| | | let n = d.getFullYear(); |
| | | let startTime = n + "-01-01 00:00:00"; |
| | | let endTime = n + "-12-31 23:59:59"; |
| | | getRegulatoryUnitChartData(startTime,endTime); |
| | | }else{ |
| | | let startTime = getFirstDay() + " 00:00:00"; |
| | | let endTime = getLastDay() + " 23:59:59"; |
| | | getRegulatoryUnitChartData(startTime,endTime); |
| | | } |
| | | }) |
| | | } |
| | | |
| | | //获取本月第一天 |
| | | function getFirstDay(){ |
| | | var y = new Date().getFullYear(); //获取年份 |
| | | var m = new Date().getMonth() + 1; //获取月份 |
| | | var d = '01' |
| | | m = m < 10 ? '0' + m : m; //月份补 0 |
| | | |
| | | return [y,m,d].join("-") |
| | | } |
| | | //获取本月最后一天 |
| | | function getLastDay(){ |
| | | var y = new Date().getFullYear(); //获取年份 |
| | | var m = new Date().getMonth() + 1; //获取月份 |
| | | var d = new Date(y, m, 0).getDate(); //获取当月最后一日 |
| | | m = m < 10 ? '0' + m : m; //月份补 0 |
| | | d = d < 10 ? '0' + d : d; //日数补 0 |
| | | return [y,m,d].join("-"); |
| | | } |