indexOptionChart.js 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667
  1. import { red } from 'stylus/lib/functions';
  2. //从左往右颜色渐变
  3. export const GradualChange = (color1, color2) => {
  4. return new echarts.graphic.LinearGradient(1, 0, 0, 0, [
  5. { offset: 1, color: color1 + '' },
  6. { offset: 0, color: color2 + '' || color1 + '' }
  7. ]);
  8. };
  9. export const getColor = ([color1, color2]) => {
  10. // 右 下 左 上
  11. return new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  12. { offset: 0, color: color1 + '' },
  13. { offset: 1, color: color2 + '' || color1 + '' }
  14. ]);
  15. };
  16. export const dateType = (date) => {
  17. let val = '';
  18. if (date) {
  19. val = `${date.slice(0, 4)}年${date.slice(4)}月`;
  20. } else {
  21. val = date;
  22. }
  23. return val;
  24. };
  25. //折现波浪线颜色渐变
  26. export const getItemStyle = (c1, c2) => {
  27. return {
  28. color: {
  29. type: 'linear',
  30. x: 0,
  31. y: 0,
  32. x2: 0,
  33. y2: 1,
  34. colorStops: [
  35. {
  36. offset: 0,
  37. color: c1 // 0% 处的颜色
  38. },
  39. {
  40. offset: 1,
  41. color: c2 // 100% 处的颜色
  42. }
  43. ],
  44. global: false // 缺省为 false
  45. }
  46. };
  47. };
  48. export const defaultMonth = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'];
  49. export const defaultName = ['name1', 'name2', 'name3'];
  50. const defaultColor = [
  51. GradualChange('#22D8FF', '#00B2FF'),
  52. GradualChange('#F0646C', '#F4994E'),
  53. GradualChange('#5EEDCC ', '#24C3F1'),
  54. GradualChange('#7178FF', '#D2A4FF'),
  55. GradualChange('#884DD2', '#DF63CC')
  56. ];
  57. // 饼图
  58. export const ringType = (color = [], data = [], title = {}, legendFcuntion = {}) => {
  59. let legendFcuntionValue = (v) => {
  60. let val = '';
  61. data.map((item) => {
  62. if (item.name == v) {
  63. if (legendFcuntion.type == '%') {
  64. val = `{a|${v}} · · · · · · {b|${parseInt((item.value / legendFcuntion.total).toFixed(2) * 100) || 0}%}`;
  65. } else {
  66. val = `{a|${v}} · · · · · · {b|${item.value}}`;
  67. }
  68. }
  69. });
  70. return val;
  71. };
  72. return {
  73. tooltip: {
  74. trigger: 'item'
  75. },
  76. legend: {
  77. orient: 'vertical',
  78. right: 10,
  79. top: 80,
  80. itemGap: 10,
  81. itemWidth: 12, // 图例图形宽度
  82. itemHeight: 8,
  83. type: 'scroll',
  84. formatter: (v) => {
  85. return legendFcuntionValue(v);
  86. },
  87. textStyle: {
  88. rich: {
  89. a: {
  90. fontSize: 12,
  91. color: '#858892',
  92. padding: [0, 5, 0, 0]
  93. },
  94. b: {
  95. fontSize: 14,
  96. color: '#fff',
  97. padding: [0, 0, 0, 5]
  98. }
  99. }
  100. }
  101. },
  102. title,
  103. color: !!color.length ? color : defaultColor,
  104. series: [
  105. {
  106. type: 'pie',
  107. radius: ['55%', '70%'],
  108. avoidLabelOverlap: false,
  109. center: ['25%', '50%'],
  110. label: {
  111. show: false,
  112. position: 'center'
  113. },
  114. labelLine: {
  115. show: false
  116. },
  117. data: data
  118. }
  119. ]
  120. };
  121. };
  122. // 折现波浪
  123. export const discountedWave = (name = '', xAxis = [], series = [], legendShow = false, color = []) => {
  124. let option = {
  125. tooltip: {
  126. trigger: 'axis',
  127. textStyle: {
  128. fontSize: 12,
  129. color: '#FFFFFF'
  130. }
  131. // formatter(param) {
  132. // let el = `<div class="dmp-echart-tooltip"><h4>${dateType(param[0].axisValue)}</h4>`;
  133. // param.forEach(item => {
  134. // el += `<p>
  135. // <span class="marker" style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-image: linear-gradient(to left,
  136. // ${item.color.colorStops[0].color}, ${item.color.colorStops[1].color});"></span>
  137. // <span>${item.seriesName}:${item.value}</span>
  138. // </p>`;
  139. // });
  140. // el += `</div>`;
  141. // return el;
  142. // }
  143. },
  144. grid: {
  145. top: 50,
  146. left: 5,
  147. bottom: 0,
  148. right: 5,
  149. containLabel: true
  150. },
  151. legend: {
  152. show: legendShow,
  153. icon: 'circle',
  154. x: 'right', // 可设定图例在左、右、居中
  155. itemWidth: 8, // 图例图形宽度
  156. itemHeight: 8,
  157. itemGap: 20
  158. },
  159. xAxis: {
  160. type: 'category',
  161. axisLine: {
  162. show: false // 不显示坐标轴
  163. },
  164. axisTick: {
  165. show: false // 不显示坐标轴刻度
  166. },
  167. axisLabel: {
  168. formatter: function (params, index) {
  169. return params.slice(5);
  170. },
  171. color: '#9B9DA5',
  172. margin: 16
  173. },
  174. data: xAxis,
  175. axisPointer: {
  176. type: 'shadow',
  177. shadowStyle: {
  178. color: {
  179. type: 'linear',
  180. x: 0,
  181. y: 0,
  182. x2: 0,
  183. y2: 1,
  184. colorStops: [
  185. {
  186. offset: 0,
  187. color: 'rgba(31,207,245,0)' // 0% 处的颜色
  188. },
  189. {
  190. offset: 0.8,
  191. color: 'rgba(31,207,245,0.15)' // 100% 处的颜色
  192. },
  193. {
  194. offset: 0.2,
  195. color: 'rgba(31,207,245,0.15)' // 100% 处的颜色
  196. },
  197. {
  198. offset: 1,
  199. color: 'rgba(31,207,245,0.05)'
  200. }
  201. ],
  202. global: false // 缺省为 false
  203. }
  204. }
  205. }
  206. },
  207. yAxis: {
  208. type: 'value',
  209. splitNumber: 4,
  210. axisLine: {
  211. show: false
  212. },
  213. name: name,
  214. axisTick: {
  215. show: false
  216. },
  217. axisLabel: {
  218. color: '#9B9DA5',
  219. margin: 15,
  220. textStyle: {
  221. align: 'right',
  222. baseline: 'middle'
  223. }
  224. },
  225. nameLocation: 'end',
  226. nameTextStyle: { color: '#9B9DA5', padding: [0, 0, 0, -40] },
  227. splitLine: {
  228. lineStyle: {
  229. type: 'dotted',
  230. width: 0.2
  231. }
  232. }
  233. },
  234. series: [
  235. {
  236. // name: "设备告警",
  237. type: 'line',
  238. smooth: true,
  239. symbol: 'circle', // 实心
  240. symbolSize: 1, // 设定实心点的大小
  241. itemStyle: getItemStyle('#5EEDCC', '#24C3F1'),
  242. data: series,
  243. areaStyle: {
  244. normal: {
  245. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  246. {
  247. offset: 0,
  248. color: 'rgba(36,121,253,0.1)'
  249. },
  250. {
  251. offset: 1,
  252. color: 'rgba(19,194,247,0.3)'
  253. }
  254. ])
  255. }
  256. },
  257. lineStyle: {
  258. width: 1
  259. }
  260. }
  261. ]
  262. };
  263. return option;
  264. };
  265. //柱状日期
  266. export const columnOptionsChart = (name = '', xAxis = [], series = [], color = [], barWidth = 6) => {
  267. let defaultData = [
  268. {
  269. name: '',
  270. type: 'bar',
  271. data: []
  272. }
  273. ];
  274. let defaultColor = [
  275. ['#0EAEFF', '#85E9FF'],
  276. ['#F0646C', '#F4994E']
  277. ];
  278. let seriesConfiguration = () => {
  279. let seriesData = [];
  280. series.map((item, index) => {
  281. seriesData.push({
  282. name: item.name,
  283. type: 'bar',
  284. data: item.data,
  285. barWidth: barWidth,
  286. itemStyle: {
  287. normal: {
  288. barBorderRadius: [15, 15, 0, 0],
  289. color: getColor(color[index] || defaultColor[index])
  290. }
  291. },
  292. barGap: '100%'
  293. });
  294. });
  295. return seriesData;
  296. };
  297. let option = {
  298. tooltip: {
  299. trigger: 'axis',
  300. axisPointer: {
  301. type: 'shadow',
  302. shadowStyle: {
  303. color: {
  304. type: 'linear',
  305. x: 0,
  306. y: 0,
  307. x2: 0,
  308. y2: 1,
  309. colorStops: [
  310. {
  311. offset: 0,
  312. color: 'rgba(31,207,245,0)' // 0% 处的颜色
  313. },
  314. {
  315. offset: 0.8,
  316. color: 'rgba(31,207,245,0.15)' // 100% 处的颜色
  317. },
  318. {
  319. offset: 0.2,
  320. color: 'rgba(31,207,245,0.15)' // 100% 处的颜色
  321. },
  322. {
  323. offset: 1,
  324. color: 'rgba(31,207,245,0.05)'
  325. }
  326. ],
  327. global: false // 缺省为 false
  328. }
  329. },
  330. crossStyle: {
  331. shadowBlur: 30,
  332. shadowColor: 'rgba(0, 0, 0, 0.5)'
  333. }
  334. },
  335. extraCssText: 'background:rgba(33,40,56,0.6);border-radius:4px;padding:6px 10px',
  336. textStyle: {
  337. fontSize: 12,
  338. color: '#FFFFFF'
  339. },
  340. formatter(param) {
  341. let el = `<div class="dmp-echart-tooltip" style="text-align: center;"><h4>${dateType(param[0].axisValue)}</h4>`;
  342. param.forEach((item) => {
  343. el += `<p style="text-align: left;">
  344. <span style="display:inline-block;margin-right:5px;border-radius:4px;width:12px;height:8px;background-image: linear-gradient(to left,
  345. ${item.color.colorStops[0].color}, ${item.color.colorStops[1].color})"></span>
  346. <span>${item.seriesName}:${item.value.toFixed(2)}</span>
  347. </p>`;
  348. });
  349. el += `</div>`;
  350. return el;
  351. }
  352. },
  353. grid: {
  354. top: 50,
  355. left: 0,
  356. bottom: 0,
  357. right: 0,
  358. containLabel: true
  359. },
  360. xAxis: {
  361. type: 'category',
  362. axisLine: {
  363. show: false // 不显示坐标轴
  364. },
  365. axisTick: {
  366. show: false // 不显示坐标轴刻度
  367. },
  368. axisLabel: {
  369. formatter: function (params, index) {
  370. if (params.length == 2) {
  371. return params + '月';
  372. } else {
  373. return params.slice(5) + '月';
  374. }
  375. },
  376. color: '#9B9DA5',
  377. margin: 15
  378. },
  379. data: !!xAxis.length ? xAxis : defaultMonth
  380. },
  381. yAxis: {
  382. type: 'value',
  383. splitNumber: 4,
  384. name: name,
  385. axisLine: {
  386. show: false
  387. },
  388. axisTick: {
  389. show: false
  390. },
  391. axisLabel: {
  392. color: '#9B9DA5',
  393. margin: 15,
  394. textStyle: {
  395. align: 'right',
  396. baseline: 'middle'
  397. }
  398. },
  399. nameLocation: 'end',
  400. nameTextStyle: { color: '#9B9DA5', padding: [0, 0, 0, -40] },
  401. splitLine: {
  402. lineStyle: {
  403. type: 'dotted',
  404. width: 0.5
  405. }
  406. }
  407. },
  408. legend: {
  409. show: false,
  410. x: 'right',
  411. icon: 'circle',
  412. itemWidth: 8, // 图例图形宽度
  413. itemHeight: 8,
  414. itemGap: 20
  415. },
  416. series: seriesConfiguration() || defaultData
  417. };
  418. return option;
  419. };
  420. //柱状name 单柱状
  421. export const columnOptionsChartName = (name = '', xAxis = [], series = [], color = [], barWidth = 6) => {
  422. let defaultData = [
  423. {
  424. name: '',
  425. type: 'bar',
  426. data: []
  427. }
  428. ];
  429. let defaultColor = [
  430. ['#0EAEFF', '#85E9FF'],
  431. ['#F0646C', '#F4994E']
  432. ];
  433. let seriesConfiguration = () => {
  434. let seriesData = [
  435. {
  436. type: 'bar',
  437. data: [],
  438. barWidth: barWidth,
  439. itemStyle: {
  440. normal: {
  441. barBorderRadius: [15, 15, 0, 0],
  442. color: getColor(color[0] || defaultColor[0])
  443. }
  444. },
  445. barGap: '100%'
  446. }
  447. ];
  448. series.map((item, index) => {
  449. seriesData[0].data.push(item.data);
  450. });
  451. return seriesData;
  452. };
  453. let option = {
  454. tooltip: {
  455. trigger: 'axis',
  456. axisPointer: {
  457. type: 'shadow',
  458. shadowStyle: {
  459. color: {
  460. type: 'linear',
  461. x: 0,
  462. y: 0,
  463. x2: 0,
  464. y2: 1,
  465. colorStops: [
  466. {
  467. offset: 0,
  468. color: 'rgba(31,207,245,0)' // 0% 处的颜色
  469. },
  470. {
  471. offset: 0.8,
  472. color: 'rgba(31,207,245,0.15)' // 100% 处的颜色
  473. },
  474. {
  475. offset: 0.2,
  476. color: 'rgba(31,207,245,0.15)' // 100% 处的颜色
  477. },
  478. {
  479. offset: 1,
  480. color: 'rgba(31,207,245,0.05)'
  481. }
  482. ],
  483. global: false // 缺省为 false
  484. }
  485. },
  486. crossStyle: {
  487. shadowBlur: 30,
  488. shadowColor: 'rgba(0, 0, 0, 0.5)'
  489. }
  490. },
  491. extraCssText: 'background:rgba(33,40,56,0.6);border-radius:4px;padding:6px 10px',
  492. textStyle: {
  493. fontSize: 12,
  494. color: '#FFFFFF'
  495. },
  496. formatter(param) {
  497. let el = ``;
  498. param.forEach((item) => {
  499. el += `<p style="text-align: left;">
  500. <span style="display:inline-block;margin-right:5px;border-radius:4px;width:12px;height:8px;background-image: linear-gradient(to left,
  501. ${item.color.colorStops[0].color}, ${item.color.colorStops[1].color})"></span>
  502. <span>${item.name}:${item.value}${name}</span>
  503. </p>`;
  504. });
  505. el += ``;
  506. return el;
  507. }
  508. },
  509. grid: {
  510. top: 50,
  511. left: 10,
  512. bottom: 0,
  513. right: 0,
  514. containLabel: true
  515. },
  516. xAxis: {
  517. type: 'category',
  518. axisLine: {
  519. show: false // 不显示坐标轴
  520. },
  521. axisTick: {
  522. show: false // 不显示坐标轴刻度
  523. },
  524. axisLabel: {
  525. // interval: 0,
  526. // rotate: 45,
  527. formatter: function (params, index) {
  528. if (params.length > 5) {
  529. return `${params.slice(0, 3)}...`;
  530. } else {
  531. return params;
  532. }
  533. // return params;
  534. },
  535. color: '#9B9DA5',
  536. margin: 15
  537. },
  538. data: !!xAxis.length ? xAxis : defaultName
  539. },
  540. yAxis: {
  541. type: 'value',
  542. splitNumber: 4,
  543. name: name,
  544. axisLine: {
  545. show: false
  546. },
  547. axisTick: {
  548. show: false
  549. },
  550. axisLabel: {
  551. color: '#9B9DA5',
  552. margin: 15,
  553. textStyle: {
  554. align: 'right',
  555. baseline: 'middle'
  556. }
  557. },
  558. nameLocation: 'end',
  559. nameTextStyle: { color: '#9B9DA5', padding: [0, 0, 0, -40] },
  560. splitLine: {
  561. lineStyle: {
  562. type: 'dotted',
  563. width: 0.5
  564. }
  565. }
  566. },
  567. legend: {
  568. show: false,
  569. x: 'right',
  570. icon: 'circle',
  571. itemWidth: 8, // 图例图形宽度
  572. itemHeight: 8,
  573. itemGap: 20
  574. },
  575. series: seriesConfiguration() || defaultData
  576. };
  577. return option;
  578. };
  579. //柱状name 单柱状 x轴倾斜
  580. export const columnOptionsChartNameTilt = (name = '', xAxis = [], series = [], color = [], barWidth = 6) => {
  581. let defaultData = [
  582. {
  583. name: '',
  584. type: 'bar',
  585. data: []
  586. }
  587. ];
  588. let defaultColor = [
  589. ['#0EAEFF', '#85E9FF'],
  590. ['#F0646C', '#F4994E']
  591. ];
  592. let seriesConfiguration = () => {
  593. let seriesData = [
  594. {
  595. type: 'bar',
  596. data: [],
  597. barWidth: barWidth,
  598. itemStyle: {
  599. normal: {
  600. barBorderRadius: [15, 15, 0, 0],
  601. color: getColor(color[0] || defaultColor[0])
  602. }
  603. },
  604. barGap: '100%'
  605. }
  606. ];
  607. series.map((item, index) => {
  608. seriesData[0].data.push(item.data);
  609. });
  610. return seriesData;
  611. };
  612. let option = {
  613. tooltip: {
  614. trigger: 'axis',
  615. axisPointer: {
  616. type: 'shadow',
  617. shadowStyle: {
  618. color: {
  619. type: 'linear',
  620. x: 0,
  621. y: 0,
  622. x2: 0,
  623. y2: 1,
  624. colorStops: [
  625. {
  626. offset: 0,
  627. color: 'rgba(31,207,245,0)' // 0% 处的颜色
  628. },
  629. {
  630. offset: 0.8,
  631. color: 'rgba(31,207,245,0.15)' // 100% 处的颜色
  632. },
  633. {
  634. offset: 0.2,
  635. color: 'rgba(31,207,245,0.15)' // 100% 处的颜色
  636. },
  637. {
  638. offset: 1,
  639. color: 'rgba(31,207,245,0.05)'
  640. }
  641. ],
  642. global: false // 缺省为 false
  643. }
  644. },
  645. crossStyle: {
  646. shadowBlur: 30,
  647. shadowColor: 'rgba(0, 0, 0, 0.5)'
  648. }
  649. },
  650. extraCssText: 'background:rgba(33,40,56,0.6);border-radius:4px;padding:6px 10px',
  651. textStyle: {
  652. fontSize: 12,
  653. color: '#FFFFFF'
  654. },
  655. formatter(param) {
  656. let el = ``;
  657. param.forEach((item) => {
  658. el += `<p style="text-align: left;">
  659. <span style="display:inline-block;margin-right:5px;border-radius:4px;width:12px;height:8px;background-image: linear-gradient(to left,
  660. ${item.color.colorStops[0].color}, ${item.color.colorStops[1].color})"></span>
  661. <span>${item.name}:${item.value}${name}</span>
  662. </p>`;
  663. });
  664. el += ``;
  665. return el;
  666. }
  667. },
  668. grid: {
  669. top: 50,
  670. left: 10,
  671. bottom: 0,
  672. right: 0,
  673. containLabel: true
  674. },
  675. xAxis: {
  676. type: 'category',
  677. axisLine: {
  678. show: false // 不显示坐标轴
  679. },
  680. axisTick: {
  681. show: false // 不显示坐标轴刻度
  682. },
  683. axisLabel: {
  684. // interval: 0,
  685. rotate: 45,
  686. formatter: function (params, index) {
  687. if (params.length > 5) {
  688. return `${params.slice(0, 3)}...`;
  689. } else {
  690. return params;
  691. }
  692. // return params;
  693. },
  694. color: '#9B9DA5',
  695. margin: 15
  696. },
  697. data: !!xAxis.length ? xAxis : defaultName
  698. },
  699. yAxis: {
  700. type: 'value',
  701. splitNumber: 4,
  702. name: name,
  703. axisLine: {
  704. show: false
  705. },
  706. axisTick: {
  707. show: false
  708. },
  709. axisLabel: {
  710. color: '#9B9DA5',
  711. margin: 15,
  712. textStyle: {
  713. align: 'right',
  714. baseline: 'middle'
  715. }
  716. },
  717. nameLocation: 'end',
  718. nameTextStyle: { color: '#9B9DA5', padding: [0, 0, 0, -40] },
  719. splitLine: {
  720. lineStyle: {
  721. type: 'dotted',
  722. width: 0.5
  723. }
  724. }
  725. },
  726. legend: {
  727. show: false,
  728. x: 'right',
  729. icon: 'circle',
  730. itemWidth: 8, // 图例图形宽度
  731. itemHeight: 8,
  732. itemGap: 20
  733. },
  734. series: seriesConfiguration() || defaultData
  735. };
  736. return option;
  737. };
  738. //柱状name 单柱状 x轴倾斜 多条提示信息
  739. export const columnOptionsChartNameTiltes = (name = '', xAxis = [], series = [], color = [], barWidth = 6, name1 = [], name2 = []) => {
  740. let defaultData = [
  741. {
  742. name: '',
  743. type: 'bar',
  744. data: []
  745. }
  746. ];
  747. let defaultColor = [
  748. ['#0EAEFF', '#85E9FF'],
  749. ['#F0646C', '#F4994E']
  750. ];
  751. let seriesConfiguration = () => {
  752. let seriesData = [
  753. {
  754. type: 'bar',
  755. data: [],
  756. barWidth: barWidth,
  757. itemStyle: {
  758. normal: {
  759. barBorderRadius: [15, 15, 0, 0],
  760. color: getColor(color[0] || defaultColor[0])
  761. }
  762. },
  763. barGap: '100%'
  764. }
  765. ];
  766. series.map((item, index) => {
  767. seriesData[0].data.push(item.data);
  768. });
  769. return seriesData;
  770. };
  771. let option = {
  772. tooltip: {
  773. trigger: 'axis',
  774. axisPointer: {
  775. type: 'shadow',
  776. shadowStyle: {
  777. color: {
  778. type: 'linear',
  779. x: 0,
  780. y: 0,
  781. x2: 0,
  782. y2: 1,
  783. colorStops: [
  784. {
  785. offset: 0,
  786. color: 'rgba(31,207,245,0)' // 0% 处的颜色
  787. },
  788. {
  789. offset: 0.8,
  790. color: 'rgba(31,207,245,0.15)' // 100% 处的颜色
  791. },
  792. {
  793. offset: 0.2,
  794. color: 'rgba(31,207,245,0.15)' // 100% 处的颜色
  795. },
  796. {
  797. offset: 1,
  798. color: 'rgba(31,207,245,0.05)'
  799. }
  800. ],
  801. global: false // 缺省为 false
  802. }
  803. },
  804. crossStyle: {
  805. shadowBlur: 30,
  806. shadowColor: 'rgba(0, 0, 0, 0.5)'
  807. }
  808. },
  809. extraCssText: 'background:rgba(33,40,56,0.6);border-radius:4px;padding:6px 10px',
  810. textStyle: {
  811. fontSize: 12,
  812. color: '#FFFFFF'
  813. },
  814. formatter(param) {
  815. let el = ``;
  816. param.forEach((item) => {
  817. // console.log(item.dataIndex);
  818. el += `
  819. <p style="text-align: left;">
  820. <span style="display:inline-block;margin-right:5px;border-radius:4px;width:12px;height:8px;background-image: linear-gradient(to left,
  821. ${item.color.colorStops[0].color}, ${item.color.colorStops[1].color})"></span>
  822. <span>${item.name}:${item.value}${name}</span>
  823. </p>
  824. <p style="text-align: left;">
  825. <span style="display:inline-block;margin-right:5px;border-radius:4px;width:12px;height:8px;background-image: linear-gradient(to left,
  826. ${item.color.colorStops[0].color}, ${item.color.colorStops[1].color})"></span>
  827. <span>所属社区:${name1[item.dataIndex]}</span>
  828. </p>
  829. <p style="text-align: left;">
  830. <span style="display:inline-block;margin-right:5px;border-radius:4px;width:12px;height:8px;background-image: linear-gradient(to left,
  831. ${item.color.colorStops[0].color}, ${item.color.colorStops[1].color})"></span>
  832. <span>时间:${name2[item.dataIndex]}</span>
  833. </p>
  834. `;
  835. });
  836. el += ``;
  837. return el;
  838. }
  839. },
  840. grid: {
  841. top: 50,
  842. left: 10,
  843. bottom: 0,
  844. right: 0,
  845. containLabel: true
  846. },
  847. xAxis: {
  848. type: 'category',
  849. axisLine: {
  850. show: false // 不显示坐标轴
  851. },
  852. axisTick: {
  853. show: false // 不显示坐标轴刻度
  854. },
  855. axisLabel: {
  856. // interval: 0,
  857. rotate: 45,
  858. formatter: function (params, index) {
  859. if (params.length > 5) {
  860. return `${params.slice(0, 3)}...`;
  861. } else {
  862. return params;
  863. }
  864. // return params;
  865. },
  866. color: '#9B9DA5',
  867. margin: 15
  868. },
  869. data: !!xAxis.length ? xAxis : defaultName
  870. },
  871. yAxis: {
  872. type: 'value',
  873. splitNumber: 4,
  874. name: name,
  875. minInterval: 1,
  876. axisLine: {
  877. show: false
  878. },
  879. axisTick: {
  880. show: false
  881. },
  882. axisLabel: {
  883. color: '#9B9DA5',
  884. margin: 15,
  885. textStyle: {
  886. align: 'right',
  887. baseline: 'middle'
  888. }
  889. },
  890. nameLocation: 'end',
  891. nameTextStyle: { color: '#9B9DA5', padding: [0, 0, 0, -40] },
  892. splitLine: {
  893. lineStyle: {
  894. type: 'dotted',
  895. width: 0.5
  896. }
  897. }
  898. },
  899. legend: {
  900. show: false,
  901. x: 'right',
  902. icon: 'circle',
  903. itemWidth: 8, // 图例图形宽度
  904. itemHeight: 8,
  905. itemGap: 20
  906. },
  907. series: seriesConfiguration() || defaultData
  908. };
  909. return option;
  910. };
  911. // 柱状图堆叠
  912. export const columnOptionsChartStacking = (name = '', xAxis = [], series = [], color = [], barWidth = 6) => {
  913. let defaultData = [
  914. {
  915. name: '',
  916. type: 'bar',
  917. data: []
  918. }
  919. ];
  920. let defaultColor = [
  921. // ['#0EAEFF', '#85E9FF'],
  922. ['#0EAEFF', '#0EAEFF'],
  923. ['#85E9FF', '#85E9FF']
  924. // ['#F0646C', '#F4994E']
  925. ];
  926. let seriesConfiguration = () => {
  927. let seriesData = [
  928. {
  929. type: 'bar',
  930. data: [],
  931. name: '',
  932. barWidth: barWidth,
  933. itemStyle: {
  934. normal: {
  935. barBorderRadius: [15, 15, 0, 0],
  936. color: getColor(color[0] || defaultColor[0])
  937. }
  938. },
  939. barGap: '100%'
  940. },
  941. {
  942. type: 'bar',
  943. data: [],
  944. name: '',
  945. barWidth: barWidth,
  946. itemStyle: {
  947. normal: {
  948. barBorderRadius: [15, 15, 0, 0],
  949. color: getColor(color[1] || defaultColor[1])
  950. }
  951. },
  952. barGap: '-100%',
  953. z: '1'
  954. }
  955. ];
  956. series.map((item, index) => {
  957. seriesData[index].data = item.data;
  958. seriesData[index].name = item.name;
  959. });
  960. return seriesData;
  961. };
  962. let option = {
  963. tooltip: {
  964. trigger: 'axis',
  965. axisPointer: {
  966. type: 'shadow',
  967. shadowStyle: {
  968. color: {
  969. type: 'linear',
  970. x: 0,
  971. y: 0,
  972. x2: 0,
  973. y2: 1,
  974. colorStops: [
  975. {
  976. offset: 0,
  977. color: 'rgba(31,207,245,0)' // 0% 处的颜色
  978. },
  979. {
  980. offset: 0.8,
  981. color: 'rgba(31,207,245,0.15)' // 100% 处的颜色
  982. },
  983. {
  984. offset: 0.2,
  985. color: 'rgba(31,207,245,0.15)' // 100% 处的颜色
  986. },
  987. {
  988. offset: 1,
  989. color: 'rgba(31,207,245,0.05)'
  990. }
  991. ],
  992. global: false // 缺省为 false
  993. }
  994. },
  995. crossStyle: {
  996. shadowBlur: 30,
  997. shadowColor: 'rgba(0, 0, 0, 0.5)'
  998. }
  999. },
  1000. extraCssText: 'background:rgba(33,40,56,0.6);border-radius:4px;padding:6px 10px',
  1001. textStyle: {
  1002. fontSize: 12,
  1003. color: '#FFFFFF'
  1004. },
  1005. formatter(param) {
  1006. let el = ``;
  1007. let elitme = ``;
  1008. param.forEach((item) => {
  1009. elitme = `<p>${item.name}</p>`;
  1010. el += `
  1011. <p style="text-align: left;">
  1012. <span style="display:inline-block;margin-right:5px;border-radius:4px;width:12px;height:8px;background-image: linear-gradient(to left,
  1013. ${item.color.colorStops[0].color}, ${item.color.colorStops[1].color})"></span>
  1014. <span>${item.seriesName}:${item.value}${name}</span>
  1015. </p>`;
  1016. });
  1017. el += ``;
  1018. return elitme + el;
  1019. }
  1020. },
  1021. grid: {
  1022. top: 50,
  1023. left: 0,
  1024. bottom: 0,
  1025. right: 0,
  1026. containLabel: true
  1027. },
  1028. xAxis: {
  1029. type: 'category',
  1030. axisLine: {
  1031. show: false // 不显示坐标轴
  1032. },
  1033. axisTick: {
  1034. show: false // 不显示坐标轴刻度
  1035. },
  1036. axisLabel: {
  1037. formatter: function (params, index) {
  1038. return params;
  1039. },
  1040. color: '#9B9DA5',
  1041. margin: 15
  1042. },
  1043. data: !!xAxis.length ? xAxis : defaultName
  1044. },
  1045. yAxis: {
  1046. type: 'value',
  1047. splitNumber: 4,
  1048. name: name,
  1049. axisLine: {
  1050. show: false
  1051. },
  1052. axisTick: {
  1053. show: false
  1054. },
  1055. axisLabel: {
  1056. color: '#9B9DA5',
  1057. margin: 15,
  1058. textStyle: {
  1059. align: 'right',
  1060. baseline: 'middle'
  1061. }
  1062. },
  1063. nameLocation: 'end',
  1064. nameTextStyle: { color: '#9B9DA5', padding: [0, 0, 0, -40] },
  1065. splitLine: {
  1066. lineStyle: {
  1067. type: 'dotted',
  1068. width: 0.5
  1069. }
  1070. }
  1071. },
  1072. legend: {
  1073. show: false,
  1074. x: 'right',
  1075. icon: 'circle',
  1076. itemWidth: 8, // 图例图形宽度
  1077. itemHeight: 8,
  1078. itemGap: 20
  1079. },
  1080. series: seriesConfiguration() || defaultData
  1081. };
  1082. return option;
  1083. };
  1084. // 折线日期 间隔4个
  1085. export const discountedChart = (name = '', xAxis = [], series = [], legendShow = false, color = []) => {
  1086. let option = {
  1087. tooltip: {
  1088. trigger: 'axis',
  1089. textStyle: {
  1090. fontSize: 12,
  1091. color: '#FFFFFF'
  1092. }
  1093. // formatter(param) {
  1094. // let el = `<div class="dmp-echart-tooltip"><h4>${dateType(param[0].axisValue)}</h4>`;
  1095. // param.forEach(item => {
  1096. // el += `<p>
  1097. // <span class="marker" style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-image: linear-gradient(to left,
  1098. // ${item.color.colorStops[0].color}, ${item.color.colorStops[1].color});"></span>
  1099. // <span>${item.seriesName}:${item.value}</span>
  1100. // </p>`;
  1101. // });
  1102. // el += `</div>`;
  1103. // return el;
  1104. // }
  1105. },
  1106. grid: {
  1107. top: 50,
  1108. left: 5,
  1109. bottom: 0,
  1110. right: 5,
  1111. containLabel: true
  1112. },
  1113. legend: {
  1114. show: legendShow,
  1115. icon: 'circle',
  1116. x: 'right', // 可设定图例在左、右、居中
  1117. itemWidth: 8, // 图例图形宽度
  1118. itemHeight: 8,
  1119. itemGap: 20
  1120. },
  1121. xAxis: {
  1122. type: 'category',
  1123. axisLine: {
  1124. show: false // 不显示坐标轴
  1125. },
  1126. axisTick: {
  1127. show: false // 不显示坐标轴刻度
  1128. },
  1129. axisLabel: {
  1130. interval: 4,
  1131. // formatter: function (params, index) {
  1132. // return params.slice(5);
  1133. // },
  1134. color: '#9B9DA5',
  1135. margin: 16
  1136. },
  1137. data: xAxis,
  1138. axisPointer: {
  1139. type: 'shadow',
  1140. shadowStyle: {
  1141. color: {
  1142. type: 'linear',
  1143. x: 0,
  1144. y: 0,
  1145. x2: 0,
  1146. y2: 1,
  1147. colorStops: [
  1148. {
  1149. offset: 0,
  1150. color: 'rgba(31,207,245,0)' // 0% 处的颜色
  1151. },
  1152. {
  1153. offset: 0.8,
  1154. color: 'rgba(31,207,245,0.15)' // 100% 处的颜色
  1155. },
  1156. {
  1157. offset: 0.2,
  1158. color: 'rgba(31,207,245,0.15)' // 100% 处的颜色
  1159. },
  1160. {
  1161. offset: 1,
  1162. color: 'rgba(31,207,245,0.05)'
  1163. }
  1164. ],
  1165. global: false // 缺省为 false
  1166. }
  1167. }
  1168. }
  1169. },
  1170. yAxis: {
  1171. type: 'value',
  1172. splitNumber: 4,
  1173. axisLine: {
  1174. show: false
  1175. },
  1176. name: name,
  1177. axisTick: {
  1178. show: false
  1179. },
  1180. axisLabel: {
  1181. color: '#9B9DA5',
  1182. margin: 15,
  1183. textStyle: {
  1184. align: 'right',
  1185. baseline: 'middle'
  1186. }
  1187. },
  1188. nameLocation: 'end',
  1189. nameTextStyle: { color: '#9B9DA5', padding: [0, 0, 0, -40] },
  1190. splitLine: {
  1191. lineStyle: {
  1192. type: 'dotted',
  1193. width: 0.2
  1194. }
  1195. }
  1196. },
  1197. series: [
  1198. {
  1199. // name: "设备告警",
  1200. type: 'line',
  1201. smooth: true,
  1202. symbol: 'circle', // 实心
  1203. symbolSize: 1, // 设定实心点的大小
  1204. itemStyle: getItemStyle('#5EEDCC', '#24C3F1'),
  1205. data: series,
  1206. areaStyle: {
  1207. normal: {
  1208. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  1209. {
  1210. offset: 0,
  1211. color: 'rgba(36,121,253,0.1)'
  1212. },
  1213. {
  1214. offset: 1,
  1215. color: 'rgba(19,194,247,0.3)'
  1216. }
  1217. ])
  1218. }
  1219. },
  1220. lineStyle: {
  1221. width: 1
  1222. }
  1223. }
  1224. ]
  1225. };
  1226. return option;
  1227. };
  1228. // 漏斗图
  1229. export const funnelChart = (dataseries = [], series = []) => {
  1230. // var colors=[['#22D8FF','#00B2FF']]
  1231. var colorList = [
  1232. {
  1233. colorStops: [
  1234. {
  1235. offset: 0,
  1236. color: '#22D8FF' // 0% 处的颜色
  1237. },
  1238. {
  1239. offset: 1,
  1240. color: '#00B2FF' // 100% 处的颜色
  1241. }
  1242. ]
  1243. },
  1244. {
  1245. colorStops: [
  1246. {
  1247. offset: 0,
  1248. color: '#5EEDCC' // 0% 处的颜色
  1249. },
  1250. {
  1251. offset: 1,
  1252. color: '#24C3F1' // 100% 处的颜色
  1253. }
  1254. ]
  1255. },
  1256. {
  1257. colorStops: [
  1258. {
  1259. offset: 0,
  1260. color: '#F0646C' // 0% 处的颜色
  1261. },
  1262. {
  1263. offset: 1,
  1264. color: '#F4994E' // 100% 处的颜色
  1265. }
  1266. ]
  1267. },
  1268. {
  1269. colorStops: [
  1270. {
  1271. offset: 0,
  1272. color: '#7178FF' // 0% 处的颜色
  1273. },
  1274. {
  1275. offset: 1,
  1276. color: '#D2A4FF ' // 100% 处的颜色
  1277. }
  1278. ]
  1279. },
  1280. {
  1281. colorStops: [
  1282. {
  1283. offset: 0,
  1284. color: '#884DD2' // 0% 处的颜色
  1285. },
  1286. {
  1287. offset: 1,
  1288. color: '#DF63CC' // 100% 处的颜色
  1289. }
  1290. ]
  1291. }
  1292. ];
  1293. let option = {
  1294. title: {
  1295. text: ''
  1296. },
  1297. // backgroundColor:'#ffffff',
  1298. color: colorList,
  1299. series: [
  1300. {
  1301. top: 0,
  1302. type: 'funnel',
  1303. left: '15%',
  1304. top: '15%',
  1305. width: '50%',
  1306. height: '85%',
  1307. gap: 0,
  1308. minSize: 50,
  1309. maxSize: 260,
  1310. label: {
  1311. show: true,
  1312. position: 'inside',
  1313. // formatter: '{d}'
  1314. formatter: function (data) {
  1315. return data.percent.toFixed(0) + '%';
  1316. },
  1317. textStyle: {
  1318. shadowOffsetX: 0,
  1319. fontSize: '14',
  1320. shadowColor: 'rgba(0, 0, 0, 0)',
  1321. color: '#FFFFFF'
  1322. }
  1323. },
  1324. data: dataseries
  1325. },
  1326. {
  1327. top: 0,
  1328. type: 'funnel',
  1329. left: '0',
  1330. width: '30%',
  1331. height: '85%',
  1332. top: '15%',
  1333. gap: 16,
  1334. z: 1,
  1335. // minSize: 50,
  1336. // maxSize: 50,
  1337. label: {
  1338. normal: {
  1339. // padding :[11,25],
  1340. formatter: function (params) {
  1341. let el = `{a|${params.name}} {b|${params.value}}`;
  1342. return el;
  1343. },
  1344. textStyle: {
  1345. rich: {
  1346. a: {
  1347. fontSize: 12,
  1348. color: '#858892',
  1349. padding: [0, 5, 0, 0]
  1350. },
  1351. b: {
  1352. fontSize: 14,
  1353. color: '#fff',
  1354. padding: [0, 0, 0, 5]
  1355. }
  1356. }
  1357. }
  1358. }
  1359. },
  1360. //右侧的百分比显示的地方
  1361. labelLine: {
  1362. show: true,
  1363. normal: {
  1364. show: false,
  1365. length: 200,
  1366. position: 'center',
  1367. lineStyle: {
  1368. width: 1,
  1369. color: 'red',
  1370. type: 'solid'
  1371. }
  1372. }
  1373. },
  1374. // 主体是透明的
  1375. itemStyle: {
  1376. normal: {
  1377. color: 'transparent',
  1378. borderWidth: 0,
  1379. opacity: 1
  1380. }
  1381. },
  1382. data: series
  1383. }
  1384. ]
  1385. };
  1386. return option;
  1387. };
  1388. // 柱状图 双个柱图
  1389. export const columnOptionsChartss = (name = '', xAxis = [], series = [], dataseries = [], dataName = [], color = [], barWidth = 6) => {
  1390. let defaultData = [
  1391. {
  1392. name: '',
  1393. type: 'bar',
  1394. data: []
  1395. }
  1396. ];
  1397. let defaultColor = [
  1398. ['#0EAEFF', '#85E9FF'],
  1399. ['#F0646C', '#F4994E']
  1400. ];
  1401. let seriesConfiguration = () => {
  1402. let seriesData = [
  1403. {
  1404. name: '',
  1405. type: 'bar',
  1406. data: [],
  1407. barWidth: barWidth,
  1408. itemStyle: {
  1409. normal: {
  1410. barBorderRadius: [15, 15, 0, 0],
  1411. color: getColor(color[0] || defaultColor[0])
  1412. }
  1413. },
  1414. barGap: '100%'
  1415. },
  1416. {
  1417. name: '',
  1418. type: 'bar',
  1419. data: [],
  1420. barWidth: barWidth,
  1421. itemStyle: {
  1422. normal: {
  1423. barBorderRadius: [15, 15, 0, 0],
  1424. color: getColor(color[1] || defaultColor[1])
  1425. }
  1426. },
  1427. barGap: '100%'
  1428. }
  1429. ];
  1430. series.map((item, index) => {
  1431. seriesData[0].data.push(item.data);
  1432. seriesData[0].name = dataName[0];
  1433. });
  1434. dataseries.map((items, indexs) => {
  1435. seriesData[1].data.push(items.data);
  1436. seriesData[1].name = dataName[1];
  1437. });
  1438. return seriesData;
  1439. };
  1440. let option = {
  1441. tooltip: {
  1442. trigger: 'axis',
  1443. axisPointer: {
  1444. type: 'shadow',
  1445. shadowStyle: {
  1446. color: {
  1447. type: 'linear',
  1448. x: 0,
  1449. y: 0,
  1450. x2: 0,
  1451. y2: 1,
  1452. colorStops: [
  1453. {
  1454. offset: 0,
  1455. color: 'rgba(31,207,245,0)' // 0% 处的颜色
  1456. },
  1457. {
  1458. offset: 0.8,
  1459. color: 'rgba(31,207,245,0.15)' // 100% 处的颜色
  1460. },
  1461. {
  1462. offset: 0.2,
  1463. color: 'rgba(31,207,245,0.15)' // 100% 处的颜色
  1464. },
  1465. {
  1466. offset: 1,
  1467. color: 'rgba(31,207,245,0.05)'
  1468. }
  1469. ],
  1470. global: false // 缺省为 false
  1471. }
  1472. },
  1473. crossStyle: {
  1474. shadowBlur: 30,
  1475. shadowColor: 'rgba(0, 0, 0, 0.5)'
  1476. }
  1477. },
  1478. extraCssText: 'background:rgba(33,40,56,0.6);border-radius:4px;padding:6px 10px',
  1479. textStyle: {
  1480. fontSize: 12,
  1481. color: '#FFFFFF'
  1482. },
  1483. formatter(param) {
  1484. let el = ``;
  1485. param.forEach((item) => {
  1486. el += `<p style="text-align: left;">
  1487. <span style="display:inline-block;margin-right:5px;border-radius:4px;width:12px;height:8px;background-image: linear-gradient(to left,
  1488. ${item.color.colorStops[0].color}, ${item.color.colorStops[1].color})"></span>
  1489. <span>${item.seriesName}:${item.value}${name}</span>
  1490. </p>`;
  1491. });
  1492. el += ``;
  1493. return el;
  1494. }
  1495. },
  1496. grid: {
  1497. top: 50,
  1498. left: 10,
  1499. bottom: 0,
  1500. right: 0,
  1501. containLabel: true
  1502. },
  1503. xAxis: {
  1504. type: 'category',
  1505. axisLine: {
  1506. show: false // 不显示坐标轴
  1507. },
  1508. axisTick: {
  1509. show: false // 不显示坐标轴刻度
  1510. },
  1511. axisLabel: {
  1512. formatter: function (params, index) {
  1513. return params;
  1514. },
  1515. color: '#9B9DA5',
  1516. margin: 15
  1517. },
  1518. data: !!xAxis.length ? xAxis : defaultName
  1519. },
  1520. yAxis: {
  1521. type: 'value',
  1522. splitNumber: 4,
  1523. name: name,
  1524. axisLine: {
  1525. show: false
  1526. },
  1527. axisTick: {
  1528. show: false
  1529. },
  1530. axisLabel: {
  1531. color: '#9B9DA5',
  1532. margin: 15,
  1533. textStyle: {
  1534. align: 'right',
  1535. baseline: 'middle'
  1536. }
  1537. },
  1538. nameLocation: 'end',
  1539. nameTextStyle: { color: '#9B9DA5', padding: [0, 0, 0, -40] },
  1540. splitLine: {
  1541. lineStyle: {
  1542. type: 'dotted',
  1543. width: 0.5
  1544. }
  1545. }
  1546. },
  1547. legend: {
  1548. show: true,
  1549. x: 'right',
  1550. icon: 'circle',
  1551. itemWidth: 8, // 图例图形宽度
  1552. itemHeight: 8,
  1553. itemGap: 20,
  1554. textStyle: {
  1555. color: '#FFF'
  1556. }
  1557. },
  1558. series: seriesConfiguration() || defaultData
  1559. };
  1560. return option;
  1561. };
  1562. // 散点图
  1563. export const quantitativeAnalysisProblems = (name = [], namexAxis = '', nameyAxis = '', xAxis = [], series = [], color = []) => {
  1564. let defaultColor = [
  1565. ['#22D8FF'],
  1566. ['#F0646C'],
  1567. ['#5EEDCC', '#24C3F1'],
  1568. ['#7178FF', '#D2A4FF'],
  1569. ['#884DD2', '#DF63CC'],
  1570. ['#00B2FF'],
  1571. ['#F4994E']
  1572. ];
  1573. let seriesConfiguration = () => {
  1574. let seriesData = [];
  1575. series.map((item, index) => {
  1576. seriesData.push({
  1577. name: item.name,
  1578. type: 'scatter',
  1579. data: item.data,
  1580. color: defaultColor[index][0],
  1581. symbolSize: function (data) {
  1582. return data * 5 || 0;
  1583. }
  1584. });
  1585. });
  1586. return seriesData;
  1587. };
  1588. let option = {
  1589. tooltip: {
  1590. trigger: 'axis',
  1591. axisPointer: {
  1592. type: 'cross',
  1593. crossStyle: {
  1594. color: '#999'
  1595. }
  1596. }
  1597. },
  1598. legend: {
  1599. data: name,
  1600. itemWidth: 20,
  1601. itemHeight: 10,
  1602. top: 5,
  1603. textStyle: {
  1604. color: '#9B9DA5'
  1605. }
  1606. },
  1607. grid: {
  1608. top: 75,
  1609. left: 8,
  1610. bottom: 0,
  1611. right: 0,
  1612. containLabel: true
  1613. },
  1614. xAxis: {
  1615. name: namexAxis,
  1616. type: 'category',
  1617. data: xAxis,
  1618. axisLabel: {
  1619. color: '#9B9DA5',
  1620. lineStyle: {
  1621. color: '#9B9DA5'
  1622. }
  1623. }
  1624. },
  1625. yAxis: {
  1626. name: nameyAxis,
  1627. nameTextStyle: {
  1628. color: '#9B9DA5'
  1629. },
  1630. axisLabel: {
  1631. formatter: '{value}'
  1632. },
  1633. axisLabel: {
  1634. color: '#9B9DA5',
  1635. lineStyle: {
  1636. color: '#9B9DA5'
  1637. }
  1638. }
  1639. },
  1640. series: seriesConfiguration() || defaultData
  1641. };
  1642. return option;
  1643. };