Customize header dimension tree
In some business scenarios, facing huge amounts of database data and complex filtering or sorting rules, VTable's data analytics capabilities will not be able to meet business requirements. At this time, it can be achieved by customizing the row and column header dimension trees'rowTree 'and'columnTree'.
custom rowTree columnTree
Example
Custom tree configuration:
VTable official website example: https://visactor.io/vtable/demo/table-type/pivot-table.
The complexity of custom trees lies in the formation of row and column dimension trees, which can be selected according to business scenarios. If you have complex sorting, summarization or paging rules, you can choose to use custom methods.
If rowHierarchyType is set to tree and you expect to load lazily when you click to expand the node, you also need to use a pivot table with a custom header. For the specific demo, please refer to: https://visactor.io/vtable/demo/table-type/pivot-table-tree-lazy-load.
Virtual header node
In some scenarios of pivot table analysis, the table structure and data to be displayed do not match perfectly. For example, the pivot table may only have row dimensions and indicator values. When there are many fields for indicator values, you want to group the indicators by customizing column headers. In fact, the column headers are virtual, and the data records are not associated with corresponding dimension fields, and the number of levels is uncertain.
Based on this scenario, VTable provides the function of virtual header node, through which the headers on the column can be grouped. For a specific example, see: URL_ADDRESS.
Just add virtual: true
when configuring the nodes in rowTree columnTree.
like:
rowTree: [
{
dimensionKey: 'Segment-1',
value: 'Segment-1 (virtual-node)',
virtual: true,
children: [
{
indicatorKey: 'Quantity',
value: 'Quantity'
},
{
indicatorKey: 'Sales',
value: 'Sales'
},
{
indicatorKey: 'Profit',
value: 'Profit'
}
]
}
],
Specific demo: https://visactor.io/vtable/demo/table-type/pivot-table-virtual-header
Custom Header Cross-column Merge
In the nodes of rowTree or columnTree, configure levelSpan, which is 1 by default. This configuration can specify the range of header cell merging. If the maximum number of header levels is 3, there are a total of three dimension levels, and the middle dimension sets levelSpan to 2, then the last level will be merged as large as the number of levels, and there will be no space. The effect of the following example:
levelSpan
Custom tree completion indicator node
By default, VTable will automatically complete the indicator node. For example, the user can pass in a dimension tree without an indicator node:
rowTree: [
{
dimensionKey: 'Region',
value: 'North',
}
],
At the same time, the user configures indicator information in indicators:
indicators: ['Sales', 'Profit'],
indicatorsAsCol:false,
VTable will automatically complete the indicator nodes into the row dimension header tree:
rowTree: [
{
dimensionKey: 'Region',
value: 'North',
children: [
{
indicatorKey: 'Sales',
value: 'Sales'
},
{
indicatorKey: 'Profit',
value: 'Profit'
}
]
}
],
If you don't need to automatically complete indicator nodes, you can turn off automatic completion by setting supplementIndicatorNodes: false
.
Custom tree irregular case
The parseCustomTreeToMatchRecords
configuration needs to be turned on if you have configured rowTree or columnTree and it is a non-regular tree structure to match the corresponding data record.
The regular tree structure refers to: the nodes on the same layer have the same dimension keys.
The non-regular tree structure is the tree where nodes on the same layer exist with different dimension values.