{"dependencies":[{"name":"78f9fc7ed987bf72f0fae6b99573fddb.json","size":10993386,"url":"https://gw.alipayobjects.com/os/f6/305cf8aa-17e8-4fa2-ba2d-8c5cab6ad66a/demo_elements_extrashape/dependencies/herbox/78f9fc7ed987bf72f0fae6b99573fddb.json","ETag":"78F9FC7ED987BF72F0FAE6B99573FDDB","type":"json"},{"name":"0d7b758fdc47c7af5db47deeda4d99d4.json","size":5210534,"url":"https://gw.alipayobjects.com/os/f6/bacccbc9-e162-46dd-a0d2-0fc172a822e9/demo_elements_extrashape/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/Elements/extraShape/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/Elements/extraShape/data.js":"export default {\n nodes: [\n {\n id: 'node1',\n x: 100,\n y: 100,\n },\n {\n id: 'node2',\n x: 300,\n y: 100,\n },\n {\n id: 'node3',\n x: 300,\n y: 200,\n },\n ],\n edges: [\n {\n source: 'node1',\n target: 'node2',\n midPointColor: '#f00',\n quatileColor: '#f00',\n },\n {\n source: 'node1',\n target: 'node3',\n midPointColor: '#0f0',\n quatileColor: '#0f0',\n },\n ],\n};\n","pages/Elements/extraShape/index.acss":"/* required by usingComponents */","pages/Elements/extraShape/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/Elements/extraShape/index.js":"import F6 from '@antv/f6';\nimport { wrapContext } from '../../../utils/context';\nimport data from './data';\n/**\n * extraShapes\n */\n// 注册边\nF6.registerEdge(\n 'extra-shape-edge',\n {\n afterDraw(cfg, group) {\n // get the first shape in the graphics group of this edge, it is the path of the edge here\n // 获取图形组中的第一个图形,在这里就是边的路径图形\n const shape = group.get('children')[0];\n // get the coordinate of the mid point on the path\n // 获取路径图形的中点坐标\n const midPoint = shape.getPoint(0.5);\n const rectColor = cfg.midPointColor || '#333';\n // add a rect on the mid point of the path. note that the origin of a rect shape is on its lefttop\n // 在中点增加一个矩形,注意矩形的原点在其左上角\n group.addShape('rect', {\n attrs: {\n width: 10,\n height: 10,\n fill: rectColor || '#333',\n // x and y should be minus width / 2 and height / 2 respectively to translate the center of the rect to the midPoint\n // x 和 y 分别减去 width / 2 与 height / 2,使矩形中心在 midPoint 上\n x: midPoint.x - 5,\n y: midPoint.y - 5,\n },\n });\n\n // get the coordinate of the quatile on the path\n // 获取路径上的四分位点坐标\n const quatile = shape.getPoint(0.25);\n const quatileColor = cfg.quatileColor || '#333';\n // add a circle on the quatile of the path\n // 在四分位点上放置一个圆形\n group.addShape('circle', {\n attrs: {\n r: 5,\n fill: quatileColor || '#333',\n x: quatile.x,\n y: quatile.y,\n },\n });\n },\n update: undefined,\n },\n 'cubic',\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 // 同步获取window的宽高\n const { windowWidth, windowHeight, pixelRatio } = my.getSystemInfoSync();\n this.setData({\n width: windowWidth,\n height: windowHeight,\n pixelRatio,\n });\n },\n\n /**\n * 初始化cnavas回调,缓存获得的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 fitViewPadding: 60,\n fitCenter: true,\n modes: {\n // behavior\n default: ['drag-node', 'drag-canvas'],\n },\n defaultEdge: {\n type: 'extra-shape-edge',\n style: {\n stroke: '#F6BD16',\n },\n },\n });\n this.graph.data(data);\n this.graph.render();\n this.graph.fitView();\n },\n});\n","pages/Elements/extraShape/index.json":"{\n \"defaultTitle\": \"extra shape\",\n \"usingComponents\": {\n \"f6-canvas\": \"@antv/f6-alipay/es/container/container\"\n }\n}\n","pages/Elements/extraShape/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":"1cd2ed0de11ca075ad9cd370caf9e1f2.json","size":688783,"url":"https://gw.alipayobjects.com/os/f6/f355627e-7200-4420-8cc4-765b89c6e1ef/demo_elements_extrashape/dist/herbox/1cd2ed0de11ca075ad9cd370caf9e1f2.json","ETag":"1CD2ED0DE11CA075AD9CD370CAF9E1F2","type":"json"}],"name":"pages/Elements/extraShape/index","buildVersion":"0.72.7","remaxVersion":"2.0.3","component2":false,"css2":false}