| | |
| | | </template> |
| | | <script> |
| | | import * as d3 from 'd3'; |
| | | |
| | | |
| | | export default { |
| | | props: { |
| | | data: Object, |
| | |
| | | }, |
| | | }, |
| | | } |
| | | |
| | | |
| | | // 获取树的深度 |
| | | function getDepth(json) { |
| | | var arr = []; |
| | |
| | | } |
| | | return depth; |
| | | } |
| | | |
| | | |
| | | // 提取树的子节点,最终所有树的子节点都会存入传入的leafList数组中 |
| | | function getTreeLeaf(treeData, leafList) { |
| | | // 判断是否为数组 |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // 获取包含汉字的字符串的长度 |
| | | function getStringSizeLength(string) { |
| | | //先把中文替换成两个字节的英文,再计算长度 |
| | | return string.replace(/[\u0391-\uFFE5]/g, "aa").length; |
| | | } |
| | | |
| | | |
| | | // 生成随机的字符串 |
| | | function randomString(strLength) { |
| | | strLength = strLength || 32; |
| | |
| | | } |
| | | return n |
| | | } |
| | | |
| | | |
| | | // 获取字符串的像素宽度 |
| | | function getPXwidth(str, fontSize = "12px", fontFamily = "Microsoft YaHei") { |
| | | var span = document.createElement("span"); |
| | |
| | | // result.height = parseFloat(window.getComputedStyle(span).height) - result.height; |
| | | return result.width; |
| | | } |
| | | </script> |
| | | </script> |