| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495 |
- <!DOCTYPE HTML>
- <html xmlns:th="http://www.thymeleaf.org"
- xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
- layout:decorate="~{admin/common/common}">
- <head>
- <title>项目统计</title>
- </head>
- <body layout:fragment="content">
- <div class="page-container">
- <form class="form form-horizontal" id="form-add" th:action="@{/projectDeclaration/statistics}" th:method="get">
- <input type="hidden" id="chartType" name="chartType"/>
- <div class="row cl highlight">
- <span><a onclick="streetDeclaerNum(1)" class="btn btn-info radius"> 各街道申报数量</a></span>
- <span><a onclick="projectCategoryRate()" class="btn btn-info radius"> 项目类别占比</a></span>
- <span><a onclick="projectDevelopmentTrend()" class="btn btn-info radius"> 项目发展趋势</a></span>
- <span><a onclick="streetReportingTrend()" class="btn btn-info radius"> 各街道申报趋势</a></span>
- <span><a onclick="filingSituation()" class="btn btn-info radius"> 各类别项目申请情况</a></span>
- </div>
- <div class="row cl">
- <span><a onclick="getDataByYear(1)" class="btn btn-info radius">最近1年</a></span>
- <span><a onclick="getDataByYear(2)" class="btn btn-info radius">最近2年</a></span>
- <span><a onclick="getDataByYear(5)" class="btn btn-info radius">最近5年</a></span>
- <label>开始日期:</label><input type="text" class="input-text" style="width:200px" readonly placeholder="请输入开始日期"
- id="begin_date" name="begin_date" th:value="${condition.begin_date}"/>
- <label>结束日期:</label><input type="text" class="input-text" style="width:200px" readonly placeholder="请输入结束日期"
- id="end_date" name="end_date" th:value="${condition.end_date}"/>
- <!--<button type="submit" class="btn btn-primary" hidden>-->
- <!--<i class="Hui-iconfont"></i>-->
- <!--搜索-->
- <!--</button>-->
- <span><a onclick="streetDeclaer()" class="btn btn-info radius"><i
- class="Hui-iconfont"></i> 搜索</a></span>
- </div>
- <div class="chart_data mt-20 col-xs-12 col-sm-12" style="height: 500px; width: 800px;" id="container"></div>
- <div class="row cl">
- <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
- <button onClick="removeIframe();" class="btn btn-default radius" type="button"> 返回 </button>
- </div>
- </div>
- </form>
- </div>
- <script th:src="@{https://code.highcharts.com/5.0.12/highcharts.js}"></script>
- <script th:src="@{https://code.highcharts.com/5.0.12/highcharts-more.js}"></script>
- <script th:src="@{https://code.highcharts.com/maps/5.0.12/modules/map.js}"></script>
- <script type="text/javascript" th:src="@{/js/lib/highcharts/highcharts.js}"></script>
- <script type="text/javascript" th:src="@{/js/lib/highcharts/exporting.js}"></script>
- <script type="text/javascript" th:src="@{/js/lib/highcharts/highcharts-zh_CN.js}"></script>
- <style>
- a.cur {
- background: #0a6999;
- color: #fff;
- }
- </style>
- <script th:inline="javascript">
- $(function () {
- $(".highlight a").click(function () {
- $(this).addClass("cur").parent().siblings().find("a").removeClass("cur")
- })
- // var date=new Date;
- // var year=date.getFullYear();
- // var month=date.getMonth()+1;
- // month =(month<10 ? "0"+month:month);
- // var currentDate = (year.toString()+"-"+month.toString());
- streetDeclaerNum("");
- //initPie(currentDate);
- //initPolyline();
- });
- var date = new Date();
- var year = date.getFullYear();
- //初始化柱形图
- var initColumn = {
- chart: {
- renderTo: 'container',
- type: 'column',
- events: {
- render: function () {
- }
- }
- },
- title: {
- text: (year - 1) + '年各街道申报项目数'
- },
- subtitle: {
- text: null
- },
- xAxis: {
- crosshair: true
- },
- yAxis: {
- min: 0,
- allowDecimals: false,
- title: {
- text: '',
- align: 'high'
- },
- labels: {
- overflow: 'justify'
- }
- },
- tooltip: {
- valueSuffix: ' 个'
- },
- plotOptions: {
- column: {
- pointPadding: 0.2,
- borderWidth: 0
- }
- },
- series: []
- };
- //初始化饼图
- var initPie = {
- chart: {
- renderTo: 'container',
- plotBackgroundColor: null,
- plotBorderWidth: null,
- plotShadow: false
- },
- title: {
- text: '项目类别占比'
- },
- tooltip: {
- headerFormat: '',
- pointFormat: '{point.name}: <b>{point.y}</b> %'
- },
- plotOptions: {
- pie: {
- allowPointSelect: true,
- cursor: 'pointer',
- dataLabels: {
- enabled: true,
- // 通过 format 或 formatter 来格式化数据标签显示
- //format: '值: {point.y} 占比 {point.percentage} %',
- formatter: function () {
- //this 为当前的点(扇区)对象,可以通过 console.log(this) 来查看详细信息
- return '<span"> ' + this.point.name + ':' + this.y + '%</span>';
- }
- },
- showInLegend: true // 显示在图例中
- }
- },
- series: [{
- type: 'pie',
- name: ''
- }]
- };
- //各街道申报数量
- function streetDeclaerNum(type) {
- $("#chartType").val(1);
- var begin_date = $("#begin_date").val();
- var end_date =$("#end_date").val();
- if (end_date == "") end_date = getDay(0)
- if (begin_date == "") {
- if (type > 0){
- begin_date = getDay(type)
- } else {
- begin_date = getDay(1)
- }
- }
- initColumn.title.text = begin_date +"~"+ end_date +' 各街道申报项目数';
- $.ajax({
- type: "post",
- dataType: "json",
- data: {
- begin_date: begin_date,
- end_date: end_date,
- type: type
- },
- url: pagePath + "/projectDeclaration/streetDeclaerNum/",
- success: function (result) {
- console.log(result);
- if (result.success) {
- var chart = new Highcharts.Chart(initColumn);
- var categoies = [];
- var row1 = [];
- var row2 = [];
- var value = result.obj;
- for (var j = 0; j < value.length; j++) {
- categoies.push(value[j].street_name);
- row1.push(value[j].declare_num);
- row2.push(value[j].declare_success);
- }
- chart.xAxis[0].categories = categoies;
- chart.addSeries({
- name: "申报项目",
- data: row1
- });
- chart.addSeries({
- name: "申报成功",
- data: row2
- });
- } else {
- errorMessage(result.message);
- }
- },
- error: function () {
- errorMessage('系统错误!');
- }
- });
- }
- function getDay(minusYear) {
- var currentday = new Date(new Date(new Date().toLocaleDateString()).getTime());
- return (currentday.getFullYear()-minusYear) + "-" + ((currentday.getMonth() + 1) < 10 ? "0" + (currentday.getMonth() + 1):(currentday.getMonth() + 1))+ "-" + (currentday.getDate() < 10 ? "0" + currentday.getDate():currentday.getDate())
- }
- //项目类别占比
- function projectCategoryRate(type) {
- $("#chartType").val(2);
- $.ajax({
- type: "post",
- dataType: "json",
- data: {
- begin_date: $("#begin_date").val(),
- end_date: $("#end_date").val(),
- type: type
- },
- url: pagePath + "/projectDeclaration/projectCategoryRate",
- success: function (result) {
- console.log(result);
- if (result.success) {
- var value = result.obj;
- var data = [];
- for (var j = 0; j < value.length; j++) {
- data.push({"name": value[j].project_type_name, "y": value[j].category_rate});
- }
- console.log(data);
- var chart = new Highcharts.Chart(initPie);
- chart.series[0].setData(data);
- } else {
- errorMessage(result.message);
- }
- },
- error: function () {
- errorMessage('系统错误!');
- }
- });
- }
- //项目发展趋势
- function projectDevelopmentTrend(type) {
- $("#chartType").val(3);
- var initPolyline = Highcharts.chart('container', {
- title: {
- text: '项目发展趋势',
- x: -20 //center
- },
- // subtitle: {
- // text: 'Source: WorldClimate.com',
- // x: -20
- // },
- xAxis: {
- categories: []
- },
- yAxis: {
- title: {
- text: '项目申请次数(次)'
- },
- plotLines: [{
- value: 0,
- width: 1,
- color: '#808080'
- }]
- },
- tooltip: {
- valueSuffix: '次'
- },
- legend: {
- layout: 'vertical',
- align: 'right',
- verticalAlign: 'middle',
- borderWidth: 0
- },
- series: []
- });
- $.ajax({
- type: "post",
- dataType: "json",
- data: {
- begin_date: $("#begin_date").val(),
- end_date: $("#end_date").val(),
- type: type
- },
- url: pagePath + "/projectDeclaration/projectDevelopmentTrend",
- success: function (result) {
- console.log(result);
- if (result.success) {
- var obj = result.obj;
- var map = obj.polyline_data;
- //x轴年份
- var categories = obj.year_array;
- initPolyline.xAxis[0].categories = categories;
- //展示数据
- for (var key in map) {
- initPolyline.addSeries({
- name: key,
- data: map[key]
- });
- }
- } else {
- errorMessage(result.message);
- }
- },
- error: function () {
- errorMessage('系统错误!');
- }
- });
- }
- //各街道申报趋势
- function streetReportingTrend(type) {
- $("#chartType").val(4);
- var initPolyline = Highcharts.chart('container', {
- title: {
- text: '各街道申报趋势',
- x: -20 //center
- },
- // subtitle: {
- // text: 'Source: WorldClimate.com',
- // x: -20
- // },
- xAxis: {
- categories: []
- },
- yAxis: {
- title: {
- text: '申请次数(次)'
- },
- min: 0,
- allowDecimals: false,
- },
- tooltip: {
- valueSuffix: '次'
- },
- legend: {
- layout: 'vertical',
- align: 'right',
- verticalAlign: 'middle',
- borderWidth: 0
- },
- series: []
- });
- $.ajax({
- type: "post",
- dataType: "json",
- data: {
- begin_date: $("#begin_date").val(),
- end_date: $("#end_date").val(),
- type: type
- },
- url: pagePath + "/projectDeclaration/streetReportingTrend",
- success: function (result) {
- console.log(result);
- if (result.success) {
- var obj = result.obj;
- var map = obj.polyline_data;
- //x轴年份
- var categories = obj.year_array;
- initPolyline.xAxis[0].categories = categories;
- //展示数据
- for (var key in map) {
- initPolyline.addSeries({
- name: key,
- data: map[key]
- });
- }
- } else {
- errorMessage(result.message);
- }
- },
- error: function () {
- errorMessage('系统错误!');
- }
- });
- }
- //各类别项目申请情况
- function filingSituation(type) {
- $("#chartType").val(5);
- $.ajax({
- type: "post",
- dataType: "json",
- data: {
- begin_date: $("#begin_date").val(),
- end_date: $("#end_date").val(),
- type: type
- },
- url: pagePath + "/projectDeclaration/filingSituation/",
- success: function (result) {
- console.log(result);
- if (result.success) {
- var chart = new Highcharts.Chart(initColumn);
- var categoies = [];
- var row1 = [];
- var row2 = [];
- var value = result.obj;
- for (var j = 0; j < value.length; j++) {
- categoies.push(value[j].project_type_name);
- row1.push(value[j].declare_num);
- row2.push(value[j].declare_success);
- }
- chart.xAxis[0].categories = categoies;
- chart.addSeries({
- name: "申报项目",
- data: row1
- });
- chart.addSeries({
- name: "申报成功",
- data: row2
- });
- } else {
- errorMessage(result.message);
- }
- },
- error: function () {
- errorMessage('系统错误!');
- }
- });
- }
- function streetDeclaer() {
- var chartType = $("#chartType").val();
- if (chartType == 1) {
- streetDeclaerNum();
- }
- if (chartType == 2) {
- projectCategoryRate();
- }
- if (chartType == 3) {
- projectDevelopmentTrend();
- }
- if (chartType == 4) {
- streetReportingTrend();
- }
- if (chartType == 5) {
- filingSituation();
- }
- }
- function getDataByYear(type) {
- var chartType = $("#chartType").val();
- $("#begin_date").val("");
- $("#end_date").val("");
- if (chartType == 1) {
- streetDeclaerNum(type);
- }
- if (chartType == 2) {
- projectCategoryRate(type);
- }
- if (chartType == 3) {
- projectDevelopmentTrend(type);
- }
- if (chartType == 4) {
- streetReportingTrend(type);
- }
- if (chartType == 5) {
- filingSituation(type);
- }
- }
- /**
- * 取消
- */
- function removeIframe() {
- var index = parent.layer.getFrameIndex(window.name);
- parent.layer.close(index);
- }
- laydate.render({
- elem: '#begin_date', //指定元素
- // min: 0
- });
- laydate.render({
- elem: '#end_date', //指定元素
- // min: 0
- });
- </script>
- </body>
- </html>
|