CustomChart.vue 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114
  1. <template>
  2. <div ref="chartRef" :style="{ height, width }"></div>
  3. </template>
  4. <script lang="ts" setup>
  5. import { ref, Ref, watch } from 'vue';
  6. import { useECharts } from '/@/hooks/web/useECharts';
  7. import { get } from 'lodash-es';
  8. import { ModuleDataChart } from '/@/views/vent/deviceManager/configurationTable/types';
  9. import { color, EChartsOption, graphic } from 'echarts';
  10. import { getData, getFormattedText } from '../../hooks/helper';
  11. import { getAssetURL } from '/@/utils/ui';
  12. import { size } from 'lodash';
  13. const props = withDefaults(
  14. defineProps<{
  15. chartData: Record<string, any>[] | Record<string, any>;
  16. chartConfig: ModuleDataChart;
  17. height?: string;
  18. width?: string;
  19. }>(),
  20. {
  21. chartData: () => [],
  22. height: '100%',
  23. width: '100%',
  24. }
  25. );
  26. const chartRef = ref<HTMLDivElement | null>(null);
  27. const { setOptions, getInstance } = useECharts(chartRef as Ref<HTMLDivElement>);
  28. // 核心方法,生成适用与 echart 的选项,这个方法需要适配 chart 类型的每种子类型
  29. const genChartOption = () => {
  30. const inst = getInstance();
  31. const domWidth = inst ? inst.getWidth() : 500;
  32. // 依据每一个图表配置生成图表选项
  33. const { yAxis = [], xAxis = [], legend, order, type, sortBy, series, dataZoom = [] } = props.chartConfig;
  34. const textStyle = {
  35. color: '#fff',
  36. };
  37. let sorttedData: any[] = [];
  38. if (Array.isArray(props.chartData)) {
  39. sorttedData = props.chartData;
  40. } else {
  41. sorttedData = [props.chartData];
  42. }
  43. // 如果这个配置指明了需要排序则执行排序
  44. if (sortBy && order) {
  45. sorttedData.sort((pre, cur) => {
  46. if (order === 'asc') {
  47. return get(pre, sortBy, 0) - get(cur, sortBy, 0);
  48. } else {
  49. return get(cur, sortBy, 0) - get(pre, sortBy, 0);
  50. }
  51. });
  52. }
  53. // 该项作为下面所有图表依赖的基准系列数据
  54. const baseSeries: { name: string; data: [string, string][]; color: string }[] = sorttedData.reduce((res: any[], baseData) => {
  55. series.forEach((serie) => {
  56. // 将读取出的数据转为数组
  57. const temp = getData(baseData, serie.readFrom) || [];
  58. res.push({
  59. name: getFormattedText(baseData, serie.label),
  60. data: (Array.isArray(temp) ? temp : [temp]).map((data) => {
  61. return [getData(data, serie.xprop), getData(data, serie.yprop)]; /** x y */
  62. // return { name: getData(data, serie.xprop), value: getData(data, serie.yprop) }; /** x y */
  63. }),
  64. color: serie.color,
  65. });
  66. });
  67. return res;
  68. }, []);
  69. const baseDataZoom = dataZoom.map((e, i) => {
  70. return {
  71. type: 'slider',
  72. show: e.show,
  73. // show: get(baseSeries, '[0].data.length', 1) > e.maxAxisLength,
  74. xAxisIndex: i,
  75. end: e.end,
  76. };
  77. });
  78. if (type === 'scatter') {
  79. return {
  80. textStyle,
  81. legend: {
  82. show: legend.show,
  83. top: 0,
  84. left: 0,
  85. orient: 'vertical',
  86. height: '10%',
  87. textStyle: {
  88. width: 80,
  89. overflow: 'break',
  90. color: '#fff',
  91. fontSize: 10,
  92. },
  93. },
  94. grid: {
  95. left: 40,
  96. top: 60,
  97. right: 37,
  98. bottom: 30,
  99. },
  100. dataZoom: [
  101. {
  102. type: 'slider',
  103. xAxisIndex: 0,
  104. show: true,
  105. height: 10,
  106. bottom: 5,
  107. start: 0,
  108. end: 100, // 默认显示50%的数据
  109. handleSize: '80%',
  110. handleStyle: {
  111. color: '#fff',
  112. shadowBlur: 3,
  113. shadowColor: 'rgba(0, 0, 0, 0.6)',
  114. shadowOffsetX: 2,
  115. shadowOffsetY: 2,
  116. },
  117. },
  118. {
  119. type: 'inside',
  120. xAxisIndex: 0,
  121. zoomOnMouseWheel: true, // 关闭滚轮缩放
  122. moveOnMouseMove: true, // 开启拖拽平移
  123. moveOnMouseWheel: true, // 开启滚轮平移
  124. },
  125. ],
  126. xAxis: xAxis.map((e) => ({
  127. ...e,
  128. type: 'category',
  129. axisLabel: {
  130. width: 80,
  131. overflow: 'truncate',
  132. formatter: function (value) {
  133. const date = new Date(value);
  134. const yearMonthDay = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
  135. const time = `${date.getHours()}:${date.getMinutes().toString().padStart(2, '0')}:${date.getSeconds().toString().padStart(2, '0')}`;
  136. return [`${yearMonthDay}`, `${time}`].join('\n');
  137. },
  138. },
  139. })),
  140. yAxis: [
  141. {
  142. type: 'value',
  143. splitLine: { show: false },
  144. name: '氧气浓度',
  145. position: 'left',
  146. min: function (value) {
  147. return (value.min - 0.5).toFixed(1);
  148. },
  149. max: function (value) {
  150. return (value.max + 0.5).toFixed(1);
  151. },
  152. axisLine: {
  153. lineStyle: {
  154. color: '#5470C6',
  155. },
  156. },
  157. axisLabel: {
  158. formatter: '{value}',
  159. },
  160. },
  161. {
  162. type: 'value',
  163. splitLine: { show: false },
  164. name: '',
  165. position: 'left',
  166. min: function (value) {
  167. return (value.min - 0.5).toFixed(1);
  168. },
  169. max: function (value) {
  170. return (value.max + 0.5).toFixed(1);
  171. },
  172. axisLine: {
  173. lineStyle: {
  174. color: '#EE6666',
  175. },
  176. },
  177. axisLabel: {
  178. formatter: '{value}',
  179. },
  180. },
  181. {
  182. type: 'value',
  183. splitLine: { show: false },
  184. name: '大气压',
  185. position: 'right',
  186. min: function (value) {
  187. return value.min - 5;
  188. },
  189. max: function (value) {
  190. return value.max + 5;
  191. },
  192. axisLine: {
  193. lineStyle: {
  194. color: '#EE6666',
  195. },
  196. },
  197. axisLabel: {
  198. formatter: '{value}',
  199. },
  200. },
  201. {
  202. type: 'value',
  203. splitLine: { show: false },
  204. name: '',
  205. position: 'right',
  206. min: function (value) {
  207. return value.min - 5;
  208. },
  209. max: function (value) {
  210. return value.max + 5;
  211. },
  212. axisLine: {
  213. lineStyle: {
  214. color: '#EE6666',
  215. },
  216. },
  217. axisLabel: {
  218. formatter: '{value}',
  219. },
  220. },
  221. ],
  222. series: baseSeries.map((serie, index) => {
  223. return {
  224. yAxisIndex: index,
  225. ...serie,
  226. symbolSize: 5,
  227. type: series[index].type,
  228. };
  229. }),
  230. tooltip: {
  231. trigger: 'axis',
  232. axisPointer: {
  233. type: 'cross',
  234. label: {
  235. backgroundColor: '#6a7985',
  236. },
  237. },
  238. },
  239. };
  240. }
  241. if (type === 'pie') {
  242. return {
  243. textStyle,
  244. legend: {
  245. textStyle,
  246. show: legend.show,
  247. },
  248. tooltip: {
  249. trigger: 'item',
  250. },
  251. color: ['#73C0DE', '#5470C6', '#91CC75', '#FAC858', '#ED6666', '#17d1b2', '#2ae271', '#11bce7', '#c127f0', '#ee125b'],
  252. series: baseSeries.reduce((curr: EChartsOption[], serie) => {
  253. const colors = ['#73C0DE', '#5470C6', '#91CC75', '#FAC858', '#ED6666', '#17d1b2', '#2ae271', '#11bce7', '#c127f0', '#ee125b'];
  254. if (baseSeries.length === 1) {
  255. curr.push({
  256. ...serie,
  257. type: 'pie',
  258. radius: ['30%', '64%'],
  259. center: ['50%', '55%'],
  260. z: 1,
  261. padAngle: 5,
  262. itemStyle: {
  263. shadowColor: 'rgba(0, 0, 0, 0.5)',
  264. borderWidth: 10,
  265. },
  266. label: {
  267. show: true,
  268. position: 'inner',
  269. formatter: '{d}%',
  270. color: '#fff',
  271. fontSize: 14,
  272. rich: {
  273. d: {
  274. fontFamily: '微软雅黑',
  275. fontSize: 16,
  276. color: '#fff',
  277. lineHeight: 30,
  278. },
  279. },
  280. },
  281. labelLine: { show: false },
  282. data: serie.data.map((e) => ({
  283. name: e[0],
  284. value: e[1],
  285. })),
  286. });
  287. curr.push({
  288. ...serie,
  289. type: 'pie',
  290. radius: ['64%', '74%'],
  291. center: ['50%', '55%'],
  292. labelLine: { show: false },
  293. label: { show: false },
  294. padAngle: 5,
  295. avoidLabelOverlap: false,
  296. itemStyle: {
  297. borderWidth: 10,
  298. normal: {
  299. color: function (obj) {
  300. return `${colors[obj['dataIndex']]}88`;
  301. },
  302. },
  303. },
  304. data: serie.data.map((e) => ({
  305. name: e[0],
  306. value: e[1],
  307. })),
  308. });
  309. }
  310. curr.push({
  311. ...serie,
  312. type: 'pie',
  313. radius: ['25%', '30%'],
  314. center: ['50%', '55%'],
  315. labelLine: { show: false },
  316. label: { show: false },
  317. z: 5,
  318. padAngle: 5,
  319. itemStyle: {
  320. borderWidth: 10,
  321. normal: {
  322. color: function (obj) {
  323. return `${colors[obj['dataIndex']]}88`;
  324. },
  325. },
  326. },
  327. data: serie.data.map((e) => ({
  328. name: e[0],
  329. value: e[1],
  330. })),
  331. });
  332. return curr;
  333. }, []),
  334. };
  335. }
  336. if (type === 'pie_halo') {
  337. // 光环的图片
  338. const img =
  339. 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMYAAADGCAYAAACJm/9dAAABS2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxMzggNzkuMTU5ODI0LCAyMDE2LzA5LzE0LTAxOjA5OjAxICAgICAgICAiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIi8+CiA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgo8P3hwYWNrZXQgZW5kPSJyIj8+IEmuOgAAE/9JREFUeJztnXmQVeWZxn/dIA2UgsriGmNNrEQNTqSio0IEFXeFkqi4kpngEhXjqMm4MIldkrE1bnGIMmPcUkOiIi6gJIragLKI0Songo5ZJlHGFTADaoRuhZ4/nnPmnO4+l+7bfc85d3l+VV18373n3Ptyvve53/5+da1L6jDdYjgwBhgNHALMBn6Sq0VdcxlwGvACsAx4HliTq0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GGAypU+SAijg7/DgF0LXLsZiWA2Cp68PgP7ypZarTEKMQzVIOPRr+rWJgivRkPA5cxVaIi1EJ+i2vAJVEOU7WrXtHCN0T3WovU+96DO6OEoksk4FNqn0n9F2tC+iGZUWy4CNuZqUZliYRRmI5pND2fUd0JDwKPRMGVLgfvKiRa0EegF1PxbDnyQq0UVwv8BNYmwIpIWBvwAAAAASUVORK5CYII=';
  340. const color = ['#70F081', '#EEE780', '#F07070', '#ffe000', '#ffa800', '#ff5b00', '#ff3000'];
  341. return {
  342. textStyle,
  343. legend: {
  344. textStyle,
  345. show: legend.show,
  346. },
  347. tooltip: {
  348. trigger: 'item',
  349. },
  350. graphic: {
  351. elements: [
  352. {
  353. type: 'image',
  354. z: 3,
  355. style: {
  356. image: img,
  357. width: 120,
  358. height: 120,
  359. },
  360. left: 'center',
  361. top: 'center',
  362. position: [20, 20],
  363. },
  364. ],
  365. },
  366. series: baseSeries.reduce((curr: EChartsOption[], serie) => {
  367. curr.push({
  368. ...serie,
  369. type: 'pie',
  370. clockWise: false,
  371. radius: [45, 45],
  372. label: {
  373. show: true,
  374. position: 'outside',
  375. color: '#ddd',
  376. formatter: get(legend, 'formatter', '{b}\n{c}pa'),
  377. },
  378. labelLine: {
  379. length: 30,
  380. length2: 40,
  381. show: true,
  382. color: '#00ffff',
  383. },
  384. data: serie.data.map((e, i) => ({
  385. name: e[0],
  386. value: e[1],
  387. itemStyle: {
  388. normal: {
  389. borderWidth: 10,
  390. shadowBlur: 30,
  391. borderColor: color[i],
  392. shadowColor: color[i],
  393. },
  394. },
  395. })),
  396. });
  397. return curr;
  398. }, []),
  399. };
  400. }
  401. if (type === 'pie_drag') {
  402. return {
  403. legend: baseSeries.map((e) => {
  404. return {
  405. orient: 'vertical',
  406. left: '54%',
  407. top: '8%',
  408. itemGap: 34,
  409. itemWidth: 10,
  410. itemHeight: 10,
  411. align: 'left',
  412. textStyle: {
  413. fontSize: 14,
  414. color: '#b3b8cc',
  415. },
  416. data: e.data.map((e) => {
  417. return `${e[0]}: ${e[1]}`;
  418. }),
  419. };
  420. }),
  421. graphic: {
  422. elements: [
  423. {
  424. type: 'image',
  425. style: {
  426. image: getAssetURL('home-container/pie.png'),
  427. width: 20,
  428. height: 100,
  429. },
  430. left: 'center',
  431. top: 'center',
  432. },
  433. ],
  434. },
  435. tooltip: {
  436. formatter: '{b}',
  437. },
  438. series: baseSeries.reduce((curr: EChartsOption[], serie) => {
  439. curr.push({
  440. radius: ['40%', '80%'],
  441. center: ['25%', '50%'],
  442. type: 'pie',
  443. z: 10,
  444. label: {
  445. show: false,
  446. },
  447. labelLine: {
  448. show: false,
  449. },
  450. itemStyle: {
  451. opacity: 0.7,
  452. },
  453. padAngle: 5,
  454. data: serie.data.map((e) => ({
  455. name: `${e[0]}: ${e[1]}`,
  456. value: e[1],
  457. })),
  458. });
  459. curr.push({
  460. radius: ['40%', '55%'],
  461. center: ['25%', '50%'],
  462. type: 'pie',
  463. z: 5,
  464. label: {
  465. show: false,
  466. },
  467. labelLine: {
  468. show: false,
  469. },
  470. animation: false,
  471. tooltip: {
  472. show: false,
  473. },
  474. padAngle: 6,
  475. data: serie.data.map((e) => ({
  476. name: `${e[0]}: ${e[1]}`,
  477. value: e[1],
  478. })),
  479. });
  480. return curr;
  481. }, []),
  482. };
  483. }
  484. // 柱状图
  485. if (type === 'bar') {
  486. return {
  487. textStyle,
  488. grid: {
  489. top: 50,
  490. bottom: dataZoom.length ? 70 : 30,
  491. },
  492. legend: {
  493. textStyle,
  494. show: legend.show,
  495. },
  496. tooltip: {
  497. trigger: 'item',
  498. },
  499. dataZoom: baseDataZoom,
  500. xAxis: xAxis.map((e) => {
  501. return {
  502. ...e,
  503. type: 'category',
  504. axisLabel: {
  505. interval: 0,
  506. width: baseDataZoom.length ? 100 : 800 / get(baseSeries, '[0].data.length', 1),
  507. overflow: 'break',
  508. },
  509. };
  510. }),
  511. yAxis: yAxis.map((e, i) => {
  512. return {
  513. ...e,
  514. splitLine: {
  515. lineStyle: {
  516. opacity: i === 0 ? 0.1 : 0,
  517. },
  518. },
  519. };
  520. }),
  521. series: baseSeries.reduce((curr: EChartsOption[], serie, index) => {
  522. const colors = ['#66ffff', '#ffff66'];
  523. if (baseSeries.length === 1) {
  524. curr.push({
  525. ...serie,
  526. type: 'pictorialBar',
  527. symbol: 'circle',
  528. symbolPosition: 'end',
  529. symbolSize: [20, 20],
  530. symbolOffset: [0, -10],
  531. barGap: '-100%',
  532. yAxisIndex: index,
  533. itemStyle: {
  534. color: colors[index % colors.length],
  535. },
  536. });
  537. }
  538. curr.push({
  539. ...serie,
  540. type: 'bar',
  541. silent: true,
  542. yAxisIndex: index,
  543. barWidth: 20,
  544. barGap: '100%',
  545. label: {
  546. show: true,
  547. textStyle,
  548. position: 'top',
  549. },
  550. itemStyle: {
  551. color: new graphic.LinearGradient(0, 0, 0, 1, [
  552. { offset: 0, color: colors[index % colors.length] },
  553. { offset: 0.2, color: colors[index % colors.length] },
  554. { offset: 1, color: `${colors[index % colors.length]}22` },
  555. ]),
  556. borderRadius: [5, 5, 0, 0],
  557. },
  558. });
  559. return curr;
  560. }, []),
  561. };
  562. }
  563. // 折线图和上面的柱状图类似
  564. if (type === 'line') {
  565. return {
  566. textStyle,
  567. legend: {
  568. show: legend.show,
  569. top: 10,
  570. right: 10,
  571. textStyle,
  572. },
  573. grid: {
  574. left: 60,
  575. top: 40,
  576. right: 60,
  577. bottom: dataZoom.length ? 70 : 30,
  578. },
  579. dataZoom: baseDataZoom,
  580. xAxis: xAxis.map((e) => {
  581. return {
  582. ...e,
  583. type: 'category',
  584. axisLabel: {
  585. width: 100,
  586. overflow: 'break',
  587. },
  588. };
  589. }),
  590. yAxis: yAxis.map((e, i) => {
  591. return {
  592. ...e,
  593. splitLine: {
  594. lineStyle: {
  595. opacity: i === 0 ? 0.1 : 0,
  596. },
  597. },
  598. };
  599. }),
  600. series: baseSeries.map((serie) => {
  601. return {
  602. ...serie,
  603. type: 'line',
  604. };
  605. }),
  606. };
  607. }
  608. if (type === 'line_enhance') {
  609. return {
  610. textStyle,
  611. legend: {
  612. show: legend.show,
  613. top: 10,
  614. right: 10,
  615. textStyle,
  616. },
  617. tooltip: {
  618. trigger: 'item',
  619. },
  620. grid: {
  621. left: 60,
  622. top: 40,
  623. right: 60,
  624. bottom: dataZoom.length ? 70 : 30,
  625. },
  626. dataZoom: baseDataZoom,
  627. xAxis: xAxis.map((e) => {
  628. return {
  629. ...e,
  630. type: 'category',
  631. axisLabel: {
  632. width: 100,
  633. overflow: 'break',
  634. },
  635. };
  636. }),
  637. yAxis: yAxis.map((e, i) => {
  638. return {
  639. ...e,
  640. min: (value) => {
  641. return parseInt(value.min * 0.8);
  642. },
  643. max: (value) => {
  644. return parseInt(value.max * 1.2);
  645. },
  646. splitLine: {
  647. lineStyle: {
  648. opacity: i === 0 ? 0.1 : 0,
  649. },
  650. },
  651. };
  652. }),
  653. series: baseSeries.map((serie) => {
  654. return {
  655. ...serie,
  656. type: 'line',
  657. };
  658. }),
  659. };
  660. }
  661. // 平滑曲线图
  662. if (type === 'line_smooth') {
  663. return {
  664. textStyle,
  665. legend: {
  666. show: legend.show,
  667. top: 10,
  668. textStyle,
  669. },
  670. grid: {
  671. left: 60,
  672. right: 60,
  673. bottom: dataZoom.length ? 70 : 30,
  674. },
  675. dataZoom: baseDataZoom,
  676. xAxis: xAxis.map((e) => {
  677. return {
  678. ...e,
  679. type: 'category',
  680. };
  681. }),
  682. yAxis: yAxis.map((e, i) => {
  683. return {
  684. ...e,
  685. min: (value) => {
  686. return parseInt(value.min * 0.8);
  687. },
  688. max: (value) => {
  689. return parseInt(value.max * 1.2);
  690. },
  691. splitLine: {
  692. lineStyle: {
  693. opacity: i === 0 ? 0.1 : 0,
  694. },
  695. },
  696. };
  697. }),
  698. series: baseSeries.map((serie) => {
  699. return {
  700. ...serie,
  701. type: 'line',
  702. smooth: true,
  703. itemStyle: {
  704. opacity: 0,
  705. },
  706. };
  707. }),
  708. };
  709. }
  710. // 折线区域图,即折线下面的区域填满
  711. if (type === 'line_area') {
  712. return {
  713. textStyle,
  714. legend: {
  715. textStyle,
  716. show: legend.show,
  717. },
  718. grid: {
  719. left: 50,
  720. top: 50,
  721. right: 50,
  722. bottom: dataZoom.length ? 70 : 30,
  723. },
  724. dataZoom: baseDataZoom,
  725. xAxis: xAxis.map((e) => {
  726. return {
  727. ...e,
  728. type: 'category',
  729. boundaryGap: false,
  730. axisLabel: {
  731. width: 100,
  732. overflow: 'break',
  733. },
  734. };
  735. }),
  736. yAxis: yAxis.map((e, i) => {
  737. return {
  738. ...e,
  739. splitLine: {
  740. lineStyle: {
  741. color: '#fff',
  742. opacity: i === 0 ? 0.1 : 0,
  743. },
  744. },
  745. };
  746. }),
  747. series: baseSeries.map((serie, index) => {
  748. const colors = ['#66ffff', '#6666ff'];
  749. let color;
  750. if (serie.color) {
  751. color = serie.color;
  752. } else {
  753. color = colors[index % colors.length];
  754. }
  755. return {
  756. ...serie,
  757. type: 'line',
  758. symbol: 'none',
  759. endLabel: { distance: 0 },
  760. lineStyle: { color: color },
  761. areaStyle: {
  762. origin: 'auto',
  763. color: new graphic.LinearGradient(0, 0, 0, 1, [
  764. { offset: 0, color: color },
  765. { offset: 0.2, color: color },
  766. { offset: 1, color: `${color}22` },
  767. ]),
  768. },
  769. };
  770. }),
  771. };
  772. }
  773. if (type === 'line_bar') {
  774. return {
  775. textStyle,
  776. legend: {
  777. textStyle,
  778. show: legend.show,
  779. top: 10,
  780. right: 10,
  781. },
  782. grid: {
  783. left: 40,
  784. top: 50,
  785. right: 40,
  786. bottom: dataZoom.length ? 70 : 30,
  787. show: false,
  788. },
  789. dataZoom: baseDataZoom,
  790. xAxis: xAxis.map((e) => {
  791. return {
  792. ...e,
  793. type: 'category',
  794. };
  795. }),
  796. yAxis: yAxis.map((e) => {
  797. return {
  798. ...e,
  799. };
  800. }),
  801. series: baseSeries.map((serie, i) => {
  802. return {
  803. ...serie,
  804. type: i % 2 ? 'line' : 'bar',
  805. smooth: true,
  806. barWidth: 20,
  807. };
  808. }),
  809. };
  810. }
  811. // 堆叠柱状图
  812. if (type === 'bar_stack') {
  813. return {
  814. textStyle,
  815. tooltip: {
  816. trigger: 'axis',
  817. axisPointer: {
  818. type: 'shadow',
  819. },
  820. },
  821. grid: {
  822. top: 50,
  823. bottom: 30,
  824. },
  825. legend: {
  826. textStyle,
  827. show: legend.show,
  828. },
  829. xAxis: xAxis.map((e) => {
  830. return {
  831. ...e,
  832. type: 'category',
  833. };
  834. }),
  835. yAxis: yAxis.map((e) => {
  836. return {
  837. ...e,
  838. splitLine: {
  839. lineStyle: {
  840. color: 'rgba(21,80,126,0.3)',
  841. type: 'dashed',
  842. },
  843. },
  844. };
  845. }),
  846. series: baseSeries.map((serie) => {
  847. return {
  848. ...serie,
  849. type: 'bar',
  850. stack: 'stackME',
  851. barMaxWidth: '24',
  852. emphasis: {
  853. focus: 'series',
  854. },
  855. label: {
  856. show: true,
  857. position: 'top', //在上方显示
  858. textStyle: {
  859. //数值样式
  860. color: '#fff',
  861. fontSize: 14,
  862. },
  863. },
  864. };
  865. }),
  866. color: ['#F56731', '#00E8FF'],
  867. };
  868. }
  869. // 柱状图,圆柱形样式
  870. if (type === 'bar_cylinder') {
  871. return {
  872. textStyle,
  873. grid: {
  874. top: 40,
  875. bottom: 30,
  876. },
  877. legend: {
  878. textStyle,
  879. show: legend.show,
  880. },
  881. tooltip: {
  882. trigger: 'item',
  883. },
  884. xAxis: xAxis.map((e) => {
  885. return {
  886. ...e,
  887. type: 'category',
  888. axisLabel: {
  889. interval: 0,
  890. width: (domWidth - 100) / get(baseSeries, '[0].data.length', 1),
  891. overflow: 'break',
  892. },
  893. };
  894. }),
  895. yAxis: yAxis.map((e, i) => {
  896. return {
  897. ...e,
  898. splitLine: {
  899. lineStyle: {
  900. opacity: i === 0 ? 0.1 : 0,
  901. },
  902. },
  903. };
  904. }),
  905. series: baseSeries.reduce((curr: EChartsOption[], serie, index) => {
  906. // const colors = ['#66ffff', '#00ff66', '#ffff66'];
  907. const colors = ['#73C0DE', '#ED6666', '#5470C6', '#91CC75', '#FAC858', '#17d1b2', '#2ae271', '#11bce7', '#c127f0', '#ee125b'];
  908. if (baseSeries.length === 1) {
  909. curr.push({
  910. ...serie,
  911. type: 'pictorialBar',
  912. symbol: 'circle',
  913. symbolPosition: 'end',
  914. symbolSize: [20, 10],
  915. symbolOffset: [0, -5],
  916. barGap: '-100%',
  917. yAxisIndex: index,
  918. itemStyle: {
  919. color: ({ dataIndex }) => colors[dataIndex % colors.length],
  920. },
  921. });
  922. curr.push({
  923. ...serie,
  924. type: 'pictorialBar',
  925. symbol: 'circle',
  926. symbolPosition: 'start',
  927. symbolSize: [20, 10],
  928. symbolOffset: [0, 5],
  929. barGap: '-100%',
  930. yAxisIndex: index,
  931. itemStyle: {
  932. color: ({ dataIndex }) => colors[dataIndex % colors.length],
  933. },
  934. });
  935. }
  936. curr.push({
  937. ...serie,
  938. type: 'bar',
  939. // silent: true,
  940. yAxisIndex: index,
  941. barWidth: 20,
  942. barGap: '100%',
  943. itemStyle: {
  944. color: ({ dataIndex }) =>
  945. new graphic.LinearGradient(0, 0, 0, 1, [
  946. { offset: 0, color: `${colors[dataIndex % colors.length]}44` },
  947. { offset: 0.5, color: colors[dataIndex % colors.length] },
  948. { offset: 1, color: colors[dataIndex % colors.length] },
  949. ]),
  950. borderRadius: [5, 5, 0, 0],
  951. },
  952. label: {
  953. show: true, //开启显示
  954. position: 'top', //在上方显示
  955. textStyle: {
  956. //数值样式
  957. color: '#ffffffbb',
  958. fontSize: 13,
  959. },
  960. formatter: function (obj) {
  961. return obj['data'][1];
  962. },
  963. },
  964. });
  965. return curr;
  966. }, []),
  967. };
  968. }
  969. // 柱状图,圆柱形样式
  970. if (type === 'bar_cylinder_wide') {
  971. return {
  972. textStyle,
  973. grid: {
  974. top: 40,
  975. bottom: 30,
  976. },
  977. legend: {
  978. textStyle,
  979. show: legend.show,
  980. },
  981. tooltip: {
  982. trigger: 'item',
  983. },
  984. xAxis: xAxis.map((e) => {
  985. return {
  986. ...e,
  987. type: 'category',
  988. axisLabel: {
  989. interval: 0,
  990. width: (domWidth - 100) / get(baseSeries, '[0].data.length', 1),
  991. overflow: 'break',
  992. },
  993. };
  994. }),
  995. yAxis: yAxis.map((e, i) => {
  996. return {
  997. ...e,
  998. splitLine: {
  999. lineStyle: {
  1000. opacity: i === 0 ? 0.1 : 0,
  1001. },
  1002. },
  1003. };
  1004. }),
  1005. series: baseSeries.reduce((curr: EChartsOption[], serie, index) => {
  1006. // const colors = ['#66ffff', '#00ff66', '#ffff66'];
  1007. const colors = ['#73C0DE', '#ED6666', '#5470C6', '#91CC75', '#FAC858', '#17d1b2', '#2ae271', '#11bce7', '#c127f0', '#ee125b'];
  1008. if (baseSeries.length === 1) {
  1009. curr.push({
  1010. ...serie,
  1011. type: 'pictorialBar',
  1012. symbol: 'circle',
  1013. symbolPosition: 'end',
  1014. symbolSize: [50, 10],
  1015. symbolOffset: [0, -5],
  1016. barGap: '-100%',
  1017. yAxisIndex: index,
  1018. itemStyle: {
  1019. color: ({ dataIndex }) => colors[dataIndex % colors.length],
  1020. },
  1021. });
  1022. curr.push({
  1023. ...serie,
  1024. type: 'pictorialBar',
  1025. symbol: 'circle',
  1026. symbolPosition: 'start',
  1027. symbolSize: [50, 10],
  1028. symbolOffset: [0, 5],
  1029. barGap: '-100%',
  1030. yAxisIndex: index,
  1031. itemStyle: {
  1032. color: ({ dataIndex }) => colors[dataIndex % colors.length],
  1033. },
  1034. });
  1035. }
  1036. curr.push({
  1037. ...serie,
  1038. type: 'bar',
  1039. // silent: true,
  1040. yAxisIndex: index,
  1041. barWidth: 50,
  1042. barGap: '100%',
  1043. itemStyle: {
  1044. color: ({ dataIndex }) =>
  1045. new graphic.LinearGradient(0, 0, 0, 1, [
  1046. { offset: 0, color: `${colors[dataIndex % colors.length]}44` },
  1047. { offset: 0.5, color: colors[dataIndex % colors.length] },
  1048. { offset: 1, color: colors[dataIndex % colors.length] },
  1049. ]),
  1050. borderRadius: [5, 5, 0, 0],
  1051. },
  1052. label: {
  1053. show: true, //开启显示
  1054. position: 'top', //在上方显示
  1055. textStyle: {
  1056. //数值样式
  1057. color: '#ffffffbb',
  1058. fontSize: 13,
  1059. },
  1060. formatter: function (obj) {
  1061. return obj['data'][1];
  1062. },
  1063. },
  1064. });
  1065. return curr;
  1066. }, []),
  1067. };
  1068. }
  1069. return {};
  1070. };
  1071. watch(
  1072. () => props.chartData,
  1073. () => {
  1074. initCharts();
  1075. },
  1076. {
  1077. immediate: true,
  1078. }
  1079. );
  1080. function initCharts() {
  1081. const o = genChartOption();
  1082. setOptions(o as EChartsOption, Boolean(props.chartConfig.clear));
  1083. }
  1084. </script>