var Option = {}; Option.getLastEnterpriseOption = function (type,data) { var myEcharts = echarts.init(document.getElementById('e1'),"macarons"); var title = new Array(); var detail = new Array(); var max = 200; for(var key in data.obj){ title.push(data.obj[key].time); detail.push(data.obj[key].count); if(max{b} : {c} ({d}%)' // }, // legend: { // left: 'center', // top: 'bottom', // show:true, // data: data // }, // xAxis: { // show:false // }, // yAxis:{ // show:false // }, // toolbox: { // show: true, // feature: { // mark: {show: true}, // dataView: {show: true, readOnly: false}, // magicType: { // show: true, // type: ['pie', 'funnel'] // }, // restore: {show: true}, // saveAsImage: {show: true} // } // }, // series: [ // { // name: titleName, // type: 'pie', // radius: [30, 110], // center: ['50%', '50%'], // roseType: 'area', // data: detail // } // ] // }; myEcharts.setOption(option); } if(type == 2){ var colorList = ['#f36c6c', '#e6cf4e', '#20d180', '#0093ff','#ca8622', '#bda29a', '#a8d8ea', '#aa96da', '#fcbad3', '#ffffd2']; var option = { title: { text: '人才认定行业领域', }, tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' }, formatter: "行业领域"+'
{b} : {c} ' }, legend: { show: false }, grid: { left: '3%', right: '4%', bottom: '3%', containLabel: true }, xAxis: { type: 'value', axisLine: { show: true }, axisTick: { show: true, interval:0 }, }, yAxis: { inverse: true, type: 'category', data: title, axisLine: { show: false }, axisTick: { show: false }, axisTick: { show: false, interval: 0 }, }, series: [ { type: 'bar', data: type2Detail.map((item, i) => { itemStyle = { color: colorList[i] } return { value: item, itemStyle: itemStyle }; }), label: { show: true, position: 'right', color: '#333333', fontSize: 14, offset: [10, 0] } } ] }; myEcharts.setOption(option); }if(type == 3){ var colorList = ['#f36c6c', '#e6cf4e', '#20d180', '#0093ff','#ca8622', '#bda29a', '#a8d8ea', '#aa96da', '#fcbad3', '#ffffd2']; var option = { title: { text: '人才认定最高学历分布', }, tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' }, formatter: "最高学历"+'
{b} : {c} ' }, legend: { show: false }, grid: { left: '3%', right: '4%', bottom: '3%', containLabel: true }, xAxis: { type: 'value', axisLine: { show: true }, axisTick: { show: true, interval:0 }, }, yAxis: { inverse: true, type: 'category', data: title, axisLine: { show: false }, axisTick: { show: false }, axisTick: { show: false, interval: 0 }, }, series: [ { type: 'bar', data: type2Detail.map((item, i) => { itemStyle = { color: colorList[i] } return { value: item, itemStyle: itemStyle }; }), label: { show: true, position: 'right', color: '#333333', fontSize: 14, offset: [10, 0] } } ] }; myEcharts.setOption(option); } } Option.getCountByStreetOption = function (type,data) { var res = data.obj.data; var total = data.obj.total; var myEcharts = echarts.init(document.getElementById('e3'),"macarons"); var years = new Array(); var jdData = new Array(); var resData = new Array(); for(var key in res){ years.push(key); var tmpData = new Array(); var resTempData = new Array(); for(var street in res[key]){ tmpData.push(street); resTempData.push(res[key][street]); } jdData.push(tmpData); resData.push(resTempData); } var option = { baseOption: { // backgroundColor: '#2c343c', //背景颜色 timeline: { data: years, axisType: 'category', autoPlay: true, playInterval: 3000, //播放速度 left: '5%', right: '5%', bottom: '0%', width: '90%', // height: null, label: { normal: { textStyle: { color: 'red', } }, emphasis: { textStyle: { color: 'red' } } }, symbolSize: 10, lineStyle: { color: '#red' }, checkpointStyle: { borderColor: '#red', borderWidth: 2 }, controlStyle: { showNextBtn: true, showPrevBtn: true, normal: { color: '#ff8800', borderColor: '#ff8800' }, emphasis: { color: 'red', borderColor: 'red' } }, }, title: { text: '', right: '2%', bottom: '8%', textStyle: { fontSize: 50, color: 'black' //标题字体颜色 } }, tooltip: { 'trigger': 'axis' }, calculable: true, grid: { left: '8%', right: '2%', bottom: '6%', top: '0%', containLabel: true }, label: { normal: { textStyle: { color: 'red' } } }, yAxis: [{ nameGap: 50, offset: '37', 'type': 'category', interval: 50, //inverse: ture,//图表倒叙或者正序排版 data: '', nameTextStyle: { color: 'red' }, axisLabel: { //rotate:45, show: false, textStyle: { fontSize: 32, color: function(params, Index) { // 标签国家字体颜色 //color:function(d){return "#"+Math.floor(Math.random()*(256*256*256-1)).toString(16);//随机生成颜色 var colorarrays = ['#6bc0fb', '#7fec9d', '#fedd8b', '#ffa597', '#84e4dd', '#749f83', '#ca8622', '#bda29a', '#a8d8ea', '#aa96da', '#fcbad3', '#ffffd2', '#f38181', '#fce38a', '#eaffd0', '#95e1d3', '#e3fdfd', '#749f83', '#ca8622' ]; //console.log("111", Index, colorarrays[Index],params); //打印序列 return colorarrays[jdData[0].indexOf(params)]; }, }, //rotate:45, interval: 50 }, axisLine: { lineStyle: { color: 'balck' //Y轴颜色 }, }, splitLine: { show: false, lineStyle: { color: 'balck' } }, }], xAxis: [{ 'type': 'value', 'name': '', splitNumber: 8, //轴线个数 nameTextStyle: { color: 'balck' }, axisLine: { lineStyle: { color: '#ffa597' //X轴颜色 } }, axisLabel: { formatter: '{value} ' }, splitLine: { show: true, lineStyle: { color: '#fedd8b' } }, }], series: [{ 'name': '', 'type': 'bar', markLine: { label: { normal: { show: false } }, lineStyle: { normal: { color: 'red', width: 3 } }, }, label: { normal: { show: true, position: 'right', //数值显示在右侧 formatter: '{c}' } }, itemStyle: { normal: { color: function(params) { // build a color map as your need. //color:function(d){return "#"+Math.floor(Math.random()*(256*256*256-1)).toString(16);//随机生成颜色 var colorList = ['#6bc0fb', '#7fec9d', '#fedd8b', '#ffa597', '#84e4dd', '#749f83', '#ca8622', '#bda29a', '#a8d8ea', '#aa96da', '#fcbad3', '#ffffd2', '#f38181', '#fce38a', '#eaffd0', '#95e1d3', '#e3fdfd', '#749f83', '#ca8622' ]; // return colorList[params.dataIndex] return colorList[jdData[0].indexOf(params.name)]; }, } }, }, { 'name': '', 'type': 'bar', markLine: { label: { normal: { show: false } }, lineStyle: { normal: { color: 'red', width: 3 } }, }, barWidth: '50%', barGap: '-100%', label: { normal: { show: true, position: 'left', //数值显示在右侧 formatter: function(p) { return p.name; } } }, itemStyle: { normal: { color: function(params) { // build a color map as your need. //color:function(d){return "#"+Math.floor(Math.random()*(256*256*256-1)).toString(16);//随机生成颜色 var colorList = ['#6bc0fb', '#7fec9d', '#fedd8b', '#ffa597', '#84e4dd', '#749f83', '#ca8622', '#bda29a', '#a8d8ea', '#aa96da', '#fcbad3', '#ffffd2', '#f38181', '#fce38a', '#eaffd0', '#95e1d3', '#e3fdfd', '#749f83', '#ca8622' ]; // return colorList[params.dataIndex] // console.log("111", params.name); //打印序列 return colorList[jdData[0].indexOf(params.name)]; }, } }, } ], animationEasingUpdate: 'quinticInOut', animationDurationUpdate: 1500, //动画效果 }, options: [] }; for (var n = 0; n < years.length; n++) { var res = []; for (j = 0; j < resData[n].length; j++) { res.push({ name: jdData[n][j], value: resData[n][j] }); } res.sort(function(a, b) { return b.value - a.value; }).slice(0, 6); res.sort(function(a, b) { return a.value - b.value; }); var res1 = []; var res2 = []; var res3 = []; //console.log(res); for (t = 0; t < res.length; t++) { res1[t] = res[t].name; res2[t] = res[t].value; res3[t] = (res[t].value/total[years[n]]*100).toFixed(2); } option.options.push({ title: { text: years[n] + '年' }, yAxis: { data: res1, }, series: [{ data: res2 }, { data: res2 }] }); } myEcharts.setOption(option); } Option.talentIdentifyChangeOption = function (data) { var myEcharts = echarts.init(document.getElementById('e4'),"macarons"); var xData = new Array(); var totalData = new Array(); var boyData = new Array(); var girlData = new Array(); for(var key in data.obj){ xData.push(key); totalData.push(data.obj[key].total); boyData.push(data.obj[key].boy); girlData.push(data.obj[key].girl); } var option = { // backgroundColor: "#344b58", "title": { "text": "近几年人才认定数走势图", x: "4%", textStyle: { color: '#fff', fontSize: '22' }, subtextStyle: { color: '#90979c', fontSize: '16', }, }, "tooltip": { "trigger": "axis", "axisPointer": { "type": "shadow", textStyle: { color: "#fff" } }, }, "grid": { "borderWidth": 0, "top": 110, "bottom": 95, textStyle: { color: "#fff" } }, "legend": { x: '4%', top: '8%', textStyle: { color: '#90979c', }, "data": ['女', '男', '平均'] }, "calculable": true, "xAxis": [{ "type": "category", "axisLine": { lineStyle: { color: '#90979c' } }, "splitLine": { "show": false }, "axisTick": { "show": false }, "splitArea": { "show": false }, "axisLabel": { "interval": 0, }, "data": xData, }], "yAxis": [{ "type": "value", "splitLine": { "show": false }, "axisLine": { lineStyle: { color: '#90979c' } }, "axisTick": { "show": false }, "axisLabel": { "interval": 0, }, "splitArea": { "show": false }, }], "dataZoom": [{ "show": true, "height": 30, "xAxisIndex": [ 0 ], bottom: 30, "start": 10, "end": 80, handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z', handleSize: '110%', handleStyle:{ color:"#d3dee5", }, textStyle:{ color:"#fff"}, borderColor:"#90979c" }, { "type": "inside", "show": true, "height": 15, "start": 1, "end": 35 }], "series": [{ "name": "女", "type": "bar", "stack": "总量", "barMaxWidth": 35, "barGap": "10%", "itemStyle": { "normal": { "color": "rgba(255,144,128,1)", "label": { "show": true, "textStyle": { "color": "#fff" }, "position": "inside", formatter: function(p) { return p.value > 0 ? (p.value) : ''; } } } }, "data": girlData, }, { "name": "男", "type": "bar", "stack": "总量", "itemStyle": { "normal": { "color": "rgba(0,191,183,1)", "barBorderRadius": 0, "label": { "show": true, "position": "inside", formatter: function(p) { return p.value > 0 ? (p.value) : ''; } } } }, "data":boyData }, { "name": "总数", "type": "line", symbolSize:10, symbol:'circle', "itemStyle": { "normal": { "color": "rgba(252,230,48,1)", "barBorderRadius": 0, "label": { "show": true, "position": "top", formatter: function(p) { return p.value > 0 ? (p.value) : ''; } } } }, "data": totalData }, ] } myEcharts.setOption(option); }