|
| 1 | +import React from 'react'; |
| 2 | + |
| 3 | +import ReactDOM from 'react-dom'; |
| 4 | +import { NarrativeTextVis } from '@antv/ava-react'; |
| 5 | + |
| 6 | +import type { NtvTypes } from '@antv/ava-react'; |
| 7 | + |
| 8 | +const spec: NtvTypes.NarrativeTextSpec = { |
| 9 | + sections: [ |
| 10 | + { |
| 11 | + paragraphs: [ |
| 12 | + { |
| 13 | + type: 'normal', |
| 14 | + phrases: [ |
| 15 | + { type: 'entity', value: 'DAU', metadata: { entityType: 'metric_name' } }, |
| 16 | + { type: 'text', value: ' ' }, |
| 17 | + { type: 'entity', value: '1.23亿', metadata: { entityType: 'metric_value', origin: 123077.34 } }, |
| 18 | + { type: 'text', value: ',环比昨日 ' }, |
| 19 | + { type: 'entity', value: '80万', metadata: { entityType: 'delta_value', assessment: 'positive' } }, |
| 20 | + { type: 'text', value: '(' }, |
| 21 | + { type: 'entity', value: '2.3%', metadata: { entityType: 'ratio_value', assessment: 'positive' } }, |
| 22 | + { type: 'text', value: ')。' }, |
| 23 | + { type: 'text', value: '最近 3 个动态 7 天' }, |
| 24 | + { |
| 25 | + type: 'entity', |
| 26 | + value: '趋势上涨', |
| 27 | + metadata: { |
| 28 | + entityType: 'trend_desc', |
| 29 | + detail: [1, 2, 6, 18, 24, 48], |
| 30 | + }, |
| 31 | + }, |
| 32 | + { type: 'text', value: '。' }, |
| 33 | + { type: 'text', value: '按垂直行业分:' }, |
| 34 | + ], |
| 35 | + }, |
| 36 | + { |
| 37 | + type: 'bullets', |
| 38 | + isOrder: true, |
| 39 | + bullets: [ |
| 40 | + ...[ |
| 41 | + ['数金服务', '3.23亿', '40.12%'], |
| 42 | + ['民生服务', '1.23亿', '20.12%'], |
| 43 | + ].map<NtvTypes.BulletItemSpec>((item) => ({ |
| 44 | + type: 'bullet-item', |
| 45 | + phrases: [ |
| 46 | + { type: 'entity', value: item[0], metadata: { entityType: 'dim_value' } }, |
| 47 | + { type: 'text', value: ' ' }, |
| 48 | + { type: 'entity', value: item[1], metadata: { entityType: 'metric_value' } }, |
| 49 | + { type: 'text', value: '(占比 ' }, |
| 50 | + { type: 'entity', value: item[2], metadata: { entityType: 'proportion' } }, |
| 51 | + { type: 'text', value: ' )。' }, |
| 52 | + ], |
| 53 | + })), |
| 54 | + { |
| 55 | + type: 'bullet-item', |
| 56 | + phrases: [{ type: 'text', value: '...' }], |
| 57 | + }, |
| 58 | + ], |
| 59 | + }, |
| 60 | + ], |
| 61 | + }, |
| 62 | + ], |
| 63 | +}; |
| 64 | + |
| 65 | +ReactDOM.render(<NarrativeTextVis spec={spec} />, document.getElementById('container')); |
0 commit comments