From 9415fa0b5677987ea5fd9d8aece8081d7a8e2832 Mon Sep 17 00:00:00 2001 From: QSJia Date: Wed, 19 Oct 2016 20:14:16 +0800 Subject: [PATCH 1/2] =?UTF-8?q?unicode=E8=BD=AC=E4=B9=89=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E7=9A=84=E5=89=8D=E7=BC=80=E5=BA=94=E8=AF=A5=E6=98=AF'\u'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/datetime/format.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/datetime/format.js b/src/components/datetime/format.js index 601bc1563..c3d2670ba 100644 --- a/src/components/datetime/format.js +++ b/src/components/datetime/format.js @@ -10,19 +10,19 @@ module.exports = function (date, fmt = 'YYYY-MM-DD HH:mm:ss') { 'S': date.getMilliseconds() } var week = { - '0': '/u65e5', - '1': '/u4e00', - '2': '/u4e8c', - '3': '/u4e09', - '4': '/u56db', - '5': '/u4e94', - '6': '/u516d' + '0': '\u65e5', + '1': '\u4e00', + '2': '\u4e8c', + '3': '\u4e09', + '4': '\u56db', + '5': '\u4e94', + '6': '\u516d' } if (/(Y+)/.test(fmt)) { fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)) } if (/(E+)/.test(fmt)) { - fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? '/u661f/u671f' : '/u5468') : '') + week[date.getDay() + '']) + fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? '\u661f\u671f' : '\u5468') : '') + week[date.getDay() + '']) } for (var k in o) { if (new RegExp('(' + k + ')').test(fmt)) { From 03d426e1ba635b05d43fd01a21b14d9439b36027 Mon Sep 17 00:00:00 2001 From: lzx <623253747@qq.com> Date: Wed, 17 Apr 2019 23:55:42 +0800 Subject: [PATCH 2/2] new commit --- index.js | 9 ++- package.json | 2 +- src/components/map.json | 4 +- src/components/v-chart/v-chart.vue | 77 ++++++++++++++------- src/components/v-chart/v-labelline-pie.vue | 40 +++++++++++ src/components/v-chart/v-pielabel.vue | 23 +++++++ src/demos/v-chart/pie_labelline.vue | 79 ++++++++++++++++++++++ 7 files changed, 207 insertions(+), 27 deletions(-) create mode 100644 src/components/v-chart/v-labelline-pie.vue create mode 100644 src/components/v-chart/v-pielabel.vue create mode 100644 src/demos/v-chart/pie_labelline.vue diff --git a/index.js b/index.js index ff54a36fd..4835504fb 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,7 @@ // THIS FILE IS ONLY FOR IDE ENTRY CHECKING NOT FOR REAL USAGE -console.warn('VUX: 如果你看到这一行,说明 vux-loader 配置有问题或者代码书写规范的原因导致无法解析成按需引入组件,会导致打包体积过大。请升级到最新版本 vux-loader,建议开启 eslint(standard)。') +console.warn( + 'VUX: 如果你看到这一行,说明 vux-loader 配置有问题或者代码书写规范的原因导致无法解析成按需引入组件,会导致打包体积过大。请升级到最新版本 vux-loader,建议开启 eslint(standard)。') import Actionsheet from './src/components/actionsheet/index.vue' import Agree from './src/components/agree/index.vue' @@ -139,9 +140,11 @@ import VChart from './src/components/v-chart/v-chart.vue' import VGuide from './src/components/v-chart/v-guide.vue' import Video from './src/components/video/index.vue' import ViewBox from './src/components/view-box/index.vue' +import VLabellinePie from './src/components/v-chart/v-labelline-pie.vue' import VLegend from './src/components/v-chart/v-legend.vue' import VLine from './src/components/v-chart/v-line.vue' import VPie from './src/components/v-chart/v-pie.vue' +import VPielabel from './src/components/v-chart/v-pielabel.vue' import VPoint from './src/components/v-chart/v-point.vue' import VScale from './src/components/v-chart/v-scale.vue' import VTooltip from './src/components/v-chart/v-tooltip.vue' @@ -302,9 +305,11 @@ export { VGuide, Video, ViewBox, + VLabellinePie, VLegend, VLine, VPie, + VPielabel, VPoint, VScale, VTooltip, @@ -326,4 +331,4 @@ export { XSwitch, XTable, XTextarea -} \ No newline at end of file +} diff --git a/package.json b/package.json index 5865aa700..02b267e16 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "xbuild": "npm run build-styles && npm run build-components" }, "dependencies": { - "@antv/f2": "^3.1.4-beta.2", + "@antv/f2": "^3.3.8", "array-filter": "^1.0.0", "array-find": "^1.0.0", "array-map": "^0.0.0", diff --git a/src/components/map.json b/src/components/map.json index 92a7b3ef8..8001ef4e5 100644 --- a/src/components/map.json +++ b/src/components/map.json @@ -136,9 +136,11 @@ "VGuide": "src/components/v-chart/v-guide.vue", "Video": "src/components/video/index.vue", "ViewBox": "src/components/view-box/index.vue", + "VLabellinePie": "src/components/v-chart/v-labelline-pie.vue", "VLegend": "src/components/v-chart/v-legend.vue", "VLine": "src/components/v-chart/v-line.vue", "VPie": "src/components/v-chart/v-pie.vue", + "VPielabel": "src/components/v-chart/v-pielabel.vue", "VPoint": "src/components/v-chart/v-point.vue", "VScale": "src/components/v-chart/v-scale.vue", "VTooltip": "src/components/v-chart/v-tooltip.vue", @@ -160,4 +162,4 @@ "XSwitch": "src/components/x-switch/index.vue", "XTable": "src/components/x-table/index.vue", "XTextarea": "src/components/x-textarea/index.vue" -} \ No newline at end of file +} diff --git a/src/components/v-chart/v-chart.vue b/src/components/v-chart/v-chart.vue index 028e04d3e..55e85b5e3 100644 --- a/src/components/v-chart/v-chart.vue +++ b/src/components/v-chart/v-chart.vue @@ -22,7 +22,7 @@ // schema: ['candle'] // } -import F2 from '@antv/f2' +import F2 from '@antv/f2/lib/index-all' export default { props: { @@ -67,6 +67,8 @@ export default { barOptions: null, + labellinePieOptions: null, + pieOptions: null, guideOptions: null, @@ -78,6 +80,8 @@ export default { guides: [], + pieLabels: [], + seriesField: '', xAxisOptions: null, @@ -88,7 +92,7 @@ export default { }, computed: { currentData () { - if (this.pieOptions) { + if (this.pieOptions || this.labellinePieOptions) { return this.data.slice().map(item => { item.a = '1' return item @@ -161,6 +165,9 @@ export default { addGuide (options) { this.guides.push(options) }, + addPielabel (options) { + this.pieLabels.push(options) + }, setScale (options) { if (options.x) { this.xFieldOptions = options.x @@ -191,6 +198,9 @@ export default { } return color }, + setLabellinePie (options = {}) { + this.labellinePieOptions = options + }, setPie (options = {}) { this.pieOptions = options }, @@ -373,6 +383,14 @@ export default { }) } + if (this.pieLabels.length) { + this.pieLabels.forEach(pieLabel => { + chart.pieLabel( + pieLabel.options + ) + }) + } + if (this.areaOptions) { const { adjust, seriesField } = this.areaOptions let color = this.buildColor(this.areaOptions.colors) @@ -409,25 +427,37 @@ export default { } }) + if (this.labellinePieOptions) { + chart.coord(this.labellinePieOptions.coord, this.labellinePieOptions) + chart.axis(false) + chart.legend(false) + chart.tooltip(false) + chart.interval().position('a*percent').color(this.labellinePieOptions.seriesField, + (this.labellinePieOptions.colors && this.labellinePieOptions.colors.length) + ? this.labellinePieOptions.colors + : '').adjust('stack') + } + if (this.pieOptions) { chart.coord(this.pieOptions.coord, this.pieOptions) chart.axis(false) chart.interval() - .position('a*percent') - .color(this.pieOptions.seriesField, (this.pieOptions.colors && this.pieOptions.colors.length) ? this.pieOptions.colors : '') - .adjust('stack') - .style({ - lineWidth: 1, - stroke: '#fff', - lineJoin: 'round', - lineCap: 'round' - }) - .animate({ - appear: { - duration: 1200, - easing: 'bounceOut' - } - }) + .position('a*percent') + .color(this.pieOptions.seriesField, + (this.pieOptions.colors && this.pieOptions.colors.length) ? this.pieOptions.colors : '') + .adjust('stack') + .style({ + lineWidth: 1, + stroke: '#fff', + lineJoin: 'round', + lineCap: 'round' + }) + .animate({ + appear: { + duration: 1200, + easing: 'bounceOut' + } + }) } if (this.pointOptions) { @@ -469,11 +499,12 @@ export default { diff --git a/src/components/v-chart/v-labelline-pie.vue b/src/components/v-chart/v-labelline-pie.vue new file mode 100644 index 000000000..aa3748735 --- /dev/null +++ b/src/components/v-chart/v-labelline-pie.vue @@ -0,0 +1,40 @@ + diff --git a/src/components/v-chart/v-pielabel.vue b/src/components/v-chart/v-pielabel.vue new file mode 100644 index 000000000..1a58d1714 --- /dev/null +++ b/src/components/v-chart/v-pielabel.vue @@ -0,0 +1,23 @@ + diff --git a/src/demos/v-chart/pie_labelline.vue b/src/demos/v-chart/pie_labelline.vue new file mode 100644 index 000000000..4a11a42b1 --- /dev/null +++ b/src/demos/v-chart/pie_labelline.vue @@ -0,0 +1,79 @@ + + + + + + title: 饼图 +