chartsCom.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. let colors = Cfg.colorData[Cfg.colors];
  2. let c_axisLine = 'rgba(76,180,231,0.33)';
  3. let c_bg_bar = 'rgba(76,180,231,0.15)';
  4. //所有图表的公共属性
  5. let com_charts = {
  6. color: colors,
  7. grid: {
  8. top: '25%',
  9. bottom: '10%'
  10. },
  11. textStyle: {
  12. fontFamily: 'PingFang SC, sans-serif',
  13. fontSize: 10 * scale
  14. },
  15. legend: {
  16. itemWidth: 20 * scale,
  17. itemHeight: 10 * scale,
  18. inactiveColor: '#666',
  19. lineHeight: 10 * scale,
  20. textStyle: {
  21. color: colors[0],
  22. fontSize: 16 * scale,
  23. }
  24. },
  25. tooltip: {
  26. textStyle: {
  27. fontSize: 16 * scale,
  28. color: colors[0]
  29. },
  30. },
  31. };
  32. //直角坐标系坐标轴
  33. let com_axis = {
  34. axisLabel: { //标签名称
  35. color: colors[0],
  36. margin: 8 * scale,
  37. fontSize: 16 * scale,
  38. },
  39. nameTextStyle: { //坐标轴名称
  40. color: colors[0],
  41. fontSize: 18 * scale
  42. },
  43. nameGap: 16 * scale, //坐标轴名称距离
  44. axisTick: { //小刻度线
  45. show: false
  46. },
  47. axisLine: { //坐标轴
  48. show: true,
  49. lineStyle: {
  50. color: c_axisLine
  51. }
  52. },
  53. splitLine: { //分割线
  54. show: false,
  55. lineStyle:{
  56. color:['rgba(255,255,255,.63)', 'rgba(255,255,255,.33)'],
  57. type:'dashed'
  58. }
  59. },
  60. boundaryGap: false
  61. };
  62. //折线图公共属性
  63. let opt_line = $.extend(true, {}, com_charts, {
  64. xAxis: $.extend(true, {}, com_axis, {
  65. type: 'category',
  66. }),
  67. yAxis: $.extend(true, {}, com_axis, {
  68. type: 'value',
  69. }),
  70. //这里写此类图表其他属性
  71. tooltip: {
  72. trigger: 'axis',
  73. },
  74. });
  75. let seri_line = {
  76. type: 'line',
  77. smooth: true,
  78. lineStyle: {
  79. width: 1.5 * scale,
  80. shadowColor: 'rgba(255,255,255,0.4)', //线条外发光
  81. shadowBlur: 1.5 * scale,
  82. },
  83. };
  84. let seri_area = $.extend(true, {}, seri_line, {
  85. areaStyle: {
  86. color: {
  87. x: 0,
  88. y: 0,
  89. x2: 0,
  90. y2: 1,
  91. colorStops: [{
  92. offset: 0, color: colors[0] // 0% 处的颜色
  93. }, {
  94. offset: 1, color: 'transparent' // 100% 处的颜色
  95. }]
  96. }
  97. }
  98. });
  99. // let opt_area = $.extend(true, {}, com_charts,opt_line)
  100. //横条图公共属性
  101. let opt_bar_h = $.extend(true, {}, com_charts, {
  102. xAxis: $.extend(true, {}, com_axis, {
  103. type: 'value'
  104. }),
  105. yAxis: $.extend(true, {}, com_axis, {
  106. boundaryGap: true,
  107. type: 'category'
  108. }),
  109. });
  110. let seri_bar_h = {
  111. type: 'bar',
  112. };
  113. //竖条图公共属性
  114. let opt_bar_v = $.extend(true, {}, com_charts, {
  115. xAxis: $.extend(true, {}, com_axis, {
  116. boundaryGap: true,
  117. type: 'category'
  118. }),
  119. yAxis: $.extend(true, {}, com_axis, {
  120. type: 'value'
  121. }),
  122. tooltip: {
  123. trigger: 'axis',
  124. }
  125. //这里写此类图表其他属性
  126. });
  127. let seri_bar_v = {
  128. type: 'bar',
  129. barWidth: '60%'
  130. };
  131. //圆环图 series里的属性设置
  132. let circle_series_label = {
  133. normal: {
  134. show: true,
  135. fontSize: 12 * scale
  136. },
  137. emphasis: {
  138. show: true,
  139. textStyle: {
  140. fontSize: 15 * scale,
  141. fontWeight: 'normal'
  142. }
  143. }
  144. };
  145. //竖柱条组合图公共属性
  146. let com_lineBar_vertical = $.extend(true, {}, com_charts, {
  147. xAxis: $.extend(true, {}, com_axis, {
  148. boundaryGap: true,
  149. type: 'category'
  150. }),
  151. yAxis: [
  152. {
  153. min: 0,
  154. max: 250,
  155. interval: 50,
  156. },
  157. {
  158. min: 0,
  159. max: 25,
  160. interval: 5,
  161. axisLine: { //y轴
  162. show: false
  163. },
  164. axisTick: { //y轴刻度线
  165. show: false
  166. },
  167. splitLine: { //网格线
  168. show: false
  169. }
  170. }
  171. ].map(function (item, index) {
  172. return $.extend(true, {type: 'value'}, com_axis, item);
  173. }),
  174. legend: {
  175. show: true,
  176. x: 'right',
  177. y: 'top',
  178. },
  179. tooltip: {
  180. trigger: 'axis',
  181. backgroundColor: 'rgba(0,51,124,0.8)',
  182. axisPointer: {
  183. type: 'shadow',
  184. shadowStyle: {
  185. color: "rgba(6,88,255,0.1)",
  186. }
  187. },
  188. textStyle: {
  189. fontSize: 16 * scale,
  190. color: '#fff'
  191. },
  192. },
  193. //这里写此类图表其他属性*/
  194. });
  195. let com_lineBarSeries = {
  196. type: 'bar',
  197. barGap: 0,
  198. barWidth: '30%',
  199. itemStyle: {
  200. normal: {
  201. color: new echarts.graphic.LinearGradient(
  202. 0, 0, 0, 1,
  203. [
  204. {offset: 1, color: '#227cff'},
  205. {offset: 0, color: '#2377fe'}
  206. ]
  207. )
  208. }
  209. },
  210. };
  211. let com_circleSeries = {
  212. type: 'pie',
  213. radius: ['45%', '65%'],
  214. }
  215. //散点图公共属性
  216. let opt_scatter = $.extend(true, {}, com_charts, {
  217. xAxis: $.extend(true, {}, com_axis, {
  218. type: 'category'
  219. }),
  220. yAxis: $.extend(true, {}, com_axis, {
  221. type: 'category'
  222. }),
  223. //这里写此类图表其他属性
  224. });
  225. //雷达图公共属性
  226. let opt_radar = $.extend(true, {}, {
  227. legend: {
  228. itemWidth: 7 * scale,
  229. itemHeight: 7 * scale,
  230. textStyle: {
  231. fontSize: 12 * scale,
  232. },
  233. top: '2%',
  234. left: 'right',
  235. orient: 'vertical'
  236. },
  237. tooltip: {
  238. axisPointer: {
  239. label: {
  240. backgroundColor: '#6a7985'
  241. }
  242. },
  243. textStyle: {
  244. align: 'left',
  245. fontFamily: 'PingFang SC, sans-serif',
  246. // fontSize: 15 * scale
  247. }
  248. },
  249. radar: {
  250. center: ['50%', '58%'],
  251. // shape: 'circle',
  252. name: {
  253. textStyle: {
  254. color: '#0cf',
  255. fontSize: 12 * scale
  256. // backgroundColor: '#999',
  257. // borderRadius: 3,
  258. // padding: [3, 5]
  259. }
  260. },
  261. splitArea: {
  262. areaStyle: {
  263. color: 'rgba(0,0,0,0)'
  264. }
  265. },
  266. axisLine: {
  267. lineStyle: {
  268. color: '#0cf'
  269. }
  270. },
  271. splitLine: {
  272. lineStyle: {
  273. color: '#0cf'
  274. }
  275. }
  276. },
  277. });
  278. //饼图公共属性
  279. let opt_pie = $.extend(true, {}, com_charts, {});
  280. let seri_pie = $.extend(true, {}, com_charts, {
  281. type: 'pie',
  282. radius: '60%',
  283. center: ['50%', '55%'],
  284. label: {
  285. fontSize: 16 * scale
  286. },
  287. });
  288. let seri_circle = $.extend(true, {}, com_charts, seri_pie, {
  289. radius: ['20%', '60%'],
  290. });
  291. function scatterSymbolSize(data) {
  292. return Math.sqrt(data[2]) * scale / 2;
  293. }
  294. function lineAreaStyle(index) {
  295. return {
  296. color: {
  297. x: 0,
  298. y: 0,
  299. x2: 0,
  300. y2: 1,
  301. colorStops: [{
  302. offset: 0, color: colors[index] // 0% 处的颜色
  303. }, {
  304. offset: 1, color: '#00adef11' // 100% 处的颜色
  305. }]
  306. }
  307. }
  308. }
  309. /*
  310. * 首页中所有表的公共属性。
  311. *
  312. * */