Method, device, computer equipment and storage medium for real-time display of visual charts
By reusing the rendering method and encapsulating different chart components on the collection page, and generating charts based on user IDs and query conditions, the problem of difficulty in real-time display of database data in the existing technology is solved, and diversified display and scalability are achieved.
Patent Information
- Application Number
- CN202010355859.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-04-29
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2040-04-29
AI Technical Summary
The existing technology makes it difficult to display the data in the database in real time on the collection page, and it is difficult to display the real-time data through different chart types.
Through the reuse of preset rendering methods and interfaces, chart types are identified and different chart components are encapsulated. Charts are generated based on user IDs and query conditions to achieve real-time display of chart data.
It realizes diverse chart display on the collection page, reduces the code error rate, has good scalability and maintainability, can flexibly display different chart data in the database, and avoids the problem of fixed data display.
Smart Images

Figure CN111666328B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, computer equipment and storage medium for displaying visual charts in real time. Background Art
[0002] Data visualization, as the name implies, is to display relatively obscure data in a visual and interactive way, and then vividly and intuitively express the information and rules behind the data. After entering the era of big data, all walks of life pay more and more attention to data, and then a series of data integration, mining, and visualization analysis are carried out, which injects infinite vitality into data visualization. Therefore, the visual elements are becoming more and more diverse, including bar charts, line charts, line graphs and other rich graphics.
[0003] At present, the data collected by most traditional user collection functions are basically fixed, and the chart type displayed on the user collection page is also unique. It is difficult to display the real-time data in the database on the collection page, and it is also difficult to display the real-time data through different chart types. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a method, apparatus, computer device and storage medium for displaying a visual chart in real time, which can display real-time data in a database through charts on a favorites page.
[0005] In order to solve the above technical problems, the embodiment of the present application provides a method for displaying a visual chart in real time, which adopts the following technical solution:
[0006] A method for displaying a visual chart in real time, comprising the following steps:
[0007] Setting a preset rendering mode in a preset interface, wherein the rendering mode is used to render a chart;
[0008] Identifying a preset interface associated with a chart page, and associating the preset interface with a favorite page to implement multiplexing of rendering methods, wherein the chart page is a page where favorited and unfavorited charts are located;
[0009] The rendering method includes a method name, each chart is identified by a first field, and the first field is mapped to the method name of the rendering method;
[0010] Identify the chart type of each chart, and encapsulate different chart components according to different chart types;
[0011] When it is detected that a user adds the chart to the favorites page on the chart page, save and associate the current user ID and data parameters of each current chart, wherein the data parameters at least include the chart type, the first field, the method name, and the query condition for rendering the chart; and
[0012] When it is detected that the user clicks on the favorites page, the corresponding first field is determined according to the user ID, the chart component is selected and loaded according to the chart type, the rendering method is selected and called according to the first field, the chart data in the database is obtained according to the query conditions, and the chart component generates a chart using the obtained chart data according to the called rendering method.
[0013] Furthermore, the step of encapsulating different chart components according to different chart types includes:
[0014] Use echarts as the basic library and reference the corresponding components in echarts according to the chart type;
[0015] Receive UI design drafts and configure chart style files according to the UI design drafts;
[0016] Configure the design file according to the preset logic;
[0017] Encapsulate the corresponding components, chart style files and design files in echarts to generate chart components.
[0018] Furthermore, the step of identifying the chart type of each chart and encapsulating different chart components according to different chart types includes:
[0019] Pre-identify the chart type with the second field;
[0020] identifying a second field of each chart, and encapsulating different chart components according to the second field;
[0021] Assign component names to the encapsulated different chart components respectively, and map the component names to the second field;
[0022] The steps of selecting and loading a chart component according to the chart type, and selecting and calling a rendering method according to the first field include:
[0023] The chart component is selected and loaded according to the second field, and the rendering method is selected and called according to the first field.
[0024] Furthermore, the chart data in the database obtained according to the query conditions is used to generate a chart using the chart component according to the called rendering method.
[0025] Check whether the query conditions corresponding to different charts include the saving time;
[0026] If the query condition includes the saving time, then the chart data in the database corresponding to the saving time is obtained according to the saving time, and the chart component generates a chart with the obtained chart data according to the called rendering method;
[0027] If the query condition does not include the saved time, the chart data in the database corresponding to the current time is obtained according to the current time, and the chart component generates a chart using the obtained chart data according to the called rendering method.
[0028] Further, the step of identifying all preset interfaces associated with the chart page, after the step of associating the preset interfaces with the favorites page, further includes:
[0029] Encapsulate the common Ajax request in a request method for calling when rendering the chart;
[0030] The steps of selecting a loaded chart component according to the chart type and selecting a calling rendering method according to the first field include:
[0031] Verify the chart in the favorites page according to the saved data parameters;
[0032] If the verification is successful, the chart component selected and loaded according to the chart type, and the rendering method selected and called according to the first field;
[0033] By calling the public Ajax request, request the database to obtain the chart data.
[0034] Furthermore, the step of verifying the chart in the favorites page according to the saved data parameters includes:
[0035] When it is detected that a user opens a chart page, the parameters of each chart in the chart page are saved, and corresponding chart information is generated respectively;
[0036] comparing the chart information with the data parameters, wherein the chart information includes at least a chart type, a first field, and a method name;
[0037] If the chart information is consistent with the data parameters, the verification is passed.
[0038] Furthermore, the step of setting the preset rendering mode in the preset interface includes:
[0039] The preset interface is provided with different modules, and the preset rendering methods are set in the different modules.
[0040] In order to solve the above technical problems, the embodiment of the present application further provides a device for displaying a visual chart in real time, which adopts the following technical solution:
[0041] A preset module, used to set a preset rendering method in a preset interface, and associate different preset interfaces with corresponding chart pages respectively, wherein the rendering method is used to render the chart;
[0042] An association module, used to identify all preset interfaces associated with a chart page, and associate the preset interfaces with a favorite page to achieve multiplexing of rendering methods, wherein the chart page is a page where favorited and unfavorited charts are located;
[0043] A mapping module, for rendering a mode including a mode name, identifying each chart with a first field, and mapping the first field with the mode name of the rendering mode;
[0044] The encapsulation module is used to identify the type of each chart and encapsulate different chart components according to the chart type;
[0045] a detection module, configured to save and associate a current user ID with data parameters of each current chart when detecting that a user adds the chart to a favorites page on a chart page, wherein the data parameters at least include a chart type, a first field, a method name, and a query condition for rendering the chart; and
[0046] A generation module is used to determine the corresponding first field according to the user ID when it is detected that the user clicks on the favorites page, select and load the chart component according to the chart type, select and call the rendering method according to the first field, obtain the chart data in the database according to the query conditions, and generate a chart through the chart component using the obtained chart data according to the called rendering method.
[0047] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:
[0048] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned method for real-time display of visual charts when executing the computer program.
[0049] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:
[0050] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the above-mentioned method for real-time display of visual charts.
[0051] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0052] The present application associates different preset interfaces with corresponding chart pages and favorites pages respectively, and sets different rendering methods in the preset interfaces, and selects the rendering method according to the first field, thereby realizing the reuse of rendering methods, reducing the code error rate while also meeting the demand for diverse rendering forms of different charts. Different chart components are encapsulated and called according to the chart type, so that different chart components can be set according to requirements to display data, that is, the display form of data is not unique. The present application separately calls the chart components, rendering methods and data acquisition by means of the chart type, the first field and the query conditions, so that the present solution has good scalability and maintainability, and can adjust the chart components, rendering methods, etc. according to actual needs without interfering with other functions. At the same time, the required chart data in the database is selected according to the query conditions, so that different chart data in the database can be flexibly displayed on the favorites page according to the needs of the query conditions, thereby avoiding the data displayed on the favorites page being fixed. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0054] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;
[0055] Figure 2 A flowchart of an embodiment of a method for displaying a visual chart in real time according to the present application;
[0056] Figure 3 is a structural schematic diagram of an embodiment of a device for displaying a visual chart in real time according to the present application;
[0057] Figure 4 It is a structural diagram of an embodiment of a computer device according to the present application.
[0058] Figure numerals: 200, computer device; 201, memory; 202, processor; 203, network interface; 300, device for displaying visual charts in real time; 301, preset module; 302, association module; 303, mapping module; 304, encapsulation module; 305, detection module; 306, generation module. DETAILED DESCRIPTION
[0059] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0060] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0061] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0062] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0063] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0064] Terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, Moving Picture Experts Group Audio Layer 3), MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Group Audio Layer 4) players, laptop computers and desktop computers, etc.
[0065] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .
[0066] It should be noted that the method for real-time display of visual charts provided in the embodiments of the present application is generally executed by a server / terminal device, and accordingly, the device for real-time display of visual charts is generally set in the server / terminal device.
[0067] It should be understood that Figure 1 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 the implementation requirements.
[0068] Continue to refer Figure 2 , shows a flow chart of an embodiment of a method for displaying a visual chart in real time according to the present application. The method for displaying a visual chart in real time comprises the following steps:
[0069] S1: setting a preset rendering method in a preset interface, and associating different preset interfaces with corresponding chart pages respectively, wherein the rendering method is used to render a chart.
[0070] In this embodiment, the front end of this application uses the vue framework, which is a progressive JavaScript framework for building user interfaces. The preset interface refers to: Mixin, that is, an interface with partial implementation. The reusable code is placed in this interface, and the interface can be directly referenced when the code is used multiple times.
[0071] Wherein, in step S1, that is, the step of setting the preset rendering mode in the preset interface includes:
[0072] The preset interface is provided with different modules, and the preset rendering methods are set in the different modules.
[0073] In this embodiment, the placement of calls by modules is because most systems are equipped with different front-end page display modules, and the rendering methods set in different modules are different. In order to realize the display of charts in the front-end collection page, two different rendering methods can be performed simultaneously for the same chart in the same page according to the corresponding rendering methods in different modules, so that they can be displayed simultaneously in different display modules of the front-end page. The preset interface can be introduced and called in the front-end page display module, or it can be introduced and called directly in the collection page. Different front-end page display modules can introduce the rendering method in the module of their corresponding preset interface, which is convenient for decoupling between modules and better reusability.
[0074] S2: Identify all preset interfaces associated with the chart page, and associate the preset interfaces with the favorite page to achieve multiplexing of rendering methods. The chart page is a page where favorited and unfavorited charts are located.
[0075] In this embodiment, the chart page is the page where the chart to be collected is located, that is, the page of the collected chart, wherein the chart page includes the collected charts and the uncollected charts. The charts on the collection page come from "those charts on the page to be collected", and the charts on the chart page and the collection page need to be rendered; the preset interface is associated with the collection page, and the code in the interface can be reused.
[0076] S3: The rendering method includes a method name, each chart is identified by a first field, and the first field is mapped to the name of the rendering method.
[0077] In this embodiment, the first field is cardCode; after the first field is mapped to the method name, because the mapping can have the same name, such as: abc:abc, the method name of the rendering method is also cardCode. The rendering method includes the method name, and each chart is identified by the first field, and the method name of the rendering method can be mapped to the first field through map mapping.
[0078] S4: Identify the chart type of each chart, and encapsulate different chart components according to the different chart types.
[0079] In this embodiment, line charts, bar charts, and doughnut charts are encapsulated into different components. Different types of charts such as line charts and bar charts are encapsulated into different chart components, and only the data format required for rendering the chart is exposed to the outside, so as to achieve low coupling and high cohesion. In the process of encapsulating charts, this application fully considers the compatibility, scalability, maintainability, and richness of chart components.
[0080] Specifically, in step S4, the step of encapsulating different chart components according to different chart types includes:
[0081] Use echarts as the basic library and reference the corresponding components in echarts according to the chart type;
[0082] Receive UI design drafts and configure chart style files according to the UI design drafts;
[0083] Configure the design file according to the preset logic;
[0084] Encapsulate the corresponding components, chart style files and design files in echarts to generate chart components.
[0085] In this embodiment, ECharts (Enterprise Charts, commercial data charts) is an open source visualization library implemented in JavaScript. It relies on the lightweight graphics library ZRender at the bottom layer to provide intuitive, interactive, and highly customized data visualization charts. For example, a line chart: 1. Use echarts as the basic library and reference its line chart component; 2. Configure the line chart style (such as line color, line pop-up box, etc.) file according to the UI design draft; 3. Configure the line chart design (such as the number of lines, whether the line has a pop-up box, the virtuality of the line, the range of the y-coordinate value of the line, etc.) file according to the product logic; 4. Encapsulate the line chart component, line chart style file, and line chart design file to generate a chart component.
[0086] S5: When it is detected that the user adds the chart to the favorites page on the chart page, save and associate the current user ID and the data parameters of each current chart, wherein the data parameters at least include the chart type, the first field, the method name, and the query conditions for rendering the chart.
[0087] In this embodiment, the role of user ID is: each user will collect different charts, and the user can only see the charts he or she has collected. The user ID is used as an index in the database. Chart type (renderType), according to the name of the rendering method (cardCode), determines the method of loading data to render the chart. The query conditions for rendering the chart can be selected by the user on the page; the collected charts must have query conditions; the query conditions include secondary institutions, channels, calibers and time, etc.
[0088] S6: When it is detected that the user clicks on the favorites page, the corresponding first field is determined according to the user ID, the chart component is selected and loaded according to the chart type, the rendering method is selected and called according to the first field, the chart data in the database is obtained according to the query conditions, and the chart component generates a chart using the obtained chart data according to the called rendering method.
[0089] In this embodiment, specifically, the first field is obtained; the method name corresponding to the first field is determined according to the first field; and the corresponding rendering method is determined according to the method name. When the favorites page is directly opened, the rendering method and the chart component are called to generate a chart, thereby realizing real-time viewing of the chart.
[0090] Specifically, the chart data in the database is obtained according to the query conditions, and the chart component generates a chart according to the called rendering method by using the obtained chart data.
[0091] Check whether the query conditions corresponding to different charts include the saving time;
[0092] If the query condition includes the saving time, then the chart data in the database corresponding to the saving time is obtained according to the saving time, and the chart component generates a chart with the obtained chart data according to the called rendering method;
[0093] If the query condition does not include the saved time, the chart data in the database corresponding to the current time is obtained according to the current time, and the chart component generates a chart using the obtained chart data according to the called rendering method.
[0094] In this embodiment, the query condition in this application may include the time when the chart is collected, that is, the saving time. Because some charts do not need to display the data of the current time in the database according to the latest time on the collection page, but need to display the data in the database displayed by the chart when the chart was originally saved; so when the saving time appears in the query condition, the data in the database corresponding to the saving time is obtained to realize the display of the data in the database corresponding to the saving time. Correspondingly, the query condition may not include the saving time, then the computer loads the data in the database according to the current time (the time when the user clicks on the collection page), so as to realize the real-time display of the latest data in the database in the collection. Therefore, the saving time is distinguished from the current time when the collection page is opened, and the computer determines the data to be obtained from the database when the user opens the collection page based on whether the saving time is carried in the query condition.
[0095] In addition, after step S2, that is, the step of identifying all preset interfaces associated with the chart page, and after the step of associating the preset interfaces with the favorites page, the method further includes:
[0096] Encapsulate the common Ajax request in a request method for calling when rendering the chart;
[0097] In step S6, the chart component selected and loaded according to the chart type, the step of selecting and calling the rendering mode according to the first field includes:
[0098] Verify the chart in the favorites page according to the saved data parameters;
[0099] If the verification is successful, the chart component selected and loaded according to the chart type, and the rendering method selected and called according to the first field;
[0100] By calling the public Ajax request, request the database to obtain the chart data.
[0101] In this embodiment, ajax (Asynchronous Javascript and XML) refers to a web development technology for creating interactive web applications. Ajax is a technology for creating fast dynamic web pages. It allows developers to only obtain data from the server.
[0102] The public ajax request is encapsulated into a public method. The public method includes a public method name, which is used as a unique identifier for the server request that needs to be called to render the chart. The reason for encapsulating the public ajax request into a public method is that if there are many repeated codes in the Ajax request, encapsulation is convenient for calling. When rendering the chart, call the public ajax request. This application realizes the reuse of rendering methods. There is no need to retest and debug the chart rendering on the collection page. Only verification is required, which improves efficiency.
[0103] The step of verifying the chart in the favorites page according to the saved data parameters includes:
[0104] When it is detected that a user opens a chart page, the parameters of each chart in the chart page are saved, and corresponding chart information is generated respectively;
[0105] Comparing the chart information with the data parameters, wherein the chart information at least includes a chart type, a first field, a method name, and a query condition for rendering the chart;
[0106] If the chart information is consistent with the data parameters, the verification is passed;
[0107] If the chart information is inconsistent with the data parameters, the verification will fail.
[0108] In this embodiment, the specific verification process is:
[0109] Click to collect the chart on the favorite page: request the interface and pass the parameters to the backend database;
[0110] The parameters passed are as follows:
[0111] {renderType: 1, / / Rendering chart type
[0112] renderTypeName: "*" / / rendering chart type name
[0113] cardCode: "***", / / chart rendering method name
[0114] cardName: "*", / / name of the rendered chart
[0115] moduleCode: "*", / / Which module code does the favorite chart come from?
[0116] moduleName: "*" / / Which module name does the favorite chart come from?
[0117] routerUrl:'' / / The page route where the favorite chart is located
[0118] dimensionCodeList: "*" / / Query conditions for rendering charts
[0119] dimensionNameList:'*' / / Query condition name for rendering chart
[0120] …}
[0121] The chart information refers to the parameters of the initial chart saved by the chart page when the user opens the chart page. The data parameters are the parameters of the corresponding chart obtained when the user collects the chart in the chart page after browsing the chart page. This application uses the passed parameters as data parameters. When the user opens the favorites page, the favorites page requests to obtain the data parameters of the collected chart. If the data parameters are consistent with the chart information, it means that the corresponding chart in the favorites page is the same as the corresponding chart in the chart page, and can be rendered normally without the need for testing and joint debugging, thereby improving efficiency.
[0122] In addition, in step S4, that is, the step of identifying the chart type of each chart and encapsulating different chart components according to different chart types includes:
[0123] Pre-identify the chart type with the second field;
[0124] identifying a second field of each chart, and encapsulating different chart components according to the second field;
[0125] Assign component names to the encapsulated different chart components respectively, and map the component names to the second field;
[0126] In step S6, the step of selecting and loading a chart component according to the chart type and selecting and calling a rendering method according to the first field includes:
[0127] The chart component is selected and loaded according to the second field, and the rendering method is selected and called according to the first field.
[0128] In this embodiment, for example, the second field includes 1, 2, and 3. Field 1 represents a line chart, field 2 represents a bar chart, and field 3 represents a ring chart. Using fields to identify chart types facilitates computer recognition. When the computer calls a chart component, the second field is directly identified, and the component is determined and called according to the mapping relationship, which is convenient and fast, and effectively improves the computer response speed.
[0129] The present application associates different preset interfaces with corresponding chart pages and favorites pages respectively, and sets different rendering methods in the preset interfaces, and selects the rendering method according to the first field, thereby realizing the reuse of rendering methods, reducing the code error rate while also meeting the demand for diverse rendering forms of different charts. Different chart components are encapsulated and called according to the chart type, so that different chart components can be set according to requirements to display data, that is, the display form of data is not unique. The present application separately calls the chart components, rendering methods and data acquisition by means of the chart type, the first field and the query conditions, so that the present solution has good scalability and maintainability, and can adjust the chart components, rendering methods, etc. according to actual needs without interfering with other functions. At the same time, the required chart data in the database is selected according to the query conditions, so that different chart data in the database can be flexibly displayed on the favorites page according to the needs of the query conditions, thereby avoiding the data displayed on the favorites page being fixed.
[0130] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0131] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0132] Further references Figure 3 , as a response to the above Figure 2 The present application provides an embodiment of a device for displaying a visual chart in real time. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0133] like Figure 3 As shown, the device 300 for displaying visual charts in real time described in this embodiment includes: a preset module 301, an association module 302, a mapping module 303, an encapsulation module 304, a detection module 305 and a generation module 306. Among them: the preset module 301 is used to set the preset rendering method in the preset interface, and associate different preset interfaces with corresponding chart pages respectively, and the rendering method is used to render charts; the association module 302 is used to identify all preset interfaces associated with the chart page, and associate the preset interface with the favorite page to achieve multiplexing of the rendering method, and the chart page is the page where the favorited and unfavorited charts are located; the mapping module 303 is used for the rendering method including the method name, each chart is identified by the first field, and the first field is mapped with the method name of the rendering method; the encapsulation module 304 is used to identify the type of each chart, according to the chart Different chart components are encapsulated according to different types; the detection module 305 is used to save and associate the current user ID and the data parameters of each current chart when it is detected that the user adds the chart to the favorites page on the chart page, wherein the data parameters include at least the chart type, the first field, the method name, and the query conditions for rendering the chart; the generation module 306 is used to determine the corresponding first field according to the user ID when it is detected that the user clicks on the favorites page, select and load the chart component according to the chart type, select and call the rendering method according to the first field, obtain the chart data in the database according to the query conditions, and generate a chart using the obtained chart data through the chart component according to the called rendering method.
[0134] In this embodiment, the rendering methods required for the charts that need to be rendered on the favorites page are from different preset interfaces, which solves the need for diverse rendering forms on the favorites page. It is achieved that the data in the database can be displayed in real time on the favorites page. The solution of the present application has good scalability and maintainability. The encapsulated chart components and rendering methods can be reused, which improves development efficiency. It is achieved that the user's favorites page displays different types of charts, that is, the display form of the data is not unique, and the chart type and data in the chart displayed after collection are changeable; the data displayed in these charts are with query conditions, that is, the data is not fixed.
[0135] The encapsulation module 304 includes a reference submodule, a first configuration submodule, a second configuration submodule and an encapsulation submodule. The reference submodule is used to use echarts as a basic library and reference the corresponding components in echarts according to the chart type; the first configuration submodule is used to receive the UI design draft and configure the chart style file according to the UI design draft; the second configuration submodule is used to configure the design file according to the preset logic; the encapsulation submodule is used to encapsulate the corresponding components, chart style files and design files in echarts to generate chart components.
[0136] The encapsulation module 304 further includes an identification submodule, a recognition submodule and a mapping submodule. The identification submodule is used to identify the chart type with the second field in advance; the recognition submodule is used to identify the second field of each chart and encapsulate different chart components according to the second field; the mapping submodule is used to assign component names to the encapsulated different chart components respectively and map the component names with the second field; the generation module is also used to select and load the chart component according to the second field and select and call the rendering method according to the first field.
[0137] The generation module includes: a judgment submodule, a first generation submodule and a second generation submodule; the judgment submodule is used to detect whether the query conditions corresponding to different charts include the saving time; the first generation submodule is used to obtain the chart data in the database corresponding to the saving time according to the saving time when the query conditions include the saving time, and generate a chart with the obtained chart data according to the called rendering method through the chart component; the second generation submodule is used to obtain the chart data in the database corresponding to the current time according to the current time when the query conditions do not include the saving time, and generate a chart with the obtained chart data according to the called rendering method through the chart component.
[0138] In some optional implementations of this embodiment, the apparatus 300 further includes: a common module, which is used to encapsulate a common ajax request in a request method for calling when rendering a chart.
[0139] The generation module also includes a verification submodule, a selection submodule and an acquisition submodule; the verification submodule is used to verify the chart in the collection page according to the saved data parameters; the selection submodule is used to select and load the chart component according to the chart type and select and call the rendering method according to the first field when the verification is passed; the acquisition submodule is used to request the database to obtain the chart data by calling a common ajax request.
[0140] The verification submodule includes an acquisition unit, a comparison unit and a passing unit. The acquisition unit is used to save the parameters of each chart in the chart page and generate corresponding chart information respectively when detecting that a user has opened the chart page; the comparison unit is used to compare the chart information with the data parameters, wherein the chart information at least includes the chart type, the first field, the method name, and the query condition for rendering the chart; the passing unit is used to pass the verification when the chart information is consistent with the data parameters, and fail the verification when the chart information is inconsistent with the data parameters.
[0141] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.
[0142] The computer device 200 includes a memory 201, a processor 202, and a network interface 203 that are interconnected and communicated through a system bus. It should be noted that the figure only shows a computer device 200 having components 201-203, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.
[0143] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.
[0144] The memory 201 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 201 can be an internal storage unit of the computer device 200, such as a hard disk or memory of the computer device 200. In other embodiments, the memory 201 can also be an external storage device of the computer device 200, such as a plug-in hard disk equipped on the computer device 200, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Of course, the memory 201 can also include both the internal storage unit of the computer device 200 and its external storage device. In this embodiment, the memory 201 is generally used to store an operating system and various application software installed on the computer device 200, such as program code of a method for displaying a visual chart in real time. In addition, the memory 201 can also be used to temporarily store various data that have been output or are to be output.
[0145] The processor 202 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 202 is generally used to control the overall operation of the computer device 200. In this embodiment, the processor 202 is used to run the program code stored in the memory 201 or process data, such as running the program code of the method for displaying a real-time visualization chart.
[0146] The network interface 203 may include a wireless network interface or a wired network interface. The network interface 203 is generally used to establish a communication connection between the computer device 200 and other electronic devices.
[0147] In this embodiment, the present application implements the display of different types of charts on the user's favorites page, that is, the data display format is not unique, and the chart type and data in the chart displayed after collection are changeable; that is, it is possible to display real-time data in the database through charts on the favorites page.
[0148] The present application also provides another embodiment, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores a program for displaying visual charts in real time, and the program for displaying visual charts in real time can be executed by at least one processor so that the at least one processor performs the steps of the method for displaying visual charts in real time as described above.
[0149] In this embodiment, the present application realizes that different types of charts can be displayed on the user's favorites page, that is, the display form of data is not unique, and the chart type and data in the chart displayed after collection are changeable; that is, the real-time data in the database can be displayed through charts on the favorites page.
[0150] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0151] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0152] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
Claims
1. A method for displaying a visual chart in real time, characterized in that: The steps include: Setting a preset rendering method in a preset interface, and associating different preset interfaces with corresponding chart pages respectively, wherein the rendering method is used to render the chart; Identify all preset interfaces associated with a chart page, and associate the preset interfaces with a favorite page to achieve multiplexing of rendering methods, wherein the chart page is a page where favorited and unfavorited charts are located; The rendering method includes a method name, each chart is identified by a first field, and the first field is mapped to the method name of the rendering method; Identify the chart type of each chart, and encapsulate different chart components according to different chart types; When it is detected that a user adds the chart to the favorites page on the chart page, the current user ID and the data parameters of each current chart are saved and associated, wherein the data parameters at least include the chart type, the first field, the method name, and the query condition for rendering the chart; as well as When it is detected that the user clicks on the favorites page, the corresponding first field is determined according to the user ID, the chart component is selected and loaded according to the chart type, the rendering method is selected and called according to the first field, the chart data in the database is obtained according to the query conditions, and the chart component generates a chart using the obtained chart data according to the called rendering method.
2. The method for displaying a real-time visual chart according to claim 1, characterized in that: The steps of encapsulating different chart components according to different chart types include: Use echarts as the basic library and reference the corresponding components in echarts according to the chart type; Receive UI design drafts and configure chart style files according to the UI design drafts; Configure the design file according to the preset logic; Encapsulate the corresponding components, chart style files and design files in echarts to generate chart components.
3. The method for displaying a real-time visual chart according to claim 1, characterized in that: The step of identifying the chart type of each chart and packaging different chart components according to different chart types includes: Pre-identify the chart type with the second field; identifying a second field of each chart, and encapsulating different chart components according to the second field; Assign component names to the encapsulated different chart components respectively, and map the component names to the second field; The steps of selecting and loading a chart component according to the chart type, and selecting and calling a rendering method according to the first field include: The chart component is selected and loaded according to the second field, and the rendering method is selected and called according to the first field.
4. The method for displaying a real-time visual chart according to claim 1, characterized in that: The steps of obtaining chart data in a database according to query conditions and generating a chart using a chart component according to the called rendering method include: Check whether the query conditions corresponding to different charts include the saving time; If the query condition includes the saving time, then the chart data in the database corresponding to the saving time is obtained according to the saving time, and the chart component generates a chart with the obtained chart data according to the called rendering method; If the query condition does not include the saved time, the chart data in the database corresponding to the current time is obtained according to the current time, and the chart component generates a chart using the obtained chart data according to the called rendering method.
5. The method for displaying a real-time visual chart according to claim 1, characterized in that: The step of identifying all preset interfaces associated with the chart page, after the step of associating the preset interfaces with the favorites page, further includes: Encapsulate the common Ajax request in a request method for calling when rendering the chart; The steps of selecting a loaded chart component according to the chart type and selecting a calling rendering method according to the first field include: Verify the chart in the favorites page according to the saved data parameters; If the verification is successful, the chart component selected and loaded according to the chart type, and the rendering method selected and called according to the first field; By calling the public Ajax request, request the database to obtain the chart data.
6. The method for displaying a real-time visual chart according to claim 5, characterized in that: The step of verifying the chart in the favorites page according to the saved data parameters includes: When it is detected that a user opens a chart page, the parameters of each chart in the chart page are saved, and corresponding chart information is generated respectively; comparing the chart information with the data parameters, wherein the chart information includes at least a chart type, a first field, and a method name; If the chart information is consistent with the data parameters, the verification is passed.
7. The method for displaying a real-time visualization chart according to any one of claims 1 to 6, characterized in that: The step of setting the preset rendering mode in the preset interface includes: The preset interface is provided with different modules, and the preset rendering methods are set in the different modules.
8. A device for displaying a real-time visual chart, characterized in that: include: A preset module, used to set a preset rendering method in a preset interface, and associate different preset interfaces with corresponding chart pages respectively, wherein the rendering method is used to render the chart; An association module, used to identify all preset interfaces associated with a chart page, and associate the preset interfaces with a favorite page to achieve multiplexing of rendering methods, wherein the chart page is a page where favorited and unfavorited charts are located; A mapping module, for rendering a mode including a mode name, identifying each chart with a first field, and mapping the first field with the mode name of the rendering mode; The encapsulation module is used to identify the type of each chart and encapsulate different chart components according to the chart type; A detection module, for saving and associating a current user ID with data parameters of each current chart when detecting that a user adds the chart to a favorites page on a chart page, wherein the data parameters at least include a chart type, a first field, a method name, and a query condition for rendering the chart; as well as A generation module is used to determine the corresponding first field according to the user ID when it is detected that the user clicks on the favorites page, select and load the chart component according to the chart type, select and call the rendering method according to the first field, obtain the chart data in the database according to the query conditions, and generate a chart through the chart component using the obtained chart data according to the called rendering method.
9. A computer device, characterized in that: It comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the method for displaying a real-time visual chart as described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for displaying a real-time visual chart according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Method and apparatus for bookmarking webpage
CN102830894A
Method of adding collection / user-defined collection of websites in hypertext markup language (HTML) 5 webpage
CN103064868A
