{"remainingRequest":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\@jiaminghi\\data-view\\lib\\components\\capsuleChart\\src\\main.vue?vue&type=script&lang=js&","dependencies":[{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\@jiaminghi\\data-view\\lib\\components\\capsuleChart\\src\\main.vue","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\babel-loader\\lib\\index.js","mtime":315532800000},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-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\nimport { deepMerge } from '@jiaminghi/charts/lib/util/index'\n\nimport { deepClone } from '@jiaminghi/c-render/lib/plugin/util'\n\nexport default {\n  name: 'DvCapsuleChart',\n  props: {\n    config: {\n      type: Object,\n      default: () => ({})\n    }\n  },\n  data() {\n    return {\n      defaultConfig: {\n        /**\n         * @description Capsule chart data\n         * @type {Array<Object>}\n         * @default data = []\n         * @example data = [{ name: 'foo1', value: 100 }, { name: 'foo2', value: 100 }]\n         */\n        data: [],\n        /**\n         * @description Colors (hex|rgb|rgba|color keywords)\n         * @type {Array<String>}\n         * @default color = ['#37a2da', '#32c5e9', '#67e0e3', '#9fe6b8', '#ffdb5c', '#ff9f7f', '#fb7293']\n         * @example color = ['#000', 'rgb(0, 0, 0)', 'rgba(0, 0, 0, 1)', 'red']\n         */\n        colors: [\n          '#37a2da',\n          '#32c5e9',\n          '#67e0e3',\n          '#9fe6b8',\n          '#ffdb5c',\n          '#ff9f7f',\n          '#fb7293'\n        ],\n        /**\n         * @description Chart unit\n         * @type {String}\n         * @default unit = ''\n         */\n        unit: '',\n        /**\n         * @description Show item value\n         * @type {Boolean}\n         * @default showValue = false\n         */\n        showValue: false\n      },\n\n      mergedConfig: null,\n\n      capsuleLength: [],\n      capsuleValue: [],\n      labelData: [],\n      labelDataLength: []\n    }\n  },\n  watch: {\n    config() {\n      const { calcData } = this\n\n      calcData()\n    }\n  },\n  methods: {\n    calcData() {\n      const { mergeConfig, calcCapsuleLengthAndLabelData } = this\n\n      mergeConfig()\n\n      calcCapsuleLengthAndLabelData()\n    },\n    mergeConfig() {\n      let { config, defaultConfig } = this\n\n      this.mergedConfig = deepMerge(\n        deepClone(defaultConfig, true),\n        config || {}\n      )\n    },\n    calcCapsuleLengthAndLabelData() {\n      const { data } = this.mergedConfig\n\n      if (!data.length) return\n\n      const capsuleValue = data.map(({ value }) => value)\n\n      const maxValue = Math.max(...capsuleValue)\n\n      this.capsuleValue = capsuleValue\n\n      this.capsuleLength = capsuleValue.map(v => (maxValue ? v / maxValue : 0))\n\n      const oneFifth = maxValue / 5\n\n      const labelData = Array.from(\n        new Set(new Array(6).fill(0).map((v, i) => Math.ceil(i * oneFifth)))\n      )\n\n      this.labelData = labelData\n\n      this.labelDataLength = Array.from(labelData).map(v =>\n        maxValue ? v / maxValue : 0\n      )\n    }\n  },\n  mounted() {\n    const { calcData } = this\n\n    calcData()\n  }\n}\n",null]}