{"dependencies":[{"name":"78f9fc7ed987bf72f0fae6b99573fddb.json","size":10993386,"url":"https://gw.alipayobjects.com/os/f6/b4bd2a21-9171-4362-a1d9-9ab77b742496/demo_generalgraph_custombigraph/dependencies/herbox/78f9fc7ed987bf72f0fae6b99573fddb.json","ETag":"78F9FC7ED987BF72F0FAE6B99573FDDB","type":"json"},{"name":"0d7b758fdc47c7af5db47deeda4d99d4.json","size":5210534,"url":"https://gw.alipayobjects.com/os/f6/933ac16b-80f7-44d8-abcd-5b3a6517ef17/demo_generalgraph_custombigraph/dependencies/herbox/0d7b758fdc47c7af5db47deeda4d99d4.json","ETag":"0D7B758FDC47C7AF5DB47DEEDA4D99D4","type":"json"}],"sourceCode":{"app.js":"App({\n onLaunch(options) {\n // 第一次打开\n // options.query == {number:1}\n console.info('App onLaunch');\n },\n onShow(options) {\n // 从后台被 scheme 重新打开\n // options.query == {number:1}\n },\n});\n","app.json":"{\"window\":{\"defaultTitle\":\"F6移动端demo\",\"allowsBounceVertical\":\"NO\",\"canPullDown\":\"NO\"},\"pages\":[\"pages/GeneralGraph/customBiGraph/index\"]}\n","mini.project.json":"{\n \"enableAppxNg\": true,\n \"component2\": true\n}","package.json":"{\n \"name\": \"f6demo\",\n \"version\": \"1.0.0\",\n \"description\": \"f6demo\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n },\n \"dependencies\": {\n \"@antv/f6\": \"^0.0.12\",\n \"@antv/f6-alipay\": \"^0.0.2\",\n \"@babel/runtime\": \"^7.14.0\"\n },\n \"author\": \"\",\n \"license\": \"ISC\"\n}\n","pages/GeneralGraph/customBiGraph/data.js":"export default {\n nodes: [\n {\n id: '0',\n label: 'A',\n cluster: 'part1',\n },\n {\n id: '1',\n label: 'B',\n cluster: 'part1',\n },\n {\n id: '2',\n label: 'C',\n cluster: 'part1',\n },\n {\n id: '3',\n label: 'D',\n cluster: 'part1',\n },\n {\n id: '4',\n label: 'E',\n cluster: 'part1',\n },\n {\n id: '5',\n label: 'F',\n cluster: 'part1',\n },\n {\n id: '6',\n label: 'a',\n cluster: 'part2',\n },\n {\n id: '7',\n label: 'b',\n cluster: 'part2',\n },\n {\n id: '8',\n label: 'c',\n cluster: 'part2',\n },\n {\n id: '9',\n label: 'd',\n cluster: 'part2',\n },\n ],\n edges: [\n {\n source: '0',\n target: '6',\n },\n {\n source: '0',\n target: '7',\n },\n {\n source: '0',\n target: '9',\n },\n {\n source: '1',\n target: '6',\n },\n {\n source: '1',\n target: '9',\n },\n {\n source: '1',\n target: '7',\n },\n {\n source: '2',\n target: '8',\n },\n {\n source: '2',\n target: '9',\n },\n {\n source: '2',\n target: '6',\n },\n {\n source: '3',\n target: '8',\n },\n {\n source: '4',\n target: '6',\n },\n {\n source: '4',\n target: '7',\n },\n {\n source: '5',\n target: '9',\n },\n ],\n};\n","pages/GeneralGraph/customBiGraph/index.acss":"/* required by usingComponents */","pages/GeneralGraph/customBiGraph/index.axml":"<f6-canvas\n width=\"{{width}}\"\n height=\"{{height}}\"\n forceMini=\"{{forceMini}}\"\n pixelRatio=\"{{pixelRatio}}\"\n onTouchEvent=\"handleTouch\"\n onInit=\"handleInit\"\n></f6-canvas>","pages/GeneralGraph/customBiGraph/index.js":"import F6 from '@antv/f6';\nimport { wrapContext } from '../../../utils/context';\nimport data from './data';\n\n/**\n * customBiGraph\n */\n\nPage({\n canvas: null,\n ctx: null,\n renderer: '', // mini、mini-native等,F6需要,标记环境\n isCanvasInit: false, // canvas是否准备好了\n graph: null,\n\n data: {\n width: 375,\n height: 600,\n pixelRatio: 2,\n forceMini: false,\n },\n\n onLoad() {\n // 注册布局\n F6.registerLayout('bigraphLayout', {\n execute() {\n const self = this;\n const center = self.center || [0, 0];\n const biSep = self.biSep || 100;\n const nodeSep = self.nodeSep || 20;\n const nodeSize = self.nodeSize || 20;\n const direction = self.direction || 'horizontal';\n let part1Pos = 0;\n let part2Pos = 0;\n if (direction === 'horizontal') {\n part1Pos = center[0] - biSep / 2;\n part2Pos = center[0] + biSep / 2;\n }\n const { nodes, edges } = self;\n const part1Nodes = [];\n const part2Nodes = [];\n const part1NodeMap = new Map();\n const part2NodeMap = new Map();\n // separate the nodes and init the positions\n nodes.forEach(function(node, i) {\n if (node.cluster === 'part1') {\n part1Nodes.push(node);\n part1NodeMap.set(node.id, i);\n } else {\n part2Nodes.push(node);\n part2NodeMap.set(node.id, i);\n }\n });\n\n // order the part1 node\n part1Nodes.forEach(function(p1n) {\n let index = 0;\n let adjCount = 0;\n edges.forEach(function(edge) {\n const sourceId = edge.source;\n const targetId = edge.target;\n if (sourceId === p1n.id) {\n index += part2NodeMap.get(targetId);\n adjCount += 1;\n } else if (targetId === p1n.id) {\n index += part2NodeMap.get(sourceId);\n adjCount += 1;\n }\n });\n index /= adjCount;\n p1n.index = index;\n });\n part1Nodes.sort(function(a, b) {\n return a.index - b.index;\n });\n part2Nodes.forEach(function(p2n) {\n let index = 0;\n let adjCount = 0;\n edges.forEach(function(edge) {\n const sourceId = edge.source;\n const targetId = edge.target;\n if (sourceId === p2n.id) {\n index += part1NodeMap.get(targetId);\n adjCount += 1;\n } else if (targetId === p2n.id) {\n index += part1NodeMap.get(sourceId);\n adjCount += 1;\n }\n });\n index /= adjCount;\n p2n.index = index;\n });\n part2Nodes.sort(function(a, b) {\n return a.index - b.index;\n });\n\n // place the nodes\n const hLength =\n part1Nodes.length > part2Nodes.length ? part1Nodes.length : part2Nodes.length;\n const height = hLength * (nodeSep + nodeSize);\n let begin = center[1] - height / 2;\n if (direction === 'vertical') {\n begin = center[0] - height / 2;\n }\n part1Nodes.forEach(function(p1n, i) {\n if (direction === 'horizontal') {\n p1n.x = part1Pos;\n p1n.y = begin + i * (nodeSep + nodeSize);\n } else {\n p1n.x = begin + i * (nodeSep + nodeSize);\n p1n.y = part1Pos;\n }\n });\n part2Nodes.forEach(function(p2n, i) {\n if (direction === 'horizontal') {\n p2n.x = part2Pos;\n p2n.y = begin + i * (nodeSep + nodeSize);\n } else {\n p2n.x = begin + i * (nodeSep + nodeSize);\n p2n.y = part2Pos;\n }\n });\n },\n });\n // 同步获取window的宽高\n const { windowWidth, windowHeight, pixelRatio } = my.getSystemInfoSync();\n\n this.setData({\n width: windowWidth,\n height: windowHeight,\n pixelRatio,\n });\n },\n\n /**\n * 初始化canvas回调,缓存获得的context\n * @param {*} ctx 绘图context\n * @param {*} rect 宽高信息\n * @param {*} canvas canvas对象,在render为mini时为null\n * @param {*} renderer 使用canvas 1.0还是canvas 2.0,mini | mini-native\n */\n handleInit(ctx, rect, canvas, renderer) {\n this.isCanvasInit = true;\n this.ctx = wrapContext(ctx);\n this.renderer = renderer;\n this.canvas = canvas;\n this.updateChart();\n },\n\n /**\n * canvas派发的事件,转派给graph实例\n */\n handleTouch(e) {\n this.graph && this.graph.emitEvent(e);\n },\n\n updateChart() {\n const { width, height, pixelRatio } = this.data;\n\n // 创建F6实例\n this.graph = new F6.Graph({\n context: this.ctx,\n renderer: this.renderer,\n width,\n height,\n pixelRatio,\n fitView: true,\n layout: {\n type: 'bigraphLayout',\n biSep: 300,\n nodeSep: 20,\n nodeSize: 20,\n },\n animate: true,\n defaultNode: {\n size: 20,\n style: {\n fill: '#C6E5FF',\n stroke: '#5B8FF9',\n },\n },\n defaultEdge: {\n size: 1,\n color: '#e2e2e2',\n },\n modes: {\n default: ['drag-canvas'],\n },\n });\n\n this.graph.data(data);\n this.graph.render();\n this.graph.fitView();\n },\n});\n","pages/GeneralGraph/customBiGraph/index.json":"{\n \"defaultTitle\": \"customBiGraph\",\n \"usingComponents\": {\n \"f6-canvas\": \"@antv/f6-alipay/es/container/container\"\n }\n}\n","pages/GeneralGraph/customBiGraph/index.less":"page {\n background-color: #f7f7f7;\n border: 1px solid rgba(0,0,0,0);\n box-sizing: border-box;\n}\n\n.page-section-demo {\n padding: 32rpx;\n}","utils/common.js":"function strLen(str = '') {\n let len = 0;\n for (let i = 0; i < str.length; i++) {\n if (str.charCodeAt(i) > 0 && str.charCodeAt(i) < 128) {\n len += 1;\n } else {\n len += 2;\n }\n }\n\n return len;\n}\n\nfunction measureText(text, font) {\n let fontSize = 12;\n if (font) {\n fontSize = parseInt(font.split(' ')[3], 10);\n }\n fontSize /= 2;\n return {\n width: strLen(text) * fontSize,\n };\n}\n\nexport { measureText };\n","utils/context.js":"import { measureText } from './common';\n/**\n * 部分小程序context会缺少函数,补上\n */\nfunction wrapContext(ctx) {\n if (!ctx) return;\n if (!ctx.measureText) {\n ctx.measureText = measureText;\n }\n return ctx;\n}\n\nexport { wrapContext };\n"},"dist":[{"name":"ccae56f3cd46ddc52dcb1cba09e8aa10.json","size":692446,"url":"https://gw.alipayobjects.com/os/f6/86c7ac90-c464-4c7b-b725-4f92b4ba7046/demo_generalgraph_custombigraph/dist/herbox/ccae56f3cd46ddc52dcb1cba09e8aa10.json","ETag":"CCAE56F3CD46DDC52DCB1CBA09E8AA10","type":"json"}],"name":"pages/GeneralGraph/customBiGraph/index","buildVersion":"0.72.7","remaxVersion":"2.0.3","component2":false,"css2":false}