Skip to content

Commit

Permalink
Merge pull request #1673 from VisActor/1644-feature-pivot-tree-suppor…
Browse files Browse the repository at this point in the history
…t-virtual

1644 feature pivot tree support virtual
  • Loading branch information
fangsmile committed May 21, 2024
2 parents f1689a3 + ab168cb commit 3eec1e0
Show file tree
Hide file tree
Showing 106 changed files with 6,046 additions and 4,153 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "feat: rows and tree can combined use #1644\n\n",
"type": "none",
"packageName": "@visactor/vtable"
}
],
"packageName": "@visactor/vtable",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "feat: add virtual option for rowTree and columnTree #1644\n\n BREAKING CHANGE: getCellOriginRecord will return an array of source data.",
"type": "major",
"packageName": "@visactor/vtable"
}
],
"packageName": "@visactor/vtable",
"email": "[email protected]"
}
2 changes: 1 addition & 1 deletion docs/assets/api/en/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ If it is a pivot analysis table (a pivot table with data analysis turned on), an
* Get source data based on row and column numbers
* @param {number} col col index.
* @param {number} row row index.
* @return {object} record or record array
* @return {object} record or record array. ListTable return one record, PivotTable return an array of records.
*/
getCellOriginRecord(col: number, row: number)
```
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/api/zh/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ setRecords(records: Array<any>)
* 根据行列号获取源数据
* @param {number} col col index.
* @param {number} row row index.
* @return {object} record or record array
* @return {object} record or record array. ListTable return one record, PivotTable return an array of records.
*/
getCellOriginRecord(col: number, row: number)
```
Expand Down
10 changes: 4 additions & 6 deletions docs/assets/demo/en/business/sales-bubble.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ Map sales to circle size and color to help you gain more visual insights into yo
## Key Configurations

- `PivotTable`
- `customRender`
- `customRender`

## Code demo
## Code demo

```javascript livedemo template=vtable

let tableInstance;
function getColor(min, max, value, opacity) {
let tableInstance;
function getColor(min, max, value, opacity) {
if (max === min) {
if (value > 0) {
return `rgba(255,0,0,${opacity})`;
Expand Down Expand Up @@ -86,7 +85,6 @@ fetch('https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/North_American
isShowOverflowTextTooltip: true
},
hideIndicatorName: true,
enableDataAnalysis: true,
defaultHeaderRowHeight: 30,
defaultRowHeight: 40,
defaultColWidth: 60,
Expand Down
148 changes: 73 additions & 75 deletions docs/assets/demo/en/data-analysis/pivot-analysis-aggregation.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ To pivot analysis table data data filtering rules, configure aggregationRules in
- `columns`
- `rows`
- `indicators`
- `enableDataAnalysis` turns on pivot data analysis
- `dataConfig` configures data rules,set aggregationRules

## Code demo

```javascript livedemo template=vtable
Expand All @@ -30,84 +30,82 @@ const countNumberFormat = VTable.DataStatistics.numberFormat({
thousandsSep: '',
suffix: ' orders'
});
let tableInstance;
fetch('https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/North_American_Superstore_data.json')
.then((res) => res.json())
.then((data) => {

const option = {
records:data,
"rows": [
{
"dimensionKey": "Category",
"title": "Category",
"headerStyle": {
"textStick": true
},
"width": "auto",
},
{
"dimensionKey": "Sub-Category",
"title": "Sub-Catogery",
"headerStyle": {
"textStick": true
},
"width": "auto",
},
],
"columns": [
{
"dimensionKey": "Region",
"title": "Region",
"headerStyle": {
"textStick": true
},
"width": "auto",
},
{
"dimensionKey": "Segment",
"title": "Segment",
"headerStyle": {
"textStick": true
},
"width": "auto",
},
],
indicators: ['TotalSales', 'OrderCount', 'AverageOrderSales'],
"corner": {
"titleOnDimension": "row",
"headerStyle": {
"textStick": true
}
},
dataConfig: {
aggregationRules: [
//As the basis for aggregate calculations, if the sales amount is not configured,
//the cell content will be displayed by default according to the aggregate sum calculation.
let tableInstance;
fetch('https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/North_American_Superstore_data.json')
.then(res => res.json())
.then(data => {
const option = {
records: data,
rows: [
{
indicatorKey: 'TotalSales', //Indicator name
field: 'Sales', //The field which the indicator is based
aggregationType: VTable.TYPES.AggregationType.SUM, //Calculation type
formatFun: sumNumberFormat
dimensionKey: 'Category',
title: 'Category',
headerStyle: {
textStick: true
},
width: 'auto'
},
{
indicatorKey: 'OrderCount', //Indicator name
field: 'Sales', //The field which the indicator is based
aggregationType: VTable.TYPES.AggregationType.COUNT, //Calculation type
formatFun: countNumberFormat
dimensionKey: 'Sub-Category',
title: 'Sub-Catogery',
headerStyle: {
textStick: true
},
width: 'auto'
}
],
columns: [
{
dimensionKey: 'Region',
title: 'Region',
headerStyle: {
textStick: true
},
width: 'auto'
},
{
indicatorKey: 'AverageOrderSales', //Indicator name
field: 'Sales', //The field which the indicator is based
aggregationType: VTable.TYPES.AggregationType.AVG, //Calculation type
formatFun: sumNumberFormat
dimensionKey: 'Segment',
title: 'Segment',
headerStyle: {
textStick: true
},
width: 'auto'
}
]
},
enableDataAnalysis: true,
widthMode:'autoWidth'
};
tableInstance = new VTable.PivotTable(document.getElementById(CONTAINER_ID),option);
window['tableInstance'] = tableInstance;
})
],
indicators: ['TotalSales', 'OrderCount', 'AverageOrderSales'],
corner: {
titleOnDimension: 'row',
headerStyle: {
textStick: true
}
},
dataConfig: {
aggregationRules: [
//As the basis for aggregate calculations, if the sales amount is not configured,
//the cell content will be displayed by default according to the aggregate sum calculation.
{
indicatorKey: 'TotalSales', //Indicator name
field: 'Sales', //The field which the indicator is based
aggregationType: VTable.TYPES.AggregationType.SUM, //Calculation type
formatFun: sumNumberFormat
},
{
indicatorKey: 'OrderCount', //Indicator name
field: 'Sales', //The field which the indicator is based
aggregationType: VTable.TYPES.AggregationType.COUNT, //Calculation type
formatFun: countNumberFormat
},
{
indicatorKey: 'AverageOrderSales', //Indicator name
field: 'Sales', //The field which the indicator is based
aggregationType: VTable.TYPES.AggregationType.AVG, //Calculation type
formatFun: sumNumberFormat
}
]
},
widthMode: 'autoWidth'
};
tableInstance = new VTable.PivotTable(document.getElementById(CONTAINER_ID), option);
window['tableInstance'] = tableInstance;
});
```
Loading

0 comments on commit 3eec1e0

Please sign in to comment.