widgetBarlinechart.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. <template>
  2. <div :style="styleObj">
  3. <v-chart ref="myVChart" :option="options" autoresize/>
  4. </div>
  5. </template>
  6. <script>
  7. import {targetWidgetLinkageLogic} from "@/views/bigscreenDesigner/designer/linkageLogic";
  8. export default {
  9. name: "WidgetBarlinechart",
  10. components: {},
  11. props: {
  12. value: Object,
  13. ispreview: Boolean,
  14. },
  15. data() {
  16. return {
  17. options: {
  18. color: [],
  19. grid: {},
  20. title: {
  21. text: "",
  22. textStyle: {
  23. color: "#fff",
  24. },
  25. },
  26. tooltip: {
  27. trigger: "item",
  28. formatter: "{a} <br/>{b} : {c}%",
  29. },
  30. legend: {
  31. textStyle: {
  32. color: "#fff",
  33. },
  34. },
  35. xAxis: [
  36. {
  37. type: "category",
  38. data: [],
  39. axisLabel: {
  40. show: false,
  41. textStyle: {
  42. color: "#fff",
  43. },
  44. },
  45. },
  46. ],
  47. yAxis: [
  48. {
  49. type: "value",
  50. name: "",
  51. min: 0,
  52. max: 250,
  53. interval: 50,
  54. axisLabel: {
  55. show: true,
  56. textStyle: {
  57. color: "#fff",
  58. },
  59. },
  60. },
  61. {
  62. type: "value",
  63. name: "",
  64. min: 0,
  65. max: 25,
  66. interval: 5,
  67. axisLabel: {
  68. show: true,
  69. textStyle: {
  70. color: "#fff",
  71. },
  72. },
  73. },
  74. ],
  75. series: [
  76. {
  77. name: "",
  78. type: "bar",
  79. yAxisIndex: 0,
  80. data: [],
  81. itemStyle: {
  82. barBorderRadius: null,
  83. },
  84. },
  85. {
  86. name: "",
  87. type: "line",
  88. yAxisIndex: 1,
  89. data: [],
  90. itemStyle: {},
  91. },
  92. ],
  93. },
  94. optionsStyle: {}, // 样式
  95. optionsData: {}, // 数据
  96. optionsCollapse: {}, // 图标属性
  97. optionsSetup: {},
  98. flagInter: null,
  99. };
  100. },
  101. computed: {
  102. styleObj() {
  103. return {
  104. position: this.ispreview ? "absolute" : "static",
  105. width: this.optionsStyle.width + "px",
  106. height: this.optionsStyle.height + "px",
  107. left: this.optionsStyle.left + "px",
  108. top: this.optionsStyle.top + "px",
  109. background: this.optionsSetup.background,
  110. };
  111. },
  112. allComponentLinkage() {
  113. return this.$store.state.designer.allComponentLinkage;
  114. },
  115. },
  116. watch: {
  117. value: {
  118. handler(val) {
  119. this.optionsStyle = val.position;
  120. this.optionsData = val.data;
  121. this.optionsCollapse = val.collapse;
  122. this.optionsSetup = val.setup;
  123. this.editorOptions();
  124. },
  125. deep: true,
  126. },
  127. },
  128. created() {
  129. this.optionsStyle = this.value.position;
  130. this.optionsData = this.value.data;
  131. this.optionsCollapse = this.value.collapse;
  132. this.optionsSetup = this.value.setup;
  133. this.editorOptions();
  134. targetWidgetLinkageLogic(this); // 联动-目标组件逻辑
  135. },
  136. methods: {
  137. // 修改图标options属性
  138. editorOptions() {
  139. this.setOptionsTitle();
  140. this.setOptionsX();
  141. this.setOptionsY();
  142. this.setOptionsLine();
  143. this.setOptionsBar();
  144. this.setOptionsTooltip();
  145. this.setOptionsData();
  146. this.setOptionsMargin();
  147. this.setOptionsLegend();
  148. this.setOptionsColor();
  149. },
  150. // 标题修改
  151. setOptionsTitle() {
  152. const optionsSetup = this.optionsSetup;
  153. const title = {
  154. text: optionsSetup.text,
  155. show: optionsSetup.isShowTitle,
  156. left: optionsSetup.titleLeft,
  157. top: optionsSetup.titleTop + "%",
  158. itemGap: optionsSetup.titleItemGap,
  159. textStyle: {
  160. color: optionsSetup.textColor,
  161. fontSize: optionsSetup.textFontSize,
  162. fontWeight: optionsSetup.textFontWeight,
  163. fontStyle: optionsSetup.textFontStyle,
  164. fontFamily: optionsSetup.textFontFamily,
  165. },
  166. subtext: optionsSetup.subtext,
  167. subtextStyle: {
  168. color: optionsSetup.subtextColor,
  169. fontWeight: optionsSetup.subtextFontWeight,
  170. fontSize: optionsSetup.subtextFontSize,
  171. fontStyle: optionsSetup.subtextFontStyle,
  172. fontFamily: optionsSetup.subtextFontFamily
  173. },
  174. };
  175. this.options.title = title;
  176. },
  177. // X轴设置
  178. setOptionsX() {
  179. const optionsSetup = this.optionsSetup;
  180. const xAxis = {
  181. type: "category",
  182. // 坐标轴是否显示
  183. show: optionsSetup.isShowX,
  184. position: optionsSetup.positionX,
  185. offset: optionsSetup.offsetX,
  186. // 坐标轴名称
  187. name: optionsSetup.nameX,
  188. nameLocation: optionsSetup.nameLocationX,
  189. nameTextStyle: {
  190. color: optionsSetup.nameColorX,
  191. fontSize: optionsSetup.nameFontSizeX,
  192. fontWeight: optionsSetup.nameFontWeightX,
  193. fontStyle: optionsSetup.nameFontStyleX,
  194. fontFamily: optionsSetup.nameFontFamilyX,
  195. },
  196. // 轴反转
  197. inverse: optionsSetup.reversalX,
  198. axisLabel: {
  199. show: optionsSetup.isShowAxisLabelX,
  200. interval: optionsSetup.textIntervalX,
  201. // 文字角度
  202. rotate: optionsSetup.textAngleX,
  203. textStyle: {
  204. // 坐标文字颜色
  205. color: optionsSetup.textColorX,
  206. fontSize: optionsSetup.textFontSizeX,
  207. fontWeight: optionsSetup.textFontWeightX,
  208. fontStyle: optionsSetup.textFontStyleX,
  209. fontFamily: optionsSetup.textFontFamilyX,
  210. },
  211. },
  212. // X轴线
  213. axisLine: {
  214. show: optionsSetup.isShowAxisLineX,
  215. lineStyle: {
  216. color: optionsSetup.lineColorX,
  217. width: optionsSetup.lineWidthX,
  218. },
  219. },
  220. // X轴刻度线
  221. axisTick: {
  222. show: optionsSetup.isShowAxisLineX,
  223. lineStyle: {
  224. color: optionsSetup.lineColorX,
  225. width: optionsSetup.lineWidthX,
  226. },
  227. },
  228. // X轴分割线
  229. splitLine: {
  230. show: optionsSetup.isShowSplitLineX,
  231. lineStyle: {
  232. color: optionsSetup.splitLineColorX,
  233. width: optionsSetup.splitLineWidthX,
  234. },
  235. },
  236. };
  237. this.options.xAxis = xAxis;
  238. },
  239. // Y轴设置
  240. setOptionsY() {
  241. const optionsSetup = this.optionsSetup;
  242. const yAxis = [
  243. {
  244. max: optionsSetup.maxYLeft !== "" ? optionsSetup.maxYLeft : null,
  245. type: "value",
  246. scale: optionsSetup.scaleYLeft,
  247. // 均分
  248. splitNumber: optionsSetup.splitNumberYLeft,
  249. // 坐标轴是否显示
  250. show: optionsSetup.isShowYLeft,
  251. position: optionsSetup.positionYLeft,
  252. offset: optionsSetup.offsetYLeft,
  253. // 坐标轴名称
  254. name: optionsSetup.textNameYLeft,
  255. nameLocation: optionsSetup.nameLocationYLeft,
  256. // 别名
  257. nameTextStyle: {
  258. color: optionsSetup.nameColorYLeft,
  259. fontSize: optionsSetup.nameFontSizeYLeft,
  260. fontWeight: optionsSetup.nameFontWeightYLeft,
  261. fontStyle: optionsSetup.nameFontStyleYLeft,
  262. fontFamily: optionsSetup.nameFontFamilyYLeft,
  263. },
  264. axisLabel: {
  265. show: optionsSetup.isShowAxisLabelYLeft,
  266. // 文字角度
  267. rotate: optionsSetup.textAngleYLeft,
  268. textStyle: {
  269. // 坐标文字颜色
  270. color: optionsSetup.textColorYLeft,
  271. fontSize: optionsSetup.textFontSizeYLeft,
  272. fontWeight: optionsSetup.textFontWeightYLeft,
  273. fontStyle: optionsSetup.textFontStyleYLeft,
  274. fontFamily: optionsSetup.textFontFamilyYLeft,
  275. },
  276. },
  277. axisLine: {
  278. show: optionsSetup.isShowAxisLineYLeft,
  279. lineStyle: {
  280. width: optionsSetup.lineWidthYLeft,
  281. color: optionsSetup.lineColorYLeft,
  282. },
  283. },
  284. axisTick: {
  285. // 刻度
  286. show: optionsSetup.isShowAxisLineYLeft,
  287. lineStyle: {
  288. width: optionsSetup.lineWidthYLeft,
  289. color: optionsSetup.lineColorYLeft,
  290. },
  291. },
  292. splitLine: {
  293. show: optionsSetup.isShowSplitLineYLeft,
  294. lineStyle: {
  295. color: optionsSetup.splitLineColorYLeft,
  296. width: optionsSetup.splitLineFontWidthYLeft,
  297. },
  298. },
  299. },
  300. {
  301. max: optionsSetup.maxYRight !== "" ? optionsSetup.maxYRight : null,
  302. type: "value",
  303. scale: optionsSetup.scaleYRight,
  304. // 均分
  305. splitNumber: optionsSetup.splitNumberYRight,
  306. // 坐标轴是否显示
  307. show: optionsSetup.isShowYRight,
  308. position: optionsSetup.positionYRight,
  309. offset: optionsSetup.offsetYRight,
  310. // 坐标轴名称
  311. name: optionsSetup.textNameYRight,
  312. nameLocation: optionsSetup.nameLocationYRight,
  313. // 别名
  314. nameTextStyle: {
  315. color: optionsSetup.nameColorYRight,
  316. fontSize: optionsSetup.nameFontSizeYRight,
  317. fontWeight: optionsSetup.nameFontWeightYRight,
  318. fontStyle: optionsSetup.nameFontStyleYRight,
  319. fontFamily: optionsSetup.nameFontFamilyYRight,
  320. },
  321. axisLabel: {
  322. show: optionsSetup.isShowAxisLabelYRight,
  323. // 文字角度
  324. rotate: optionsSetup.textAngleYRight,
  325. textStyle: {
  326. // 坐标文字颜色
  327. color: optionsSetup.textColorYRight,
  328. fontSize: optionsSetup.textFontSizeYRight,
  329. fontWeight: optionsSetup.textFontWeightYRight,
  330. fontStyle: optionsSetup.textFontStyleYRight,
  331. fontFamily: optionsSetup.textFontFamilyYRight,
  332. },
  333. },
  334. axisLine: {
  335. show: optionsSetup.isShowAxisLineYRight,
  336. lineStyle: {
  337. width: optionsSetup.lineWidthYRight,
  338. color: optionsSetup.lineColorYRight,
  339. },
  340. },
  341. axisTick: {
  342. // 刻度
  343. show: optionsSetup.isShowAxisLineYRight,
  344. lineStyle: {
  345. width: optionsSetup.lineWidthYRight,
  346. color: optionsSetup.lineColorYRight,
  347. }
  348. },
  349. splitLine: {
  350. show: optionsSetup.isShowSplitLineYRight,
  351. lineStyle: {
  352. color: optionsSetup.splitLineColorYRight,
  353. width: optionsSetup.splitLineFontWidthYRight,
  354. },
  355. },
  356. },
  357. ];
  358. this.options.yAxis = yAxis;
  359. },
  360. // 折线设置 数值设置
  361. setOptionsLine() {
  362. const optionsSetup = this.optionsSetup;
  363. const series = this.options.series;
  364. for (const key in series) {
  365. if (series[key].type == "line") {
  366. series[key].symbol = optionsSetup.symbol;
  367. series[key].showSymbol = optionsSetup.markPoint;
  368. series[key].symbolSize = optionsSetup.pointSize;
  369. series[key].smooth = optionsSetup.smoothCurve;
  370. if (optionsSetup.area) {
  371. series[key].areaStyle = {
  372. opacity: optionsSetup.areaThickness / 100,
  373. };
  374. } else {
  375. series[key].areaStyle = {
  376. opacity: 0,
  377. };
  378. }
  379. series[key].lineStyle = {
  380. width: optionsSetup.lineWidth,
  381. };
  382. series[key].itemStyle.borderRadius = optionsSetup.radius;
  383. series[key].label = {
  384. show: optionsSetup.isShowLine,
  385. position: optionsSetup.fontPositionLine,
  386. distance: optionsSetup.fontDistanceLine,
  387. fontSize: optionsSetup.fontSizeLine,
  388. color: optionsSetup.fontColorLine,
  389. fontWeight: optionsSetup.fontWeightLine,
  390. formatter: !!optionsSetup.percentSignLine ? '{c}%' : '{c}',
  391. fontStyle: optionsSetup.fontStyleLine,
  392. fontFamily: optionsSetup.fontFamilyLine,
  393. };
  394. }
  395. }
  396. this.options.series = series;
  397. },
  398. // 柱体设置 数值设置
  399. setOptionsBar() {
  400. const optionsSetup = this.optionsSetup;
  401. const series = this.options.series;
  402. for (const key in series) {
  403. if (series[key].type == "bar") {
  404. series[key].label = {
  405. show: optionsSetup.isShowBar,
  406. position: optionsSetup.fontPositionBar,
  407. distance: optionsSetup.fontDistanceBar,
  408. fontSize: optionsSetup.fontSizeBar,
  409. color: optionsSetup.fontColorBar,
  410. fontWeight: optionsSetup.fontWeightBar,
  411. formatter: !!optionsSetup.percentSignBar ? '{c}%' : '{c}',
  412. fontStyle: optionsSetup.fontStyleBar,
  413. fontFamily: optionsSetup.fontFamilyBar,
  414. };
  415. //柱体背景属性
  416. series[key].showBackground = optionsSetup.isShowBackground;
  417. series[key].backgroundStyle = {
  418. color: optionsSetup.backgroundStyleColor,
  419. borderColor: optionsSetup.backgroundStyleBorderColor,
  420. borderWidth: optionsSetup.backgroundStyleBorderWidth,
  421. borderType: optionsSetup.backgroundStyleBorderType,
  422. shadowBlur: optionsSetup.backgroundStyleShadowBlur,
  423. shadowColor: optionsSetup.backgroundStyleShadowColor,
  424. opacity: optionsSetup.backgroundStyleOpacity / 100,
  425. };
  426. series[key].barWidth = optionsSetup.maxWidth;
  427. series[key].barMinHeight = optionsSetup.minHeight;
  428. series[key].itemStyle.barBorderRadius = optionsSetup.radius;
  429. }
  430. }
  431. this.options.series = series;
  432. },
  433. // tooltip 设置
  434. setOptionsTooltip() {
  435. const optionsSetup = this.optionsSetup;
  436. const tooltip = {
  437. show: optionsSetup.isShowTooltip,
  438. trigger: optionsSetup.tooltipTrigger,
  439. axisPointer: {
  440. type: optionsSetup.tooltipAxisPointerType,
  441. },
  442. backgroundColor: optionsSetup.tooltipBackgroundColor,
  443. borderColor: optionsSetup.tooltipBorderColor,
  444. borderWidth: optionsSetup.tooltipBorderWidth,
  445. textStyle: {
  446. color: optionsSetup.tooltipColor,
  447. fontSize: optionsSetup.tooltipFontSize,
  448. fontWeight: optionsSetup.tooltipFontWeight,
  449. fontStyle: optionsSetup.tooltipFontStyle,
  450. fontFamily: optionsSetup.tooltipFontFamily,
  451. },
  452. };
  453. this.options.tooltip = tooltip;
  454. },
  455. // 边距设置
  456. setOptionsMargin() {
  457. const optionsSetup = this.optionsSetup;
  458. const grid = {
  459. left: optionsSetup.marginLeft,
  460. right: optionsSetup.marginRight,
  461. bottom: optionsSetup.marginBottom,
  462. top: optionsSetup.marginTop,
  463. containLabel: true,
  464. };
  465. this.options.grid = grid;
  466. },
  467. setOptionsLegend() {
  468. const optionsSetup = this.optionsSetup;
  469. const legend = {
  470. show: optionsSetup.isShowLegend,
  471. left: optionsSetup.lateralPosition,
  472. //right: optionsSetup.lateralPosition,
  473. top: optionsSetup.longitudinalPosition,
  474. //bottom: optionsSetup.longitudinalPosition,
  475. orient: optionsSetup.layoutFront,
  476. textStyle: {
  477. color: optionsSetup.legendColor,
  478. fontSize: optionsSetup.legendFontSize,
  479. fontWeight: optionsSetup.legendFontWeight,
  480. fontStyle: optionsSetup.legendFontStyle,
  481. fontFamily: optionsSetup.legendFontFamily,
  482. },
  483. itemHeight: optionsSetup.legendHeight,
  484. itemWidth: optionsSetup.legendWidth,
  485. };
  486. this.options.legend = legend;
  487. },
  488. // 图例名称设置
  489. setOptionsLegendName(name) {
  490. const optionsSetup = this.optionsSetup;
  491. const series = this.options.series;
  492. const legendName = optionsSetup.legendName;
  493. // 图例没有手动写则显示原值,写了则显示新值
  494. if (null == legendName || legendName == "") {
  495. for (let i = 0; i < name.length; i++) {
  496. series[i].name = name[i];
  497. }
  498. this.options.legend["data"] = name;
  499. } else {
  500. const arr = legendName.split("|");
  501. for (let i = 0; i < arr.length; i++) {
  502. series[i].name = arr[i];
  503. }
  504. this.options.legend["data"] = arr;
  505. }
  506. },
  507. // 图例颜色修改
  508. setOptionsColor() {
  509. const optionsSetup = this.optionsSetup;
  510. const customColor = optionsSetup.customColor;
  511. if (!customColor) return;
  512. const arrColor = [];
  513. for (let i = 0; i < customColor.length; i++) {
  514. arrColor.push(customColor[i].color);
  515. }
  516. this.options.color = arrColor;
  517. this.options = Object.assign({}, this.options);
  518. },
  519. // 数据处理
  520. setOptionsData(e, paramsConfig) {
  521. const optionsData = this.optionsData; // 数据类型 静态 or 动态
  522. // 联动接收者逻辑开始
  523. optionsData.dynamicData = optionsData.dynamicData || {}; // 兼容 dynamicData undefined
  524. const myDynamicData = optionsData.dynamicData;
  525. clearInterval(this.flagInter); // 不管咋,先干掉上一次的定时任务,避免多跑
  526. if (
  527. e &&
  528. optionsData.dataType !== "staticData" &&
  529. Object.keys(myDynamicData.contextData).length
  530. ) {
  531. const keyArr = Object.keys(myDynamicData.contextData);
  532. paramsConfig.forEach((conf) => {
  533. if (keyArr.includes(conf.targetKey)) {
  534. myDynamicData.contextData[conf.targetKey] = e[conf.originKey];
  535. }
  536. });
  537. }
  538. // 联动接收者逻辑结束
  539. optionsData.dataType == "staticData"
  540. ? this.staticDataFn(optionsData.staticData)
  541. : this.dynamicDataFn(optionsData.dynamicData, optionsData.refreshTime);
  542. },
  543. staticDataFn(val) {
  544. const series = this.options.series;
  545. let axis = [];
  546. let bar = [];
  547. let line = [];
  548. for (const i in val) {
  549. axis[i] = val[i].axis;
  550. bar[i] = val[i].bar;
  551. line[i] = val[i].line;
  552. }
  553. // x轴
  554. this.options.xAxis.data = axis;
  555. // series
  556. for (const i in series) {
  557. if (series[i].type == "bar") {
  558. series[i].data = bar;
  559. } else {
  560. series[i].data = line;
  561. }
  562. }
  563. const legendName = [];
  564. legendName.push("bar");
  565. legendName.push("line");
  566. const optionsSetup = this.optionsSetup;
  567. // 根据图表的宽度 x轴的字体大小、长度来估算X轴的label能展示多少个字
  568. const rowsNum = optionsSetup.textRowsNum !== "" ? optionsSetup.textRowsNum : parseInt((this.optionsStyle.width / axis.length) / optionsSetup.textFontSizeX);
  569. const axisLabel = {
  570. show: optionsSetup.isShowAxisLabelX,
  571. interval: optionsSetup.textIntervalX,
  572. // 文字角度
  573. rotate: optionsSetup.textAngleX,
  574. textStyle: {
  575. // 坐标文字颜色
  576. color: optionsSetup.textColorX,
  577. fontSize: optionsSetup.textFontSizeX,
  578. fontWeight: optionsSetup.textFontWeightX,
  579. fontStyle: optionsSetup.textFontStyleX,
  580. fontFamily: optionsSetup.textFontFamilyX,
  581. },
  582. // 自动换行
  583. formatter: function (value, index) {
  584. const strs = value.split('');
  585. let str = ''
  586. for (let i = 0, s; s = strs[i++];) {
  587. str += s;
  588. if (!(i % rowsNum)) str += '\n';
  589. }
  590. return str
  591. }
  592. }
  593. if (optionsSetup.textRowsBreakAuto) {
  594. this.options.xAxis.axisLabel = axisLabel;
  595. }
  596. this.options.legend["data"] = legendName;
  597. this.setOptionsLegendName(legendName);
  598. },
  599. dynamicDataFn(val, refreshTime) {
  600. if (!val) return;
  601. if (this.ispreview) {
  602. this.getEchartData(val);
  603. this.flagInter = setInterval(() => {
  604. this.getEchartData(val);
  605. }, refreshTime);
  606. } else {
  607. this.getEchartData(val);
  608. }
  609. },
  610. getEchartData(val) {
  611. const data = this.queryEchartsData(val);
  612. data.then((res) => {
  613. this.renderingFn(res);
  614. });
  615. },
  616. renderingFn(val) {
  617. this.options.xAxis.data = val.xAxis;
  618. // series
  619. const series = this.options.series;
  620. const legendName = [];
  621. for (const i in series) {
  622. for (const j in val.series) {
  623. if (series[i].type == val.series[j].type) {
  624. series[i].data = val.series[j].data;
  625. legendName.push(val.series[j].name);
  626. }
  627. }
  628. }
  629. const optionsSetup = this.optionsSetup;
  630. // 根据图表的宽度 x轴的字体大小、长度来估算X轴的label能展示多少个字
  631. const xAxisDataLength = val.length !== 0 ? val.xAxis.length : 1;
  632. const rowsNum = optionsSetup.textRowsNum !== "" ? optionsSetup.textRowsNum : parseInt((this.optionsStyle.width / xAxisDataLength) / optionsSetup.textFontSizeX);
  633. const axisLabel = {
  634. show: optionsSetup.isShowAxisLabelX,
  635. interval: optionsSetup.textIntervalX,
  636. // 文字角度
  637. rotate: optionsSetup.textAngleX,
  638. textStyle: {
  639. // 坐标文字颜色
  640. color: optionsSetup.textColorX,
  641. fontSize: optionsSetup.textFontSizeX,
  642. fontWeight: optionsSetup.textFontWeightX,
  643. fontStyle: optionsSetup.textFontStyleX,
  644. fontFamily: optionsSetup.textFontFamilyX,
  645. },
  646. // 自动换行
  647. formatter: function (value, index) {
  648. const strs = value.split('');
  649. let str = ''
  650. for (let i = 0, s; s = strs[i++];) {
  651. str += s;
  652. if (!(i % rowsNum)) str += '\n';
  653. }
  654. return str
  655. }
  656. }
  657. if (optionsSetup.textRowsBreakAuto) {
  658. this.options.xAxis.axisLabel = axisLabel;
  659. }
  660. this.options.legend["data"] = legendName;
  661. this.setOptionsLegendName(legendName);
  662. },
  663. },
  664. };
  665. </script>
  666. <style scoped lang="scss">
  667. .echarts {
  668. width: 100%;
  669. height: 100%;
  670. overflow: hidden;
  671. }
  672. </style>