VSeed, an elegant data composer, transforming complexity into simplicity.
!!!###!!!title=4.4 VTable State Management Types——VisActor/VTable Contributing Documents!!!###!!!!!!###!!!description=---title: 4.4 VTable State Management Types
key words: VisActor,VChart,VTable,VStrory,VMind,VGrammar,VRender,Visualization,Chart,Data,Table,Graph,Gis,LLM---
!!!###!!!
Introduction
This article will introduce the state management module of VTable, as well as the types of management maintained within the management module.
State Management Module
The status module StateManager is responsible for managing the states of various interactions in the table, including selected cells, hover highlight effects, menu display effects, etc.
StateManager not only maintains the values of various states, but also defines methods to update each state. When the corresponding event is triggered, it will update the corresponding state. When the state changes, it will update the scene tree and re-render the chart.
Let's focus on what states are maintained in StateManager and the application scenarios of different types of states.
Status Type Enumeration
About the enumeration of state types, located in packages\vtable\src\state\state.ts
select state maintains the position of the currently selected cell and the configuration of select interactions, including highlightInRange, disableHeader, headerSelectMode, etc.
columnResize maintains the state of dragging to adjust column width, the resizing field indicates whether it is currently in the state of dragging to adjust column width, and col records the index of the column currently being adjusted.
Relatively, rowResize records the state of dragging to adjust the row height, row is the index of the current row, and y is the y-coordinate of the current drag position relative to the table.
The state of dragging and swapping columns is maintained in columnRemove, which internally records the current mouse coordinates, as well as the information of the starting row/column and the target row/column.
menu is responsible for the information of the dropdown menu, maintaining information such as the menu display coordinates, display status, menu items, and highlighted submenu configuration.
The built-in sorting state of VTable is maintained by sort. Since VTable supports multi-column sorting, this configuration is an array. It is responsible for storing which columns are currently sorted, as well as saving information about the sorting icon and sorting direction.
The information of frozen columns is maintained in frozen, and only the number of columns frozen by this configuration frozenColCount will be saved. When the number of columns changes, the scene tree will be updated.
Pivot tables support roll-up and drill-down operations. Information about the current drill-down is mainly maintained in the drill field, including the dimension fields currently drilled and the title displayed for the drill-down.
sparkline stores the row and column values when hovering over the mini chart, making it easy to clear the highlight state of the Sparkline when the mouse moves to other cells.
Conclusion
The state module in VTable has multiple management types, such as the state of selected cells, hover state, etc.
By extracting all the states of the table and maintaining them in one place, the coupling between different modules can be reduced.
Break down the interaction into state modules, event modules, and rendering modules, establishing a process where events drive states and states drive rendering. This will also make it clearer to organize logic when maintaining and adding new features in the future. \r
This document is provided by the following personnel