widgetBarCompareChart.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. <!--
  2. * @Descripttion: 大屏报表设计器-动态组件
  3. * @Author: qianming
  4. * @Date: 2021-8-24 16:38:27
  5. * @LastEditors: qianming
  6. * @LastEditTime: 2023-11-21 17:38:44
  7. -->
  8. <template>
  9. <div :style="styleObj">
  10. <v-chart ref="myVChart" :option="options" autoresize/>
  11. </div>
  12. </template>
  13. <script>
  14. import {targetWidgetLinkageLogic} from "@/views/bigscreenDesigner/designer/linkageLogic";
  15. export default {
  16. name: "WidgetBarCompareChart",
  17. //参考 https://www.makeapie.com/editor.html?c=xrJwcCF3NZ
  18. components: {},
  19. props: {
  20. value: Object,
  21. ispreview: Boolean,
  22. },
  23. data() {
  24. return {
  25. options: {
  26. title: {
  27. //text: '柱状对比图',
  28. x: "center",
  29. textStyle: {
  30. color: "#ffffff",
  31. },
  32. },
  33. //边距
  34. grid: [
  35. {
  36. //左
  37. show: false, //边框线
  38. left: "4%",
  39. top: 60,
  40. bottom: 10,
  41. containLabel: true,
  42. width: "40%",
  43. },
  44. {
  45. //中间字体位置
  46. show: false,
  47. left: "50.5%",
  48. top: 60,
  49. bottom: 25,
  50. width: "0%",
  51. },
  52. {
  53. //右
  54. show: false,
  55. right: "4%",
  56. top: 60,
  57. bottom: 10,
  58. containLabel: true,
  59. width: "40%",
  60. },
  61. ],
  62. //图例
  63. legend: {
  64. textStyle: {
  65. color: "#fff",
  66. textAlign: "center",
  67. },
  68. //itemGap:80,
  69. //itemWidth: 0
  70. },
  71. xAxis: [
  72. {
  73. // 左
  74. splitNumber: 2,
  75. show: true,
  76. type: "value",
  77. inverse: true,
  78. axisLine: {
  79. //底分割线
  80. show: false,
  81. },
  82. axisTick: {
  83. show: false,
  84. },
  85. position: "bottom",
  86. axisLabel: {
  87. // x轴
  88. show: true,
  89. textStyle: {
  90. color: "#ffffff",
  91. fontSize: 12,
  92. },
  93. },
  94. splitLine: {
  95. // 竖分割线
  96. show: true,
  97. lineStyle: {
  98. color: "#57617f",
  99. width: 1,
  100. type: "solid",
  101. },
  102. },
  103. },
  104. {
  105. gridIndex: 1,
  106. show: false,
  107. },
  108. {
  109. // 右
  110. gridIndex: 2,
  111. show: true,
  112. type: "value",
  113. axisLine: {
  114. show: false,
  115. },
  116. axisTick: {
  117. show: false,
  118. },
  119. position: "bottom",
  120. axisLabel: {
  121. show: true,
  122. textStyle: {
  123. color: "#ffffff",
  124. fontSize: 12,
  125. },
  126. },
  127. splitLine: {
  128. show: true,
  129. lineStyle: {
  130. color: "#57617f",
  131. width: 1,
  132. type: "solid",
  133. },
  134. },
  135. },
  136. ],
  137. yAxis: [
  138. {
  139. type: "category",
  140. inverse: true,
  141. position: "right",
  142. axisLine: {
  143. show: false,
  144. },
  145. axisTick: {
  146. show: false,
  147. },
  148. axisLabel: {
  149. show: false,
  150. },
  151. data: [],
  152. },
  153. {
  154. //处理轴数据
  155. gridIndex: 1,
  156. type: "category",
  157. inverse: true,
  158. position: "left",
  159. axisLine: {
  160. show: false,
  161. },
  162. axisTick: {
  163. show: false,
  164. },
  165. axisLabel: {
  166. show: true,
  167. textStyle: {
  168. align: "center",
  169. color: "#ffffff",
  170. fontSize: 14,
  171. },
  172. },
  173. data: [],
  174. },
  175. {
  176. gridIndex: 2,
  177. type: "category",
  178. inverse: true,
  179. position: "left",
  180. axisLine: {
  181. show: false,
  182. },
  183. axisTick: {
  184. show: false,
  185. },
  186. axisLabel: {
  187. show: false,
  188. },
  189. },
  190. ],
  191. series: [
  192. {
  193. name: "",
  194. type: "bar",
  195. barGap: 20,
  196. barWidth: 15,
  197. label: {
  198. normal: {
  199. show: true,
  200. color: "red",
  201. position: "insideLeft",
  202. textStyle: {
  203. color: "#ffffff",
  204. },
  205. },
  206. emphasis: {
  207. show: false,
  208. },
  209. },
  210. itemStyle: {
  211. normal: {
  212. color: "#36c5e7",
  213. barBorderRadius: [8, 0, 0, 8],
  214. },
  215. emphasis: {
  216. show: false,
  217. },
  218. },
  219. data: [],
  220. },
  221. {
  222. name: "",
  223. type: "bar",
  224. barGap: 20,
  225. barWidth: 15,
  226. xAxisIndex: 2,
  227. yAxisIndex: 2,
  228. label: {
  229. normal: {
  230. show: true,
  231. color: "red",
  232. position: "insideRight",
  233. textStyle: {
  234. color: "#ffffff",
  235. },
  236. },
  237. },
  238. itemStyle: {
  239. normal: {
  240. color: "#e68b55",
  241. barBorderRadius: [0, 8, 8, 0],
  242. },
  243. emphasis: {
  244. show: false,
  245. },
  246. },
  247. data: [],
  248. },
  249. ],
  250. },
  251. optionsStyle: {},
  252. optionsData: {},
  253. optionsSetup: {},
  254. flagInter: null,
  255. };
  256. },
  257. computed: {
  258. styleObj() {
  259. return {
  260. position: this.ispreview ? "absolute" : "static",
  261. width: this.optionsStyle.width + "px",
  262. height: this.optionsStyle.height + "px",
  263. left: this.optionsStyle.left + "px",
  264. top: this.optionsStyle.top + "px",
  265. background: this.optionsSetup.background,
  266. };
  267. },
  268. allComponentLinkage() {
  269. return this.$store.state.designer.allComponentLinkage;
  270. },
  271. },
  272. watch: {
  273. value: {
  274. handler(val) {
  275. this.optionsStyle = val.position;
  276. this.optionsData = val.data;
  277. this.optionsCollapse = val.setup;
  278. this.optionsSetup = val.setup;
  279. this.editorOptions();
  280. },
  281. deep: true,
  282. },
  283. },
  284. mounted() {
  285. this.optionsStyle = this.value.position;
  286. this.optionsData = this.value.data;
  287. this.optionsCollapse = this.value.setup;
  288. this.optionsSetup = this.value.setup;
  289. this.editorOptions();
  290. targetWidgetLinkageLogic(this); // 联动-目标组件逻辑
  291. },
  292. methods: {
  293. // 修改图标options属性
  294. editorOptions() {
  295. this.setOptionsTitle();
  296. this.setOptionsXLeft();
  297. this.setOptionsXRight();
  298. this.setOptionsY();
  299. this.setOptionsTop();
  300. this.setOptionsTooltip();
  301. this.setOptionsGrid();
  302. this.setOptionsLegend();
  303. this.setOptionsColor();
  304. this.setOptionsData();
  305. },
  306. // 标题修改
  307. setOptionsTitle() {
  308. const optionsSetup = this.optionsSetup;
  309. const title = {
  310. text: optionsSetup.text,
  311. show: optionsSetup.isShowTitle,
  312. left: optionsSetup.titleLeft,
  313. top: optionsSetup.titleTop + "%",
  314. itemGap: optionsSetup.titleItemGap,
  315. textStyle: {
  316. color: optionsSetup.textColor,
  317. fontSize: optionsSetup.textFontSize,
  318. fontWeight: optionsSetup.textFontWeight,
  319. fontStyle: optionsSetup.textFontStyle,
  320. fontFamily: optionsSetup.textFontFamily,
  321. },
  322. subtext: optionsSetup.subtext,
  323. subtextStyle: {
  324. color: optionsSetup.subtextColor,
  325. fontWeight: optionsSetup.subtextFontWeight,
  326. fontSize: optionsSetup.subtextFontSize,
  327. fontStyle: optionsSetup.subtextFontStyle,
  328. fontFamily: optionsSetup.subtextFontFamily
  329. },
  330. };
  331. this.options.title = title;
  332. },
  333. // 左X轴设置
  334. setOptionsXLeft() {
  335. const optionsSetup = this.optionsSetup;
  336. const xAxisLeft = {
  337. max: optionsSetup.maxXLeft !== "" ? optionsSetup.maxXLeft : null,
  338. splitNumber: optionsSetup.splitNumberXLeft,
  339. type: "value",
  340. show: optionsSetup.isShowXLeft,
  341. inverse: true,
  342. position: "bottom",
  343. axisLabel: {
  344. // x轴
  345. show: optionsSetup.isShowAxisLabelXLeft,
  346. //interval: optionsSetup.textIntervalXLeft,
  347. textStyle: {
  348. color: optionsSetup.textColorXLeft,
  349. fontSize: optionsSetup.textFontSizeXLeft,
  350. fontWeight: optionsSetup.textFontWeightXLeft,
  351. fontStyle: optionsSetup.textFontStyleXLeft,
  352. fontFamily: optionsSetup.textFontFamilyXLeft,
  353. },
  354. },
  355. //X轴线
  356. axisLine: {
  357. show: optionsSetup.isShowAxisLineXLeft,
  358. lineStyle: {
  359. color: optionsSetup.lineColorXLeft,
  360. width: optionsSetup.lineWidthXLeft,
  361. },
  362. },
  363. // X轴刻度线
  364. axisTick: {
  365. show: optionsSetup.isShowAxisLineXLeft,
  366. lineStyle: {
  367. color: optionsSetup.lineColorXLeft,
  368. width: optionsSetup.lineWidthXLeft,
  369. },
  370. },
  371. splitLine: {
  372. // 分割线
  373. show: optionsSetup.isShowSplitLineXLeft,
  374. lineStyle: {
  375. color: optionsSetup.splitLineColorXLeft,
  376. width: optionsSetup.splitLineWidthXLeft,
  377. type: "solid",
  378. },
  379. },
  380. };
  381. this.options.xAxis[0] = xAxisLeft;
  382. },
  383. // 右X轴设置
  384. setOptionsXRight() {
  385. const optionsSetup = this.optionsSetup;
  386. const xAxisRight = {
  387. max: optionsSetup.maxXRight !== "" ? optionsSetup.maxXRight : null,
  388. gridIndex: 2,
  389. splitNumber: optionsSetup.splitNumberXRight,
  390. show: optionsSetup.isShowXRight,
  391. type: "value",
  392. position: "bottom",
  393. axisLabel: {
  394. // x轴
  395. show: optionsSetup.isShowAxisLabelXRight,
  396. textStyle: {
  397. color: optionsSetup.textColorXRight,
  398. fontSize: optionsSetup.textFontSizeXRight,
  399. fontWeight: optionsSetup.textFontWeightXRight,
  400. fontStyle: optionsSetup.textFontStyleXRight,
  401. fontFamily: optionsSetup.textFontFamilyXRight,
  402. },
  403. },
  404. axisLine: {
  405. //X轴线
  406. show: optionsSetup.isShowAxisLineXRight,
  407. lineStyle: {
  408. color: optionsSetup.lineColorXRight,
  409. width: optionsSetup.lineWidthXRight,
  410. },
  411. },
  412. axisTick: {
  413. show: optionsSetup.isShowAxisLineXRight,
  414. lineStyle: {
  415. color: optionsSetup.lineColorXRight,
  416. width: optionsSetup.lineWidthXRight,
  417. },
  418. },
  419. splitLine: {
  420. // 分割线
  421. show: optionsSetup.isShowSplitLineXRight,
  422. lineStyle: {
  423. color: optionsSetup.splitLineColorXRight,
  424. width: optionsSetup.splitLineWidthXRight,
  425. type: "solid",
  426. },
  427. },
  428. };
  429. this.options.xAxis[2] = xAxisRight;
  430. },
  431. // Y轴设置
  432. setOptionsY() {
  433. const optionsSetup = this.optionsSetup;
  434. const yAxis = {
  435. //处理轴数据
  436. gridIndex: 1,
  437. type: "category",
  438. inverse: true,
  439. show: true,
  440. axisLabel: {
  441. show: optionsSetup.isShowAxisLabelY,
  442. interval: optionsSetup.textIntervalY,
  443. textStyle: {
  444. align: "center",
  445. color: optionsSetup.textColorY,
  446. fontSize: optionsSetup.textFontSizeY,
  447. fontWeight: optionsSetup.textFontWeightY,
  448. fontStyle: optionsSetup.textFontStyleY,
  449. fontFamily: optionsSetup.textFontFamilyY,
  450. },
  451. },
  452. axisLine: {
  453. show: false,
  454. },
  455. axisTick: {
  456. show: false,
  457. },
  458. };
  459. this.options.yAxis[1] = yAxis;
  460. },
  461. // 数值设定、柱体设置
  462. setOptionsTop() {
  463. const optionsSetup = this.optionsSetup;
  464. const series = this.options.series;
  465. series[0].label = {
  466. normal: {
  467. show: optionsSetup.isShow,
  468. position: "insideLeft",
  469. textStyle: {
  470. fontSize: optionsSetup.fontSize,
  471. color: optionsSetup.dataColor,
  472. fontWeight: optionsSetup.fontWeight,
  473. },
  474. },
  475. emphasis: {
  476. show: false,
  477. },
  478. };
  479. series[1].label = {
  480. normal: {
  481. show: optionsSetup.isShow,
  482. color: "red",
  483. position: "insideRight",
  484. textStyle: {
  485. fontSize: optionsSetup.fontSize,
  486. color: optionsSetup.dataColor,
  487. fontWeight: optionsSetup.fontWeight,
  488. },
  489. },
  490. emphasis: {
  491. show: false,
  492. },
  493. };
  494. for (const key in series) {
  495. series[key].barWidth = optionsSetup.maxWidth;
  496. //柱体背景属性
  497. series[key].showBackground = optionsSetup.isShowBackground;
  498. series[key].backgroundStyle = {
  499. color: optionsSetup.backgroundStyleColor,
  500. borderColor: optionsSetup.backgroundStyleBorderColor,
  501. borderWidth: optionsSetup.backgroundStyleBorderWidth,
  502. borderType: optionsSetup.backgroundStyleBorderType,
  503. shadowBlur: optionsSetup.backgroundStyleShadowBlur,
  504. shadowColor: optionsSetup.backgroundStyleShadowColor,
  505. opacity: optionsSetup.backgroundStyleOpacity / 100,
  506. };
  507. }
  508. this.options.series = series;
  509. },
  510. // tooltip 提示语设置
  511. setOptionsTooltip() {
  512. const optionsSetup = this.optionsSetup;
  513. const tooltip = {
  514. show: optionsSetup.isShowTooltip,
  515. trigger: optionsSetup.tooltipTrigger,
  516. axisPointer: {
  517. type: optionsSetup.tooltipAxisPointerType,
  518. },
  519. backgroundColor: optionsSetup.tooltipBackgroundColor,
  520. borderColor: optionsSetup.tooltipBorderColor,
  521. borderWidth: optionsSetup.tooltipBorderWidth,
  522. textStyle: {
  523. color: optionsSetup.tooltipColor,
  524. fontSize: optionsSetup.tooltipFontSize,
  525. fontWeight: optionsSetup.tooltipFontWeight,
  526. fontStyle: optionsSetup.tooltipFontStyle,
  527. fontFamily: optionsSetup.tooltipFontFamily,
  528. },
  529. };
  530. this.options.tooltip = tooltip;
  531. },
  532. // 边距设置
  533. setOptionsGrid() {
  534. const optionsSetup = this.optionsSetup;
  535. const grid = [
  536. {
  537. //左
  538. show: optionsSetup.frameLineLeft,
  539. borderColor: optionsSetup.borderColorLeft,
  540. borderWidth: optionsSetup.borderWidthLeft,
  541. left: optionsSetup.marginLeftRight,
  542. top: optionsSetup.marginTop,
  543. bottom: optionsSetup.marginBottom,
  544. containLabel: true,
  545. width: "40%",
  546. },
  547. {
  548. //中间字体位置
  549. show: false,
  550. left: "51%",
  551. top: optionsSetup.marginTop,
  552. bottom: optionsSetup.marginBottom + 15,
  553. width: "0%",
  554. },
  555. {
  556. //右
  557. show: optionsSetup.frameLineRight,
  558. borderColor: optionsSetup.borderColorRight,
  559. borderWidth: optionsSetup.borderWidthRight,
  560. right: optionsSetup.marginLeftRight,
  561. top: optionsSetup.marginTop,
  562. bottom: optionsSetup.marginBottom,
  563. containLabel: true,
  564. width: "40%",
  565. },
  566. ];
  567. this.options.grid = grid;
  568. },
  569. // 图例操作
  570. setOptionsLegend() {
  571. const optionsSetup = this.optionsSetup;
  572. const legend = {
  573. show: optionsSetup.isShowLegend,
  574. left: optionsSetup.lateralPosition,
  575. //right: optionsSetup.lateralPosition,
  576. top: optionsSetup.longitudinalPosition,
  577. //bottom: optionsSetup.longitudinalPosition,
  578. orient: optionsSetup.layoutFront,
  579. textStyle: {
  580. color: optionsSetup.legendColor,
  581. fontSize: optionsSetup.legendFontSize,
  582. fontWeight: optionsSetup.legendFontWeight,
  583. fontStyle: optionsSetup.legendFontStyle,
  584. fontFamily: optionsSetup.legendFontFamily,
  585. },
  586. itemHeight: optionsSetup.legendHeight,
  587. itemWidth: optionsSetup.legendWidth,
  588. };
  589. this.options.legend = legend;
  590. },
  591. // 图例名称设置
  592. setOptionsLegendName(name) {
  593. const optionsSetup = this.optionsSetup;
  594. const series = this.options.series;
  595. const legendName = optionsSetup.legendName;
  596. // 图例没有手动写则显示原值,写了则显示新值
  597. if (null == legendName || legendName == "") {
  598. for (let i = 0; i < name.length; i++) {
  599. series[i].name = name[i];
  600. }
  601. this.options.legend["data"] = name;
  602. } else {
  603. const arr = legendName.split("|");
  604. for (let i = 0; i < arr.length; i++) {
  605. series[i].name = arr[i];
  606. }
  607. this.options.legend["data"] = arr;
  608. }
  609. },
  610. // 颜色修改、圆角修改
  611. setOptionsColor() {
  612. const optionsSetup = this.optionsSetup;
  613. const customColor = optionsSetup.customColor;
  614. if (!customColor) return;
  615. const itemStyleLeft = {
  616. normal: {
  617. color: customColor[0].color,
  618. barBorderRadius: [optionsSetup.radius, 0, 0, optionsSetup.radius],
  619. },
  620. emphasis: {
  621. show: false,
  622. },
  623. };
  624. const itemStyleRight = {
  625. normal: {
  626. color: customColor[1].color,
  627. barBorderRadius: [0, optionsSetup.radius, optionsSetup.radius, 0],
  628. },
  629. emphasis: {
  630. show: false,
  631. },
  632. };
  633. this.options.series[0].itemStyle = itemStyleLeft;
  634. this.options.series[1].itemStyle = itemStyleRight;
  635. },
  636. // 数据解析
  637. setOptionsData(e, paramsConfig) {
  638. const optionsSetup = this.optionsSetup;
  639. const optionsData = this.optionsData; // 数据类型 静态 or 动态
  640. // 联动接收者逻辑开始
  641. optionsData.dynamicData = optionsData.dynamicData || {}; // 兼容 dynamicData undefined
  642. const myDynamicData = optionsData.dynamicData;
  643. clearInterval(this.flagInter); // 不管咋,先干掉上一次的定时任务,避免多跑
  644. if (
  645. e &&
  646. optionsData.dataType !== "staticData" &&
  647. Object.keys(myDynamicData.contextData).length
  648. ) {
  649. const keyArr = Object.keys(myDynamicData.contextData);
  650. paramsConfig.forEach((conf) => {
  651. if (keyArr.includes(conf.targetKey)) {
  652. myDynamicData.contextData[conf.targetKey] = e[conf.originKey];
  653. }
  654. });
  655. }
  656. // 联动接收者逻辑结束
  657. optionsData.dataType == "staticData"
  658. ? this.staticDataFn(optionsData.staticData, optionsSetup)
  659. : this.dynamicDataFn(
  660. optionsData.dynamicData,
  661. optionsData.refreshTime,
  662. optionsSetup
  663. );
  664. },
  665. //去重
  666. setUnique(arr) {
  667. let newArr = [];
  668. arr.forEach((item) => {
  669. return newArr.includes(item) ? "" : newArr.push(item);
  670. });
  671. return newArr;
  672. },
  673. //静态数据
  674. staticDataFn(val) {
  675. //数据
  676. let xAxisList = [];
  677. let yAxisList = [];
  678. let arrayList = [];
  679. const legendName = [];
  680. for (const i in val) {
  681. xAxisList[i] = val[i].axis;
  682. yAxisList[i] = val[i].name;
  683. }
  684. xAxisList = this.setUnique(xAxisList);
  685. yAxisList = this.setUnique(yAxisList);
  686. for (const i in yAxisList) {
  687. const data = new Array(xAxisList.length).fill(0);
  688. for (const j in xAxisList) {
  689. for (const k in val) {
  690. if (val[k].name == yAxisList[i]) {
  691. if (val[k].axis == xAxisList[j]) {
  692. data[j] = val[k].data;
  693. }
  694. }
  695. }
  696. }
  697. arrayList.push({
  698. name: yAxisList[i],
  699. data: data,
  700. });
  701. legendName.push(yAxisList[i]);
  702. }
  703. this.options.series[0]["name"] = arrayList[0].name;
  704. this.options.series[0]["data"] = arrayList[0].data;
  705. this.options.series[1]["name"] = arrayList[1].name;
  706. this.options.series[1]["data"] = arrayList[1].data;
  707. this.options.yAxis[1]["data"] = xAxisList;
  708. this.options.legend["data"] = legendName;
  709. this.setOptionsLegendName(legendName);
  710. },
  711. // 动态数据
  712. dynamicDataFn(val, refreshTime, optionsSetup) {
  713. if (!val) return;
  714. if (this.ispreview) {
  715. this.getEchartData(val, optionsSetup);
  716. this.flagInter = setInterval(() => {
  717. this.getEchartData(val, optionsSetup);
  718. }, refreshTime);
  719. } else {
  720. this.getEchartData(val, optionsSetup);
  721. }
  722. },
  723. getEchartData(val, optionsSetup) {
  724. const data = this.queryEchartsData(val);
  725. data.then((res) => {
  726. this.renderingFn(optionsSetup, res);
  727. });
  728. },
  729. renderingFn(optionsSetup, val) {
  730. const legendName = [];
  731. this.options.yAxis[1]["data"] = val.xAxis;
  732. if (val.series[0].type == "bar") {
  733. this.options.series[0]["name"] = val.series[0].name;
  734. this.options.series[0]["data"] = val.series[0].data;
  735. this.options.series[1]["name"] = val.series[1].name;
  736. this.options.series[1]["data"] = val.series[1].data;
  737. legendName.push(val.series[0].name);
  738. legendName.push(val.series[1].name);
  739. }
  740. this.options.legend["data"] = legendName;
  741. this.setOptionsLegendName(legendName);
  742. },
  743. },
  744. };
  745. </script>
  746. <style scoped lang="scss">
  747. .echarts {
  748. width: 100%;
  749. height: 100%;
  750. overflow: hidden;
  751. }
  752. </style>