defaultOptions.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. import bus from "@/api/bus";
  2. export const defaultOpts = {
  3. //图表配置
  4. chart: {
  5. spacing: [2,10,2,10]
  6. },
  7. title: {
  8. enabled: false
  9. },
  10. exporting: {
  11. enabled: false,
  12. },
  13. //默认颜色配置
  14. colors:['#00f','#f00','#999','#000','#7cb5ec', '#90ed7d', '#f7a35c', '#8085e9',
  15. '#f15c80', '#e4d354', '#2b908f', '#f45b5b', '#91e8e1'],
  16. //版权信息
  17. credits: {enabled:false},
  18. //数据列通用配置
  19. plotOptions: {
  20. series: {
  21. turboThreshold: 0, //不限制数据点个数
  22. dataGrouping: {
  23. enabled: false,
  24. },//取消数据大自动数据合并
  25. animation: {
  26. duration: 1000
  27. }
  28. },
  29. areaspline: {
  30. lineWidth: 1,
  31. stacking: 'normal',
  32. marker: {
  33. enabled: false,
  34. },
  35. // fillOpacity: 0.5,
  36. },
  37. column:{
  38. pointPadding: 0.05,
  39. stacking: 'normal',
  40. },
  41. scatter: {
  42. turboThreshold: 0,
  43. marker: {
  44. symbol: 'circle',
  45. radius: 5,
  46. states: {
  47. hover: {
  48. enabled: true,
  49. }
  50. }
  51. },
  52. states: {
  53. hover: {
  54. marker: {
  55. enabled: true
  56. }
  57. }
  58. },
  59. }
  60. },
  61. //范围选择器
  62. rangeSelector: {
  63. enabled: false,
  64. selected: 2,
  65. },
  66. //悬浮提示框
  67. tooltip: {
  68. split: false,
  69. shared: true,
  70. dateTimeLabelFormats: {
  71. // 时间格式化字符
  72. day: '%Y/%m/%d',
  73. week: "%Y/%m",
  74. month: '%Y/%m',
  75. year: '%Y/%m',
  76. },
  77. xDateFormat:'%Y/%m/%d',
  78. // valueDecimals: 4,
  79. },
  80. //图例
  81. legend: {
  82. enabled: true,
  83. verticalAlign: 'top',
  84. margin:12,
  85. itemMarginBottom:0,
  86. itemMarginTop: 0
  87. // layout: 'vertical'
  88. },
  89. //滚动条
  90. scrollbar: {
  91. enabled: false,
  92. },
  93. //导航器
  94. navigator: {
  95. enabled: false,
  96. },
  97. //范围选择器
  98. rangeSelector: {
  99. enabled: false,
  100. },
  101. xAxis: {
  102. tickPosition: 'inside',
  103. lineColor: '#bfbfbf',
  104. tickColor: '#bfbfbf',
  105. tickLength:5,
  106. type: 'datetime',
  107. ordinal: false,
  108. dateTimeLabelFormats: {
  109. day: '%y/%m',
  110. week: '%y/%m',
  111. month: '%y/%m',
  112. year: '%y/%m',
  113. }
  114. // gridLineWidth:0
  115. }
  116. };
  117. /* 图表分类弹窗校验 */
  118. export const formRules = {
  119. level_1:[
  120. { required: true, message: /* '分类名称不能为空' */bus.$i18nt.t('Chart.Vailds.classify_msg'), trigger: 'blur' },
  121. ],
  122. level_2:[
  123. { required: true, message: /* '分类名称不能为空' */bus.$i18nt.t('Chart.Vailds.classify_msg'), trigger: 'blur' },
  124. ],
  125. level_3:[
  126. { required: true, message: /* '分类名称不能为空' */bus.$i18nt.t('Chart.Vailds.classify_msg'), trigger: 'blur' },
  127. ],
  128. level_4:[
  129. { required: true, message: /* '图表名称不能为空' */bus.$i18nt.t('Chart.Vailds.name_msg'), trigger: 'blur' },
  130. ],
  131. level_menu:[
  132. { required: true, message: /* '图表分类不能为空' */bus.$i18nt.t('Chart.Vailds.classify_msg'), trigger: 'blur' },
  133. ],
  134. }
  135. /* 添加图表表单校验 */
  136. export const chartRules = {
  137. style:[
  138. { required: true, message: '生成样式不能为空', trigger: 'blur' },
  139. ],
  140. name:[
  141. { required: true, message: '图表名称不能为空', trigger: 'blur' },
  142. ],
  143. classify:[
  144. { required: true, message: '图表分类不能为空', trigger: 'blur' },
  145. ],
  146. }
  147. /* 公用指标单位 */
  148. export const unitArr = [
  149. '无',
  150. '万吨',
  151. '亿元',
  152. '元',
  153. '元/吨',
  154. '元/湿吨',
  155. '千克',
  156. '吨',
  157. '短吨',
  158. '美元/吨',
  159. '万平方米',
  160. '美元/桶',
  161. '美分/加仑',
  162. '手'
  163. ]
  164. /* 季节性图配置 */
  165. export const seasonOptions = {
  166. //默认颜色配置
  167. /* '#4B0082','#7FFFAA','#FF4500','#808000','#EEE8AA', */
  168. colors:['#849EC1','#8A4294','#578B5A','#FDA8C7','#53B3FF','#999999','#000000','#FFDF0C','#FF0000','#0033FF'],
  169. yAxis: {
  170. lineWidth: 1,
  171. lineColor: '#bfbfbf',
  172. tickColor: '#bfbfbf',
  173. // offset: 0,
  174. opposite: false,
  175. reversed: false,
  176. visible: true,
  177. gridLineWidth: 0,
  178. tickWidth: 1,
  179. tickLength:5,
  180. tickPosition: 'inside',
  181. endOnTick: false,
  182. startOnTick: false,
  183. showLastLabel: true, //显示最后刻度值
  184. tickPixelInterval: 50
  185. }
  186. }
  187. /* 散点图颜色 */
  188. export const scatterColorsOptions = [ 'rgba(119, 152, 191, .5)','rgba(223, 83, 83, .5)' ]
  189. /* 复制图片额外option */
  190. export const copyOtherOptions = {
  191. legend: {
  192. align: 'center',
  193. layout: 'horizontal',
  194. itemStyle: {
  195. fontSize: "14px",
  196. color: '#444',
  197. textOverflow:undefined
  198. },
  199. itemMarginBottom:0,
  200. itemDistance: 0,
  201. padding: 0,
  202. margin: 10
  203. },
  204. seasonLegend:{
  205. align: 'center',
  206. layout: 'horizontal',
  207. itemStyle: {
  208. fontSize: "14px",
  209. color: '#444',
  210. }
  211. }
  212. }
  213. /* 图表年份筛选框 */
  214. export const yearSelector = [
  215. {
  216. name: bus.$i18nt?bus.$i18nt.t('Chart.since_onefive'):'15年至今',//'15年至今'
  217. value: 3,
  218. },
  219. // // {
  220. // // name: '18年至今',
  221. // // value: 7,
  222. // // },
  223. // // {
  224. // // name: '19年至今',
  225. // // value: 8,
  226. // // },
  227. {
  228. name: bus.$i18nt?bus.$i18nt.t('Chart.since_twozero'):'20年至今',//'20年至今'
  229. value: 9,
  230. },
  231. {
  232. name: bus.$i18nt?bus.$i18nt.t('Chart.since_twoone'):'21年至今',//'21年至今'
  233. value: 4,
  234. },
  235. {
  236. name: bus.$i18nt?bus.$i18nt.t('Chart.since_twotwo'):'22年至今',//'22年至今'
  237. value: 11,
  238. },
  239. ]
  240. export const browser = () => {
  241. // 取得浏览器的userAgent字符串
  242. var userAgent = navigator.userAgent
  243. // 判断是否Opera浏览器
  244. var isOpera = userAgent.indexOf('Opera') > -1
  245. // 判断是否IE浏览器
  246. var isIE =
  247. userAgent.indexOf('compatible') > -1 &&
  248. userAgent.indexOf('MSIE') > -1 &&
  249. !isOpera
  250. // 判断是否IE的Edge浏览器
  251. var isEdge = userAgent.indexOf('Edge') > -1
  252. // 判断是否Firefox浏览器
  253. var isFF = userAgent.indexOf('Firefox') > -1
  254. // 判断是否Safari浏览器
  255. var isSafari =
  256. userAgent.indexOf('Safari') > -1 && userAgent.indexOf('Chrome') === -1
  257. // 判断Chrome浏览器
  258. var isChrome =
  259. userAgent.indexOf('Chrome') > -1 && userAgent.indexOf('Safari') > -1
  260. if (isIE) {
  261. var reIE = new RegExp('MSIE (\\d+\\.\\d+);')
  262. reIE.test(userAgent)
  263. var fIEVersion = parseFloat(RegExp['$1'])
  264. if (fIEVersion === 7) {
  265. return 'IE7'
  266. } else if (fIEVersion === 8) {
  267. return 'IE8'
  268. } else if (fIEVersion === 9) {
  269. return 'IE9'
  270. } else if (fIEVersion === 10) {
  271. return 'IE10'
  272. } else if (fIEVersion === 11) {
  273. return 'IE11'
  274. } else {
  275. return 'IE'
  276. }
  277. }else if (isOpera) {
  278. return 'Opera'
  279. }else if (isEdge) {
  280. return 'Edge'
  281. }else if (isFF) {
  282. return 'FF'
  283. }else if (isSafari) {
  284. return 'Safari'
  285. }else if (isChrome) {
  286. return 'Chrome'
  287. }else {
  288. return ''
  289. }
  290. }
  291. // 判断设备
  292. export const getTerminal = () => {
  293. // 获取终端的相关信息
  294. var Terminal = {
  295. // 辨别移动终端类型
  296. platform: function () {
  297. var u = navigator.userAgent,
  298. app = navigator.appVersion;
  299. return {
  300. // android终端或者uc浏览器
  301. android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1,
  302. // 是否为iPhone或者QQHD浏览器
  303. iPhone: u.indexOf('iPhone') > -1,
  304. // 是否iPad
  305. iPad: u.indexOf('iPad') > -1
  306. };
  307. }()
  308. }
  309. // 根据不同的终端,跳转到不同的地址
  310. if (Terminal.platform.android) {
  311. return 'android';
  312. } else if (Terminal.platform.iPhone || Terminal.platform.iPad) {
  313. return 'ios';
  314. }
  315. }