chart.js 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122
  1. // 绘制中间动态环图
  2. const drawWorkShopChart = (myChart, datas) => {
  3. const options = [];
  4. let number = 50;
  5. datas.forEach((item) => {
  6. const obj = { value: number, name: item.name };
  7. options.push(obj);
  8. number += 10;
  9. });
  10. const workShopOption = {
  11. title: [{
  12. show: true,
  13. text: "",
  14. textStyle: {
  15. color: "white",
  16. fontSize: 24,
  17. fontWeight: "bold"
  18. },
  19. top: "48%",
  20. left: "26%"
  21. },
  22. ],
  23. series: [
  24. {
  25. name: 'pie',
  26. type: 'pie',
  27. width: "80%",
  28. height: "55%",
  29. center: ['50%', '50%'],
  30. top: "center",
  31. radius: ['54%', '90%'],
  32. avoidLabelOverlap: false,
  33. hoverAnimation: false,
  34. padAngle: 5,
  35. itemStyle: {
  36. borderRadius: 10,
  37. },
  38. label: {
  39. show: false,
  40. position: 'center'
  41. },
  42. emphasis: {
  43. label: {
  44. show: true,
  45. fontSize: 24,
  46. fontWeight: "bold",
  47. },
  48. },
  49. labelLine: {
  50. show: false
  51. },
  52. selectedMode: 'single',
  53. selectedOffset: 20,
  54. // 选中的样式
  55. select: {
  56. label: {
  57. show: true,
  58. fontSize: 24,
  59. fontWeight: 'bold',
  60. color: "#ffffff"
  61. },
  62. },
  63. data: options,
  64. }
  65. ]
  66. };
  67. workShopOption.title[0].text = workShopOption.series[0].data[0].name;
  68. window.dispatchEvent(
  69. new CustomEvent("onmessageChange", {
  70. detail: {
  71. warehouseId: datas[0].id
  72. },
  73. })
  74. );
  75. let index = 1;
  76. window.timeTicket = window.setInterval(() => {
  77. if (index > datas.length - 1) {
  78. index = 0
  79. }
  80. myChart.dispatchAction({
  81. type: 'select',
  82. seriesIndex: 0,
  83. dataIndex: index
  84. });
  85. window.dispatchEvent(
  86. new CustomEvent("onmessageChange", {
  87. detail: {
  88. warehouseId: datas[index].id
  89. },
  90. })
  91. );
  92. myChart.setOption({
  93. title: [{ text: '' }],
  94. });
  95. index++
  96. }, 5000)
  97. return workShopOption
  98. }
  99. // 绘制模检具故障数量图
  100. const drawMalfunctionNumber = () => {
  101. let category = [
  102. {
  103. name: "检具近三十天故障数量",
  104. value: 0,
  105. },
  106. {
  107. name: "模具近三十天故障数量",
  108. value: 0,
  109. },
  110. ]
  111. let yName = [];
  112. let bgData = [];
  113. let number = []
  114. let maxValue = 500; //最大值
  115. category.forEach(element => {
  116. yName.push(element.name);
  117. number.push({ name: element.name, value: element.value + '个' })
  118. bgData.push({
  119. name: element.name,
  120. value: maxValue,
  121. type: element.type,
  122. });
  123. });
  124. const malfunctionNumberOption = {
  125. xAxis: {
  126. // max: maxValue,
  127. splitLine: {
  128. show: false
  129. },
  130. axisLine: {
  131. show: false
  132. },
  133. axisLabel: {
  134. show: false
  135. },
  136. axisTick: {
  137. show: false
  138. }
  139. },
  140. grid: {
  141. left: 150,
  142. top: 20,
  143. right: 80,
  144. bottom: 20
  145. },
  146. yAxis: [
  147. { // y轴最左侧的文字
  148. axisTick: 'none',
  149. axisLine: 'none',
  150. position: 'left',
  151. axisLabel: {
  152. padding: [0, 0, 0, 0],
  153. textStyle: {
  154. color: '#ffffff',
  155. fontSize: '14',
  156. }
  157. },
  158. data: yName
  159. },
  160. { // y轴最右侧的文字
  161. name: 'right',
  162. axisTick: 'none',
  163. axisLine: 'none',
  164. type: 'category',
  165. position: 'right',
  166. axisLabel: {
  167. margin: 10,
  168. textStyle: {
  169. color: '#ffffff',
  170. fontSize: '14',
  171. }
  172. },
  173. data: number,
  174. }],
  175. series: [
  176. {
  177. // 背景样式
  178. name: '背景',
  179. type: "bar",
  180. barWidth: 18,
  181. stack: '总量',
  182. barGap: '-100%',
  183. symbol: 'fixed',
  184. symbolRepeat: 'repeat',
  185. legendHoverLink: false,
  186. itemStyle: {
  187. normal: {
  188. color: '#131943'
  189. }
  190. },
  191. data: bgData,
  192. animation: false, //关闭动画
  193. z: 0
  194. },
  195. {
  196. name: '故障数量',
  197. // 内(显示的内容)
  198. type: "bar",
  199. barGap: '-100%',
  200. barWidth: 18,
  201. legendHoverLink: false,
  202. silent: true,
  203. itemStyle: {
  204. normal: {
  205. color: {
  206. type: "linear",
  207. x: 0,
  208. y: 0,
  209. x2: 1,
  210. y2: 0,
  211. colorStops: [{
  212. offset: 0,
  213. color: '#53aee6' // 0% 处的颜色
  214. },
  215. {
  216. offset: 1,
  217. color: '#ef1dfc' // 100% 处的颜色
  218. }
  219. ]
  220. }
  221. }
  222. },
  223. data: category,
  224. z: 1,
  225. animationEasing: "elasticOut"
  226. },
  227. {
  228. // 分隔
  229. type: "pictorialBar",
  230. itemStyle: {
  231. normal: {
  232. color: 'rgba(0,0,0,1)'
  233. }
  234. },
  235. symbolRepeat: "fixed",
  236. symbolMargin: '300%',
  237. symbol: "rect",
  238. symbolClip: true,
  239. symbolSize: [5, 21],
  240. symbolPosition: "start",
  241. symbolOffset: [0, 0],
  242. symbolBoundingData: maxValue,
  243. data: bgData,
  244. animation: false, //关闭动画
  245. z: 2
  246. }
  247. ]
  248. };
  249. return malfunctionNumberOption
  250. }
  251. // 绘制模检具故障趋势折线图
  252. const drawMalfunctionChart = () => {
  253. let stateData = {
  254. xData: [],
  255. yData1: [],
  256. yData2: [],
  257. };
  258. const option = {
  259. tooltip: {},
  260. legend: {
  261. itemWidth: 7,
  262. itemHeight: 7,
  263. icon: "rect",
  264. right: 0,
  265. textStyle: {
  266. fontSize: 14,
  267. fontFamily: "PingFangSC, PingFang SC",
  268. fontWeight: 400,
  269. color: "#ffffff",
  270. },
  271. orient: "vertical",
  272. top: "0",
  273. },
  274. xAxis: {
  275. name: "月份",
  276. type: "category",
  277. boundaryGap: false,
  278. data: stateData.xData,
  279. nameTextStyle: {
  280. fontSize: 14,
  281. fontFamily: "PingFangSC, PingFang SC",
  282. fontWeight: 400,
  283. color: "#ffffff",
  284. },
  285. axisLabel: {
  286. fontSize: 14,
  287. fontFamily: "PingFangSC, PingFang SC",
  288. fontWeight: 400,
  289. color: "#ffffff",
  290. },
  291. },
  292. yAxis: {
  293. type: "value",
  294. name: "数量",
  295. nameTextStyle: {
  296. fontSize: 14,
  297. fontFamily: "PingFangSC, PingFang SC",
  298. fontWeight: 400,
  299. color: "#ffffff",
  300. },
  301. axisLabel: {
  302. fontSize: 14,
  303. fontFamily: "PingFangSC, PingFang SC",
  304. fontWeight: 400,
  305. color: "#ffffff",
  306. },
  307. splitLine: {
  308. lineStyle: {
  309. color: "#5f5f5f",
  310. },
  311. },
  312. },
  313. series: [
  314. {
  315. name: "模具故障趋势",
  316. data: stateData.yData1,
  317. type: "line",
  318. smooth: true,
  319. label: {
  320. show: true,
  321. position: "top",
  322. color: '#f20d0d'
  323. },
  324. itemStyle: {
  325. normal: {
  326. color: "#f20d0d",
  327. lineStyle: {
  328. color: "#f20d0d",
  329. width: 2,
  330. },
  331. areaStyle: {
  332. color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [
  333. {
  334. offset: 0,
  335. color: "#2d0838",
  336. },
  337. {
  338. offset: 1,
  339. color: "#43072f",
  340. },
  341. ]),
  342. },
  343. },
  344. },
  345. },
  346. {
  347. name: "检具故障趋势",
  348. data: stateData.yData2,
  349. type: "line",
  350. smooth: true,
  351. label: {
  352. show: true,
  353. position: "top",
  354. color: '#5fafff'
  355. },
  356. itemStyle: {
  357. normal: {
  358. color: "rgba(95, 175, 255, 1)",
  359. lineStyle: {
  360. color: "rgba(95, 175, 255, 1)",
  361. width: 2,
  362. },
  363. areaStyle: {
  364. color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [
  365. {
  366. offset: 0,
  367. color: "rgba(95, 175, 255, 0)",
  368. },
  369. {
  370. offset: 1,
  371. color: "rgba(95, 175, 255, 1)",
  372. },
  373. ]),
  374. },
  375. },
  376. },
  377. },
  378. ],
  379. };
  380. return option
  381. }
  382. // 绘制模具维修时效柱状图
  383. const drawMaintainChart = () => {
  384. let xData = ['一天内', '两天内', '三天内', '三天以上',]
  385. let yData = []
  386. const offsetX = 20;
  387. const offsetY = 10;
  388. // 绘制立体左侧面
  389. const CubeLeft = echarts.graphic.extendShape({
  390. shape: {
  391. x: 0,
  392. y: 0,
  393. },
  394. buildPath: function (ctx, shape) {
  395. const xAxisPoint = shape.xAxisPoint;
  396. const c0 = [shape.x, shape.y];
  397. const c1 = [shape.x - offsetX, shape.y - offsetY];
  398. const c2 = [xAxisPoint[0] - offsetX, xAxisPoint[1] - offsetY];
  399. const c3 = [xAxisPoint[0], xAxisPoint[1]];
  400. ctx.moveTo(c0[0], c0[1]).lineTo(c1[0], c1[1]).lineTo(c2[0], c2[1]).lineTo(c3[0], c3[1]).closePath();
  401. },
  402. });
  403. // 绘制立体右侧面
  404. const CubeRight = echarts.graphic.extendShape({
  405. shape: {
  406. x: 0,
  407. y: 0,
  408. },
  409. buildPath: function (ctx, shape) {
  410. const xAxisPoint = shape.xAxisPoint;
  411. const c1 = [shape.x, shape.y];
  412. const c2 = [xAxisPoint[0], xAxisPoint[1]];
  413. const c3 = [xAxisPoint[0] + offsetX, xAxisPoint[1] - offsetY];
  414. const c4 = [shape.x + offsetX, shape.y - offsetY];
  415. ctx.moveTo(c1[0], c1[1]).lineTo(c2[0], c2[1]).lineTo(c3[0], c3[1]).lineTo(c4[0], c4[1]).closePath();
  416. },
  417. });
  418. // 绘制立体顶面
  419. const CubeTop = echarts.graphic.extendShape({
  420. shape: {
  421. x: 0,
  422. y: 0,
  423. },
  424. buildPath: function (ctx, shape) {
  425. const c1 = [shape.x, shape.y];
  426. const c2 = [shape.x + offsetX, shape.y - offsetY]; //右点
  427. const c3 = [shape.x, shape.y - offsetX];
  428. const c4 = [shape.x - offsetX, shape.y - offsetY];
  429. ctx.moveTo(c1[0], c1[1]).lineTo(c2[0], c2[1]).lineTo(c3[0], c3[1]).lineTo(c4[0], c4[1]).closePath();
  430. },
  431. });
  432. // 注册三个面图形
  433. echarts.graphic.registerShape('CubeLeft', CubeLeft);
  434. echarts.graphic.registerShape('CubeRight', CubeRight);
  435. echarts.graphic.registerShape('CubeTop', CubeTop);
  436. const option = {
  437. tooltip: {
  438. trigger: 'axis',
  439. axisPointer: {
  440. type: 'shadow',
  441. },
  442. formatter: function (params, ticket, callback) {
  443. const item = params[1];
  444. return item.name + ' : ' + item.value;
  445. },
  446. },
  447. grid: {
  448. left: '10%',
  449. right: '10%',
  450. top: '15%',
  451. bottom: '10%',
  452. containLabel: true,
  453. },
  454. textStyle: {
  455. color: '#ffffff',
  456. },
  457. xAxis: {
  458. name: '天数',
  459. type: 'category',
  460. data: xData,
  461. axisLine: {
  462. lineStyle: {
  463. color: '#dddddd',
  464. },
  465. },
  466. axisTick: {
  467. show: false,
  468. },
  469. axisLabel: {
  470. margin: 10, //刻度标签与轴线之间的距离。
  471. textStyle: {
  472. fontFamily: 'Microsoft YaHei',
  473. color: '#ffffff',
  474. },
  475. },
  476. },
  477. yAxis: {
  478. name: "数量",
  479. nameTextStyle: {
  480. verticalAlign: 'middle',
  481. align: "right"
  482. },
  483. type: 'value',
  484. min: 0,
  485. boundaryGap: ['20%', '60%'],
  486. axisLine: {
  487. show: true,
  488. lineStyle: {
  489. color: '#ddddddd',
  490. },
  491. },
  492. splitLine: {
  493. lineStyle: {
  494. // 使用深浅的间隔色
  495. color: ['#B5B5B5'],
  496. type: 'dashed',
  497. opacity: 0.5,
  498. },
  499. },
  500. },
  501. series: [
  502. {
  503. type: 'custom',
  504. name: '时效',
  505. renderItem: (params, api) => {
  506. const location = api.coord([api.value(0), api.value(1)]);
  507. return {
  508. type: 'group',
  509. children: [
  510. {
  511. type: 'CubeLeft',
  512. shape: {
  513. api,
  514. xValue: api.value(0),
  515. yValue: api.value(1),
  516. x: location[0],
  517. y: location[1],
  518. xAxisPoint: api.coord([api.value(0), 0]),
  519. },
  520. style: {
  521. fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  522. {
  523. offset: 0,
  524. color: '#ff0101',
  525. },
  526. {
  527. offset: 1,
  528. color: '#5c0001',
  529. },
  530. ]),
  531. },
  532. },
  533. {
  534. type: 'CubeRight',
  535. shape: {
  536. api,
  537. xValue: api.value(0),
  538. yValue: api.value(1),
  539. x: location[0],
  540. y: location[1],
  541. xAxisPoint: api.coord([api.value(0), 0]),
  542. },
  543. style: {
  544. fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  545. {
  546. offset: 0,
  547. color: '#ff0101',
  548. },
  549. {
  550. offset: 1,
  551. color: '#5c0001',
  552. },
  553. ]),
  554. },
  555. },
  556. {
  557. type: 'CubeTop',
  558. shape: {
  559. api,
  560. xValue: api.value(0),
  561. yValue: api.value(1),
  562. x: location[0],
  563. y: location[1],
  564. xAxisPoint: api.coord([api.value(0), 0]),
  565. },
  566. style: {
  567. fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  568. {
  569. offset: 0,
  570. color: '#ff0101',
  571. },
  572. {
  573. offset: 1,
  574. color: '#5c0001',
  575. },
  576. ]),
  577. },
  578. },
  579. ],
  580. };
  581. },
  582. data: yData,
  583. },
  584. {
  585. type: 'bar',
  586. name: '百分比',
  587. label: {
  588. normal: {
  589. show: true,
  590. position: 'top',
  591. formatter: (e) => {
  592. return e.value / 1000 * 100 + '%';
  593. },
  594. fontSize: 16,
  595. color: '#ffffff',
  596. offset: [0, -10],
  597. },
  598. },
  599. itemStyle: {
  600. color: 'transparent',
  601. },
  602. data: yData,
  603. },
  604. ],
  605. };
  606. return option
  607. }
  608. // 绘制近七天模检具出入库胶囊柱图
  609. const drawOutInChart = () => {
  610. const xData = []
  611. const yData = [
  612. "模具入库总数",
  613. "模具出库总数",
  614. "检具入库总数",
  615. "检具出库总数",
  616. ]
  617. const totalCost = [100, 100, 100, 100]
  618. const myColor = ['#f31afd', '#316bf5', '#dd0507', '#1d3184',];
  619. const option = {
  620. grid: {
  621. left: '160',
  622. right: '100'
  623. },
  624. xAxis: {
  625. type: 'value',
  626. show: true,
  627. axisLine: {
  628. lineStyle: {
  629. color: '#000642',
  630. },
  631. },
  632. // 不显示刻度线
  633. axisTick: {
  634. show: false,
  635. },
  636. splitLine: {// 网格线为虚线
  637. show: false,
  638. },
  639. axisLabel: {
  640. interval: 0,
  641. color: '#ffffff',
  642. fontSize: 16
  643. },
  644. },
  645. yAxis: {
  646. type: 'category',
  647. axisLabel: {
  648. margin: 30,
  649. show: true,
  650. color: '#ffffff',
  651. fontSize: 16
  652. },
  653. axisTick: {
  654. show: false,
  655. },
  656. axisLine: {
  657. show: false,
  658. },
  659. data: yData
  660. },
  661. series: [
  662. {
  663. type: 'bar',
  664. barGap: '-65%',
  665. barWidth: '30%',
  666. itemStyle: {
  667. normal: {
  668. borderColor: '#0c1b4b',
  669. borderWidth: 2,
  670. barBorderRadius: 15,
  671. color: 'rgba(102, 102, 102,0)'
  672. },
  673. },
  674. z: 1,
  675. data: totalCost,
  676. },
  677. {
  678. name: "数量",
  679. type: 'bar',
  680. barGap: '-85%',
  681. barWidth: '21%',
  682. itemStyle: {
  683. normal: {
  684. barBorderRadius: 16,
  685. color: (params) => {
  686. var num = myColor.length;
  687. return {
  688. type: "linear",
  689. x: 0,
  690. y: 0,
  691. x2: 1,
  692. y2: 1,
  693. colorStops: [
  694. {
  695. offset: 1,
  696. color: "#52afe6",
  697. },
  698. {
  699. offset: 0,
  700. color: myColor[params.dataIndex % num],
  701. },
  702. ],
  703. };
  704. },
  705. }
  706. },
  707. max: 1,
  708. label: {
  709. normal: {
  710. show: true,
  711. position: 'inside',
  712. formatter: '{c}',
  713. color: '#ffffff',
  714. offset: [0, 2],
  715. }
  716. },
  717. labelLine: {
  718. show: true,
  719. },
  720. z: 2,
  721. data: xData,
  722. }]
  723. }
  724. return option
  725. }
  726. // 绘制左下角模检具数量饼图
  727. const drawCountChart = (dieCountChart, data) => {
  728. let value = 0
  729. const option2 = {
  730. title: {
  731. text: "{a|" + "总数" + "\n " + value + "}{c|}",
  732. top: "44%",
  733. textAlign: "center",
  734. left: "49%",
  735. textStyle: {
  736. color: "#00baff",
  737. fontSize: 22,
  738. fontWeight: "400",
  739. rich: {
  740. a: {
  741. fontSize: 30,
  742. color: "#00baff",
  743. fontWeight: "600",
  744. },
  745. c: {
  746. fontSize: 40,
  747. color: "#00baff",
  748. padding: [6, 4],
  749. },
  750. },
  751. },
  752. },
  753. tooltip: {
  754. trigger: "item",
  755. },
  756. series: [
  757. // 最内层的装饰圆(内一)
  758. {
  759. type: "pie",
  760. name: "装饰内圆",
  761. radius: ["20%", "20.5%"],
  762. hoverAnimation: false, //鼠标悬浮放大
  763. clockWise: false, //是否顺时针
  764. itemStyle: {
  765. normal: {
  766. color: "#87CEFA ",
  767. },
  768. },
  769. label: {
  770. show: false,
  771. },
  772. tooltip: {
  773. show: false,
  774. },
  775. data: [{ value: 0, name: 'smallPie' }],
  776. },
  777. // 真正显示数据的圆(内二)
  778. {
  779. type: "pie",
  780. name: "模检具数量",
  781. radius: ["23%", "28%"],
  782. avoidLabelOverlap: false,
  783. hoverAnimation: true,
  784. color: ["#50aee4", "#f90c29", "#2f67f6", "#0d2983"],
  785. label: {
  786. normal: {
  787. formatter: "{b} {c}",
  788. // distanceToLabelLine: 2,
  789. fontSize: 16,
  790. fontWeight: 600,
  791. color: "#ffffff",
  792. },
  793. },
  794. // 折线样式
  795. labelLine: {
  796. normal: {
  797. show: true,
  798. length: 20,
  799. length2: 50,
  800. minTurnAngle: 150,
  801. lineStyle: {
  802. width: 2,
  803. },
  804. },
  805. },
  806. // 圆环样式
  807. itemStyle: {
  808. normal: {
  809. shadowBlur: 10,
  810. shadowColor: "#00ffff",
  811. },
  812. },
  813. // 高亮状态的扇区和标签样式
  814. emphasis: {
  815. label: {
  816. show: true,
  817. fontSize: 13,
  818. fontWeight: "bold",
  819. },
  820. },
  821. data,
  822. },
  823. // 自动转圈虚线圆(内三)
  824. {
  825. type: "pie",
  826. name: "3",
  827. silent: false,
  828. radius: ["30%", "31%"],
  829. hoverAnimation: false,
  830. label: {
  831. normal: {
  832. show: false,
  833. },
  834. },
  835. labelLine: {
  836. normal: {
  837. show: false,
  838. },
  839. },
  840. data: _pie3(),
  841. },
  842. // 两个浅颜色的装饰圆
  843. {
  844. type: "pie",
  845. name: "4",
  846. silent: false,
  847. radius: ["37%", "38%"],
  848. color: "rgba(88,142,197,0.4) ",
  849. hoverAnimation: false,
  850. label: {
  851. normal: {
  852. show: false,
  853. },
  854. },
  855. labelLine: {
  856. normal: {
  857. show: false,
  858. },
  859. },
  860. data: [{ value: 0, name: 'midPie' }, { value: 10, name: 'midPie2' }],
  861. },
  862. // 自动转圈的两个大圆弧(外四)
  863. {
  864. type: "pie",
  865. name: "5",
  866. silent: false,
  867. radius: ["38%", "40%"],
  868. // startAngle: 75,
  869. hoverAnimation: false,
  870. label: {
  871. normal: {
  872. show: false,
  873. },
  874. },
  875. labelLine: {
  876. normal: {
  877. show: false,
  878. },
  879. },
  880. data: _pie5(),
  881. },
  882. // 最外层的三个自动转圈的小圆弧(外二)
  883. {
  884. type: "pie",
  885. name: "6",
  886. silent: false,
  887. radius: ["42%", "43%"],
  888. // startAngle: 75,
  889. hoverAnimation: false,
  890. label: {
  891. normal: {
  892. show: false,
  893. },
  894. },
  895. labelLine: {
  896. normal: {
  897. show: false,
  898. },
  899. },
  900. data: _pie6(),
  901. },
  902. // 最大圆浅色(外一)
  903. {
  904. type: "pie",
  905. name: "7",
  906. silent: false,
  907. radius: ["45%", "47%"],
  908. color: "rgba(88,142,197,0.4) ",
  909. hoverAnimation: false,
  910. label: {
  911. normal: {
  912. show: false,
  913. },
  914. },
  915. labelLine: {
  916. normal: {
  917. show: false,
  918. },
  919. },
  920. data: [{ value: 0, name: 'bigPie' }],
  921. },
  922. ],
  923. };
  924. function _pie3() {
  925. let dataArr = [];
  926. for (var i = 0; i < 149; i++) {
  927. if (i % 2 === 0) {
  928. dataArr.push({
  929. value: 1, //黑色间隔
  930. name: "aaa",
  931. itemStyle: {
  932. normal: {
  933. color: "rgba(88,142,197,0)",
  934. borderWidth: 0,
  935. borderColor: "rgba(0,0,0,0)",
  936. },
  937. },
  938. });
  939. } else {
  940. dataArr.push({
  941. value: 1,
  942. name: "ooo",
  943. itemStyle: {
  944. normal: {
  945. color: "#87CEFA ",
  946. borderWidth: 0,
  947. borderColor: "rgba(0,0,0,0)",
  948. },
  949. },
  950. });
  951. }
  952. }
  953. dataArr.push({
  954. value: 50,
  955. itemStyle: {
  956. normal: {
  957. color: "#87CEFA",
  958. borderWidth: 0,
  959. borderColor: "rgba(0,0,0,0)",
  960. },
  961. },
  962. });
  963. return dataArr;
  964. }
  965. function _pie5() {
  966. let dataArr = [];
  967. // for (var i = 0; i < 2; i++) {
  968. dataArr.push(
  969. {
  970. value: 15, //黑色间隔
  971. itemStyle: {
  972. normal: {
  973. color: "rgba(88,142,197,0)",
  974. borderWidth: 0,
  975. borderColor: "rgba(0,0,0,0)",
  976. },
  977. },
  978. },
  979. {
  980. value: 20,
  981. itemStyle: {
  982. normal: {
  983. color: "#87CEFA",
  984. borderWidth: 0,
  985. borderColor: "rgba(0,0,0,0)",
  986. },
  987. },
  988. },
  989. {
  990. value: 50,
  991. itemStyle: {
  992. normal: {
  993. color: "rgba(88,142,197,0)",
  994. borderWidth: 0,
  995. borderColor: "rgba(0,0,0,0)",
  996. },
  997. },
  998. },
  999. {
  1000. value: 20,
  1001. itemStyle: {
  1002. normal: {
  1003. color: "#87CEFA",
  1004. borderWidth: 0,
  1005. borderColor: "rgba(0,0,0,0)",
  1006. },
  1007. },
  1008. }
  1009. );
  1010. return dataArr;
  1011. }
  1012. function _pie6() {
  1013. let dataArr = [];
  1014. for (var i = 0; i < 1; i++) {
  1015. dataArr.push(
  1016. {
  1017. value: 3,
  1018. itemStyle: {
  1019. normal: {
  1020. color: "#87CEFA",
  1021. borderWidth: 0,
  1022. borderColor: "rgba(0,0,0,0)",
  1023. },
  1024. },
  1025. },
  1026. {
  1027. value: 1, //黑色间隔
  1028. itemStyle: {
  1029. normal: {
  1030. color: "rgba(88,142,197,0)",
  1031. borderWidth: 0,
  1032. borderColor: "rgba(0,0,0,0)",
  1033. },
  1034. },
  1035. },
  1036. {
  1037. value: 5,
  1038. itemStyle: {
  1039. normal: {
  1040. color: "#87CEFA",
  1041. borderWidth: 0,
  1042. borderColor: "rgba(0,0,0,0)",
  1043. },
  1044. },
  1045. },
  1046. {
  1047. value: 2,
  1048. itemStyle: {
  1049. normal: {
  1050. color: "rgba(88,142,197,0)",
  1051. borderWidth: 0,
  1052. borderColor: "rgba(0,0,0,0)",
  1053. },
  1054. },
  1055. },
  1056. {
  1057. value: 10,
  1058. itemStyle: {
  1059. normal: {
  1060. color: "#87CEFA",
  1061. borderWidth: 0,
  1062. borderColor: "rgba(0,0,0,0)",
  1063. },
  1064. },
  1065. },
  1066. {
  1067. value: 150,
  1068. itemStyle: {
  1069. normal: {
  1070. color: "rgba(88,142,197,0)",
  1071. borderWidth: 0,
  1072. borderColor: "rgba(0,0,0,0)",
  1073. },
  1074. },
  1075. }
  1076. );
  1077. }
  1078. return dataArr;
  1079. }
  1080. // function doing() {
  1081. // let option1 = dieCountChart.getOption();
  1082. // option1.series[2].startAngle = option1.series[2].startAngle + 10;
  1083. // option1.series[4].startAngle = option1.series[4].startAngle - 10;
  1084. // option1.series[5].startAngle = option1.series[5].startAngle + 5;
  1085. // dieCountChart.setOption(option1);
  1086. // }
  1087. // function startTimer() {
  1088. // timer = setInterval(doing, 100);
  1089. // }
  1090. // 过渡完成后开始动画
  1091. // dieCountChart.on("finished", () => {
  1092. // setTimeout(startTimer, 0);
  1093. // });
  1094. return option2
  1095. }
  1096. // 初始化图表
  1097. const initChart = (chart, chartOption) => {
  1098. chart && chart.resize();
  1099. chart && chart.clear(); // 清除上次的数据
  1100. chart && chart.setOption(chartOption, true); // 参数配置
  1101. }