export const defaultOpts = {
	//图表配置
	chart: {

	},
	title: {
		enabled: false
	},
	exporting: {
		enabled: false,
	},
	//默认颜色配置
	colors:['#00f','#f00','#999','#000','#7cb5ec', '#90ed7d', '#f7a35c', '#8085e9', 
	'#f15c80', '#e4d354', '#2b908f', '#f45b5b', '#91e8e1'],
	//版权信息
	credits: {enabled:false},
	//数据列通用配置
	plotOptions: {
		series: {
			turboThreshold: 0, //不限制数据点个数 
			dataGrouping: {
				enabled: false,
			},//取消数据大自动数据合并
			animation: {
				duration: 1000
			}
		},
		areaspline: {
			lineWidth: 1,
			stacking: 'normal',
			marker: {
					enabled: false,
			},
			// fillOpacity: 0.5,
		},
		column:{
			pointPadding: 0.05,
			stacking: 'normal',
		},
		scatter: {
			turboThreshold: 0,
			marker: {
					symbol: 'circle',
					radius: 5,
					states: {
							hover: {
									enabled: true,
							}
					}
			},
			states: {
				hover: {
					marker: {
						enabled: true
					}
				}
			},
		}
	},
	//范围选择器
	rangeSelector: {
		enabled: false,
		selected: 2,
	},
	//悬浮提示框
	tooltip: {
		split: false,
		shared: true,
		dateTimeLabelFormats: {
			// 时间格式化字符
			day: '%Y/%m/%d',
			week: "%Y/%m",
			month: '%Y/%m',
			year: '%Y/%m',
		},
		xDateFormat:'%Y/%m/%d',
		// valueDecimals: 4,
	},
	//图例
	legend: {
		enabled: true,
		verticalAlign: 'top',
		margin:20,
		// layout: 'vertical'
	},
	//滚动条
	scrollbar: {
		enabled: false,
	},
	//导航器
	navigator: {
		enabled: false,
	},
	//范围选择器
	rangeSelector: {
		enabled: false,
	},
	xAxis: {
		tickPosition: 'inside',
		lineColor: '#bfbfbf',
    tickColor: '#bfbfbf',
		tickLength:5,
		type: 'datetime',
		ordinal: false,
		dateTimeLabelFormats: {
			day: '%y/%m',
			week: '%y/%m',
			month: '%y/%m',
			year: '%y/%m',
		}
		// gridLineWidth:0
	}
};

/* 图表分类弹窗校验 */
export const formRules = {
	level_1:[
		{ required: true, message: '分类名称不能为空', trigger: 'blur' },
	],
	level_2:[
		{ required: true, message: '分类名称不能为空', trigger: 'blur' },
	],
	level_3:[
		{ required: true, message: '分类名称不能为空', trigger: 'blur' },
	],
	level_4:[
		{ required: true, message: '图表名称不能为空', trigger: 'blur' },
	],
	level_menu:[
		{ required: true, message: '所属分类不能为空', trigger: 'blur' },
	],
}
/* 添加图表表单校验 */
export const chartRules = {
	style:[
		{ required: true, message: '生成样式不能为空', trigger: 'blur' },
	],
	name:[
		{ required: true, message: '图表名称不能为空', trigger: 'blur' },
	],
	classify:[
		{ required: true, message: '图表分类不能为空', trigger: 'blur' },
	],
}

/* 公用指标单位 */
export const unitArr = [
	'无',
	'万吨',
	'亿元',
	'元',
	'元/吨',
	'元/湿吨',
	'千克',
	'吨',
	'短吨',
	'美元/吨',
	'万平方米',
	'美元/桶',
	'美分/加仑',
	'手'
]

