{"remainingRequest":"D:\\jenkins\\workspace\\examine-fvue\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\jenkins\\workspace\\examine-fvue\\node_modules\\@jiaminghi\\data-view\\lib\\components\\flylineChartEnhanced\\src\\main.vue?vue&type=script&lang=js&","dependencies":[{"path":"D:\\jenkins\\workspace\\examine-fvue\\node_modules\\@jiaminghi\\data-view\\lib\\components\\flylineChartEnhanced\\src\\main.vue","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\examine-fvue\\node_modules\\babel-loader\\lib\\index.js","mtime":315532800000},{"path":"D:\\jenkins\\workspace\\examine-fvue\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\examine-fvue\\node_modules\\vue-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\nimport { deepMerge } from '@jiaminghi/charts/lib/util/index'\n\nimport { deepClone } from '@jiaminghi/c-render/lib/plugin/util'\n\nimport { randomExtend, getPointDistance, uuid } from '../../../util/index'\n\nimport autoResize from '../../../mixin/autoResize'\n\nexport default {\n name: 'DvFlylineChartEnhanced',\n mixins: [autoResize],\n props: {\n config: {\n type: Object,\n default: () => ({})\n },\n dev: {\n type: Boolean,\n default: false\n }\n },\n data () {\n const id = uuid()\n return {\n ref: 'dv-flyline-chart-enhanced',\n unique: Math.random(),\n flylineGradientId: `flyline-gradient-id-${id}`,\n haloGradientId: `halo-gradient-id-${id}`,\n /**\n * @description Type Declaration\n * \n * interface Halo {\n * show?: boolean\n * duration?: [number, number]\n * color?: string\n * radius?: number\n * }\n * \n * interface Text {\n * show?: boolean\n * offset?: [number, number]\n * color?: string\n * fontSize?: number\n * }\n * \n * interface Icon {\n * show?: boolean\n * src?: string\n * width?: number\n * height?: number\n * }\n * \n * interface Point {\n * name: string\n * coordinate: [number, number]\n * halo?: Halo\n * text?: Text\n * icon?: Icon\n * }\n * \n * interface Line {\n * width?: number\n * color?: string\n * orbitColor?: string\n * duration?: [number, number]\n * radius?: string\n * }\n * \n * interface Flyline extends Line {\n * source: string\n * target: string\n * }\n * \n * interface FlylineWithPath extends Flyline {\n * d: string\n * path: [[number, number], [number, number], [number, number]]\n * key: string\n * }\n */\n defaultConfig: {\n /**\n * @description Flyline chart points\n * @type {Point[]}\n * @default points = []\n */\n points: [],\n /**\n * @description Lines\n * @type {Flyline[]}\n * @default lines = []\n */\n lines: [],\n /**\n * @description Global halo configuration\n * @type {Halo}\n */\n halo: {\n /**\n * @description Whether to show halo\n * @type {Boolean}\n * @default show = false\n */\n show: false,\n /**\n * @description Halo animation duration (1s = 10)\n * @type {[number, number]}\n */\n duration: [20, 30],\n /**\n * @description Halo color\n * @type {String}\n * @default color = '#fb7293'\n */\n color: '#fb7293',\n /**\n * @description Halo radius\n * @type {Number}\n * @default radius = 120\n */\n radius: 120\n },\n /**\n * @description Global text configuration\n * @type {Text}\n */\n text: {\n /**\n * @description Whether to show text\n * @type {Boolean}\n * @default show = false\n */\n show: false,\n /**\n * @description Text offset\n * @type {[number, number]}\n * @default offset = [0, 15]\n */\n offset: [0, 15],\n /**\n * @description Text color\n * @type {String}\n * @default color = '#ffdb5c'\n */\n color: '#ffdb5c',\n /**\n * @description Text font size\n * @type {Number}\n * @default fontSize = 12\n */\n fontSize: 12\n },\n /**\n * @description Global icon configuration\n * @type {Icon}\n */\n icon: {\n /**\n * @description Whether to show icon\n * @type {Boolean}\n * @default show = false\n */\n show: false,\n /**\n * @description Icon src\n * @type {String}\n * @default src = ''\n */\n src: '',\n /**\n * @description Icon width\n * @type {Number}\n * @default width = 15\n */\n width: 15,\n /**\n * @description Icon height\n * @type {Number}\n * @default width = 15\n */\n height: 15\n },\n /**\n * @description Global line configuration\n * @type {Line}\n */\n line: {\n /**\n * @description Line width\n * @type {Number}\n * @default width = 1\n */\n width: 1,\n /**\n * @description Flyline color\n * @type {String}\n * @default color = '#ffde93'\n */\n color: '#ffde93',\n /**\n * @description Orbit color\n * @type {String}\n * @default orbitColor = 'rgba(103, 224, 227, .2)'\n */\n orbitColor: 'rgba(103, 224, 227, .2)',\n /**\n * @description Flyline animation duration\n * @type {[number, number]}\n * @default duration = [20, 30]\n */\n duration: [20, 30],\n /**\n * @description Flyline radius\n * @type {Number}\n * @default radius = 100\n */\n radius: 100\n },\n /**\n * @description Back ground image url\n * @type {String}\n * @default bgImgSrc = ''\n */\n bgImgSrc: '',\n /**\n * @description K value\n * @type {Number}\n * @default k = -0.5\n * @example k = -1 ~ 1\n */\n k: -0.5,\n /**\n * @description Flyline curvature\n * @type {Number}\n * @default curvature = 5\n */\n curvature: 5,\n /**\n * @description Relative points position\n * @type {Boolean}\n * @default relative = true\n */\n relative: true\n },\n /**\n * @description Fly line data\n * @type {FlylineWithPath[]}\n * @default flylines = []\n */\n flylines: [],\n /**\n * @description Fly line lengths\n * @type {Number[]}\n * @default flylineLengths = []\n */\n flylineLengths: [],\n /**\n * @description Fly line points\n * @default flylinePoints = []\n */\n flylinePoints: [],\n\n mergedConfig: null\n }\n },\n watch: {\n config () {\n const { calcData } = this\n\n calcData()\n }\n },\n methods: {\n afterAutoResizeMixinInit () {\n const { calcData } = this\n\n calcData()\n },\n onResize () {\n const { calcData } = this\n\n calcData()\n },\n async calcData () {\n const { mergeConfig, calcflylinePoints, calcLinePaths } = this\n\n mergeConfig()\n\n calcflylinePoints()\n\n calcLinePaths()\n\n const { calcLineLengths } = this\n\n await calcLineLengths()\n },\n mergeConfig () {\n let { config, defaultConfig } = this\n\n const mergedConfig = deepMerge(deepClone(defaultConfig, true), config || {})\n\n const { points, lines, halo, text, icon, line } = mergedConfig\n\n mergedConfig.points = points.map(item => {\n item.halo = deepMerge(deepClone(halo, true), item.halo || {})\n item.text = deepMerge(deepClone(text, true), item.text || {})\n item.icon = deepMerge(deepClone(icon, true), item.icon || {})\n\n return item\n })\n\n mergedConfig.lines = lines.map(item => {\n return deepMerge(deepClone(line, true), item)\n })\n\n this.mergedConfig = mergedConfig\n },\n calcflylinePoints () {\n const { mergedConfig, width, height } = this\n\n const { relative, points } = mergedConfig\n\n this.flylinePoints = points.map((item, i) => {\n const { coordinate: [x, y], halo, icon, text } = item\n\n if (relative) item.coordinate = [x * width, y * height]\n\n item.halo.time = randomExtend(...halo.duration) / 10\n\n const { width: iw, height: ih } = icon\n item.icon.x = item.coordinate[0] - iw / 2\n item.icon.y = item.coordinate[1] - ih / 2\n\n const [ox, oy] = text.offset\n item.text.x = item.coordinate[0] + ox\n item.text.y = item.coordinate[1] + oy\n\n item.key = `${item.coordinate.toString()}${i}`\n\n return item\n })\n },\n calcLinePaths () {\n const { getPath, mergedConfig } = this\n\n const { points, lines } = mergedConfig\n\n this.flylines = lines.map(item => {\n const { source, target, duration } = item\n\n const sourcePoint = points.find(({ name }) => name === source).coordinate\n const targetPoint = points.find(({ name }) => name === target).coordinate\n\n const path = getPath(sourcePoint, targetPoint).map(item => item.map(v => parseFloat(v.toFixed(10))))\n const d = `M${path[0].toString()} Q${path[1].toString()} ${path[2].toString()}`\n const key = `path${path.toString()}`\n const time = randomExtend(...duration) / 10\n\n return { ...item, path, key, d, time }\n })\n },\n getPath (start, end) {\n const { getControlPoint } = this\n\n const controlPoint = getControlPoint(start, end)\n\n return [start, controlPoint, end]\n },\n getControlPoint ([sx, sy], [ex, ey]) {\n const { getKLinePointByx, mergedConfig } = this\n\n const { curvature, k } = mergedConfig\n\n const [mx, my] = [(sx + ex) / 2, (sy + ey) / 2]\n\n const distance = getPointDistance([sx, sy], [ex, ey])\n\n const targetLength = distance / curvature\n const disDived = targetLength / 2\n\n let [dx, dy] = [mx, my]\n\n do {\n dx += disDived\n dy = getKLinePointByx(k, [mx, my], dx)[1]\n } while (getPointDistance([mx, my], [dx, dy]) < targetLength)\n\n return [dx, dy]\n },\n getKLinePointByx (k, [lx, ly], x) {\n const y = ly - k * lx + k * x\n\n return [x, y]\n },\n async calcLineLengths () {\n const { $nextTick, flylines, $refs } = this\n\n await $nextTick()\n\n this.flylineLengths = flylines.map(({ key }) => $refs[key][0].getTotalLength())\n },\n consoleClickPos ({ offsetX, offsetY }) {\n const { width, height, dev } = this\n\n if (!dev) return\n\n const relativeX = (offsetX / width).toFixed(2)\n const relativeY = (offsetY / height).toFixed(2)\n\n console.warn(`dv-flyline-chart-enhanced DEV: \\n Click Position is [${offsetX}, ${offsetY}] \\n Relative Position is [${relativeX}, ${relativeY}]`)\n }\n }\n}\n",null]}