物管理前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

627 lines
41 KiB

  1. const e="c4c1eab4-b5b7-40f3-8ed9-4f84a96a0a99",t="custom-horizontal-barchart",a="双y轴柱状图",n='<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1697419854399" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8090" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M480 192H160a32 32 0 0 1 0-64h320a32 32 0 0 1 0 64z" fill="#4A8BFE" p-id="8091"></path><path d="M608 288H160a32 32 0 0 1 0-64h448a32 32 0 0 1 0 64z" fill="#3BD5B3" p-id="8092"></path><path d="M608 496H160a32 32 0 0 1 0-64h448a32 32 0 0 1 0 64z" fill="#4A8BFE" p-id="8093"></path><path d="M736 592H160a32 32 0 0 1 0-64h576a32 32 0 0 1 0 64zM864 896H160a32 32 0 0 1 0-64h704a32 32 0 0 1 0 64z" fill="#3BD5B3" p-id="8094"></path><path d="M736 800H160a32 32 0 0 1 0-64h576a32 32 0 0 1 0 64z" fill="#4A8BFE" p-id="8095"></path></svg>',o="svg",i="动态",r="图表组件",c=!1,p=!0,l="时间",s=`{"type":"page","id":"u:270584784ce1","name":"page1","asideResizor":false,"style":{"boxShadow":" 0px 0px 0px 0px transparent"},"pullRefresh":{"disabled":true},"body":[{"type":"tabs","name":"tab","tabs":[{"title":"样式","icon":"fa fa-th-large","body":[{"type":"form","title":"","name":"basicPropForm","body":[{"type":"input-text","label":"名称","name":"nodeAlias","id":"u:6b126f0520cb","size":"full","mode":"horizontal","inputControlClassName":"w-100","className":"m-b"},{"type":"input-text","label":"ID&nbsp;&nbsp;&nbsp;&nbsp;","name":"id","id":"u:6232710ac003","size":"full","mode":"horizontal","inputControlClassName":"w-100","className":"m-b"},{"type":"grid","id":"u:c605398a724c","className":"m-b","columns":[{"body":[{"type":"input-number","label":"宽度","name":"width","keyboard":true,"id":"u:dcc0c21d16f6","step":1,"suffix":"px","placeholder":"组件左边距","size":"full","mode":"horizontal","className":"m-b","value":200,"labelAlign":"left","precision":2,"inputClassName":"w-full","labelClassName":"w-8"}],"id":"u:14cc19d6ffb0","md":6},{"body":[{"type":"input-number","label":"高度","name":"height","keyboard":true,"id":"u:cd6fdff9ca88","step":1,"suffix":"px","placeholder":"组件上边距","size":"full","mode":"horizontal","className":"m-b","value":200,"labelAlign":"left","precision":2,"inputClassName":"w-full","labelClassName":"w-8"}],"id":"u:4931801ca9b8","md":6}]},{"type":"grid","id":"u:da449a94908a","className":"m-b","columns":[{"body":[{"type":"input-number","label":"X 轴","name":"x","keyboard":true,"id":"u:29852d093d9d","step":1,"suffix":"px","placeholder":"组件左边距","size":"full","mode":"horizontal","className":"m-b","value":200,"labelAlign":"left","precision":2,"inputClassName":"w-full","labelClassName":"w-8"}],"id":"u:1b561d652acc","md":6},{"body":[{"type":"input-number","label":"Y 轴","name":"y","keyboard":true,"id":"u:dc8c1daed8ed","step":1,"suffix":"px","placeholder":"组件上边距","size":"full","mode":"horizontal","className":"m-b","value":200,"labelAlign":"left","precision":2,"inputClassName":"w-full","labelClassName":"w-8"}],"id":"u:9672575193ac","md":6}]},{"type":"grid","id":"u:a332a7bf83c1","className":"m-b","columns":[{"body":[{"type":"input-number","label":"旋转","name":"rotation","id":"u:f6a2dbb518f9","placeholder":"组件旋转角度","mode":"horizontal","size":"full","className":"","keyboard":true,"step":1,"suffix":"deg","value":0,"labelAlign":"left","inputClassName":"w-full"}],"id":"u:646cd98b7955","md":6},{"body":[{"type":"input-number","label":"透明","name":"opacity","id":"u:cf80f59d8d42","placeholder":"组件透明度","mode":"horizontal","size":"full","className":"m-b","keyboard":true,"step":0,"suffix":"","value":1,"inputClassName":"w-full","precision":2}],"id":"u:51ddf54ac749","md":6}],"gap":""},{"type":"grid","columns":[],"id":"u:235f153e5ad5","className":"m-b"},{"type":"grid","columns":[{"body":[{"type":"input-color","label":"名称颜色","name":"nameColor","id":"u:10e95c495126","format":"hex","mode":"horizontal","inputClassName":"w-full myColorPick"}],"id":"u:1149609
  2. "nodes": [
  3. {
  4. "id": "26f2607a-db35-4f34-8653-a4fc11fafc7f",
  5. "type": "custom-horizontal-barchart",
  6. "x": 200,
  7. "y": 200,
  8. "text": {
  9. "value": "",
  10. "x": 200,
  11. "y": 200
  12. },
  13. "properties": {
  14. "id": "26f2607a-db35-4f34-8653-a4fc11fafc7f",
  15. "width": 500,
  16. "height": 200,
  17. "x": 200,
  18. "y": 200,
  19. "rotation": 0,
  20. "opacity": 1,
  21. "codeConfig": "return option",
  22. "nodeAlias": "双轴柱图",
  23. "showDefaultValue": false,
  24. "showUnit": false,
  25. "valueColor": "#000000",
  26. "fontSize": 12,
  27. "maxValueBg": "#181f44",
  28. "valueFrontBg": "linear-gradient(to right, rgb(57,89,255,1), rgb(46,200,207,1))",
  29. "nameColor": "#000000",
  30. "itemColor": "#000000",
  31. "tooltipColor": "#ffffff",
  32. "tooltipBack": "#3d2fd7",
  33. "tooltipBorderColor": "#3d2fd7",
  34. "dynamic": {
  35. "normalData": {
  36. "dataPoint": "",
  37. "compareType": "",
  38. "conditionVariables": [],
  39. "defaultValue": "",
  40. "unit": "",
  41. "renderIntervalEnabled": true,
  42. "yAxisNameType": "",
  43. "dataShowTypes": "oneThingManyAttr",
  44. "radios": "oneThingManyAttr"
  45. }
  46. }
  47. }
  48. }
  49. ]
  50. }`,javascript:`const { createApp, createVNode, render } = Vue;
  51. const app = createApp({})
  52. const timeArr = new Array(24).fill('');
  53. const totals = [];
  54. timeArr.forEach((i, index) => { const t = window.dayjs().hour(index).valueOf(); totals.push({ val: Math.random(1000) * 100, ts: t, attrKey: "A29" }) });
  55. const defaultSocketValue = []
  56. const HoriBarChart = {
  57. template: \`<div :id="chartId" :style="getStyle" class="horibar-chart-box">
  58. <div v-for="item in totalDatas" class="horibar-item-row" :style="getRowStyle(totalDatas.length)" @mouseenter="mouseEnterHandler" @mousemove="(e) => hoverTooltipDebounced(e, item)" @mouseleave="mouseLeaveHandler">
  59. <div class="horibar-name" :style="{color: nameColor}">{{item.name}}</div>
  60. <div class="horibar-value-wrapper">
  61. <div class="horibar-value" :style="getValueStyle(item.value, item.maxVal, valueFrontBg)"></div>
  62. <div class="horibar-bg" :style="getBgStyle"></div>
  63. </div>
  64. <div class="horibar-value-show" :style="{color: valueColor}">{{item.formatVal}}</div>
  65. </div>
  66. <div v-show="showTooltip" :style="getTooltipStyle" class="hori-tooltip">
  67. <span>{{currentRow.name}} :</span>
  68. <span>&nbsp;{{currentRow.value}}</span>
  69. <span>&nbsp;&nbsp;{{ unit }}</span>
  70. </div>
  71. </div>\`,
  72. props: {
  73. chartId: {
  74. type: String,
  75. default: ''
  76. },
  77. historyDatas: {
  78. type: Array,
  79. default: () => []
  80. },
  81. width: {
  82. type: Number,
  83. default: 350
  84. },
  85. height: {
  86. type: Number,
  87. default: 150
  88. },
  89. codeConfig: {
  90. type: String,
  91. default: ''
  92. },
  93. nameColor: {
  94. type: String,
  95. default: ''
  96. },
  97. valueColor: {
  98. type: String,
  99. default: ''
  100. },
  101. valueFrontBg: {
  102. type: String,
  103. default: ''
  104. },
  105. maxValueBg: {
  106. type: String,
  107. default: ''
  108. },
  109. tooltipColor: {
  110. type: String,
  111. default: ''
  112. },
  113. tooltipBack: {
  114. type: String,
  115. default: ''
  116. },
  117. tooltipBorderColor: {
  118. type: String,
  119. default: ''
  120. },
  121. unit: {
  122. type: String,
  123. default: ''
  124. },
  125. dataShowTypes: {
  126. type: String,
  127. default: ''
  128. },
  129. yAxisNameType: {
  130. type: String,
  131. default: ''
  132. },
  133. apiid: {
  134. type: String,
  135. default: ''
  136. }
  137. },
  138. computed: {
  139. getStyle() {
  140. return {
  141. width: \`\${this.width}px\`,
  142. height: \`\${this.height}px\`
  143. }
  144. },
  145. getRowStyle: () => (len) => {
  146. const ratio = 1 / (len + 3) * len / len * 100 + '%'
  147. return {
  148. flex: \`0 0 \${ratio}\`,
  149. }
  150. },
  151. getValueStyle: () => (val, maxVal, valueFrontBg) => {
  152. return {
  153. width: val / maxVal * 100 + '%',
  154. background: valueFrontBg
  155. }
  156. },
  157. getBgStyle() {
  158. return {
  159. 'background-color': this.maxValueBg
  160. }
  161. },
  162. },
  163. setup(props) {
  164. const { onMounted, computed, nextTick, ref, toRefs, watch, reactive } = Vue;
  165. const { historyDatas, codeConfig, dataShowTypes, yAxisNameType, apiid } = toRefs(props)
  166. const filterDatas = (api, yAxisName, dataArr, datas) => {
  167. if (api) {
  168. const infos = window.totalDeviceInfos[api];
  169. const thing = infos[datas[0].thingCode];
  170. const attrName = thing.attrs[datas[0].attrKey].name
  171. if (dataShowTypes.value === 'oneThingOneAttr') {
  172. switch (yAxisNameType.value) {
  173. case "thingName":
  174. yAxisName.push(thing.entityName);
  175. dataArr.push(datas[0].val);
  176. return;
  177. case "thingCode":
  178. yAxisName.push(datas[0].thingCode);
  179. dataArr.push(datas[0].val);
  180. return;
  181. case "attrName":
  182. yAxisName.push(attrName);
  183. dataArr.push(datas[0].val);
  184. return;
  185. case "attrCode":
  186. yAxisName.push(datas[0].attrKey);
  187. dataArr.push(datas[0].val);
  188. return;
  189. case "thingNameAttrName":
  190. const thingName = thing.entityName;
  191. yAxisName.push(thingName + ' ' + attrName);
  192. dataArr.push(datas[0].val);
  193. return;
  194. case "thingCodeAttrCode":
  195. const thingCode = datas[0].thingCode;
  196. const attrCode = datas[0].attrKey;
  197. yAxisName.push(thingCode + ' ' + attrCode);
  198. dataArr.push(datas[0].val);
  199. return;
  200. }
  201. } else if (dataShowTypes.value === 'oneThingManyAttr') {
  202. const datasGrouped = window._.groupBy(datas, 'attrKey');
  203. switch (yAxisNameType.value) {
  204. case "attrName":
  205. for (const key in datasGrouped) {
  206. const serieData = datasGrouped[key];
  207. const thing = infos[serieData[0].thingCode];
  208. const attrName = thing.attrs[serieData[0].attrKey].name
  209. yAxisName.push(attrName);
  210. dataArr.push(serieData[0].val);
  211. }
  212. return;
  213. case "attrCode":
  214. for (const key in datasGrouped) {
  215. const serieData = datasGrouped[key];
  216. yAxisName.push(serieData[0].attrKey);
  217. dataArr.push(serieData[0].val);
  218. }
  219. return;
  220. case "thingNameAttrName":
  221. for (const key in datasGrouped) {
  222. const serieData = datasGrouped[key];
  223. const thing = infos[serieData[0].thingCode];
  224. const thingName = thing.entityName;
  225. const attrName = thing.attrs[serieData[0].attrKey].name
  226. yAxisName.push(thingName + ' ' + attrName);
  227. dataArr.push(serieData[0].val);
  228. }
  229. return;
  230. case "thingCodeAttrCode":
  231. for (const key in datasGrouped) {
  232. const serieData = datasGrouped[key];
  233. const thingCode = serieData[0].thingCode;
  234. const attrCode = serieData[0].attrKey;
  235. yAxisName.push(thingCode + ' ' + attrCode);
  236. dataArr.push(serieData[0].val);
  237. }
  238. return;
  239. }
  240. } else if (dataShowTypes.value === 'manyThingManyAttr') {
  241. switch (yAxisNameType.value) {
  242. case "thingNameAttrName":
  243. datas.forEach((val) => {
  244. const thing = infos[val.thingCode];
  245. const thingName = thing.entityName;
  246. const attrName = thing.attrs[val.attrKey].name
  247. yAxisName.push(thingName + ' ' + attrName);
  248. dataArr.push(val.val);
  249. })
  250. return;
  251. case "thingCodeAttrCode":
  252. datas.forEach((val) => {
  253. yAxisName.push(val.thingCode + ' ' + val.attrKey);
  254. dataArr.push(val.val);
  255. })
  256. return;
  257. }
  258. } else if (dataShowTypes.value === 'manyThingOneAttr') {
  259. const datasGrouped = window._.groupBy(datas, 'thingCode');
  260. switch (yAxisNameType.value) {
  261. case "thingName":
  262. for (const key in datasGrouped) {
  263. const serieData = datasGrouped[key];
  264. const thing = infos[serieData[0].thingCode];
  265. yAxisName.push(thing.entityName);
  266. dataArr.push(serieData[0].val);
  267. }
  268. return;
  269. case "thingCode":
  270. for (const key in datasGrouped) {
  271. const serieData = datasGrouped[key];
  272. yAxisName.push(key);
  273. dataArr.push(serieData[0].val);
  274. }
  275. return;
  276. case "thingNameAttrName":
  277. for (const key in datasGrouped) {
  278. const serieData = datasGrouped[key];
  279. const thing = infos[serieData[0].thingCode];
  280. const thingName = thing.entityName;
  281. const attrName = thing.attrs[serieData[0].attrKey].name
  282. yAxisName.push(thingName + ' ' + attrName);
  283. dataArr.push(serieData[0].val);
  284. }
  285. return;
  286. case "thingCodeAttrCode":
  287. for (const key in datasGrouped) {
  288. const serieData = datasGrouped[key];
  289. const thingCode = serieData[0].thingCode;
  290. const attrCode = serieData[0].attrKey;
  291. yAxisName.push(thingCode + ' ' + attrCode);
  292. dataArr.push(serieData[0].val);
  293. }
  294. return;
  295. }
  296. }
  297. }
  298. }
  299. const totalDatas = ref([]);
  300. const totalBackground = ref([]);
  301. const initChart = (datas) => {
  302. // 基于准备好的dom,初始化echarts实例
  303. if (datas) {
  304. let dataArr = [];
  305. let databackground = [];
  306. let yAxisName = [];
  307. if (datas.length > 0) {
  308. filterDatas(apiid.value, yAxisName, dataArr, datas);
  309. const maxVal = Math.max(...dataArr);
  310. databackground = dataArr.map(() => maxVal);
  311. } else {
  312. dataArr = [50000000, 22000000, 10000000, 5000000, 1];
  313. databackground = [50000000, 50000000, 50000000, 50000000, 50000000];
  314. yAxisName = ['大米', '玉米', '蔬菜', '鸡蛋', '坚果'];
  315. }
  316. totalDatas.value = dataArr.map((item, index) => {
  317. const formatVal = dataArr[index] > 10000 ? (dataArr[index] / 10000).toFixed(2) + '万' : dataArr[index];
  318. return {
  319. name: yAxisName[index],
  320. value: dataArr[index],
  321. formatVal,
  322. maxVal: databackground[index]
  323. }
  324. })
  325. totalBackground.value = databackground;
  326. setTimeout(() => {
  327. const bgs = document.getElementById(props.chartId).querySelectorAll('.horibar-bg');
  328. bgs.forEach((bg) => {
  329. bg.style.transform = 'scaleX(1)';
  330. })
  331. const vals = document.getElementById(props.chartId).querySelectorAll('.horibar-value');
  332. vals.forEach((val) => {
  333. val.style.transform = 'scaleX(1)';
  334. })
  335. }, 100)
  336. }
  337. }
  338. watch(historyDatas, (val) => {
  339. if (val) {
  340. nextTick(() => {
  341. initChart(val);
  342. })
  343. }
  344. }, {
  345. immediate: true
  346. })
  347. const currentRow = ref({});
  348. const showTooltip = ref(false);
  349. const tooltipPos = ref({
  350. top: -1000,
  351. left: -1000,
  352. })
  353. let parentX = 0;
  354. let parentY = 0;
  355. onMounted(() => {
  356. nextTick(() => {
  357. const parentDom = document.getElementById(props.chartId);
  358. const { x, y } = parentDom.getBoundingClientRect();
  359. parentX = x;
  360. parentY = y;
  361. })
  362. })
  363. const hoverTooltip = (e, row) => {
  364. if (!showTooltip.value) {
  365. showTooltip.value = true;
  366. };
  367. const parentDom = document.getElementById(props.chartId);
  368. const { height } = parentDom.querySelector('.hori-tooltip').getBoundingClientRect();
  369. let hovertipHeight = height;
  370. currentRow.value = row;
  371. const isCloseBottom = Math.abs(props.height - (e.y - parentY)) < hovertipHeight;
  372. tooltipPos.value = {
  373. left: e.x - parentX,
  374. top: isCloseBottom ? e.y - parentY - hovertipHeight : e.y - parentY,
  375. }
  376. }
  377. const hoverTooltipDebounced = window._.throttle(hoverTooltip, 500);
  378. const getTooltipStyle = computed(() => {
  379. const pos = tooltipPos.value;
  380. return {
  381. position: 'absolute',
  382. top: pos.top + 'px',
  383. left: pos.left + 'px',
  384. padding: '15px 15px',
  385. color: props.tooltipColor,
  386. 'background-color': props.tooltipBack,
  387. border: \`1px solid \${props.tooltipBorderColor}\`,
  388. 'border-radius': '5px',
  389. 'z-index': 9999,
  390. transition: 'all 0.25s ease-in-out'
  391. }
  392. })
  393. const mouseEnterHandler = window._.throttle(() => {
  394. showTooltip.value = true;
  395. }, 200)
  396. const mouseLeaveHandler = window._.throttle(() => {
  397. showTooltip.value = false;
  398. }, 200)
  399. return reactive({
  400. totalDatas,
  401. totalBackground,
  402. hoverTooltipDebounced,
  403. currentRow,
  404. tooltipPos,
  405. showTooltip,
  406. getTooltipStyle,
  407. mouseEnterHandler,
  408. mouseLeaveHandler,
  409. })
  410. }
  411. }
  412. class CustomHoriBarChartNode extends HtmlResize.view {
  413. chartRendered = false
  414. historyDatas = []
  415. oldProperties = {}
  416. setHtml(rootEl) {
  417. if (!rootEl) return;
  418. const { properties, width, height, } = this.props.model;
  419. const { nodeAlias, codeConfig, nameColor, valueColor, valueFrontBg, maxValueBg, tooltipColor, tooltipBack, tooltipBorderColor } = properties;
  420. const { normalData } = properties.dynamic || {};
  421. const { unit, dataShowTypes, yAxisNameType } = normalData || {};
  422. const el = document.createElement('div');
  423. rootEl.innerHTML = '';
  424. const instance = createVNode(HoriBarChart, {
  425. name: nodeAlias,
  426. chartId: \`horibar-\${properties.id}\`,
  427. historyDatas: this.historyDatas,
  428. width,
  429. height,
  430. codeConfig,
  431. nameColor, valueColor, valueFrontBg, maxValueBg,
  432. tooltipColor, tooltipBack, tooltipBorderColor, unit,
  433. dataShowTypes, yAxisNameType,
  434. apiid: properties.apiid
  435. })
  436. instance.appContext = app._context
  437. render(instance, el)
  438. rootEl.appendChild(el);
  439. }
  440. sameProps(properties) {
  441. const isSame = window._.isEqual(this.oldProperties, properties);
  442. if (isSame) return true;
  443. this.oldProperties = properties;
  444. return false
  445. }
  446. filterHistoryData(thingCodeArr, dataPointArr, apiid, renderIntervalEnabled) {
  447. if (dataPointArr && dataPointArr.length > 0) {
  448. let datas = []
  449. if (renderIntervalEnabled) {
  450. datas = window.totalHistoryDatas[apiid];
  451. } else {
  452. if (window.globalDashboardDatas[apiid]) {
  453. datas = window.globalDashboardDatas[apiid].values;
  454. }
  455. }
  456. if (datas && datas.length > 0) {
  457. const gotValues = datas.filter((val) => thingCodeArr.includes(val.thingCode) && dataPointArr.includes(val.attrKey))
  458. this.historyDatas = gotValues
  459. this.chartRendered = true;
  460. }
  461. }
  462. }
  463. // 生命周期 支持重写内容, 但格式需一致
  464. shouldUpdate() {
  465. const { properties } = this.props.model;
  466. const { apiid } = properties;
  467. const { normalData } = properties.dynamic || {};
  468. const { thingCodeArr, dataPointArr, defaultValue } = normalData || {}
  469. if (normalData && !normalData.dataPoint && !normalData.defaultValue) {
  470. this.historyDatas = defaultSocketValue;
  471. return true
  472. } else if (normalData && !normalData.dataPoint && normalData.defaultValue) {
  473. this.historyDatas = JSON.parse(defaultValue);
  474. return true
  475. }
  476. const propertiesBack = window._.cloneDeep(properties);
  477. if (propertiesBack.dynamic.normalData) {
  478. propertiesBack.dynamic.normalData.defaultValue = '';
  479. if (this.sameProps(propertiesBack) && this.chartRendered) {
  480. return false
  481. }
  482. if (dataPointArr && apiid && !this.chartRendered) {
  483. this.filterHistoryData(thingCodeArr, dataPointArr, apiid, normalData.renderIntervalEnabled);
  484. return true;
  485. }
  486. }
  487. return true;
  488. }
  489. updateHtml() {
  490. this.setHtml(this.rootEl);
  491. }
  492. componentDidMount() {
  493. // 防止拖动时候频繁渲染图表
  494. this.updateHtmlDebounced = window._.debounce(this.updateHtml.bind(this), 500);
  495. const { properties } = this.props.model;
  496. const { normalData } = properties.dynamic || {};
  497. const { renderInterval, dataPointArr, thingCodeArr } = normalData || {};
  498. if (this.shouldUpdate()) {
  499. this.setHtml(this.rootEl);
  500. }
  501. let inters = parseInt(renderInterval || '30000')
  502. if (normalData && !normalData.renderIntervalEnabled) {
  503. inters = 1000
  504. }
  505. setInterval(() => {
  506. if (window.totalHistoryDatas[properties.apiid]) {
  507. this.filterHistoryData(thingCodeArr, dataPointArr, properties.apiid, normalData.renderIntervalEnabled);
  508. this.setHtml(this.rootEl);
  509. }
  510. }, inters)
  511. }
  512. componentDidUpdate() {
  513. if (this.shouldUpdate()) {
  514. this.updateHtmlDebounced();
  515. }
  516. }
  517. }
  518. class CustomHoriBarChartModel extends HtmlResize.model {
  519. initNodeData(data) {
  520. // 自定义组件,需最开始重置一下text 。
  521. data.text = {
  522. value: "",
  523. x: data.x,
  524. y: data.y,
  525. };
  526. super.initNodeData(data);
  527. const { properties } = this;
  528. this.width = properties.width || 80;
  529. this.height = properties.height || 35;
  530. this.text.editable = false; // 不允许文本被编辑
  531. }
  532. setAttributes() {
  533. // 自定义组件需重置 text
  534. const { x, y, properties } = this;
  535. const { textHorizontalMove = 0, textVerticalMove = 0 } = properties;
  536. this.text = {
  537. ...this.text,
  538. x: x + textHorizontalMove,
  539. y: y + textVerticalMove,
  540. value: "",
  541. }
  542. }
  543. }
  544. lf.register({
  545. type: 'custom-horizontal-barchart',
  546. view: CustomHoriBarChartNode,
  547. model: CustomHoriBarChartModel,
  548. })`,css:`.horibar-chart-box {\r
  549. display: flex;\r
  550. flex-direction: column;\r
  551. justify-content: space-between;\r
  552. position: relative;\r
  553. }\r
  554. .horibar-chart-box .horibar-item-row {\r
  555. display: flex;\r
  556. }\r
  557. .horibar-chart-box .horibar-item-row .horibar-name {\r
  558. flex: 0 0 auto;\r
  559. overflow: hidden;\r
  560. text-overflow: ellipsis;\r
  561. white-space: nowrap;\r
  562. display: flex;\r
  563. align-items: center;\r
  564. padding: 0 5px;\r
  565. }\r
  566. .horibar-chart-box .horibar-item-row .horibar-value-wrapper {\r
  567. flex: 1;\r
  568. position: relative;\r
  569. }\r
  570. .horibar-chart-box .horibar-item-row .horibar-value-wrapper .horibar-value {\r
  571. position: absolute;\r
  572. top: 0;\r
  573. bottom: 0;\r
  574. height: 100%;\r
  575. z-index: 1;\r
  576. border-radius: 20px;\r
  577. transform: scaleX(0);\r
  578. transform-origin: 0%;\r
  579. transition: all 0.35s ease-in-out;\r
  580. }\r
  581. .horibar-chart-box .horibar-item-row .horibar-value-wrapper .horibar-bg {\r
  582. width: 100%;\r
  583. height: 100%;\r
  584. border-radius: 20px;\r
  585. transform: scaleX(0);\r
  586. transform-origin: 0%;\r
  587. transition: all 0.2s ease-in-out;\r
  588. }\r
  589. \r
  590. .horibar-chart-box .horibar-item-row .horibar-value-show {\r
  591. flex: 0 0 70px;\r
  592. overflow: hidden;\r
  593. text-overflow: ellipsis;\r
  594. white-space: nowrap;\r
  595. display: flex;\r
  596. align-items: center;\r
  597. padding-left: 5px;\r
  598. }`,fakeData:""},u={id:e,name:t,aliasName:a,image:n,imageType:o,groupName:i,groupType:r,isRemote:!1,isDefault:!0,sectionType:l,config:s,files:d};export{a as aliasName,s as config,u as default,d as files,i as groupName,r as groupType,e as id,n as image,o as imageType,p as isDefault,c as isRemote,t as name,l as sectionType};