/* 季节性图配置 */
export const seasonOptions = {
		//默认颜色配置
	colors:['#4B0082','#7FFFAA','#FF4500','#808000','#EEE8AA','#849EC1','#8A4294','#578B5A','#FDA8C7','#53B3FF','#999999','#000000','#FFDF0C','#FF0000','#0033FF'],
	yAxis: {
		lineWidth: 1,
		lineColor: '#bfbfbf',
		tickColor: '#bfbfbf',
		offset: 0,
		opposite: false,
		reversed: false,
		visible: true,
		gridLineWidth: 0,
		tickWidth: 1,
		tickLength:5,
		tickPosition: 'inside',
		endOnTick: false,
		startOnTick: false,
		showLastLabel: true, //显示最后刻度值
		tickPixelInterval: 50
	}
}

/* 散点图颜色 */
export const scatterColorsOptions = [ 'rgba(119, 152, 191, .5)','rgba(223, 83, 83, .5)' ]


/* 复制图片额外option */
export const copyOtherOptions = {
	legend: {
		align: 'center',
		layout: 'horizontal',
		itemStyle: {
			fontSize: "14px",
			color: '#444',
			textOverflow:undefined
		},
		itemMarginBottom:5,
		itemDistance: 0,
		padding: 0,
		margin: 10
	},
	seasonLegend:{
		align: 'center',
		layout: 'horizontal',
		itemStyle: {
			fontSize: "14px",
			color: '#444',
		}
	}
}
/* 图表年份筛选框 */
export const yearSelector = [
	{
		name: '15年至今',
		value: 3,
	},
	// {
	// 	name: '18年至今',
	// 	value: 7,
	// },
	// {
	// 	name: '19年至今',
	// 	value: 8,
	// },
	{
		name: '20年至今',
		value: 9,
	},
	{
		name: '21年至今',
		value: 4,
	},
	{
		name: '22年至今',
		value: 11,
	},
]

export const browser = () => {
	// 取得浏览器的userAgent字符串
	var userAgent = navigator.userAgent
	// 判断是否Opera浏览器
	var isOpera = userAgent.indexOf('Opera') > -1
	// 判断是否IE浏览器
	var isIE =
		userAgent.indexOf('compatible') > -1 &&
		userAgent.indexOf('MSIE') > -1 &&
		!isOpera
	// 判断是否IE的Edge浏览器
	var isEdge = userAgent.indexOf('Edge') > -1
	// 判断是否Firefox浏览器
	var isFF = userAgent.indexOf('Firefox') > -1
	// 判断是否Safari浏览器
	var isSafari =
		userAgent.indexOf('Safari') > -1 && userAgent.indexOf('Chrome') === -1
	// 判断Chrome浏览器
	var isChrome =
		userAgent.indexOf('Chrome') > -1 && userAgent.indexOf('Safari') > -1

	if (isIE) {
		var reIE = new RegExp('MSIE (\\d+\\.\\d+);')
		reIE.test(userAgent)
		var fIEVersion = parseFloat(RegExp['$1'])
		if (fIEVersion === 7) {
			return 'IE7'
		} else if (fIEVersion === 8) {
			return 'IE8'
		} else if (fIEVersion === 9) {
			return 'IE9'
		} else if (fIEVersion === 10) {
			return 'IE10'
		} else if (fIEVersion === 11) {
			return 'IE11'
		} else {
			return 'IE'
		}
	}else if (isOpera) {
		return 'Opera'
	}else if (isEdge) {
		return 'Edge'
	}else if (isFF) {
		return 'FF'
	}else if (isSafari) {
		return 'Safari'
	}else if (isChrome) {
		return 'Chrome'
	}else {
		return ''
	}
}

// 判断设备
export const getTerminal = () => {
  // 获取终端的相关信息
  var Terminal = {
    // 辨别移动终端类型
    platform: function () {
      var u = navigator.userAgent,
        app = navigator.appVersion;
      return {
        // android终端或者uc浏览器
        android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1,
        // 是否为iPhone或者QQHD浏览器
        iPhone: u.indexOf('iPhone') > -1,
        // 是否iPad
        iPad: u.indexOf('iPad') > -1
      };
    }()
  }
  // 根据不同的终端，跳转到不同的地址
  if (Terminal.platform.android) {
    return 'android';
  } else if (Terminal.platform.iPhone || Terminal.platform.iPad) {
    return 'ios';
  }
}

