Chart generation method and device, electronic equipment and readable storage medium
By creating template files and configuring attribute data to establish mapping relationships, the problem of long chart development cycles is solved, and efficient chart generation is achieved.
Patent Information
- Application Number
- CN202110576796.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-26
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2041-05-26
AI Technical Summary
In existing technologies, chart development requires professional developers to develop both the front-end display and back-end data display logic, resulting in long development cycles, low efficiency, and difficulty in generating charts.
Create a template file and configure attribute data, establish a mapping relationship between template identifier data, element identifier data and attribute data, find the target attribute data according to the mapping relationship and connect to the data source, and generate a chart file using data query statements.
It reduces the difficulty of chart development, improves chart generation efficiency, and reduces reliance on professional developers.
Smart Images

Figure CN115409008B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the development field, and in particular to a chart generation method and device, electronic equipment and readable storage medium. BACKGROUND
[0002] In daily work, it is often necessary to display background data into a report form that is easy to understand. In the past report development, each time a report is developed, the developer needs to develop the front-end display (view layer) and the back-end data display logic (controller layer) once, resulting in a long development cycle, low efficiency, and the need for professional developers, making it difficult to generate reports. Therefore, a chart generation method is needed to reduce the difficulty of chart development and improve chart generation efficiency. SUMMARY
[0003] In view of the above, it is necessary to provide a chart generation method aimed at reducing the difficulty of chart development and improving the efficiency of chart generation.
[0004] The chart generation method provided by the present application comprises:
[0005] Creating and saving a template file, wherein the template file comprises template identification data and element data of at least two pre-set page elements, and the element data comprises element identification data;
[0006] Configuring attribute data for each page element in the template file, establishing a mapping relationship between the attribute data of each page element, the template identification data and the element identification data, and saving the attribute data and the mapping relationship to a preset database, wherein the attribute data comprises data source connection information and data query statements;
[0007] In response to a chart generation instruction sent by a client and carrying target template identification data, a target template file is obtained based on the target template identification data, and target attribute data corresponding to each page element in the target template file is searched in the preset database according to the mapping relationship;
[0008] According to the data source connection information in the target attribute data, the target data source corresponding to each page element in the target template file is connected, and the target attribute data in the data query statement is used to query the target data source to obtain the to-be-displayed data corresponding to each page element in the target template file;
[0009] According to the to-be-displayed data, the target attribute data and the target template file, a chart file is generated.
[0010] Optionally, the creating and saving of the template file comprises:
[0011] In response to a template creation instruction of a user, obtain template page data corresponding to the template creation instruction;
[0012] In response to an adding instruction of a page element, obtain element data corresponding to the page element to be added;
[0013] Based on the template page data, the element data corresponding to each page element to be added, and pre-determined template identification data, generate and save a template file corresponding to the template creation instruction.
[0014] Optionally, the element data includes layout style data, and the layout style data includes element shape data, element size data, and element position data.
[0015] Construct a polygonal virtual frame composed of a plurality of control curves on a page of the template file, and each of the control curves is provided with a plurality of control points for a user to perform a moving operation on each of the control points.
[0016] Based on the moving operation of the user on each of the control points, update each of the control curves, and based on the updated control curves, generate a new polygonal virtual frame.
[0017] Obtain shape data of the new polygonal virtual frame as element shape data, obtain size data of the new polygonal virtual frame as element size data, and obtain position data of the new polygonal virtual frame on the page of the template file as element position data.
[0018] Optionally, the generating a chart file according to the to-be-displayed data, the target attribute data, and the target template file includes:
[0019] Generating a sub-chart in each page element of the target template file according to the to-be-displayed data and the target attribute data corresponding to each page element of the target template file.
[0020] Generating a chart file according to the sub-chart and the target template file.
[0021] Optionally, after the generating a sub-chart in each page element of the target template file, the method further includes:
[0022] When each sub-chart is generated, determining whether the sub-chart needs to be adjusted, and when the sub-chart needs to be adjusted, adjusting the sub-chart based on a preset coordinate axis.
[0023] Optionally, when each sub-chart is generated, determining whether the sub-chart needs to be adjusted, and when the sub-chart needs to be adjusted, adjusting the sub-chart based on a preset coordinate axis includes:
[0024] When each sub-chart is generated, coordinates of the sub-chart are divided into multiple coordinate groups according to a reference coordinate axis of the coordinates in the sub-chart;
[0025] The coordinate groups are selected one by one, and when each coordinate group is selected, display lengths of each coordinate in the selected coordinate group on a preset coordinate axis are obtained;
[0026] It is judged whether a ratio of the display length to a total length of the preset coordinate axis is less than a preset ratio;
[0027] When the ratio of the display length to the total length of the preset coordinate axis is less than the preset ratio, a maximum value and / or a minimum value of the preset coordinate axis are adjusted, and the sub-chart is updated based on the adjusted maximum value and / or minimum value.
[0028] Optionally, after the attribute data and the mapping relationship are saved to the preset database, the method further includes:
[0029] An attribute update instruction of a user for a specified page element is parsed, element identification data of the specified page element and new attribute values corresponding to each to-be-updated attribute item carried by the attribute update instruction are obtained;
[0030] According to the element identification data of the specified page element, corresponding attribute data in the preset database is searched;
[0031] Each to-be-updated attribute item is filtered in the searched attribute data, and attribute values corresponding to each to-be-updated attribute item are modified to new attribute values.
[0032] To solve the above problems, the application further provides a chart generation device, which comprises:
[0033] A creation module is configured to create and save a template file, wherein the template file comprises template identification data and element data of at least two pre-set page elements, and the element data comprises element identification data;
[0034] A configuration module is configured to configure attribute data for each page element in the template file, establish a mapping relationship among the attribute data of each page element, the template identification data and the element identification data, and save the attribute data and the mapping relationship to a preset database, wherein the attribute data comprises data source connection information and a data query statement;
[0035] The searching module is configured to, in response to a chart generation instruction carrying target template identification data sent by a client, acquire a target template file based on the target template identification data, and search for target attribute data corresponding to each page element in the target template file in the preset database according to the mapping relationship.
[0036] The connecting module is configured to, according to data source connection information in the target attribute data, connect target data sources corresponding to each page element in the target template file, and query the target data sources in the target data sources by using a data query statement in the target attribute data to obtain to-be-displayed data corresponding to each page element in the target template file.
[0037] The generating module is configured to generate a chart file according to the to-be-displayed data, the target attribute data and the target template file.
[0038] To solve the above problems, the present application further provides an electronic device, which comprises:
[0039] at least one processor; and
[0040] a memory connected with the at least one processor in communication; wherein
[0041] the memory stores a chart generation program executable by the at least one processor, and the chart generation program is executed by the at least one processor to enable the at least one processor to execute the above chart generation method.
[0042] To solve the above problems, the present application further provides a computer readable storage medium, which stores a chart generation program, and the chart generation program is executable by one or more processors to implement the above chart generation method.
[0043] Compared with the prior art, the present application firstly creates a template file, configures attribute data for each page element in the template file, and establishes a mapping relationship among the attribute data, template identification data and element identification data; then, according to the mapping relationship, target attribute data of each page element in the target template file is found, according to data source connection information in the target attribute data, a target data source corresponding to each page element in the target template file is connected, using a data query statement in the target attribute data, target display data corresponding to each page element in the target template file is queried in the target data source; finally, according to the target display data, the target attribute data and the target template file, a chart file is generated. The present application reduces the difficulty of chart development and improves the chart generation efficiency. BRIEF DESCRIPTION OF DRAWINGS
[0044] Figure 1 A flowchart of a chart generation method provided by an embodiment of the present application is shown in the figure.
[0045] Figure 2 A module diagram of a chart generation device provided by an embodiment of the present application is shown in the figure.
[0046] Figure 3 A structure diagram of an electronic device for implementing a chart generation method provided by an embodiment of the present application is shown in the figure.
[0047] The implementation, functional features and advantages of the present application will be further described with reference to the accompanying drawings in conjunction with the embodiments. DETAILED DESCRIPTION
[0048] In order to make the purpose, technical solutions and advantages of the present application more clear, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, and are not used to limit the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.
[0049] It should be noted that the descriptions involving "first", "second", etc. in the present application are only for the purpose of description, and cannot be understood as indicating or implying the relative importance of the indicated technical features or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first", "second" can explicitly or implicitly include at least one of the features. In addition, the technical solutions of various embodiments can be combined with each other, but it must be based on the realization of ordinary skilled in the art, when the combination of technical solutions appears contradictory or cannot be realized, it should be considered that the combination of technical solutions does not exist, nor within the protection scope required by the present application.
[0050] The present application provides a chart generation method. Referring to Figure 1 The present application provides a chart generation method. Referring to
[0051] In this embodiment, the chart generation method comprises:
[0052] S1, creating and saving a template file, wherein the template file comprises template identification data and element data of at least two pre-set page elements, and the element data comprises element identification data.
[0053] In this embodiment, the creating and saving of the template file comprises:
[0054] A11, in response to a template creation instruction of a user, acquiring template page data corresponding to the template creation instruction;
[0055] Specifically, a certain template creation instruction sent by a user is received and responded to, a man-machine interaction interface is provided for the user to input template page data, and the template page data comprises page size data. In some application scenarios, the template page data further comprises page background image data, etc.
[0056] Based on the page size data and / or page background image data, a template page is displayed.
[0057] A12, in response to an adding instruction of a page element, acquiring element data corresponding to a page element to be added;
[0058] The element data comprises layout style data and element identification data. The layout style data comprises element shape data, element size data and element position data. In some application scenarios, the layout style information further comprises element inner margin data, border data, element alignment mode data, etc.
[0059] In the embodiment, the element identification data includes a placeholder, and the manner of obtaining the element identification data includes: in response to an element identification data generation instruction, generating a string for the page element, and taking the generated string as the element identification data. The string has uniqueness. In some application scenarios, the placeholder can also be configured with corresponding feature data to prompt the selection of a subsequent chart type. For example, if a column chart needs to be displayed in the page element, the feature data of the placeholder of the page element can be configured as a column chart.
[0060] In the embodiment, the manner of obtaining the element shape data, the element size data and the element position data can be various, for example:
[0061] Manner one: the user can directly input the element shape data, the element size data and the element position data corresponding to the page element to be added in an input box of the man-machine interaction interface, or can select the element shape data, the element size data and the element position data corresponding to the page element to be added in a pre-set selection box. After the user completes the input or selection, the element shape data, the element size data and the element position data corresponding to the page element to be added input or selected by the user are obtained.
[0062] Manner two: the user can frame a region on a template page through the man-machine interaction interface, and the shape data and the size data of the framed region are obtained as the element shape data and the element size data respectively, and the position data of the framed region on the template page is obtained as the element position data.
[0063] Manner three: a polygonal virtual frame composed of a plurality of control curves (for example, a quadratic curve, a cubic curve, a Bezier curve, etc.) is constructed on the template page, a plurality of control points are arranged on each of the control curves for the user to perform a moving operation on each of the control points, the control curves are updated based on the moving operation of each of the control points, a new polygonal virtual frame is generated based on the updated control curves, the shape data of the new polygonal virtual frame is obtained as the element shape data, the size data of the new polygonal virtual frame is obtained as the element size data, and the position data of the new polygonal virtual frame on the template page is obtained as the element position data.
[0064] A13、based on the template page data, the element data corresponding to each page element to be added and the pre-determined template identification data, a template file corresponding to the template creation instruction is generated and saved.
[0065] Through the above manner, a template file can be created. By repeating the above steps, a plurality of template files can be created.
[0066] S2, configure attribute data for each page element in the template file, establish a mapping relationship among the attribute data of each page element, template identification data and element identification data, and save the attribute data and the mapping relationship to a preset database, the attribute data including data source connection information and data query statements.
[0067] In this embodiment, the step S2 includes:
[0068] B11, receiving attribute data of a specified page element in a specified template file input by a user in an input box of the man-machine interaction interface, and / or receiving attribute data of the specified page element in the specified template file selected by the user in a selection box of the man-machine interaction interface;
[0069] The attribute data includes a plurality of attribute items and attribute values corresponding to each attribute item.
[0070] The attribute item is used to represent the name or code of the attribute, for example, the attribute item includes a sub-chart type, a sub-chart identification, a sub-chart belonging to a template (for example, template identification information), a data source, data display logic, a sub-chart display position, a sub-chart size, etc.
[0071] The attribute value is a specific assignment value corresponding to the attribute item.
[0072] The attribute value corresponding to the attribute item "sub-chart type" includes one of a one-dimensional column chart, a one-dimensional line chart, a multi-dimensional column chart, a multi-dimensional line chart, a multi-dimensional column-line mixed chart, a superimposed column chart, a radar chart, and a data table.
[0073] The attribute value corresponding to the attribute item "data source" can be connection information of a certain data source, for example, primary key information of a certain database, the primary key information including database type, database name, database driver class, data source address, primary key name (database unique identification), username, and password (encrypted protection).
[0074] The attribute value corresponding to the attribute item "data display logic" includes a data query statement (for example, a custom SQL statement), the data query statement including data query logic and display mode.
[0075] The data query logic can be generated according to a query condition (for example, a time condition, a keyword condition, etc.) set by the user in advance, the data query logic being used to define how to extract or count data from the data source to obtain to-be-displayed data, the to-be-displayed data including to-be-displayed data items and numerical values of each to-be-displayed data item.
[0076] The display method includes: the coordinate system information corresponding to each data item to be displayed, such as the coordinate axis referenced by each data item to be displayed, and the minimum and maximum values of each coordinate axis.
[0077] For example, the data query statement is: SELECT DATE_FORMAT(s.createtime,'%Y-%m') AS x_labels,ROUND(SUM(s.fix_problem) / SUM(s.all_problem)*100,2) AS bar_l_Fortify_90_105,(select ROUND(value*100,2)from sqr_monthly_baseline where name='focus')AS line_l_baseline_90_105_dashed FROM sqr_focus_statistics s WHERE s.is_pre='1' AND DATE_FORMAT(s.createtime,'%Y-%m')>(SELECT DATE_FORMAT((DATE_ADD('${endTime}',INTERVAL-5MONTH)),'%Y-%m')) AND DATE_FORMAT(s.createtime,'%Y-%m')<(SELECT DATE_FORMAT((DATE_ADD('${endTime}',INTERVAL+1MONTH)),'%Y-%m'))[AND s.qa_team_id='${qaId}'][AND s.subsys_id='${sysId}'];
[0078] In this context, the x-coordinate is defined as x_labels after the AS field in the Select field.
[0079] Except for those defined as x_labels, the other select fields are y-coordinates. In the y-coordinate definition, AS is separated by "_", and each field has its own meaning.
[0080] For example, select the second field: bar_l_Fortify repair rate_90_105, separated by "_".
[0081] The first field, "bar", can be defined as bar / line / dashedLine. If defined as bar, the data will be displayed as a bar shape. If defined as line, the data will be displayed as a solid line shape. If defined as dashedLine, the data will be displayed as a dashed line shape.
[0082] The second field: "l", can be defined as l / r, if defined as l, this data is based on the left coordinate. If defined as r, this data is based on the right coordinate.
[0083] The third field: "Fortify fix rate", defines the label of this data.
[0084] The fourth field: "90". Optional, if this field is defined, set the minimum value of this data corresponding to the corresponding coordinate.
[0085] The fifth field: "105". Optional, if this field is defined, set the maximum value of this data corresponding to the corresponding coordinate.
[0086] B12, establish the mapping relationship among the attribute data, template identification data and element identification data of the specified page element in the specified template file;
[0087] B13, save the attribute data and the mapping relationship to a preset database.
[0088] The type of the preset database includes a first type database and a second type database. For example, the first type database includes any one of MySQL, SQL Server, Oracle, etc., and the second type database includes a Redis database.
[0089] In some application scenarios, the attribute data can be stored in one or more first type databases, and a copy of the attribute data (or only the data source connection information) can be copied to the Redis database. When querying the attribute data, it can be directly queried from the Redis database, which can improve the data query efficiency.
[0090] S3, in response to a chart generation instruction sent by a client and carrying target template identification data, acquire a target template file based on the target template identification data, and find target attribute data corresponding to each page element in the target template file in the preset database according to the mapping relationship.
[0091] In this embodiment, the primary key information of the target attribute data can be acquired, and the associated information corresponding to the primary key information can be found in the Redis database according to the primary key information. The target attribute data corresponding to each page element can be found in the preset database according to the associated information and the primary key information.
[0092] S4, connecting a target data source corresponding to each page element in the target template file according to the data source connection information in the target attribute data, and querying the to-be-displayed data corresponding to each page element in the target template file in the target data source by using a data query statement in the target attribute data.
[0093] The data query statement includes data query logic and display mode, and the step S4 includes:
[0094] C11, connecting a server to which a target data source corresponding to each page element in the target template file belongs according to the data source connection information in the target attribute data.
[0095] The data source can be one or more of MySQL, SQL Server, and Oracle.
[0096] The data source connection information includes server information (for example, IP address) to which the data source belongs, and the electronic device establishes a network connection with the server to which the target data source corresponding to each page element in the target template file belongs according to the data source connection information, so as to facilitate subsequent data interaction (sending and receiving requests and data).
[0097] C12, sending the data query logic corresponding to each page element in the target template file to the server to which the corresponding target data source belongs through an asynchronous request.
[0098] The data query logic is generated according to the query conditions (for example, time condition, keyword condition) set by the user in advance, and is used to define how to extract or count data from the data source.
[0099] In this embodiment, the data query logic corresponding to each page element in the target template file is sent to the server to which the corresponding target data source belongs through an asynchronous request. Compared with a synchronous request, the asynchronous request does not need to wait for the completion of the request processing before performing other operations, so that the operation process is more smooth.
[0100] C13, receiving the query result returned by the server to which the target data source belongs, and obtaining the to-be-displayed data corresponding to each page element in the target template file.
[0101] After the server to which each target data source belongs receives the corresponding data query logic, data is extracted or counted from the corresponding target data source, and the to-be-displayed data corresponding to each page element in the target template file is obtained.
[0102] S5, generating a chart file according to the to-be-displayed data, the target attribute data, and the target template file.
[0103] The target page elements can be determined according to the target template file, the target presentation form of the target page elements can be determined through the target attribute data, and the to-be-displayed data corresponding to each target page element in the target template file is displayed in the target presentation form, so that the chart file is obtained.
[0104] The generating the chart file according to the to-be-displayed data, the target attribute data and the target template file includes:
[0105] D11. Generating a sub-chart in each page element of the target template file according to the to-be-displayed data corresponding to each page element of the target template file and the target attribute data.
[0106] The target attribute data defines the presentation form of each page element in the target template file, for example, the target attribute data defines the sub-chart type (a column chart, a line chart or a radar chart), the sub-chart display position and the sub-chart size.
[0107] The to-be-displayed data corresponding to each page element in the target template file is displayed in the presentation form represented by the target attribute data, so that the sub-chart is generated in each page element of the target template file.
[0108] D12. Generating the chart file according to the sub-chart and the target template file.
[0109] The sub-chart in each page element of the target template file is rendered and displayed, so that the chart file is obtained.
[0110] In the embodiment, after the sub-chart is generated in each page element of the target template file, the method further includes:
[0111] When each sub-chart is generated, it is determined whether the sub-chart needs to be adjusted, and when the sub-chart needs to be adjusted, the sub-chart is adjusted based on a preset coordinate axis.
[0112] When each sub-chart is generated, it is determined whether the sub-chart needs to be adjusted, and when the sub-chart needs to be adjusted, the sub-chart is adjusted based on a preset coordinate axis.
[0113] E11. When each sub-chart is generated, the coordinates of the sub-chart are divided into a plurality of coordinate groups according to the reference coordinate axis of the coordinates in the sub-chart.
[0114] The division rule of the coordinate groups includes: determining the reference coordinate axis of each coordinate, and dividing the coordinates with the same reference coordinate axis into a coordinate group. For example, in a double-y coordinate system including an x axis, a main y axis and a secondary y axis, all coordinates with the x axis and the main y axis as the reference coordinate axis are divided into a coordinate group, and all coordinates with the x axis and the secondary y axis as the reference coordinate axis are divided into another coordinate group.
[0115] E12, select the coordinate group one by one, and obtain the display length of each coordinate in the selected coordinate group on the preset coordinate axis after selecting one coordinate group;
[0116] E13, judge whether the ratio of the display length to the total length of the preset coordinate axis is less than a preset ratio;
[0117] For example, the preset ratio can be set according to the specific application scene, for example, the preset ratio is set to 3 / 4, 2 / 3, etc.
[0118] E14, when the ratio of the display length to the total length of the preset coordinate axis is less than the preset ratio, adjusting the maximum value and / or minimum value of the preset coordinate axis, and updating the sub chart based on the adjusted maximum value and / or minimum value.
[0119] The maximum value and / or minimum value of the preset coordinate axis can be adjusted according to a preset formula.
[0120] The preset formula can be:
[0121]
[0122] Wherein, h represents the preset ratio, a represents the display length, b represents the minimum value of the preset coordinate axis, and c represents the maximum value of the preset coordinate axis.
[0123] In the embodiment, after the attribute data and the mapping relationship are saved to the preset database, the method further comprises:
[0124] F11, analyzing the attribute update instruction of a user for a certain specified page element, obtaining the element identification data of the specified page element carried by the attribute update instruction, and the new attribute value corresponding to each to-be-updated attribute item;
[0125] In the embodiment, the attribute update instruction carries the element identification data of the to-be-updated page element (i.e. the specified page element), the to-be-updated attribute item name of the to-be-updated page element, and the new attribute value corresponding to the to-be-updated attribute item.
[0126] F12, according to the element identification data of the specified page element, searching for the corresponding attribute data in the preset database;
[0127] The preset database stores the mapping relationship among the attribute data of the page element, the template identification data and the element identification data, and the attribute data of each page element. Based on the mapping relationship and the element identification data of the specified page element, the attribute data of the specified page element can be found.
[0128] F13. Filter each attribute item to be updated in the found attribute data, and modify the attribute value corresponding to each attribute item to the new attribute value.
[0129] The retrieved attribute data is the attribute data of the specified page element. However, the attribute data includes multiple attribute items and their corresponding attribute values. It is necessary to filter out the attribute items to be updated from the attribute data and modify the attribute values of the attribute items to be updated to the new attribute values.
[0130] As described in the above embodiments, the chart generation method proposed in this invention firstly creates a template file, configures attribute data for each page element in the template file, and establishes a mapping relationship between the attribute data, template identifier data, and element identifier data. Then, based on the mapping relationship, it searches for the target attribute data of each page element in the target template file. Based on the data source connection information in the target attribute data, it connects to the target data source corresponding to each page element in the target template file. Using the data query statements in the target attribute data, it queries the target data source for the data to be displayed corresponding to each page element in the target template file. Finally, based on the data to be displayed, the target attribute data, and the target template file, it generates a chart file. This solution, by creating a template file and configuring attribute data for the page elements in the template file, achieves the determination of the data to be displayed for each page element in the target template file based on the target attribute data, thereby generating a chart file. This reduces the difficulty of chart development and improves the efficiency of chart generation. Therefore, this invention reduces the difficulty of chart development and improves the efficiency of chart generation.
[0131] like Figure 2 The diagram shown is a schematic diagram of a chart generation device provided in an embodiment of the present invention.
[0132] The chart generation device 100 of this invention can be installed in an electronic device. Depending on the functions implemented, the chart generation device 100 may include a creation module 110, a configuration module 120, a search module 130, a connection module 140, and a generation module 150. The module described in this invention can also be called a unit, which refers to a series of computer program segments that can be executed by the processor of an electronic device and can perform a fixed function, and which are stored in the memory of the electronic device.
[0133] In this embodiment, the functions of each module / unit are as follows:
[0134] The creation module 110 is used to create and save a template file, wherein the template file includes template identification data and element data of at least two pre-set page elements, and the element data includes element identification data.
[0135] In this embodiment, creating and saving the template file includes:
[0136] A21, in response to a template creation instruction of a user, obtaining template page data corresponding to the template creation instruction;
[0137] A22, in response to an adding instruction of a page element, obtaining element data corresponding to a page element to be added;
[0138] A23, based on the template page data, the element data corresponding to each page element to be added, and the pre-determined template identification data, generating and saving a template file corresponding to the template creation instruction.
[0139] The configuration module 120 is configured to configure attribute data for each page element in the template file, establish a mapping relationship between the attribute data of each page element, the template identification data, and the element identification data, and save the attribute data and the mapping relationship to a preset database. The attribute data includes data source connection information and data query statements.
[0140] In this embodiment, the configuration module 120 is specifically configured to:
[0141] B21, receiving attribute data of a specified page element in a specified template file input by a user in an input box of a human-computer interaction interface, and / or receiving attribute data of the specified page element in the specified template file selected by the user in a selection box of the human-computer interaction interface;
[0142] B22, establishing a mapping relationship between the attribute data of the specified page element in the specified template file, the template identification data, and the element identification data;
[0143] B23, saving the attribute data and the mapping relationship to a preset database.
[0144] The finding module 130 is configured to, in response to a chart generation instruction carrying target template identification data issued by a client, obtain a target template file based on the target template identification data, and find target attribute data corresponding to each page element in the target template file in the preset database according to the mapping relationship.
[0145] The connection module 140 is configured to connect target data sources corresponding to each page element in the target template file according to data source connection information in the target attribute data, and query to-be-displayed data corresponding to each page element in the target template file in the target data sources by using data query statements in the target attribute data.
[0146] The data query statement includes data query logic and display mode, and the connection module 140 is specifically configured to:
[0147] C21, connecting, according to data source connection information in the target attribute data, servers to which target data sources corresponding to each page element in the target template file belong;
[0148] C22, sending data query logic corresponding to each page element in the target template file to servers to which target data sources corresponding to the data query logic belong through an asynchronous request;
[0149] C23, receiving query results returned by the servers to which the target data sources belong, to obtain to-be-displayed data corresponding to each page element in the target template file.
[0150] The generation module 150 is configured to generate a chart file according to the to-be-displayed data, the target attribute data, and the target template file.
[0151] The generation of the chart file according to the to-be-displayed data, the target attribute data, and the target template file includes:
[0152] D21, generating sub-charts in each page element in the target template file according to to-be-displayed data and target attribute data corresponding to each page element in the target template file;
[0153] D22, generating a chart file according to the sub-charts and the target template file.
[0154] In this embodiment, after the sub-charts are generated in each page element in the target template file, the generation module 150 is further configured to:
[0155] When each sub-chart is generated, it is determined whether the sub-chart needs to be adjusted, and when the sub-chart needs to be adjusted, the sub-chart is adjusted based on a preset coordinate axis.
[0156] When each sub-chart is generated, it is determined whether the sub-chart needs to be adjusted, and when the sub-chart needs to be adjusted, the sub-chart is adjusted based on a preset coordinate axis.
[0157] E21, when each sub-chart is generated, coordinates of the sub-chart are divided into a plurality of coordinate groups according to a reference coordinate axis of the coordinates in the sub-chart;
[0158] E22, the coordinate groups are selected one by one, and when each coordinate group is selected, display lengths of each coordinate in the selected coordinate group on a preset coordinate axis are obtained;
[0159] E23, it is determined whether a ratio of the display length to a total length of the preset coordinate axis is less than a preset ratio;
[0160] E24、when the ratio of the display length to the total length of the preset coordinate axis is less than a preset ratio, adjusting the maximum value and / or the minimum value of the preset coordinate axis, and updating the sub-chart based on the adjusted maximum value and / or the minimum value.
[0161] In the embodiment, after the attribute data and the mapping relationship are saved to the preset database, the configuration module 120 is further configured to:
[0162] F21, parsing an attribute update instruction of a user for a specified page element, obtaining element identification data of the specified page element and new attribute values corresponding to each to-be-updated attribute item carried by the attribute update instruction;
[0163] F22, according to the element identification data of the specified page element, searching for corresponding attribute data in the preset database;
[0164] F23, filtering each to-be-updated attribute item in the found attribute data, and modifying the attribute values corresponding to each to-be-updated attribute item to new attribute values.
[0165] As shown in Figure 3 is a structural schematic diagram of an electronic device for implementing the chart generation method provided by an embodiment of the present application.
[0166] The electronic device 1 is a device capable of automatically performing numerical calculation and / or information processing according to a pre-set or stored instruction. The electronic device 1 can be a computer, a single network server, a server group composed of multiple network servers, or a cloud composed of a large number of hosts or network servers based on cloud computing, wherein cloud computing is a kind of distributed computing, and a super virtual computer composed of a group of loosely coupled computer clusters.
[0167] In the embodiment, the electronic device 1 includes, but is not limited to, a memory 11, a processor 12, and a network interface 13 which are communicatively connected through a system bus, the memory 11 stores a chart generation program 10, and the chart generation program 10 can be executed by the processor 12. Figure 3 Only the electronic device 1 with components 11-13 and the chart generation program 10 is shown, and those skilled in the art can understand that, Figure 3 The structure shown does not constitute a limitation on the electronic device 1, and can include fewer or more components than shown, or combine certain components, or different component arrangements.
[0168] The memory 11 includes an internal memory and at least one type of readable storage medium. The internal memory provides a cache for the operation of the electronic device 1; the readable storage medium can be a nonvolatile storage medium such as a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., an SD or DX memory, etc.), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the readable storage medium can be an internal storage unit of the electronic device 1, such as a hard disk of the electronic device 1; in other embodiments, the nonvolatile storage medium can also be an external storage device of the electronic device 1, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. In this embodiment, the readable storage medium of the memory 11 is generally used to store an operating system and various application software installed in the electronic device 1, such as the code of the chart generation program 10 in an embodiment of the present application, etc. In addition, the memory 11 can also be used to temporarily store various data that has been output or will be output.
[0169] The processor 12 can be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip in some embodiments. The processor 12 is generally used to control the overall operation of the electronic device 1, such as performing control and processing related to data interaction or communication with other devices, etc. In this embodiment, the processor 12 is used to run program codes or process data stored in the memory 11, such as running the chart generation program 10, etc.
[0170] The network interface 13 can include a wireless network interface or a wired network interface, and the network interface 13 is used to establish a communication connection between the electronic device 1 and a client (not shown in the figure).
[0171] Optionally, the electronic device 1 can also include a user interface, which can include a display (Display), an input unit such as a keyboard, and optionally the user interface can also include a standard wired interface, a wireless interface. Optionally, in some embodiments, the display can be an LED display, a liquid crystal display, a touch liquid crystal display, an OLED (Organic Light-Emitting Diode) touch, etc. The display can also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device 1 and to display a visualized user interface.
[0172] It should be understood that the embodiments are only illustrative, and the patent application scope is not limited by the structure.
[0173] The chart generation program 10 stored in the memory 11 in the electronic device 1 is a combination of a plurality of instructions, which, when executed in the processor 12, can implement the chart generation method described above.
[0174] Specifically, the specific implementation method of the chart generation program 10 described above can refer to Figure 1 The description of the related steps in the corresponding embodiments will not be repeated here.
[0175] Further, the modules / units integrated in the electronic device 1, if implemented in the form of software function units and sold or used as independent products, can be stored in a computer readable storage medium. The computer readable medium can be non-volatile or non-volatile. The computer readable medium can include any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory).
[0176] The chart generation program 10 is stored on the computer readable storage medium, and the chart generation program 10 can be executed by one or more processors to implement the chart generation method described above.
[0177] In several embodiments provided by the present application, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the modules is only a logical function division, and actual implementation can have another division way.
[0178] The modules described as separate components can or can not be physically separated, and the components displayed as modules can or can not be physical units, that is, they can be located in one place, or they can be distributed on multiple network units. According to actual needs, some or all of the modules can be selected to achieve the purpose of the embodiment scheme.
[0179] In addition, each functional module in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically independently, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of hardware plus software function module.
[0180] It will be obvious to a person skilled in the art that the application is not limited to the details of the above-described exemplary embodiments but can be implemented in other embodiments without departing from the scope of the application.
[0181] The embodiments should therefore be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the description given above, so that all changes coming within the meaning and equivalency range of the claims are intended to be embraced therein. Any reference signs in the claims should not be construed as limiting the scope of the claims.
[0182] The blockchain referred to in the present application is a new application mode of distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm and other computer technologies. The blockchain is essentially a decentralized database, which is a series of data blocks associated using cryptographic methods. Each data block contains information about a batch of network transactions, which is used to verify the validity (anti-fake) of the information and generate the next block. The blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer, etc.
[0183] Furthermore, it is clear that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or devices can be implemented by one unit or device through software or hardware. The terms "first", "second", "third", "fourth", "fifth" and "sixth" are used to distinguish between similar objects, not to imply or create any special order or priority.
[0184] Finally, it should be noted that the above embodiments are merely used to illustrate the technical solutions of the present application, rather than limit the present application. Although the present application has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present application can be modified or replaced by equivalents without departing from the spirit and scope of the present application.
Claims
1. A chart generation method, characterized in that, The method includes: In response to the user's template creation command, the system obtains the template page data corresponding to the template creation command; in response to the page element addition command, the system obtains the element identifier data, element shape data, element size data, and element position data in the page as the element data corresponding to the page element to be added; and generates the template file corresponding to the template creation command based on the template page data, the element data, and the pre-determined template identifier data. Configure data source connection information, data query statement and sub-chart type for each page element in the template file as attribute data for each page element, establish a mapping relationship between the attribute data, template identification data and element identification data of each page element, and save the attribute data and the mapping relationship to a preset database; In response to a chart generation command sent by a client carrying target template identifier data, the system obtains a target template file based on the target template identifier data and searches for target attribute data corresponding to each page element in the target template file in the preset database according to the mapping relationship. Based on the data source connection information in the target attribute data, connect to the target data source corresponding to each page element in the target template file, and use the data query statement in the target attribute data to query the data to be displayed corresponding to each page element in the target template file in the target data source. A chart file is generated based on the data to be displayed, the target attribute data, and the target template file.
2. The chart generation method as described in claim 1, characterized in that, The methods for obtaining the element shape data, element size data, and element position data include: A polygonal virtual frame composed of multiple control curves is constructed on the page of the template file. Each control curve has multiple control points for the user to move. Based on the user's movement operations at each of the control points, update each of the control curves, and generate a new polygonal virtual box based on the updated control curves; Obtain the shape data of the new polygonal virtual frame as element shape data, obtain the size data of the new polygonal virtual frame as element size data, and obtain the position data of the new polygonal virtual frame on the page of the template file as element position data.
3. The chart generation method as described in claim 1, characterized in that, The step of generating a chart file based on the data to be displayed, the target attribute data, and the target template file includes: Based on the data to be displayed and the target attribute data corresponding to each page element in the target template file, sub-charts are generated in each page element of the target template file; Generate a chart file based on the sub-chart and the target template file.
4. The chart generation method as described in claim 3, characterized in that, After generating sub-charts in each page element of the target template file, the method further includes: When a sub-chart is generated, it is determined whether the sub-chart needs to be adjusted. If the sub-chart needs to be adjusted, it is adjusted based on a preset coordinate axis.
5. The chart generation method as described in claim 4, characterized in that, When a sub-chart is generated, it is determined whether the sub-chart needs adjustment. When the sub-chart needs adjustment, the adjustment of the sub-chart based on a preset coordinate axis includes: When a sub-chart is generated, the coordinates of the sub-chart are divided into multiple coordinate groups according to the reference coordinate axis of the coordinates in the sub-chart; Select coordinate groups one by one. For each selected coordinate group, obtain the display length of each coordinate in the selected coordinate group on the preset coordinate axis. Determine whether the ratio of the displayed length to the total length of the preset coordinate axes is less than a preset ratio; When the ratio of the displayed length to the total length of the preset coordinate axis is less than the preset ratio, the maximum and / or minimum values of the preset coordinate axis are adjusted, and the sub-chart is updated based on the adjusted maximum and / or minimum values.
6. The chart generation method as described in claim 1, characterized in that, After saving the attribute data and the mapping relationship to a preset database, the method further includes: Parse the user's attribute update instruction for a specified page element, and obtain the element identifier data of the specified page element and the new attribute values corresponding to each attribute item to be updated carried in the attribute update instruction; Based on the element identifier data of the specified page element, search for the corresponding attribute data in the preset database; Filter the attribute items to be updated from the found attribute data, and modify the attribute values corresponding to each attribute item to the new attribute values.
7. A chart generation device, characterized in that, The device includes: The creation module is used to respond to the user's template creation command, obtain the template page data corresponding to the template creation command, respond to the page element addition command, obtain the element identifier data, element shape data, element size data and element position data in the page as the element data corresponding to the page element to be added, and generate the template file corresponding to the template creation command based on the template page data, the element data and the predetermined template identifier data. The configuration module is used to configure data source connection information, data query statements and sub-chart types as attribute data for each page element in the template file, establish a mapping relationship between the attribute data, template identification data and element identification data of each page element, and save the attribute data and the mapping relationship to a preset database. The search module is used to respond to the chart generation command sent by the client carrying target template identification data, obtain the target template file based on the target template identification data, and search the preset database for the target attribute data corresponding to each page element in the target template file according to the mapping relationship. The connection module is used to connect to the target data source corresponding to each page element in the target template file according to the data source connection information in the target attribute data, and use the data query statement in the target attribute data to query the data to be displayed corresponding to each page element in the target template file in the target data source. The generation module is used to generate a chart file based on the data to be displayed, the target attribute data, and the target template file.
8. An electronic device, characterized in that, The electronic device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores a chart generation program that can be executed by the at least one processor, the chart generation program being executed by the at least one processor to enable the at least one processor to perform the chart generation method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a chart generation program, which can be executed by one or more processors to implement the chart generation method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Chart display adjusting method and device
CN104298439A
Page rendering method, apparatus and device
CN107562467A
Data processing method and device and computing equipment
CN112631580A