123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- function getStartDate(chooseYear){
- // 按年度来计算的时候,开始时间是该年度7月1号还是到下一个年的6月30号结束
- if(chooseYear == 2016){
- return chooseYear + "-08-01";
- }else{
- return chooseYear+'-07-01';
- }
- }
- //获取结束时间
- function getEndDate(chooseYear){
- chooseYear = parseInt(chooseYear);
- var endDate = new Date((chooseYear+1) + '-06-30'),
- now = new Date();
- if(now <= endDate){
- return now.format("yyyy-MM-dd");
- }else{
- return (chooseYear+1) + '-06-30';
- }
- }
- /**
- * 获取多少天前的日期
- */
- function getDateBefore(days) {
- var now = new Date();
- var date = new Date(now.getTime() - days * 24 * 3600 * 1000);
- var year = date.getFullYear();
- var month = date.getMonth() + 1;
- var day = date.getDate();
- var hour = date.getHours();
- var minute = date.getMinutes();
- var second = date.getSeconds();
- return year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day);
- }
- /*
- * 获取用来排序的字段值,返回数组
- * 参数: list - 列表, key - 字段的名称
- */
- function getKeyValueArr(list, key){
- var arr = [];
- for(var k in list){
- arr.push(list[k][key]);
- }
-
- return arr;
- }
- /*
- * 排名
- */
- function soreRank(arr){
- var temp = [];
- var lis = [];
- for(var i=0;i<arr.length;i++){
- lis.push(arr[i]);
- }
- lis = _.uniq(lis);
- for(var i=0;i<arr.length;i++){
- temp[i] = lis.indexOf(arr[i])+1;
- }
-
- return temp;
- }
- /*
- * 绘制饼图
- * arry [{name: '', value: ''}]
- * color ['#ffc800', '#17b3ec']
- * silent 图形是否不响应和触发鼠标事件,默认为 false,即响应和触发鼠标事件
- */
- function drawPieChart(elId, arry, color, silent){
- var myChart = echarts.init(document.getElementById(elId));
- var option = {
- tooltip: {
- trigger: 'item',
- formatter: "{b} : {c} ({d}%)",
- position: ['50%', '50%']
- },
- color: color,
- series: [
- {
- type:'pie',
- radius: ['80%', '99%'],
- startAngle: 270,
- legendHoverLink: false,
- hoverAnimation: false,
- avoidLabelOverlap: false,
- silent: silent,
- label: {
- normal: {
- show: false,
- textStyle: {
- color: "#000"
- }
- }
- },
- labelLine: {
- normal: {
- show: false
- }
- },
- data:arry
- }]
- };
- $("#"+elId).removeAttr("_echarts_instance_");
- myChart.setOption(option);
- return myChart;
- }
- /**
- * 绘制柱状图
- */
- function drawBarChart(el, xData, yData, color, name){
- var myChart = echarts.init(document.getElementById(el));
-
- // 指定图表的配置项和数据
- var option = {
- tooltip: {
- trigger: 'item'
- },
- toolbox: {
- dataZoom: true,
- show: true,
- orient: 'vertical',
- x: 'right',
- y: 'center'
- },
- grid: {
- left: '20px',
- right: '20px',
- bottom: '20px',
- top: '20px',
- containLabel: true
- },
- xAxis: [{
- type: 'category',
- data: xData,
- axisLabel: {
- interval:0,//横轴信息全部显示
- },
- splitLine: {
- show: false
- }
- }],
- yAxis: [{
- type: 'value',
- splitLine: {show:false}
- }],
- series: [{
- clickable: true,
- name: name,
- itemStyle : {
- normal: {
- label : {
- show: true, position: 'top'
- },
- color: color
- }
- },
- barWidth: 20,
- type: 'bar',
- data: yData
- }]
- };
-
- // 使用刚指定的配置项和数据显示图表。
- myChart.setOption(option);
- return myChart;
- }
|