Column display width generation method, device and computer equipment for data table
By dynamically calculating the column width of the table, and taking into account the deviation of column data length and column name length, combined with preset maximum and minimum values, the problem of unbalanced data in multiple columns of the table is solved, and the display effect of the data table is improved.
Patent Information
- Application Number
- CN202411767363.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2044-12-04
AI Technical Summary
In traditional technology, when displaying tables, the imbalance of multiple columns of data leads to poor data readability and makes it impossible to effectively utilize the differences in content between different columns.
By retrieving raw data from a preset database, splitting the data into columns, and then iterating through each column, the column balance length is determined based on the degree of data length deviation. Combined with the column name length, the preset maximum and minimum column width values, the display width of each column is dynamically calculated.
It improves the display effect of multiple columns of data in the data table, avoids the imbalance problem caused by fixed column width, and enhances the readability and display effect of the data.
Smart Images

Figure CN119578384B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of information technology, and in particular, to a column display width generation method and device for a data table, a computer device, a computer readable storage medium, and a computer program product. BACKGROUND
[0002] In a system including a web interface, a table form is often used to display a large amount of data. However, the display form of the table usually has a problem of unbalanced display of multiple columns of data. In the database field, there are several field types for each database, and the query result set of a single table often has multiple fields. The content length of different cells has a large difference. The unbalanced display of multiple columns of data in the table affects the readability of the data.
[0003] The conventional technology mainly sets the column display width of each column in the table to the same width to display multiple columns of data. However, the conventional technology ignores the difference between the contents of different columns, which leads to compression of the displayed content and is not conducive to improving the display effect of multiple columns of data in the data table. SUMMARY
[0004] Therefore, it is necessary to provide a column display width generation method and device for a data table, a computer device, a computer readable storage medium, and a computer program product, which can improve the display effect of multiple columns of data in the data table.
[0005] In a first aspect, the present application provides a column display width generation method for a data table, comprising:
[0006] obtaining original data from a preset database and dividing the original data into at least one table data;
[0007] traversing each table data, determining a column balance length corresponding to each table data according to the deviation degree between the lengths of the data in each table data; the column balance length is used to represent the overall level of the lengths of the data in each table data;
[0008] determining a column display width corresponding to each table data according to the column balance length corresponding to each table data, the length of the column name corresponding to each table data, a preset maximum column width, and a preset minimum column width; the preset maximum column width is greater than the preset minimum column width.
[0009] In one embodiment, the determination of the column balance length corresponding to each table data according to the deviation degree between the lengths of the data in each table data comprises:
[0010] determining a length reference value according to lengths of the data in each of the table data;
[0011] traversing the data in each of the table data, and determining length difference values between the lengths of the data in each of the table data and the length reference value;
[0012] determining column balance lengths corresponding to the table data according to the length difference values.
[0013] In one embodiment, before the step of determining the column balance lengths corresponding to the table data, the method further comprises:
[0014] traversing the table data, and filtering out to-be-converted data from each of the table data according to data types of the data in each of the table data;
[0015] mapping lengths of the to-be-converted data according to length conversion manners corresponding to the to-be-converted data.
[0016] In one embodiment, the determining of the column display widths corresponding to the table data according to the column balance lengths corresponding to the table data, lengths of column names corresponding to the table data, a preset maximum column width and a preset minimum column width comprises:
[0017] for each of the table data, if the column balance length corresponding to the table data is less than the length of the column name corresponding to the table data, and the length of the column name corresponding to the table data is less than the preset minimum column width, the preset minimum column width is taken as the column display width corresponding to the table data.
[0018] In one embodiment, the determining of the column display widths corresponding to the table data according to the column balance lengths corresponding to the table data, lengths of column names corresponding to the table data, a preset maximum column width and a preset minimum column width comprises:
[0019] for each of the table data, if the column balance length corresponding to the table data is less than the length of the column name corresponding to the table data, and the column balance length corresponding to the table data is greater than or equal to the preset minimum column width, the length of the column name corresponding to the table data is taken as the column display width corresponding to the table data.
[0020] In one of the embodiments, the column display width corresponding to each table data is determined according to the column balance length corresponding to the each table data, the length of the column name corresponding to the each table data, the preset maximum column width and the preset minimum column width, which comprises:
[0021] In the case that the column balance length corresponding to the each table data is greater than or equal to the preset maximum column width, and the preset maximum column width is greater than or equal to the length of the column name corresponding to the each table data, the preset maximum column width is taken as the column display width corresponding to the each table data.
[0022] In one of the embodiments, after the step of determining the column display width corresponding to the each table data, the method further comprises:
[0023] Summing the column display width corresponding to the each table data to obtain a table width;
[0024] Adjusting the column display width corresponding to the each table data according to the table width and the interface width of the table display interface.
[0025] In the second aspect, the application further provides a column display width generation device of a data table, which comprises:
[0026] An acquisition module, configured to acquire original data from a preset database and divide the original data into columns to obtain at least one table data.
[0027] A calculation module, configured to traverse each table data and determine a column balance length corresponding to the each table data according to the deviation degree between the lengths of the data in the each table data; the column balance length is used to represent the overall level of the lengths of the data in the each table data.
[0028] A determination module, configured to determine a column display width corresponding to the each table data according to the column balance length corresponding to the each table data, the length of the column name corresponding to the each table data, a preset maximum column width and a preset minimum column width; the preset maximum column width is greater than the preset minimum column width.
[0029] In the third aspect, the application further provides a computer device. The computer device comprises a memory and a processor, the memory stores a computer program, and the computer program is executed by the processor to realize the steps of the above method.
[0030] In a fourth aspect, the present application provides a computer readable storage medium. The computer readable storage medium has a computer program stored thereon, and the computer program, when executed by a processor, implements the steps of the method described above.
[0031] In a fifth aspect, the present application provides a computer program product. The computer program product comprises a computer program, and the computer program, when executed by a processor, implements the steps of the method described above.
[0032] The column display width generation method, device, computer device, computer readable storage medium and computer program product of the data table described above, by obtaining the original data from the preset database and dividing the original data by columns, obtain at least one table data, so as to divide the original data in the database by columns, so as to determine the column display width of each column data subsequently; traverse each table data, determine the column balance length corresponding to each table data according to the deviation degree between the lengths of the data in each table data, the column balance length is used to represent the overall level of the lengths of the data in each table data, so as to analyze the deviation degree between the lengths of the data in each column data, and accurately obtain the column balance length used to represent the overall level of the lengths of each column data, so as to determine the column display width of each column data subsequently in combination with the column balance length; determine the column display width corresponding to each table data according to the column balance length corresponding to each table data, the length of the column name corresponding to each table data, the preset maximum column width and the preset minimum column width; the preset maximum column width is greater than the preset minimum column width, so that the column display width corresponding to each table data is accurately determined based on the different size relationships between the column balance length, the length of the column name, the maximum column width and the minimum column width, the column display width of each column data can be reasonably calculated based on the lengths of the data in each column data, and the problem of poor data display effect such as uneven data display caused by fixed column width is avoided, so as to improve the display effect of the multiple column data in the data table. BRIEF DESCRIPTION OF DRAWINGS
[0033] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technical solutions, the drawings needed to be used in the description of the embodiments of the present application or the related technical solutions will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other related drawings can be obtained by those skilled in the art without creating any inventive labor.
[0034] Figure 1 An application environment diagram of a column display width generation method of a data table in an embodiment;
[0035] Figure 2 A flowchart of a column display width generation method of a data table in an embodiment;
[0036] Figure 3 a schematic diagram of an architecture of a scheme for dynamically displaying a multi-column data table in a database field in an embodiment;
[0037] Figure 4 a schematic diagram of a flow for determining column display width in an embodiment;
[0038] Figure 5 a block diagram of a structure of a column display width generation apparatus of a data table in an embodiment;
[0039] Figure 6 an internal structure diagram of a computer device in an embodiment. DETAILED DESCRIPTION
[0040] In order to make the purposes, technical solutions and advantages of the present application clearer, the present application is further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and not to limit the present application.
[0041] The column display width generation method of the data table provided by the embodiments of the present application can be applied in an application environment as shown in the figure. Figure 1 The terminal 102 communicates with the server 104 through a network. The data storage system can store data required to be processed by the server 104. The data storage system can be integrated on the server 104, or placed on a cloud or other network server. The terminal 102 obtains original data from a preset database, and divides the original data into columns to obtain at least one table data. The terminal 102 traverses each table data, and determines a column balance length corresponding to each table data according to a deviation degree between lengths of data in each table data. The column balance length is used to represent the overall level of the lengths of the data in each table data. The terminal 102 determines a column display width corresponding to each table data according to the column balance length corresponding to each table data, a length of a column name corresponding to each table data, a preset maximum column width and a preset minimum column width. The preset maximum column width is greater than the preset minimum column width. The terminal 102 can be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things device can be a smart television, a smart vehicle device, a projection device, etc. The portable wearable device can be a smart watch, a head-mounted device, etc. The head-mounted device can be a virtual reality (VR) device, an augmented reality (AR) device, smart glasses, etc. The server 104 can be a standalone physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.
[0042] In one exemplary embodiment, as shown in Figure 2 a column display width generation method of a data table is provided, which is described by taking a terminal as an example and includes the following steps S202 to S206. Wherein:
[0043] Step S202, obtaining original data from a preset database, and columnizing the original data to obtain at least one table data.
[0044] Wherein, the preset database can refer to a database for storing original data. In actual application, the preset database can include a database for storing business data of a specific business.
[0045] Wherein, the original data can refer to data representing business parameters and other information of a specific business.
[0046] Wherein, the table data can refer to data in each column of a table obtained by dividing / organizing the original data by column.
[0047] As an example, in a system containing a web interface, the data to be displayed can be pre-stored in the preset database as original data. When it is needed to display the original data in the preset database in the form of a table, the terminal can first obtain the original data from the preset database, and then the terminal can organize the original data, for example, the terminal can columnize the original data according to the category (such as data meaning, etc.) corresponding to each original data to obtain a plurality of column data. At this time, the plurality of column data can constitute a data table, so the above plurality of column data can be used as a plurality of table data.
[0048] Step S204, traversing each table data, and determining a column balance length corresponding to each table data according to the deviation degree between the lengths of the data in each table data.
[0049] Wherein, the column balance length can refer to information representing the overall level of the length of the data in each table data. In actual application, the column balance length corresponding to each table data can be used as a length that can best represent the data / content in most cells in the table data.
[0050] As an example, in order to determine the width of the cell where each table data is displayed, the terminal can traverse each table data, obtain the length of each data (in the cell) in each table data one by one, analyze the deviation degree / difference degree between the lengths of the data in each table data, and calculate the column balance length corresponding to each table data based on a preset expression.
[0051] In step S206, the column display width corresponding to each table data is determined according to the column balance length corresponding to each table data, the length of the column name corresponding to each table data, the preset maximum column width, and the preset minimum column width. The preset maximum column width is greater than the preset minimum column width.
[0052] The length of the column name can refer to the length of the name of each table data in the table. In actual application, the table can be composed of a plurality of table data, and each table data has a corresponding name (e.g., a column name).
[0053] The preset maximum column width can refer to information of a maximum value preset for limiting the width of the cell in which each table data is located.
[0054] The preset minimum column width can refer to information of a minimum value preset for limiting the width of the cell in which each table data is located.
[0055] The column display width can refer to information of the width of the cell in which each table data is located when each table data is displayed in the form of a table.
[0056] As an example, in order to avoid that the column display width is too large or too small, the maximum column width and the minimum column width are preset. Meanwhile, when each table data is displayed in the form of a table, the name (e.g., a column name) corresponding to each table data can be displayed in the table. Therefore, the terminal needs to first acquire the length of the column name corresponding to each table data, the preset maximum column width, and the preset minimum column width, and then analyze the size relationship among the column balance length corresponding to each table data, the length of the column name corresponding to each table data, the preset maximum column width, and the preset minimum column width by comparing the column balance length corresponding to each table data, the length of the column name corresponding to each table data, the preset maximum column width, and the preset minimum column width. Thus, the column display width of the cell in which each table data is located when each table data is displayed in the form of a table is determined.
[0057] In the above method for generating the column display width of the data table, raw data is obtained from a preset database and divided into columns to obtain at least one column of data. This divides the raw data in the database by columns, so that the column display width of each column can be determined later. Each column of data is traversed, and the column balance length corresponding to each column is determined based on the degree of deviation between the lengths of the data in each column. The column balance length is used to characterize the overall level of the length of the data in each column, thereby analyzing the degree of deviation between the lengths of the data in each column and accurately obtaining the column balance length used to characterize the overall level of the length of each column, so that it can be used to determine the column display width later. The column display width for each column of data is determined based on the average column length, the length of the column name, the preset maximum column width, and the preset minimum column width. The preset maximum column width is greater than the preset minimum column width. This allows for accurate determination of the column display width for each column based on the varying relationships between the average column length, column name length, and the maximum and minimum column widths. It enables the reasonable calculation of the column display width based on the length of the data in each column, avoiding issues such as uneven data display due to fixed column widths and improving the overall display effect of multiple columns in a data table.
[0058] In an exemplary embodiment, determining the column balance length corresponding to each column of data based on the degree of deviation between the lengths of each data in each column of data includes: determining a length reference value based on the length of each data in each column of data; traversing each data in each column of data to determine the length difference between the length of each data in each column of data and the length reference value; and determining the column balance length corresponding to each column of data based on each length difference.
[0059] The length reference value can refer to information used to calculate the column balance length. In practical applications, the length reference value can include, but is not limited to, the average value, median, etc.
[0060] The length difference can refer to the difference between the length of each data point in each column and the length reference value.
[0061] As an example, for each table data, in order to analyze the overall level of the length of the data in the table data, the terminal can first obtain the length of each data in each table data, and then determine the median / average value and the like information based on the length of each data in each table data as the length reference value corresponding to each table data. Then, for each table data, the terminal can traverse each data in each table data, respectively calculate the length difference between the length of each data in each table data and the length reference value corresponding to the table data, and then the terminal can calculate the least absolute deviations (LAD) as the column equalization length corresponding to each table data according to the length difference corresponding to each table data. The least absolute deviations is an optimization method for estimating a parameter or a group of parameters, so that the sum of the absolute errors between the parameters and the observed values is minimized. Unlike the least squares (LS), the least absolute deviations does not find the parameters that minimize the sum of the squared errors, but finds the parameters that minimize the sum of the absolute errors. In practical applications, one of the calculation methods of the column equalization length can be to sum the length differences corresponding to each table data, and the sum result can be used as the column equalization length corresponding to the table data.
[0062] In the embodiment, by determining the length reference value according to the length of each data in each table data, traversing each data in each table data to determine the length difference between the length of each data in each table data and the length reference value, and determining the column equalization length corresponding to each table data according to the length difference, the column equalization length can be accurately calculated based on the length difference between the length of each data in each table data and the length reference value, and the accuracy of the column equalization length is improved, so as to determine the accurate column display width based on the column equalization length subsequently.
[0063] In some embodiments, before the step of determining the column equalization length corresponding to each table data, the above method further comprises: traversing each table data, and filtering out the to-be-converted data from each table data according to the data type of each data in each table data; and performing mapping processing on the length of the to-be-converted data according to the length conversion mode corresponding to the to-be-converted data.
[0064] The data type can include but is not limited to numerical type, character type, etc.
[0065] The to-be-converted data can refer to data that needs to be converted in length. In actual application, the data types of the data in a table data can be completely the same, that is, the table data corresponds to only one data type. The data types of the data in a table data can also be different, that is, the table data can correspond to at least two data types. When the table data corresponds to at least two data types A and B, if the number of data of the data type A in the table data is greater than the number of data of the data type B in the table data, the main data type of the table data can be the data type A. At this time, the data of the data type B in the table data can be the to-be-converted data. It can be understood that the to-be-converted data can also include a preset special character. When the terminal finds the preset special character in each table data, the terminal can map the length of the preset special character according to the length conversion mode corresponding to the preset special character.
[0066] The length conversion mode can refer to information representing a mapping rule / conversion rule for the to-be-converted data, which is set in advance. In actual application, the length conversion mode can include a length conversion reference value / length mapping reference value set in advance.
[0067] As an example, because the data types of the data in a table data can be different, the lengths of the data of different data types can have a large difference. Therefore, in order to avoid the lengths of the data of different data types affecting the determination of the column balanced length / display width, the terminal needs to preprocess the data of a specific data type (such as to-be-converted data) in each table data. In actual application, the terminal can traverse each table data, determine the main data type corresponding to each table data according to the data types of the data in each table data, and then the terminal can take the data of each table data whose data type is different from the main data type of the table data as to-be-converted data. Each data type can be set with a corresponding length conversion mode. At this time, the terminal can determine the length conversion mode corresponding to the to-be-converted data according to the data type of the to-be-converted data, map the length of the to-be-converted data according to the length conversion mode corresponding to the to-be-converted data, and obtain the processed length of the to-be-converted data. The processed length can be the new length of the to-be-converted data.
[0068] In the embodiment, the to-be-converted data is filtered from each table data according to the data type of each data in each table data by traversing each table data; and the length of the to-be-converted data is mapped according to the length conversion mode corresponding to the to-be-converted data, so that the data needing length conversion can be accurately analyzed and length conversion can be performed based on the data type of each data in each table data, the influence of the length of data of different data types on the column balanced length / column display width is avoided, and the accuracy of the column balanced length / column display width is improved.
[0069] In some embodiments, the column display width corresponding to each table data is determined according to the column balanced length corresponding to each table data, the length of the column name corresponding to each table data, the preset maximum column width and the preset minimum column width, including: for each table data, in a case that the column balanced length corresponding to each table data is less than the length of the column name corresponding to each table data, and the length of the column name corresponding to each table data is less than the preset minimum column width, the preset minimum column width is taken as the column display width corresponding to each table data.
[0070] As an example, the terminal can determine the column display width by analyzing the size relationship among the column balanced length corresponding to each table data, the length of the column name corresponding to each table data, the preset maximum column width and the preset minimum column width. In actual application, if the main data type of the data in a table data is a numerical type, the column balanced length corresponding to the table data is less than the length of the column name corresponding to the table data, and the length of the column name corresponding to the table data is less than the preset minimum column width, therefore, the terminal can take the preset minimum column width as the column display width corresponding to the table data.
[0071] In the embodiment, the preset minimum column width is taken as the column display width corresponding to each table data in a case that the column balanced length corresponding to each table data is less than the length of the column name corresponding to each table data, and the length of the column name corresponding to each table data is less than the preset minimum column width, so that whether the preset minimum column width is taken as the column display width can be accurately analyzed based on the size relationship among the column balanced length, the length of the column name, the preset maximum column width and the preset minimum column width, and the accuracy of the column display width is improved.
[0072] In some embodiments, the column display width corresponding to each table data is determined according to the column balance length corresponding to each table data, the length of the column name corresponding to each table data, the preset maximum column width, and the preset minimum column width, including: for each table data, in a case that the column balance length corresponding to each table data is less than the length of the column name corresponding to each table data, and the column balance length corresponding to each table data is greater than or equal to the preset minimum column width, the length of the column name corresponding to each table data is taken as the column display width corresponding to each table data.
[0073] As an example, the terminal can determine the column display width by analyzing the size relationship among the column balance length corresponding to each table data, the length of the column name corresponding to each table data, the preset maximum column width, and the preset minimum column width. In actual application, if the main data type of the data in a table data is character type, and the character length in the table data is generally short, the column balance length corresponding to the table data is less than the length of the column name corresponding to the table data, and the column balance length corresponding to the table data is greater than or equal to the preset minimum column width. Therefore, the terminal can take the length of the column name corresponding to the table data as the column display width corresponding to the table data.
[0074] In the embodiment, for each table data, in a case that the column balance length corresponding to each table data is less than the length of the column name corresponding to each table data, and the column balance length corresponding to each table data is greater than or equal to the preset minimum column width, the length of the column name corresponding to each table data is taken as the column display width corresponding to each table data. Therefore, the size relationship among the column balance length, the length of the column name, the preset maximum column width, and the preset minimum column width can be accurately analyzed to determine whether the column name corresponding to the table data is taken as the column display width, and the accuracy of the column display width is improved.
[0075] In some embodiments, the column display width corresponding to each table data is determined according to the column balance length corresponding to each table data, the length of the column name corresponding to each table data, the preset maximum column width, and the preset minimum column width, including: for each table data, in a case that the column balance length corresponding to each table data is greater than or equal to the preset maximum column width, and the preset maximum column width is greater than or equal to the length of the column name corresponding to each table data, the preset maximum column width is taken as the column display width corresponding to each table data.
[0076] As an example, the terminal can determine the column display width by analyzing the size relationship between the column balance length corresponding to each table data, the length of the column name corresponding to each table data, the preset maximum column width, and the preset minimum column width. In actual application, if the main data type of the data in a table data is a character type, and the character length in the table data is generally long, the column balance length corresponding to the table data is greater than or equal to the preset maximum column width, and the preset maximum column width is greater than or equal to the length of the column name corresponding to the table data. At this time, in order to prevent the column display width from being too large, the terminal can take the preset maximum column width as the column display width corresponding to the table data.
[0077] In this embodiment, by taking the preset maximum column width as the column display width corresponding to each table data in the case that the column balance length corresponding to each table data is greater than or equal to the preset maximum column width, and the preset maximum column width is greater than or equal to the length of the column name corresponding to each table data, the size relationship between the column balance length, the length of the column name, the preset maximum column width, and the preset minimum column width can be accurately analyzed to determine whether the preset maximum column width is taken as the column display width, thereby improving the accuracy of the column display width.
[0078] In some embodiments, after the step of determining the column display width corresponding to each table data, the above method further comprises: summing up the column display width corresponding to each table data to obtain a table width; and adjusting the column display width corresponding to each table data according to the table width and the interface width of the table display interface.
[0079] The table width can be information representing the width of the data table composed of each table data.
[0080] The table display interface can be an interface for displaying each table data / the data table composed of each table data.
[0081] The interface width can be information representing the width of the table display interface.
[0082] As an example, in order to further accurately determine the column display width of the data table in the table display interface, the terminal can sum the column display widths corresponding to each table data, calculate the table width of the data table composed of each table data, and then adjust the column display width corresponding to each table data according to the table width and the interface width of the table display interface. The adjusted column display width can be used as the width of the cell where each table data is displayed through the table display interface. In actual application, when the difference between the table width and the interface width of the table display interface is greater than a preset difference threshold, the terminal can determine a width extension ratio according to the table width and the interface width of the table display interface, and uniformly adjust the column display width corresponding to each table data according to the width extension ratio.
[0083] In the embodiment, the column display width corresponding to each table data is summed to obtain the table width, and the column display width corresponding to each table data is adjusted according to the table width and the interface width of the table display interface, which can calculate the table width based on the column display width, and adjust the column display width in combination with the table width and the interface width of the table display interface, to improve the display effect when the table data is displayed in the table display interface according to the adjusted column display width.
[0084] In some embodiments, in order to solve the problem of unbalanced display of multiple columns of data, as shown in Figure 3 As shown in the architectural schematic diagram of the database field dynamic display of multiple column data table scheme, the database field dynamic display of multiple column data table scheme can implement the column display width generation method of the data table described above. In actual application, the database field dynamic display of multiple column data table scheme can include a data acquisition module, a data processing module, a WEB calculation module, and a WEB display module. The database field dynamic display of multiple column data table scheme calculates the content display length of each cell by traversing each column of data, and then calculates the observation value of each column of data by the least absolute deviation, that is, the balanced content length of the column. It is worth noting that special characters (such as numbers, punctuation marks, etc.) are quite different from ordinary English characters when rendering, and therefore require special processing. The data processing module returns the balanced length of each column and the column name length to the web interface, and the web interface dynamically calculates the display length of each column by a specific algorithm, renders and displays the content, and folds a small amount of content that cannot be completely displayed. Users can view this part of the content by a small amount of clicking operation.
[0085] The data acquisition module can be used to acquire raw data from a preset database and divide the data into columns. The source of the raw data and the format, type, etc. of the data have no special requirements. The data acquisition module can transmit the acquired data to the data processing module.
[0086] The data processing module can be used to process the original data to obtain some statistical data, which can be transmitted to the WEB computing module as an influencing factor of the column width (column display width) calculation method. Specifically, the data processing module will traverse the data of each column, and obtain the balanced value that can best represent the length of most cell contents in the column as the column balanced length by the minimum absolute value deviation of the cell contents in the same column. At the same time, the data processing module will map the special characters in the cell contents during traversal. Then the data processing module can return the column name width (such as the length of the column name), the column balanced length, and the original multi-column data (such as table data of each column) to the WEB computing module. It is worth noting that there are a large number of numerical type fields in the database field, so it is necessary to map the special characters. When there are many original records, they are usually displayed in pages, so traversing and processing only the cells of the current page each time does not cause too much computational burden, and the delay caused by this operation is almost imperceptible.
[0087] The WEB computing module can calculate the column display width (column display width) based on the length of the column name, the column balanced length, and the screen width (such as the table display interface). In order to avoid the display effect of a column being too narrow due to the length of the content of the column being generally small, the WEB computing module can set a minimum value of the column display width (such as a preset minimum column width). In order to avoid a column occupying most of the screen due to the length of the content of the column being generally large, the WEB computing module can also set a maximum value of the column display width (such as a preset maximum column width). In actual application, in most scenarios, column name information is very important, so the column name can be displayed completely. In specific implementation, the column width minimum value and the column width maximum value can be obtained by verifying a large number of scenarios to obtain appropriate empirical values.
[0088] The WEB display module can be used to render and display the content of the table display interface. Since different operating systems have slight differences in rendering, the WEB display module can add appropriate redundancy values to the calculation results of the WEB computing module to adapt to different systems. For a small number of cell contents that cannot be displayed completely, the WEB display module can provide a button to view the full content. When the user clicks, a pop-up window will pop up to display the content completely, without affecting the original interface effect. In specific implementation, the redundancy values during rendering can be obtained by verifying a large number of scenarios to obtain appropriate empirical values.
[0089] The WEB display module can be used to render and display the content of the table display interface. Since different operating systems have slight differences in rendering, the WEB display module can add appropriate redundancy values to the calculation results of the WEB computing module to adapt to different systems. For a small number of cell contents that cannot be displayed completely, the WEB display module can provide a button to view the full content. When the user clicks, a pop-up window will pop up to display the content completely, without affecting the original interface effect. In specific implementation, the redundancy values during rendering can be obtained by verifying a large number of scenarios to obtain appropriate empirical values. Figure 4As shown, a flowchart for determining column display width is provided, a preset minimum column width can be represented as minSize, a preset maximum column width can be represented as maxSize, an interface width of a table display interface can be represented as scrSize, a column balance length can be represented as conSize, a length of a column name can be represented as titleSize, and a column display width can be represented as disSize. First, a data acquisition module reads column data from a database table, and a data processing module traverses the column data. On the basis of the original data, the length of the column name titleSize and the column balance length conSize are added and returned to a WEB calculation module as input. In a scenario in which the column in which the table data is located is of a numerical type, the following logical relationship exists: conSize < titleSize < minSize < maxSize. At this time, in order to prevent a column from being too narrow, the WEB calculation module can set the column display width disSize to minSize. In a scenario in which the column in which the table data is located is of a character type and the character length is generally short, the following logical relationship exists: minSize < conSize < titleSize < maxSize. At this time, in order to completely display the column name, the WEB calculation module can set the column display width disSize to titleSize. In a scenario in which the column in which the table data is located is of a character type and the character length is generally long, the following logical relationship exists: minSize < titleSize < maxSize < conSize. At this time, in order to prevent a column from occupying too much screen space, the WEB calculation module can set the column display width disSize to maxSize. A WEB display module compares the sum of the lengths of all columns with the screen width to determine whether to uniformly lengthen the column display width, and finally calculates a fixed width of each column to render the interface. In actual application, the column display width determined in the above manner can remain unchanged even when the screen resolution is changed.
[0090] In this embodiment, by preprocessing and calculating the original data, and based on the minimum absolute deviation, the balanced value of each column is obtained, the cell that can fully display the content is maximized, and the human-computer interaction is reduced; the most comfortable display interface is calculated by comprehensively considering the content length of each cell, the column name length, the display extreme value, the rendering difference of different systems and other influencing factors. Since the table content is usually paginated, the single-page content is not very large, and such operation will not bring noticeable negative effects to the whole system; since there is a great difference between the interface space occupied by special characters such as numbers and symbols and the interface space occupied by ordinary English characters during mapping, the special characters are processed by conversion, so that the content length calculated by each cell is more comparable, and the overall display effect of the interface is more balanced; the display width of each column is dynamically fixed and will not be deformed due to the change of screen resolution, the column display width of each column is calculated according to the display content during each rendering, and the column display width will not change with the change of resolution after being fixed. The present application not only solves the problem of unbalanced display of multi-column data, but also does not introduce complex human-computer interaction, so that the user can intuitively browse most of the data to the greatest extent.
[0091] It should be understood that, although each step in the flowchart involved in each embodiment as described above is shown in sequence according to the arrow, these steps are not necessarily executed in sequence according to the arrow. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other sequences. Moreover, at least part of the steps in the flowchart involved in each embodiment as described above can include multiple steps or stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence of these steps or stages is not necessarily sequential, but can be executed in rotation or alternation with at least part of other steps or steps or stages in other steps.
[0092] Based on the same inventive concept, the embodiment of the present application also provides a column display width generation device of a data table for implementing the column display width generation method of the data table involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so the specific limitations in one or more column display width generation device embodiments of the data table provided below can refer to the limitations of the column display width generation method of the data table in the above text, which will not be described here again.
[0093] In one exemplary embodiment, as shown in Figure 5 a column display width generation device of a data table is provided, comprising: an acquisition module 502, a calculation module 504 and a determination module 506, wherein:
[0094] The acquisition module 502 is configured to acquire original data from a preset database, and perform column separation on the original data to obtain at least one table data.
[0095] The calculation module 504 is configured to traverse each table data, and determine a column balance length corresponding to each table data according to a deviation degree between lengths of data in each table data.
[0096] The determination module 506 is configured to determine a column display width corresponding to each table data according to the column balance length corresponding to each table data, a length of a column name corresponding to each table data, a preset maximum column width, and a preset minimum column width.
[0097] In one example embodiment, the calculation module 504 is specifically configured to determine a length reference value according to lengths of data in each table data, determine a length difference between the length of each data in each table data and the length reference value by traversing each data in each table data, and determine the column balance length corresponding to each table data according to each length difference.
[0098] In one example embodiment, the apparatus further includes a processing module, which is specifically configured to traverse each table data, filter out to-be-converted data from each table data according to a data type of each data in each table data, and perform mapping processing on lengths of the to-be-converted data according to a length conversion mode corresponding to the to-be-converted data.
[0099] In one example embodiment, the determination module 506 is specifically configured to, for each table data, take the preset minimum column width as the column display width corresponding to each table data in a case where the column balance length corresponding to each table data is less than the length of the column name corresponding to each table data, and the length of the column name corresponding to each table data is less than the preset minimum column width.
[0100] In one example embodiment, the determination module 506 is specifically configured to, for each table data, take the length of the column name corresponding to each table data as the column display width corresponding to each table data in a case where the column balance length corresponding to each table data is less than the length of the column name corresponding to each table data, and the column balance length corresponding to each table data is greater than or equal to the preset minimum column width.
[0101] In one of the example embodiments, the determining module 506 is specifically further configured to, for each table data, if the column balance length corresponding to the table data is greater than or equal to the preset maximum column width, and the preset maximum column width is greater than or equal to the length of the column name corresponding to the table data, take the preset maximum column width as the column display width corresponding to the table data.
[0102] In one of the example embodiments, the apparatus further comprises an adjusting module specifically configured to sum the column display widths corresponding to each table data to obtain a table width, and adjust the column display widths corresponding to each table data according to the table width and the interface width of a table display interface.
[0103] The modules in the column display width generation apparatus of the data table can be realized by software, hardware, or a combination thereof, in whole or in part. The modules can be embedded in or independent of a processor in a computer device in hardware form, or stored in a memory in a computer device in software form, so as to be called and executed by a processor to perform the operations corresponding to the modules.
[0104] In one of the example embodiments, a computer device is provided, which can be a terminal, and the internal structure diagram thereof can be as shown in FIG. 1. The computer device comprises a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, the memory, and the input / output interface are connected through a system bus, and the communication interface, the display unit, and the input device are connected to the system bus through the input / output interface. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The input / output interface of the computer device is configured to exchange information between the processor and external devices. The communication interface of the computer device is configured to perform wired or wireless communication with external terminals. The wireless communication can be achieved through WIFI, mobile cellular network, near field communication (NFC), or other technologies. The computer program is executed by the processor to implement a column display width generation method of a data table. The display unit of the computer device is configured to form a visually visible picture, which can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer overlaid on the display screen, or a key, trackball, or touchpad arranged on the shell of the computer device, or an external keyboard, touchpad, or mouse, etc. Figure 6
[0105] Those skilled in the art can understand that, Figure 6 Those skilled in the art can understand that, The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0106] In one embodiment, a computer device is also provided, including a memory and a processor, the memory storing a computer program, and the processor implementing the steps in the above method embodiments when executing the computer program.
[0107] In one embodiment, a computer readable storage medium is provided, storing a computer program, and the computer program implements the steps in the above method embodiments when executed by a processor.
[0108] In one embodiment, a computer program product is provided, including a computer program, and the computer program implements the steps in the above method embodiments when executed by a processor.
[0109] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant regulations.
[0110] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when executed, can include the processes of the above-mentioned embodiment methods. Any reference to memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. The non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. The volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration but not limitation, the RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., without being limited thereto.
[0111] The technical features of the above embodiments can be combined in any manner. To make the description concise, all possible combinations of the technical features in the above embodiments are not described, but as long as the combinations of the technical features do not exist, they should be considered as the scope of the present application.
[0112] The above-described embodiments are merely illustrative of several embodiments of the present application, and the description is relatively specific and detailed, but should not be understood as a limitation on the scope of the patent. It should be noted that for those skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the scope of the present application. Therefore, the scope of protection of the present application should be subject to the appended claims.
Claims
1. A method of generating a column display width of a data table, characterized by, The method comprises: obtaining original data from a preset database, and performing column separation on the original data to obtain at least one table data; traversing each table data, and determining a column balance length corresponding to each table data according to a deviation degree between lengths of data in each table data, comprising: determining a length reference value according to lengths of data in each table data; traversing data in each table data to determine length difference values between lengths of data in each table data and the length reference value; and calculating a minimum absolute value deviation as the column balance length corresponding to each table data according to the length difference values; the column balance length is used to represent an overall level of lengths of data in each table data; determining a column display width corresponding to each table data according to the column balance length corresponding to each table data, a length of a column name corresponding to each table data, a preset maximum column width, and a preset minimum column width; the preset maximum column width is greater than the preset minimum column width.
2. The method of claim 1, wherein, Before the step of determining the column balance length corresponding to each table data, the method further comprises: traversing each table data, and screening out to-be-converted data from each table data according to data types of data in each table data; performing mapping processing on lengths of the to-be-converted data according to a length conversion mode corresponding to the to-be-converted data.
3. The method of claim 1, wherein, The determination of the column display width corresponding to each table data according to the column balance length corresponding to each table data, the length of the column name corresponding to each table data, the preset maximum column width, and the preset minimum column width comprises: for each table data, in a case where the column balance length corresponding to each table data is less than the length of the column name corresponding to each table data, and the length of the column name corresponding to each table data is less than the preset minimum column width, the preset minimum column width is taken as the column display width corresponding to each table data.
4. The method of claim 1, wherein, The determination of the column display width corresponding to each table data according to the column balance length corresponding to each table data, the length of the column name corresponding to each table data, the preset maximum column width, and the preset minimum column width comprises: for each table data, in a case where the column balance length corresponding to each table data is less than the length of the column name corresponding to each table data, and the column balance length corresponding to each table data is greater than or equal to the preset minimum column width, the length of the column name corresponding to each table data is taken as the column display width corresponding to each table data.
5. The method of claim 1, wherein, The determination of the column display width corresponding to each table data according to the column balance length corresponding to each table data, the length of the column name corresponding to each table data, the preset maximum column width, and the preset minimum column width comprises: In a case that the column display width corresponding to each table data is greater than or equal to the length of the column name corresponding to each table data, and the preset maximum column width is greater than or equal to the length of the column name corresponding to each table data, the preset maximum column width is taken as the column display width corresponding to each table data.
6. The method of claim 1, wherein, After the step of determining the column display width corresponding to each table data, the method further comprises: summing the column display width corresponding to each table data to obtain a table width; adjusting the column display width corresponding to each table data according to the table width and an interface width of a table display interface.
7. A column display width generating apparatus of a data table, characterized by comprising: The device comprises: an acquisition module configured to acquire original data from a preset database, and split the original data to obtain at least one table data; a calculation module configured to traverse each table data, and determine a column equalization length corresponding to each table data according to a deviation degree between lengths of data in each table data, including: determining a length reference value according to the lengths of data in each table data; traversing the data in each table data to determine length difference values between the lengths of data in each table data and the length reference value; and calculating a minimum absolute value deviation as the column equalization length corresponding to each table data according to the length difference values; the column equalization length is used to represent the overall level of the lengths of data in each table data; a determination module configured to determine a column display width corresponding to each table data according to the column equalization length corresponding to each table data, the length of the column name corresponding to each table data, a preset maximum column width, and a preset minimum column width; the preset maximum column width is greater than the preset minimum column width.
8. The apparatus of claim 7, wherein, The device further comprises a processing module, which is specifically configured to traverse each table data, filter out to-be-converted data from each table data according to data types of data in each table data, and perform mapping processing on the lengths of the to-be-converted data according to length conversion modes corresponding to the to-be-converted data. 9.A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer device is configured to perform the method according to any one of claims 1-8 when the computer program is executed by the processor. The processor executes the computer program to implement the steps of the method in any one of claims 1 to 6.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 6.
Citation Information
Patent Citations
Technology for analyzing frameless table in document image
CN110413962A
Table display method and device based on dynamic fields, computer equipment and medium
CN113268949A