A method and device for generating chart data
By matching chart definitions from the chart definition library and performing data processing and format conversion, the problems of large development volume and high maintenance costs in chart production are solved, compatibility with third-party components is achieved, and development efficiency and reusability are improved.
Patent Information
- Application Number
- CN202010295679.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-04-15
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2040-04-15
AI Technical Summary
The existing technology has problems such as large development volume, high maintenance costs, and incompatible with third-party chart components during the chart production process due to diversified data sources, diversified data processing and diversified charts.
By receiving and parsing a chart generation request, matching the corresponding chart definition from the chart definition library based on the chart identification, obtaining pending data and performing data processing and format conversion, and generating chart data compatible with third-party chart components.
Reduces development volume and maintenance costs, improves compatibility with third-party chart components, and enables reusable development from data sources to front-end charts.
Smart Images

Figure CN113536748B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for generating chart data. Background Art
[0002] At present, all walks of life are undergoing digital transformation, and charts are an indispensable form of data presentation. The usual practice is to obtain data from the data source during the development phase, then process the data and convert it into the format required by the front end.
[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:
[0004] In the process of making charts, we face problems such as diversified data sources, diversified data processing, and diversified charts, which leads to large development volume and high maintenance costs.
[0005] Although Vega (a visual syntax for displaying data as charts) can solve the conversion from data sources to front-end charts, Vega only focuses on how to generate data that meets its own format and how to display and render the corresponding charts, so its data processing capabilities are weak; and it is incompatible with third-party chart components (such as echart, hightcharts, etc.), resulting in the inability to use Vega for development of systems that use third-party chart components. Summary of the invention
[0006] In view of this, an embodiment of the present invention provides a method and apparatus for generating chart data to solve the technical problems of large development workload, high maintenance cost or incompatibility with third-party components.
[0007] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for generating chart data is provided, comprising:
[0008] Receive and parse the chart generation request to obtain the chart identifier and request parameters;
[0009] Matching a corresponding chart definition from a chart definition library according to the chart identifier; wherein the chart definition includes a data source description, a data processing flow description, and a format conversion description;
[0010] The data to be processed is acquired according to the chart definition and the request parameters, and data processing and format conversion are performed on the data to be processed, so as to generate chart data.
[0011] Optionally, obtaining the data to be processed according to the chart definition and the request parameters, performing data processing and format conversion on the data to be processed, thereby generating chart data, includes:
[0012] According to the data source description and the request parameters, data in the at least one data source is obtained in parallel from the at least one data source, and the data is respectively stored in a data table;
[0013] According to the data processing flow description, column processing and / or row processing are performed on the data in the data table to obtain a chart table;
[0014] According to the format conversion description, the data in the chart table is converted into chart data in a target format.
[0015] Optionally, the data source description includes the type of each data source and its corresponding attributes;
[0016] The data processing flow description includes each processing node and its corresponding attributes.
[0017] Optionally, according to the data processing flow description, column processing and / or row processing is performed on the data in the data table to obtain a chart table, including:
[0018] For each data table, according to the data processing flow description, column processing and / or row processing is performed on the data in the data table;
[0019] Combine the processing results in each data table into a chart table;
[0020] Complete the data of the missing fields in the chart table.
[0021] Optionally, according to the data processing flow description, column processing and / or row processing is performed on the data in the data table, including:
[0022] According to the processing order of each processing node, column processing and / or row processing is performed on the data in the data table in sequence according to the attributes of each processing node.
[0023] Optionally, according to the format conversion description, converting the data in the chart table into chart data in a target format includes:
[0024] Extracting data from the chart table and converting the data into chart data in JSON format;
[0025] The chart data in the JSON format is converted into chart data in a target format; wherein the target format is compatible with a third-party chart component.
[0026] Optionally, it also includes:
[0027] The chart data in the target format is returned to the client, so that the client renders the chart data in the target format through the third-party chart component.
[0028] In addition, according to another aspect of an embodiment of the present invention, there is provided a device for generating chart data, comprising:
[0029] A receiving module is used to receive and parse a chart generation request to obtain a chart identifier and request parameters;
[0030] A matching module, used to match a corresponding chart definition from a chart definition library according to the chart identifier; wherein the chart definition includes a data source description, a data processing flow description and a format conversion description;
[0031] The generating module is used to obtain the data to be processed according to the chart definition and the request parameters, perform data processing and format conversion on the data to be processed, so as to generate chart data.
[0032] Optionally, the generating module is further used for:
[0033] According to the data source description and the request parameters, data in the at least one data source is obtained in parallel from the at least one data source, and the data is respectively stored in a data table;
[0034] According to the data processing flow description, column processing and / or row processing are performed on the data in the data table to obtain a chart table;
[0035] According to the format conversion description, the data in the chart table is converted into chart data in a target format.
[0036] Optionally, the data source description includes the type of each data source and its corresponding attributes;
[0037] The data processing flow description includes each processing node and its corresponding attributes.
[0038] Optionally, the generating module is further used for:
[0039] For each data table, according to the data processing flow description, column processing and / or row processing is performed on the data in the data table;
[0040] Combine the processing results in each data table into a chart table;
[0041] Complete the data of the missing fields in the chart table.
[0042] Optionally, the generating module is further used for:
[0043] According to the processing order of each processing node, column processing and / or row processing is performed on the data in the data table in sequence according to the attributes of each processing node.
[0044] Optionally, the generating module is further used for:
[0045] Extracting data from the chart table and converting the data into chart data in JSON format;
[0046] The chart data in the JSON format is converted into chart data in a target format; wherein the target format is compatible with a third-party chart component.
[0047] Optionally, the generating module is further used for:
[0048] The chart data in the target format is returned to the client, so that the client renders the chart data in the target format through the third-party chart component.
[0049] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, including:
[0050] one or more processors;
[0051] a storage device for storing one or more programs,
[0052] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any one of the above embodiments.
[0053] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the method described in any one of the above embodiments is implemented.
[0054] An embodiment of the above invention has the following advantages or beneficial effects: because the technical means of matching the corresponding chart definition from the chart definition library according to the chart identifier, obtaining the data to be processed according to the chart definition and request parameters, and performing data processing and format conversion on the data to be processed, thereby generating chart data, overcomes the technical problems of large development volume, high maintenance cost or incompatibility with third-party components in the prior art. The embodiment of the present invention obtains data from multiple data sources through pre-defined chart definitions, stores the data in a data table, and then performs row and column processing and format conversion on the data. Developers can complete the development from data sources to front-end charts through chart definitions, increase reusable rows, and reduce maintenance costs.
[0055] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with specific implementation examples. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0057] Figure 1is a schematic diagram of the main process of a method for generating chart data according to an embodiment of the present invention;
[0058] Figure 2 is a schematic diagram of the main process of a method for generating chart data according to a reference embodiment of the present invention;
[0059] Figure 3 is a schematic diagram of the main process of a method for generating chart data according to another reference embodiment of the present invention;
[0060] Figure 4 It is a schematic diagram of a system framework for implementing a method for generating chart data according to an embodiment of the present invention;
[0061] Figure 5 is a schematic diagram of main modules of an apparatus for generating chart data according to an embodiment of the present invention;
[0062] Figure 6 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0063] Figure 7 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0064] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0065] Figure 1 Schematic diagram of the main process of the method for generating chart data according to an embodiment of the present invention. As an embodiment of the present invention, Figure 1 As shown, the method for generating chart data may include:
[0066] Step 101, receiving and parsing a chart generation request to obtain a chart identifier and request parameters.
[0067] The client (such as a browser) sends a chart generation request to the server, and the chart generation request carries a chart identifier, which can be a chart number and / or a chart name, so that the server can generate a chart required by the user according to the chart identifier; the request parameters can be parameters required in the chart definition, such as the start time, end time, and time period. After receiving the chart data request sent by the client, the server verifies its legitimacy. If the verification passes, it parses it to obtain the chart identifier and request parameters.
[0068] Step 102: Match a corresponding chart definition from a chart definition library according to the chart identifier.
[0069] After the server parses the chart identifier, it matches the corresponding chart definition from the chart definition library according to the chart identifier, wherein the chart definition includes a data source description, a data processing flow description, and a format conversion description. It should be noted that the chart definition library stores the correspondence between each chart identifier and each chart definition, so the corresponding chart definition can be matched from the chart definition library according to the chart identifier carried in the request.
[0070] In the embodiment of the present invention, each chart must have a corresponding chart definition defined in the development phase, and then stored in a database (i.e., a chart definition library). The server obtains the pre-defined chart definition from the database based on the chart identifier sent by the client.
[0071] Optionally, the chart definition may include the following:
[0072]
[0073]
[0074] Optionally, the data source description includes the type of each data source and its corresponding attributes, so as to facilitate obtaining data required for generating a chart from different data sources.
[0075] Optionally, the data source description may include the following content:
[0076]
[0077] Optionally, the type of data source can be a URL type, a service type (such as an RPC service type) or a database type (such as JDBC, i.e., Java database connection), etc. Different data sources have different corresponding attributes. For example, the parameters corresponding to the URL type data source mainly include access address, access method, etc., the parameters corresponding to the service type and database type data source mainly include access address, user name, password, and query statement, etc.; the parameters corresponding to the service type data source mainly include service name, filter parameters, etc.
[0078] Optionally, the data processing flow description includes various processing nodes and their corresponding attributes, so as to facilitate processing of the acquired data.
[0079] Optionally, the data processing flow description may include the following content:
[0080]
[0081]
[0082] Optionally, the data conversion description includes various conversion nodes for performing format conversion on the data. Optionally, the data conversion description may include the following content:
[0083]
[0084] Step 103: acquiring the data to be processed according to the chart definition and the request parameters, performing data processing and format conversion on the data to be processed, thereby generating chart data.
[0085] After the server matches the corresponding chart definition from the chart definition library, it obtains the data to be processed from the data source according to the chart definition and the request parameters, and stores it in the memory in the form of a data table. It then processes the data in the data table and finally converts the processing result into a format to obtain chart data.
[0086] Optionally, step 103 may include: according to the data source description and request parameters, obtaining data in at least one data source in parallel from at least one data source, and storing the data in a data table respectively; according to the data processing flow description, performing column processing and / or row processing on the data in the data table to obtain a chart table; according to the format conversion description, converting the data in the chart table into chart data in a target format.
[0087] The data source description can define multiple different data sources at the same time. Through the description of the data source in the chart definition, data is obtained from the data source and stored in the memory in the form of column storage. The subsequent data processing process can obtain the corresponding data from the memory through the name of the data result. In each attribute of each data source, the request parameters carried by the chart generation request will be used. The server will enter the business parameters into the data source description in the form of ${}. When the data source fails to be obtained, an exception will be thrown and the entire process will fail.
[0088] Optionally, according to the data processing flow description, the data in the data table is processed in columns and / or rows to obtain a chart table, including: for each data table, according to the data processing flow description, the data in the data table is processed in columns and / or rows; the processing results in each data table are merged into a chart table; the data of the missing fields in the chart table are completed. Through the description of each processing node in the chart definition, the acquired data is processed in rows and / or columns, for example: merging rows, merging columns, calculating percentages, arithmetic operations, etc. These data processing plug-ins can be expanded as needed. Optionally, the data of the missing fields in the chart table can be completed according to a time period (such as one day, one week, etc.).
[0089] Optionally, according to the data processing flow description, column processing and / or row processing is performed on the data in the data table, including: according to the processing order of each processing node, column processing and / or row processing is performed on the data in the data table in sequence according to the attributes of each processing node. In the data processing flow description, multiple processing nodes are usually defined, and these nodes are executed sequentially to process the data table data obtained from the data source one by one to obtain the final data result. Each type of processing node has different attributes. The system supports extension plug-ins and can customize processing nodes.
[0090] After data processing is completed, the processed data is first converted into JSON format, and then the JSON is converted into the format required by the client chart through the format conversion description defined in the chart definition.
[0091] According to the format conversion description, the data in the chart table is converted into chart data in a target format, including: extracting data from the chart table and converting the data into chart data in a JSON format; converting the chart data in a JSON format into chart data in a target format; wherein the target format is compatible with a third-party chart component.
[0092] When the client obtains chart data, the required result type varies depending on the component and type of chart. However, most chart components on the market, such as echart and highchart, require data in JSON format. The purpose of format conversion is to return the required chart data to the client. After the data is processed, the data from multiple data sources will eventually be combined into a Table, and then the Table will be converted into JSON format. However, the data in this JSON format is not what the client needs, so it is necessary to convert this JSON into another format of JSON and finally return it to the client.
[0093] In the embodiment of the present invention, in order to be compatible with third-party chart components, the embodiment of the present invention uses jolt (https: / / github.com / bazaarvoice / jolt), a JSON TO JSON conversion tool, to solve the problem that the format after data processing does not match the format of the front-end chart technology. Jolt can convert a JSON format into another JSON format by describing information such as location. Therefore, the embodiment of the present invention combines row and column processing with JSON format conversion, and realizes the conversion from data source to chart data through JSON-based chart definition.
[0094] Optionally, the method further includes: returning the target format chart data to the client, so that the client renders the target format chart data through the third-party chart component. The data result of the chart is returned to the client for chart display, and the returned data may include error information in addition to the chart data.
[0095] According to the various embodiments described above, it can be seen that the embodiments of the present invention match the corresponding chart definition from the chart definition library according to the chart identifier, obtain the data to be processed according to the chart definition and request parameters, and perform data processing and format conversion on the data to be processed, thereby generating chart data by means of technical means, which solves the technical problems of large development volume, high maintenance cost or incompatibility with third-party components in the prior art. The embodiments of the present invention obtain data from multiple data sources through pre-defined chart definitions, store the data in a data table, and then perform row and column processing and format conversion on the data. Developers can complete the development from data sources to front-end charts through chart definitions, increase reusable rows, and reduce maintenance costs.
[0096] Figure 2 It is a schematic diagram of the main process of a method for generating chart data according to a reference embodiment of the present invention. In order to better understand the embodiment of the present invention, the following is a complete grammatical structure of a chart definition, which obtains data from an RPC data source, and then obtains a Table through data processing such as decimal selection, percentage calculation, column deletion, and time padding, and then converts the Table into another JSON format.
[0097]
[0098]
[0099]
[0100]
[0101] Figure 3It is a schematic diagram of the main process of a method for generating chart data according to another reference embodiment of the present invention. Figure 4 Schematic diagram of the system framework for realizing the method for generating chart data in an embodiment of the present invention. The system includes a client, a chart data service node, a chart definition library, a parsing device and a data source; wherein the parsing device includes a data source device, a data processing device and a format conversion device. As another embodiment of the present invention, Figure 3 As shown, the method for generating chart data may include:
[0102] Step 301 : pre-developing chart definitions, and storing the correspondence between each chart identifier and each chart definition in a chart definition library.
[0103] Each chart must have a corresponding chart definition defined during the development phase, and then stored in a chart definition library. The chart definition includes a data source description, a data processing flow description, and a format conversion description. Optionally, the data source description includes the type of each data source and its corresponding attributes, making it easy to obtain the data required to generate the chart from different data sources.
[0104] Optionally, the type of data source can be a URL type, a service type (such as an RPC service type) or a database type (such as JDBC, i.e., Java database connection), etc. Different data sources have different corresponding attributes. For example, the parameters corresponding to the URL type data source mainly include access address, access method, etc., and the parameters corresponding to the service type and database type data source mainly include access address, user name, password, and query statement, etc.; the parameters corresponding to the service type data source mainly include service name, filter parameters, etc. Optionally, the data processing flow description includes various processing nodes and their corresponding attributes to facilitate the processing of the acquired data. Optionally, the data conversion description includes various conversion nodes for format conversion of the data.
[0105] Step 302: the client sends a chart generation request to the chart data service node, and the chart data service node receives and parses the chart generation request to obtain a chart identifier and request parameters.
[0106] After receiving the chart data request sent by the client, the chart data service node verifies the legitimacy of the request. If the verification is successful, the service node parses the request to obtain the chart identifier and request parameters. The chart generation request carries the chart identifier, which may be a chart number and / or a chart name, so that the service end can generate a chart required by the user according to the chart identifier; the request parameters may be parameters required in the chart definition such as the start time, end time and time period.
[0107] Step 303: the chart data service node matches the corresponding chart definition from the chart definition library according to the chart identifier.
[0108] Step 304: the chart data service node sends the request parameters and the matched chart definition to the parsing device.
[0109] Step 305: The data source device obtains data in at least one data source in parallel from at least one data source according to the data source description and the request parameters, and stores the data in a data table respectively.
[0110] The data source description can define multiple different data sources at the same time. The data source device obtains data from the data source through the description of the data source in the chart definition, and stores it in the memory in the form of column storage. The subsequent data processing process can obtain the corresponding data from the memory through the name of the data result. In each attribute of each data source, the request parameters carried by the chart generation request will be used. The server will enter the business parameters into the data source description in the form of ${}.
[0111] Step 306: the data device performs column processing and / or row processing on the data in the data table according to the data processing flow description to obtain a chart table.
[0112] The data device obtains data from at least one data source in parallel according to the data source description and request parameters, and stores the data in a data table respectively; performs column processing and / or row processing on the data in the data table according to the data processing flow description to obtain a chart table. Specifically, for each data table, according to the data processing flow description, performs column processing and / or row processing on the data in the data table; merges the processing results in each data table into a chart table; and completes the data of the missing fields in the chart table. Through the description of each processing node in the chart definition, the acquired data is processed in rows and / or columns, such as: merging rows, merging columns, calculating percentages, arithmetic operations, etc.
[0113] Step 307: The format conversion device converts the data in the chart table into chart data in a target format according to the format conversion description.
[0114] After completing the data processing, the format conversion device first converts the processed data into JSON format, and then converts the JSON into the format required by the client chart through the format conversion description defined in the chart definition. In order to be compatible with third-party chart components, such as echart and highchart, the embodiment of the present invention uses jolt to convert a JSON format into another JSON format.
[0115] Step 308: The parsing device returns the chart data in the target format to the client, so that the client renders the chart data in the target format through the third-party chart component.
[0116] In addition, the specific implementation content of the method for generating chart data in a reference embodiment of the present invention has been described in detail in the method for generating chart data described above, so the repeated content will not be described here.
[0117] Figure 5 is a schematic diagram of the main modules of the apparatus for generating chart data according to an embodiment of the present invention, such as Figure 5 As shown, the device 500 for generating chart data includes a receiving module 501, a matching module 502 and a generating module 503; wherein the receiving module 501 is used to receive and parse a chart generation request to obtain a chart identifier and request parameters; the matching module 502 is used to match a corresponding chart definition from a chart definition library according to the chart identifier; wherein the chart definition includes a data source description, a data processing flow description and a format conversion description; the generating module 503 is used to obtain the data to be processed according to the chart definition and the request parameters, perform data processing and format conversion on the data to be processed, thereby generating chart data.
[0118] Optionally, the generating module 503 is further used for:
[0119] According to the data source description and the request parameters, data in the at least one data source is obtained in parallel from the at least one data source, and the data is respectively stored in a data table;
[0120] According to the data processing flow description, column processing and / or row processing are performed on the data in the data table to obtain a chart table;
[0121] According to the format conversion description, the data in the chart table is converted into chart data in a target format.
[0122] Optionally, the data source description includes the type of each data source and its corresponding attributes;
[0123] The data processing flow description includes each processing node and its corresponding attributes.
[0124] Optionally, the generating module 503 is further used for:
[0125] For each data table, according to the data processing flow description, column processing and / or row processing is performed on the data in the data table;
[0126] Combine the processing results in each data table into a chart table;
[0127] Complete the data of the missing fields in the chart table.
[0128] Optionally, the generating module 503 is further used for:
[0129] According to the processing order of each processing node, column processing and / or row processing is performed on the data in the data table in sequence according to the attributes of each processing node.
[0130] Optionally, the generating module 503 is further used for:
[0131] Extracting data from the chart table and converting the data into chart data in JSON format;
[0132] The chart data in the JSON format is converted into chart data in a target format; wherein the target format is compatible with a third-party chart component.
[0133] Optionally, the generating module 503 is further used for:
[0134] The chart data in the target format is returned to the client, so that the client renders the chart data in the target format through the third-party chart component.
[0135] According to the various embodiments described above, it can be seen that the embodiments of the present invention match the corresponding chart definition from the chart definition library according to the chart identifier, obtain the data to be processed according to the chart definition and request parameters, and perform data processing and format conversion on the data to be processed, thereby generating chart data by means of technical means, which solves the technical problems of large development volume, high maintenance cost or incompatibility with third-party components in the prior art. The embodiments of the present invention obtain data from multiple data sources through pre-defined chart definitions, store the data in a data table, and then perform row and column processing and format conversion on the data. Developers can complete the development from data sources to front-end charts through chart definitions, increase reusable rows, and reduce maintenance costs.
[0136] It should be noted that the specific implementation content of the device for generating chart data in the present invention has been described in detail in the method for generating chart data described above, so the repeated content will not be described again here.
[0137] Figure 6 An exemplary system architecture 600 is shown to which the method for generating chart data or the apparatus for generating chart data according to the embodiments of the present invention can be applied.
[0138] like Figure 6As shown, system architecture 600 may include terminal devices 601, 602, 603, network 604 and server 605. Network 604 is used to provide a medium for communication links between terminal devices 601, 602, 603 and server 605. Network 604 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0139] Users can use terminal devices 601, 602, and 603 to interact with server 605 through network 604 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 601, 602, and 603, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).
[0140] The terminal devices 601 , 602 , and 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.
[0141] The server 605 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 601, 602, and 603. The backend management server may analyze and process the received data such as the item information query request, and feed back the processing results (such as target push information, item information - only an example) to the terminal device.
[0142] It should be noted that the method for generating chart data provided in the embodiment of the present invention is generally executed by the server 605 , and accordingly, the device for generating chart data is generally arranged in the server 605 .
[0143] It should be understood that Figure 6 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0144] Reference below Figure 7 , which shows a schematic diagram of the structure of a computer system 700 of a terminal device suitable for implementing an embodiment of the present invention. Figure 7 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0145] like Figure 7As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0146] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.
[0147] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present invention are executed.
[0148] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0149] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0150] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes a receiving module, a matching module and a generating module, wherein the names of these modules do not constitute a limitation on the modules themselves in some cases.
[0151] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device implements the following method: receiving and parsing a chart generation request to obtain a chart identifier and request parameters; matching a corresponding chart definition from a chart definition library according to the chart identifier; wherein the chart definition includes a data source description, a data processing flow description, and a format conversion description; obtaining data to be processed according to the chart definition and the request parameters, performing data processing and format conversion on the data to be processed, thereby generating chart data.
[0152] According to the technical solution of the embodiment of the present invention, the technical means of matching the corresponding chart definition from the chart definition library according to the chart identifier, obtaining the data to be processed according to the chart definition and request parameters, and performing data processing and format conversion on the data to be processed, thereby generating chart data, overcomes the technical problems of large development volume, high maintenance cost or incompatibility with third-party components in the prior art. The embodiment of the present invention obtains data from multiple data sources through pre-defined chart definitions, stores the data in a data table, and then performs row and column processing and format conversion on the data. Developers can complete the development from data sources to front-end charts through chart definitions, increase reusable rows, and reduce maintenance costs.
[0153] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for generating chart data, characterized in that: include: Receive and parse the chart generation request to obtain the chart identifier and request parameters; Matching a corresponding chart definition from a chart definition library according to the chart identifier; wherein the chart definition includes a data source description, a data processing flow description, and a format conversion description; Acquire the data to be processed according to the chart definition and the request parameters, perform data processing and format conversion on the data to be processed, thereby generating chart data; Acquiring the data to be processed according to the chart definition and the request parameters, performing data processing and format conversion on the data to be processed, thereby generating chart data, including: According to the data source description and the request parameters, data in the at least one data source is obtained in parallel from the at least one data source, and the data is respectively stored in a data table; According to the data processing flow description, column processing and / or row processing are performed on the data in the data table to obtain a chart table; According to the format conversion description, the data in the chart table is converted into chart data in a target format.
2. The method according to claim 1, characterized in that The data source description includes the type of each data source and its corresponding attributes; The data processing flow description includes each processing node and its corresponding attributes.
3. The method according to claim 2, characterized in that According to the data processing flow description, column processing and / or row processing is performed on the data in the data table to obtain a chart table, including: For each data table, according to the data processing flow description, column processing and / or row processing is performed on the data in the data table; Combine the processing results in each data table into a chart table; Complete the data of the missing fields in the chart table.
4. The method according to claim 3, characterized in that According to the data processing flow description, column processing and / or row processing is performed on the data in the data table, including: According to the processing order of each processing node, column processing and / or row processing is performed on the data in the data table in sequence according to the attributes of each processing node.
5. The method according to claim 2, characterized in that: According to the format conversion description, the data in the chart table is converted into chart data in a target format, including: Extracting data from the chart table and converting the data into chart data in JSON format; The chart data in the JSON format is converted into chart data in a target format; wherein the target format is compatible with a third-party chart component.
6. The method according to claim 5, characterized in that Also includes: The chart data in the target format is returned to the client, so that the client renders the chart data in the target format through the third-party chart component.
7. A device for generating chart data, characterized in that: include: A receiving module is used to receive and parse a chart generation request to obtain a chart identifier and request parameters; A matching module, used to match a corresponding chart definition from a chart definition library according to the chart identifier; wherein the chart definition includes a data source description, a data processing flow description and a format conversion description; A generating module, used for acquiring the data to be processed according to the chart definition and the request parameters, performing data processing and format conversion on the data to be processed, thereby generating chart data; The generation module is also used for: According to the data source description and the request parameters, data in the at least one data source is obtained in parallel from the at least one data source, and the data is respectively stored in a data table; According to the data processing flow description, column processing and / or row processing are performed on the data in the data table to obtain a chart table; According to the format conversion description, the data in the chart table is converted into chart data in a target format.
8. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
9. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
