defaultOptions.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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 frequencySelectList = (filterArr=[])=>{
  166. return [
  167. {
  168. value:'日度',
  169. label:bus.$i18nt.t('Edb.FreAll.day')
  170. },
  171. {
  172. value:'周度',
  173. label:bus.$i18nt.t('Edb.FreAll.week')
  174. },
  175. {
  176. value:'旬度',
  177. label:bus.$i18nt.t('Edb.FreAll.dekad')
  178. },
  179. {
  180. value:'月度',
  181. label:bus.$i18nt.t('Edb.FreAll.month')
  182. },
  183. {
  184. value:'季度',
  185. label:bus.$i18nt.t('Edb.FreAll.quarter')
  186. },
  187. {
  188. value:'半年度',
  189. label:bus.$i18nt.t('Edb.FreAll.half_year')
  190. },
  191. {
  192. value:'年度',
  193. label:bus.$i18nt.t('Edb.FreAll.year')
  194. }
  195. ].filter((i)=>{return !filterArr.includes(i.value)})
  196. }
  197. //单位筛选框,支持中英文,支持过滤筛选项
  198. export const unitSelectList = (filterArr=[])=>{
  199. return [
  200. {value:'无',label:bus.$i18nt.t('Edb.UnitAll.u_null')},
  201. {value:'万吨',label:bus.$i18nt.t('Edb.UnitAll.wanton')},
  202. {value:'亿元',label:bus.$i18nt.t('Edb.UnitAll.u_bill')},
  203. {value:'元',label:bus.$i18nt.t('Edb.UnitAll.u_yuan')},
  204. {value:'元/吨',label:bus.$i18nt.t('Edb.UnitAll.yuan_ton')},
  205. {value:'元/湿吨',label:bus.$i18nt.t('Edb.UnitAll.yuan_wetton')},
  206. {value:'千克',label:bus.$i18nt.t('Edb.UnitAll.u_kg')},
  207. {value:'吨',label:bus.$i18nt.t('Edb.UnitAll.u_ton')},
  208. {value:'短吨',label:bus.$i18nt.t('Edb.UnitAll.short_ton')},
  209. {value:'美元/吨',label:bus.$i18nt.t('Edb.UnitAll.doll_ton')},
  210. {value:'万平方千米',label:bus.$i18nt.t('Edb.UnitAll.wan_skilo')},
  211. {value:'美元/桶',label:bus.$i18nt.t('Edb.UnitAll.doll_bar')},
  212. {value:'美分/加仑',label:bus.$i18nt.t('Edb.UnitAll.cent_gal')},
  213. {value:'手',label:bus.$i18nt.t('Edb.UnitAll.u_hand')},
  214. ].filter((i)=>{return !filterArr.includes(i.value)})
  215. }
  216. /* 季节性图配置 */
  217. export const seasonOptions = {
  218. //默认颜色配置
  219. /* '#4B0082','#7FFFAA','#FF4500','#808000','#EEE8AA', */
  220. colors:['#849EC1','#8A4294','#578B5A','#FDA8C7','#53B3FF','#999999','#000000','#FFDF0C','#FF0000','#0033FF'],
  221. yAxis: {
  222. lineWidth: 1,
  223. lineColor: '#bfbfbf',
  224. tickColor: '#bfbfbf',
  225. // offset: 0,
  226. opposite: false,
  227. reversed: false,
  228. visible: true,
  229. gridLineWidth: 0,
  230. tickWidth: 1,
  231. tickLength:5,
  232. tickPosition: 'inside',
  233. endOnTick: false,
  234. startOnTick: false,
  235. showLastLabel: true, //显示最后刻度值
  236. tickPixelInterval: 50
  237. }
  238. }
  239. /* 散点图颜色 */
  240. export const scatterColorsOptions = [ 'rgba(119, 152, 191, .5)','rgba(223, 83, 83, .5)' ]
  241. /* 复制图片额外option */
  242. export const copyOtherOptions = {
  243. legend: {
  244. align: 'center',
  245. layout: 'horizontal',
  246. itemStyle: {
  247. fontSize: "14px",
  248. color: '#444',
  249. textOverflow:undefined
  250. },
  251. itemMarginBottom:0,
  252. itemDistance: 0,
  253. padding: 0,
  254. margin: 10
  255. },
  256. seasonLegend:{
  257. align: 'center',
  258. layout: 'horizontal',
  259. itemStyle: {
  260. fontSize: "14px",
  261. color: '#444',
  262. }
  263. }
  264. }
  265. /* 图表年份筛选框 */
  266. export const yearSelector = [
  267. {
  268. name: bus.$i18nt?bus.$i18nt.t('Chart.since_onefive'):'15年至今',//'15年至今'
  269. value: 3,
  270. },
  271. // // {
  272. // // name: '18年至今',
  273. // // value: 7,
  274. // // },
  275. // // {
  276. // // name: '19年至今',
  277. // // value: 8,
  278. // // },
  279. {
  280. name: bus.$i18nt?bus.$i18nt.t('Chart.since_twozero'):'20年至今',//'20年至今'
  281. value: 9,
  282. },
  283. {
  284. name: bus.$i18nt?bus.$i18nt.t('Chart.since_twoone'):'21年至今',//'21年至今'
  285. value: 4,
  286. },
  287. {
  288. name: bus.$i18nt?bus.$i18nt.t('Chart.since_twotwo'):'22年至今',//'22年至今'
  289. value: 11,
  290. },
  291. ]
  292. export const browser = () => {
  293. // 取得浏览器的userAgent字符串
  294. var userAgent = navigator.userAgent
  295. // 判断是否Opera浏览器
  296. var isOpera = userAgent.indexOf('Opera') > -1
  297. // 判断是否IE浏览器
  298. var isIE =
  299. userAgent.indexOf('compatible') > -1 &&
  300. userAgent.indexOf('MSIE') > -1 &&
  301. !isOpera
  302. // 判断是否IE的Edge浏览器
  303. var isEdge = userAgent.indexOf('Edge') > -1
  304. // 判断是否Firefox浏览器
  305. var isFF = userAgent.indexOf('Firefox') > -1
  306. // 判断是否Safari浏览器
  307. var isSafari =
  308. userAgent.indexOf('Safari') > -1 && userAgent.indexOf('Chrome') === -1
  309. // 判断Chrome浏览器
  310. var isChrome =
  311. userAgent.indexOf('Chrome') > -1 && userAgent.indexOf('Safari') > -1
  312. if (isIE) {
  313. var reIE = new RegExp('MSIE (\\d+\\.\\d+);')
  314. reIE.test(userAgent)
  315. var fIEVersion = parseFloat(RegExp['$1'])
  316. if (fIEVersion === 7) {
  317. return 'IE7'
  318. } else if (fIEVersion === 8) {
  319. return 'IE8'
  320. } else if (fIEVersion === 9) {
  321. return 'IE9'
  322. } else if (fIEVersion === 10) {
  323. return 'IE10'
  324. } else if (fIEVersion === 11) {
  325. return 'IE11'
  326. } else {
  327. return 'IE'
  328. }
  329. }else if (isOpera) {
  330. return 'Opera'
  331. }else if (isEdge) {
  332. return 'Edge'
  333. }else if (isFF) {
  334. return 'FF'
  335. }else if (isSafari) {
  336. return 'Safari'
  337. }else if (isChrome) {
  338. return 'Chrome'
  339. }else {
  340. return ''
  341. }
  342. }
  343. // 判断设备
  344. export const getTerminal = () => {
  345. // 获取终端的相关信息
  346. var Terminal = {
  347. // 辨别移动终端类型
  348. platform: function () {
  349. var u = navigator.userAgent,
  350. app = navigator.appVersion;
  351. return {
  352. // android终端或者uc浏览器
  353. android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1,
  354. // 是否为iPhone或者QQHD浏览器
  355. iPhone: u.indexOf('iPhone') > -1,
  356. // 是否iPad
  357. iPad: u.indexOf('iPad') > -1
  358. };
  359. }()
  360. }
  361. // 根据不同的终端,跳转到不同的地址
  362. if (Terminal.platform.android) {
  363. return 'android';
  364. } else if (Terminal.platform.iPhone || Terminal.platform.iPad) {
  365. return 'ios';
  366. }
  367. }