|
| 1 | +import * as VTable from '../../src'; |
| 2 | +const PivotTable = VTable.PivotTable; |
| 3 | +const CONTAINER_ID = 'vTable'; |
| 4 | + |
| 5 | +export function createTable() { |
| 6 | + const option: VTable.PivotTableConstructorOptions = { |
| 7 | + records: [ |
| 8 | + { Category: 'A', 'Sub-Category': 'A1', Sales: 100, Profit: 10 }, |
| 9 | + { Category: 'A', 'Sub-Category': 'A2', Sales: 150, Profit: 15 }, |
| 10 | + { Category: 'B', 'Sub-Category': 'B1', Sales: 200, Profit: 20 }, |
| 11 | + { Category: 'B', 'Sub-Category': 'B2', Sales: 250, Profit: 25 } |
| 12 | + ], |
| 13 | + rows: [ |
| 14 | + { |
| 15 | + dimensionKey: 'Category', |
| 16 | + title: 'Category', |
| 17 | + showSortInCorner: true |
| 18 | + } |
| 19 | + ], |
| 20 | + columns: [ |
| 21 | + { |
| 22 | + dimensionKey: 'Category', |
| 23 | + title: 'Category', |
| 24 | + showSortInCorner: true |
| 25 | + } |
| 26 | + ], |
| 27 | + indicators: [ |
| 28 | + { indicatorKey: 'Sales', title: 'Sales', showSortInCorner: true } as any, |
| 29 | + { indicatorKey: 'Profit', title: 'Profit', showSortInCorner: true } as any |
| 30 | + ], |
| 31 | + corner: { |
| 32 | + titleOnDimension: 'all' |
| 33 | + }, |
| 34 | + pivotSortState: [ |
| 35 | + { |
| 36 | + dimensions: [ |
| 37 | + { |
| 38 | + dimensionKey: 'Category', |
| 39 | + isPivotCorner: true |
| 40 | + } |
| 41 | + ], |
| 42 | + order: 'desc' |
| 43 | + } |
| 44 | + ] |
| 45 | + }; |
| 46 | + |
| 47 | + const instance = new PivotTable(document.getElementById(CONTAINER_ID)!, option); |
| 48 | + (window as any).tableInstance = instance; |
| 49 | +} |
0 commit comments