chartOptions.ts 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  1. import { graphic } from "echarts";
  2. export const chartOption1 = {
  3. legend: {},
  4. grid: {
  5. top: "40px",
  6. left: "30px",
  7. right: "20px",
  8. bottom: "30px"
  9. // containLabel: true
  10. },
  11. tooltip: {
  12. show: true,
  13. trigger: "axis"
  14. },
  15. xAxis: [
  16. {
  17. type: "category",
  18. axisLabel: {
  19. textStyle: {
  20. color: "#414F64",
  21. fontSize: 10
  22. }
  23. },
  24. axisLine: {
  25. show: true
  26. },
  27. splitLine: {
  28. show: false
  29. },
  30. axisTick: {
  31. show: false
  32. },
  33. data: []
  34. }
  35. ],
  36. yAxis: [
  37. {
  38. type: "value",
  39. splitLine: {
  40. show: true
  41. },
  42. axisLine: {
  43. show: false
  44. },
  45. axisLabel: {
  46. textStyle: {
  47. color: "#414F64",
  48. fontSize: 10
  49. }
  50. },
  51. axisTick: {
  52. show: false
  53. }
  54. }
  55. ],
  56. series: [
  57. {
  58. name: "自然灾害",
  59. type: "line",
  60. smooth: true, //是否平滑
  61. showAllSymbol: true,
  62. symbol: "circle",
  63. symbolSize: 6,
  64. lineStyle: {
  65. color: "#00b3f4"
  66. },
  67. label: {
  68. show: true,
  69. position: "top",
  70. textStyle: {
  71. color: "#00b3f4",
  72. fontSize: 10
  73. }
  74. },
  75. itemStyle: {
  76. color: "#00b3f4",
  77. borderColor: "#fff",
  78. borderWidth: 1
  79. },
  80. areaStyle: {
  81. normal: {
  82. color: new graphic.LinearGradient(
  83. 0,
  84. 0,
  85. 0,
  86. 1,
  87. [
  88. {
  89. offset: 0,
  90. color: "rgba(0,179,244,0.3)"
  91. },
  92. {
  93. offset: 1,
  94. color: "rgba(0,179,244,0)"
  95. }
  96. ],
  97. false
  98. ),
  99. shadowColor: "rgba(0,179,244, 0.9)",
  100. shadowBlur: 20
  101. }
  102. },
  103. data: []
  104. },
  105. {
  106. name: "事故灾害",
  107. type: "line",
  108. smooth: true, //是否平滑
  109. showAllSymbol: true,
  110. symbol: "circle",
  111. symbolSize: 6,
  112. lineStyle: {
  113. color: "#00ca95"
  114. },
  115. label: {
  116. show: true,
  117. position: "top",
  118. textStyle: {
  119. color: "#00ca95",
  120. fontSize: 10
  121. }
  122. },
  123. itemStyle: {
  124. color: "#00ca95",
  125. borderColor: "#fff",
  126. borderWidth: 1
  127. },
  128. areaStyle: {
  129. normal: {
  130. color: new graphic.LinearGradient(
  131. 0,
  132. 0,
  133. 0,
  134. 1,
  135. [
  136. {
  137. offset: 0,
  138. color: "rgba(0,202,149,0.3)"
  139. },
  140. {
  141. offset: 1,
  142. color: "rgba(0,202,149,0)"
  143. }
  144. ],
  145. false
  146. ),
  147. shadowColor: "rgba(0,202,149, 0.9)",
  148. shadowBlur: 20
  149. }
  150. },
  151. data: []
  152. }
  153. ]
  154. };
  155. export const chartOption2 = {
  156. grid: {
  157. top: "25%",
  158. bottom: "10%" //也可设置left和right设置距离来控制图表的大小
  159. },
  160. tooltip: {
  161. trigger: "axis",
  162. axisPointer: {
  163. type: "shadow",
  164. label: {
  165. show: true
  166. }
  167. },
  168. formatter: params => {
  169. let result = "";
  170. // 遍历每个轴上的数据点
  171. params.forEach(function (item) {
  172. if (item.seriesName === "温度") {
  173. result +=
  174. "<div>" + item.marker + item.seriesName + item.value + "℃</div>";
  175. } else {
  176. result +=
  177. "<div>" + item.marker + item.seriesName + item.value + "mm</div>";
  178. }
  179. });
  180. return result;
  181. }
  182. },
  183. legend: {
  184. data: ["温度", "降水"],
  185. top: "15%",
  186. textStyle: {
  187. color: "#7F8B9F"
  188. }
  189. },
  190. xAxis: {
  191. data: [],
  192. axisLine: {
  193. show: true,
  194. lineStyle: {
  195. color: "#eaeef7"
  196. }
  197. },
  198. axisTick: {
  199. show: true
  200. },
  201. axisLabel: {
  202. show: true,
  203. textStyle: {
  204. color: "#7F8B9F"
  205. }
  206. }
  207. },
  208. yAxis: [
  209. {
  210. type: "value",
  211. name: "单位:℃",
  212. nameTextStyle: {
  213. color: "#7F8B9F"
  214. },
  215. splitLine: {
  216. show: true,
  217. lineStyle: {
  218. color: "#eaeef7"
  219. }
  220. },
  221. axisTick: {
  222. show: false
  223. },
  224. axisLine: {
  225. show: true,
  226. lineStyle: {
  227. color: "#eaeef7"
  228. }
  229. },
  230. axisLabel: {
  231. show: true,
  232. textStyle: {
  233. color: "#7F8B9F"
  234. }
  235. }
  236. },
  237. {
  238. type: "value",
  239. name: "单位:mm",
  240. nameTextStyle: {
  241. color: "#7F8B9F"
  242. },
  243. position: "right",
  244. splitLine: {
  245. show: false
  246. },
  247. axisTick: {
  248. show: false
  249. },
  250. axisLine: {
  251. show: true,
  252. lineStyle: {
  253. color: "#eaeef7"
  254. }
  255. },
  256. axisLabel: {
  257. show: true,
  258. textStyle: {
  259. color: "#7F8B9F"
  260. }
  261. }
  262. }
  263. ],
  264. series: [
  265. {
  266. name: "温度",
  267. type: "line",
  268. smooth: true, //平滑曲线显示
  269. showSymbol: false,
  270. itemStyle: {
  271. color: new graphic.LinearGradient(0, 0, 0, 1, [
  272. {
  273. offset: 0,
  274. color: "#9bbdf4"
  275. },
  276. {
  277. offset: 1,
  278. color: "#2a72e9"
  279. }
  280. ])
  281. },
  282. data: []
  283. },
  284. {
  285. name: "降水",
  286. type: "line",
  287. yAxisIndex: 1, //使用的 y 轴的 index,在单个图表实例中存在多个 y轴的时候有用
  288. smooth: true, //平滑曲线显示
  289. // showSymbol: false,
  290. itemStyle: {
  291. //折线拐点标志的样式
  292. color: "#feaf00"
  293. },
  294. lineStyle: {
  295. color: new graphic.LinearGradient(0, 0, 1, 0, [
  296. {
  297. offset: 0,
  298. color: "#f9df83"
  299. },
  300. {
  301. offset: 1,
  302. color: "#f7983f"
  303. }
  304. ])
  305. },
  306. // areaStyle:{
  307. // color: new graphic.LinearGradient(0, 0, 0, 1, [
  308. // {
  309. // offset: 0,
  310. // color: "rgba(155, 189, 244, 0.8)"
  311. // },
  312. //
  313. // {
  314. // offset: 1,
  315. // color: "rgba(155, 189, 244, 0)"
  316. // }
  317. // ])
  318. // },
  319. data: []
  320. }
  321. ]
  322. };
  323. export const chartOption3 = {
  324. grid: {
  325. top: "30px",
  326. bottom: "50px" //也可设置left和right设置距离来控制图表的大小
  327. },
  328. tooltip: {
  329. trigger: "axis",
  330. axisPointer: {
  331. type: "shadow",
  332. label: {
  333. show: true
  334. }
  335. },
  336. formatter: params => {
  337. let result = "";
  338. // 遍历每个轴上的数据点
  339. params.forEach(function (item) {
  340. console.log(item);
  341. result +=
  342. '<div style="display: flex"><div style="color: #3177ec;font-size: 16px;font-weight: bold">' +
  343. item.value +
  344. "</div>个</div>";
  345. });
  346. return result;
  347. }
  348. },
  349. xAxis: {
  350. data: [],
  351. offset: 20,
  352. axisLine: {
  353. show: true,
  354. lineStyle: {
  355. color: "#eaeef7"
  356. }
  357. },
  358. axisTick: {
  359. show: false
  360. },
  361. axisLabel: {
  362. show: true,
  363. textStyle: {
  364. color: "#7F8B9F"
  365. }
  366. }
  367. },
  368. yAxis: [
  369. {
  370. type: "value",
  371. name: "单位:个",
  372. nameTextStyle: {
  373. color: "#7F8B9F"
  374. },
  375. splitLine: {
  376. show: true,
  377. lineStyle: {
  378. color: "#eaeef7"
  379. }
  380. },
  381. axisTick: {
  382. show: false
  383. },
  384. axisLine: {
  385. show: true,
  386. lineStyle: {
  387. color: "#eaeef7"
  388. }
  389. },
  390. axisLabel: {
  391. show: true,
  392. textStyle: {
  393. color: "#7F8B9F"
  394. }
  395. }
  396. }
  397. ],
  398. series: [
  399. {
  400. name: "非某矿山行业重大事故隐患",
  401. type: "line",
  402. smooth: true, //平滑曲线显示
  403. showSymbol: false,
  404. itemStyle: {
  405. color: new graphic.LinearGradient(0, 0, 0, 1, [
  406. {
  407. offset: 0,
  408. color: "#92E1E5"
  409. },
  410. {
  411. offset: 1,
  412. color: "#00BBC4"
  413. }
  414. ])
  415. },
  416. areaStyle: {
  417. color: new graphic.LinearGradient(0, 0, 0, 1, [
  418. {
  419. offset: 0,
  420. color: "rgba(0, 187, 196, 0.5)"
  421. },
  422. {
  423. offset: 1,
  424. color: "rgba(0, 187, 196, 0)"
  425. }
  426. ])
  427. },
  428. data: []
  429. }
  430. ]
  431. };
  432. export const chartOption4 = {
  433. grid: {
  434. top: "0",
  435. left: "10px",
  436. right: "40px",
  437. bottom: "20px",
  438. containLabel: true
  439. },
  440. tooltip: {
  441. trigger: "axis",
  442. axisPointer: {
  443. type: "shadow"
  444. }
  445. },
  446. xAxis: {
  447. type: "value",
  448. axisLabel: {
  449. show: true,
  450. textStyle: {
  451. color: "#7F8B9F"
  452. }
  453. },
  454. axisLine: {
  455. show: true,
  456. lineStyle: {
  457. color: "#eaeef7"
  458. }
  459. },
  460. splitLine: {
  461. show: false
  462. }
  463. },
  464. yAxis: {
  465. type: "category",
  466. axisLabel: {
  467. show: true,
  468. textStyle: {
  469. color: "#7F8B9F"
  470. }
  471. },
  472. axisLine: {
  473. show: true,
  474. lineStyle: {
  475. color: "#eaeef7"
  476. }
  477. },
  478. axisTick: {
  479. show: false
  480. },
  481. data: [
  482. "信宜市",
  483. "高州市",
  484. "化州市",
  485. "电白区",
  486. "茂南区",
  487. "滨海新区",
  488. "高新区"
  489. ]
  490. },
  491. series: [
  492. {
  493. name: "2011",
  494. type: "bar",
  495. label: {
  496. show: true,
  497. position: "right",
  498. fontSize: "12px",
  499. color: "#2C81FF"
  500. },
  501. data: [],
  502. itemStyle: {
  503. color: new graphic.LinearGradient(0, 0, 1, 0, [
  504. {
  505. offset: 0,
  506. color: "#266FE8"
  507. },
  508. {
  509. offset: 1,
  510. color: "#A1C0F5"
  511. }
  512. ])
  513. }
  514. }
  515. ]
  516. };
  517. export const chartOption5 = {
  518. color: ["#8984ff", "#56e09f", "#2c81ff", "#fab21b", "#ff7a0d"],
  519. tooltip: {
  520. show: false
  521. },
  522. toolbox: {
  523. show: false
  524. },
  525. series: [
  526. {
  527. name: "",
  528. type: "pie",
  529. clockWise: false,
  530. radius: [60, 65],
  531. width: 280,
  532. height: 252,
  533. hoverAnimation: false,
  534. center: ["17%", "55%"],
  535. left: "20%",
  536. top: "center",
  537. itemStyle: {
  538. normal: {
  539. label: {
  540. show: false
  541. }
  542. }
  543. },
  544. data: []
  545. }
  546. ]
  547. };
  548. export const chartOption6 = {
  549. legend: {},
  550. grid: {
  551. top: "40px",
  552. left: "30px",
  553. right: "20px",
  554. bottom: "30px"
  555. // containLabel: true
  556. },
  557. tooltip: {
  558. show: true,
  559. trigger: "axis"
  560. },
  561. xAxis: [
  562. {
  563. type: "category",
  564. axisLabel: {
  565. textStyle: {
  566. color: "#414F64",
  567. fontSize: 10
  568. }
  569. },
  570. axisLine: {
  571. show: true
  572. },
  573. splitLine: {
  574. show: false
  575. },
  576. axisTick: {
  577. show: false
  578. },
  579. data: []
  580. }
  581. ],
  582. yAxis: [
  583. {
  584. type: "value",
  585. splitLine: {
  586. show: true
  587. },
  588. axisLine: {
  589. show: false
  590. },
  591. axisLabel: {
  592. textStyle: {
  593. color: "#414F64",
  594. fontSize: 10
  595. }
  596. },
  597. axisTick: {
  598. show: false
  599. }
  600. }
  601. ],
  602. series: [
  603. {
  604. name: "一般事故",
  605. type: "line",
  606. smooth: true, //是否平滑
  607. showAllSymbol: true,
  608. symbol: "circle",
  609. symbolSize: 6,
  610. lineStyle: {
  611. color: "#00b3f4"
  612. },
  613. label: {
  614. show: true,
  615. position: "top",
  616. textStyle: {
  617. color: "#00b3f4",
  618. fontSize: 10
  619. }
  620. },
  621. itemStyle: {
  622. color: "#00b3f4",
  623. borderColor: "#fff",
  624. borderWidth: 1
  625. },
  626. areaStyle: {
  627. normal: {
  628. color: new graphic.LinearGradient(
  629. 0,
  630. 0,
  631. 0,
  632. 1,
  633. [
  634. {
  635. offset: 0,
  636. color: "rgba(0,179,244,0.3)"
  637. },
  638. {
  639. offset: 1,
  640. color: "rgba(0,179,244,0)"
  641. }
  642. ],
  643. false
  644. ),
  645. shadowColor: "rgba(0,179,244, 0.9)",
  646. shadowBlur: 20
  647. }
  648. },
  649. data: []
  650. },
  651. {
  652. name: "重大事故",
  653. type: "line",
  654. smooth: true, //是否平滑
  655. showAllSymbol: true,
  656. symbol: "circle",
  657. symbolSize: 6,
  658. lineStyle: {
  659. color: "#00ca95"
  660. },
  661. label: {
  662. show: true,
  663. position: "top",
  664. textStyle: {
  665. color: "#00ca95",
  666. fontSize: 10
  667. }
  668. },
  669. itemStyle: {
  670. color: "#00ca95",
  671. borderColor: "#fff",
  672. borderWidth: 1
  673. },
  674. areaStyle: {
  675. normal: {
  676. color: new graphic.LinearGradient(
  677. 0,
  678. 0,
  679. 0,
  680. 1,
  681. [
  682. {
  683. offset: 0,
  684. color: "rgba(0,202,149,0.3)"
  685. },
  686. {
  687. offset: 1,
  688. color: "rgba(0,202,149,0)"
  689. }
  690. ],
  691. false
  692. ),
  693. shadowColor: "rgba(0,202,149, 0.9)",
  694. shadowBlur: 20
  695. }
  696. },
  697. data: []
  698. }
  699. ]
  700. };
  701. export const chartOption7 = {
  702. grid: {
  703. top: "0",
  704. left: "10px",
  705. right: "40px",
  706. bottom: "20px",
  707. containLabel: true
  708. },
  709. tooltip: {
  710. trigger: "axis",
  711. axisPointer: {
  712. type: "shadow"
  713. }
  714. },
  715. xAxis: {
  716. type: "value",
  717. axisLabel: {
  718. show: true,
  719. textStyle: {
  720. color: "#7F8B9F"
  721. }
  722. },
  723. axisLine: {
  724. show: true,
  725. lineStyle: {
  726. color: "#eaeef7"
  727. }
  728. },
  729. splitLine: {
  730. show: false
  731. }
  732. },
  733. yAxis: {
  734. type: "category",
  735. axisLabel: {
  736. show: true,
  737. textStyle: {
  738. color: "#7F8B9F"
  739. }
  740. },
  741. axisLine: {
  742. show: true,
  743. lineStyle: {
  744. color: "#eaeef7"
  745. }
  746. },
  747. axisTick: {
  748. show: false
  749. },
  750. data: [
  751. "超速",
  752. "酒驾",
  753. "疲劳驾驶",
  754. "闯红灯",
  755. "恶劣天气",
  756. "道路设计缺陷",
  757. "路面障碍物",
  758. "车辆问题"
  759. ]
  760. },
  761. series: [
  762. {
  763. name: "2011",
  764. type: "bar",
  765. label: {
  766. show: true,
  767. position: "right",
  768. fontSize: "12px",
  769. color: "#2C81FF"
  770. },
  771. data: [],
  772. itemStyle: {
  773. color: new graphic.LinearGradient(0, 0, 1, 0, [
  774. {
  775. offset: 0,
  776. color: "#266FE8"
  777. },
  778. {
  779. offset: 1,
  780. color: "#A1C0F5"
  781. }
  782. ])
  783. }
  784. }
  785. ]
  786. };