From 0fac9e47480b2491a203861651b179c3c6a9375b Mon Sep 17 00:00:00 2001 From: cipchk Date: Mon, 11 Dec 2017 19:01:01 +0800 Subject: [PATCH] feat(abc:avatar-list): add text, icon property in avatar-list-item. close #93 --- scaffold | 2 +- src/app/abc/component.ts | 80 ++----------------- .../avatar-list/avatar-list-item.component.ts | 2 + .../avatar-list/avatar-list.component.ts | 4 +- .../abc/components/avatar-list/demo/simple.md | 6 +- src/core/abc/components/avatar-list/index.md | 2 + 6 files changed, 19 insertions(+), 77 deletions(-) diff --git a/scaffold b/scaffold index 05b3932e2..4b69ad019 160000 --- a/scaffold +++ b/scaffold @@ -1 +1 @@ -Subproject commit 05b3932e2220a880032e4f1d908a694d8b18566b +Subproject commit 4b69ad019ec41cce1092cf835e40e88d10b9bcad diff --git a/src/app/abc/component.ts b/src/app/abc/component.ts index 1f4160e27..f7e9732d8 100644 --- a/src/app/abc/component.ts +++ b/src/app/abc/component.ts @@ -1,80 +1,16 @@ -import { Component, ElementRef } from '@angular/core'; +import { Component } from '@angular/core'; @Component({ selector: 'app-demo', template: ` - + + + + + + + ` }) export class DemoComponent { - render(el: ElementRef) { - const { DataView } = DataSet; - let data = [ - { action: '浏览网站', pv: 50000 }, - { action: '放入购物车', pv: 35000 }, - { action: '生成订单', pv: 25000 }, - { action: '支付订单', pv: 15000 }, - { action: '完成交易', pv: 8000 } - ]; - const dv = new DataView().source(data); - dv.transform({ - type: 'percent', - field: 'pv', - dimension: 'action', - as: 'percent' - }); - data = dv.rows; - const chart = new G2.Chart({ - container: el.nativeElement, - forceFit: true, - height: 400, - padding: [ 20, 120, 95 ] - }); - chart.source(data, { - percent: { - nice: false - } - }); - chart.axis(false); - chart.tooltip({ - showTitle: false, - itemTpl: '
  • ' - + '' - + '{name}
    ' - + '浏览人数:{pv}
    ' - + '占比:{percent}
    ' - + '
  • ' - }); - chart.coord('rect').transpose().scale(1, -1); - chart.intervalSymmetric().position('action*percent') - .shape('funnel') - .color('action', [ '#0050B3', '#1890FF', '#40A9FF', '#69C0FF', '#BAE7FF' ]) - .tooltip('action*pv*percent', (action: any, pv: any, percent: any) => { - return { - name: action, - percent: (percent * 100).toFixed(2) + '%', - pv: pv - }; - }) - ; - data.map((obj: any) => { - // 中间标签文本 - chart.guide().text({ - top: true, - position: { - action: obj.action, - percent: 'median' - }, - content: (obj.percent * 100).toFixed(2) + '%', // 显示的文本内容 - style: { - fill: '#fff', - fontSize: '12', - textAlign: 'center', - shadowBlur: 2, - shadowColor: 'rgba(0, 0, 0, .45)' - } - }); - }); - chart.render(); - } } diff --git a/src/core/abc/components/avatar-list/avatar-list-item.component.ts b/src/core/abc/components/avatar-list/avatar-list-item.component.ts index fd9a61162..b60c179c6 100644 --- a/src/core/abc/components/avatar-list/avatar-list-item.component.ts +++ b/src/core/abc/components/avatar-list/avatar-list-item.component.ts @@ -6,5 +6,7 @@ import { Component, Input } from '@angular/core'; }) export class AvatarListItemComponent { @Input() src: string; + @Input() text: string; + @Input() icon: string; @Input() tips: string; } diff --git a/src/core/abc/components/avatar-list/avatar-list.component.ts b/src/core/abc/components/avatar-list/avatar-list.component.ts index 7a3910ccf..4c30ba084 100644 --- a/src/core/abc/components/avatar-list/avatar-list.component.ts +++ b/src/core/abc/components/avatar-list/avatar-list.component.ts @@ -7,9 +7,9 @@ import { AvatarListItemComponent } from './avatar-list-item.component'; `, diff --git a/src/core/abc/components/avatar-list/demo/simple.md b/src/core/abc/components/avatar-list/demo/simple.md index 74deeb231..49ec1f26a 100644 --- a/src/core/abc/components/avatar-list/demo/simple.md +++ b/src/core/abc/components/avatar-list/demo/simple.md @@ -11,15 +11,17 @@ Simplest of usage. import { Component } from '@angular/core'; @Component({ - selector: 'avatar-list-simple', + selector: 'app-demo', template: ` + + ` }) -export class AvatarListSimpleComponent { +export class DemoComponent { } ``` diff --git a/src/core/abc/components/avatar-list/index.md b/src/core/abc/components/avatar-list/index.md index e533fe935..6a446ca04 100644 --- a/src/core/abc/components/avatar-list/index.md +++ b/src/core/abc/components/avatar-list/index.md @@ -20,4 +20,6 @@ size | 头像大小 | `large`、`small`、`mini`、`default` | `default` |----------|------------------------------------------|-------------|-------| | tips | 头像展示文案 | `string` | - | | src | 头像图片连接 | `string` | - | +| text | 文本类头像 | `string` | - | +| icon | 图标类型 | `string` | - |