Chart display method and device, electronic equipment and storage medium
By using conversion scripts in the Draw.io application to convert the chart text generated by PlantUML into a supported format, the problem that PlantUML charts cannot be displayed in the Draw.io application is solved, and the cross-platform display ability of charts is realized.
Patent Information
- Application Number
- CN202411584739.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-07
- Publication Date
- 2025-03-04
AI Technical Summary
The existing technology cannot directly display chart text written through the PlantUML tool in the Draw.io application, resulting in the inability to take into account the drawing display capabilities of a specific application on the basis of simplifying the drawing workflow.
By serially calling the preconfigured first conversion script and the second conversion script, the first format chart text generated by the PlantUML tool is converted into the third format chart text supported by Draw.io, realizing the display of the chart drawn by the PlantUML tool in the Draw.io application.
It implements the display of charts drawn by PlantUML tool in the Draw.io application, simplifies the user's drawing process, while taking into account the display function of charts in general applications.
Smart Images

Figure CN119558276A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of chart processing, and in particular to a chart display method, device, electronic device and storage medium. Background Art
[0002] PlantUML is a tool that allows developers to use code to write design diagrams. It can be used to draw timing diagrams, flow charts, class diagrams, use case diagrams, mind maps, etc., which can simplify the diagram drawing work of developers; however, the diagrams drawn with PlantUML are essentially a domain-specific language and require special parsing tools to be displayed normally; for example, the diagrams drawn with PlantUML cannot be directly displayed in the Draw.io application, resulting in the inability to take into account the drawing display capabilities of specific applications while simplifying the drawing workflow. Summary of the invention
[0003] The present disclosure provides a method, device, electronic device and storage medium for displaying a chart. The technical solution is as follows:
[0004] According to one aspect of the present disclosure, a diagram display method is provided, the method comprising:
[0005] Acquire a first chart text in a first format that needs to be displayed in a target application, where the first chart text is generated by coding, and the target application does not support displaying the chart text in the first format;
[0006] Performing format conversion processing on the first chart text by using a first conversion script to obtain a second chart text in a second format, wherein the second chart text is used to describe chart shape information;
[0007] Performing format conversion processing on the second chart text by using a second conversion script to obtain a third chart text in a third format, wherein the target application supports displaying the chart text in the third format;
[0008] In response to a display operation on the third chart text, a target chart indicated by the first chart text is displayed in the target application.
[0009] According to another aspect of the present disclosure, there is provided a chart display device, the device comprising:
[0010] An acquisition module, used for acquiring a first chart text in a first format to be displayed in a target application, wherein the first chart text is generated by coding, and the target application does not support displaying the chart text in the first format;
[0011] A first conversion module, configured to perform format conversion processing on the first chart text through a first conversion script to obtain a second chart text in a second format, wherein the second chart text is used to describe chart shape information;
[0012] A second conversion module is used to perform format conversion processing on the second chart text through a second conversion script to obtain a third chart text in a third format, and the target application supports displaying the chart text in the third format;
[0013] The display module is used for displaying the target chart indicated by the first chart text in the target application in response to the display operation on the third chart text.
[0014] According to one aspect of the present disclosure, an electronic device is provided, including: a processor and a memory storing a program, wherein the program includes instructions, and when the instructions are executed by the processor, the processor executes the above-mentioned chart display method.
[0015] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the chart presentation method as described above.
[0016] According to another aspect of the present disclosure, a computer program product is provided, the computer program product comprising computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned chart display method.
[0017] The beneficial effects brought by the technical solution provided by the embodiments of the present disclosure include at least:
[0018] The disclosed embodiment provides a chart display method: by serially calling a pre-configured first conversion script and a second conversion script, a first chart text in a first format is converted into a third chart text in a third format, and the target application supports the display of the third chart text; so that a chart text that does not support display can be converted into a chart text that supports display through multiple format conversions; when the target application is a Draw.io application and the first chart text in the first format is a PlantUML chart text, the purpose of displaying a chart drawn by a PlantUML tool in the Draw.io application can be achieved; the user can first use a simple PlantUML to draw a chart, and the drawn chart can also be displayed in a general Draw.io application, which simplifies the user's drawing process while taking into account the chart display function. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Further details, features and advantages of the present disclosure are disclosed in the following description of exemplary embodiments in conjunction with the accompanying drawings, in which:
[0020] Figure 1 A flowchart of a diagram display method according to an exemplary embodiment of the present disclosure is shown;
[0021] Figure 2 is a schematic diagram of the architecture of a chart format conversion service provided by an exemplary embodiment of the present disclosure;
[0022] Figure 3 is a schematic diagram of a chart display process provided by an exemplary embodiment of the present disclosure;
[0023] Figure 4 A flowchart of another diagram display method according to an exemplary embodiment of the present disclosure is shown;
[0024] Figure 5 It is a schematic diagram of a process of converting a PlantUML diagram text into an SVG diagram text provided by an exemplary embodiment of the present disclosure;
[0025] Figure 6 is a functional schematic diagram of a first conversion script provided by an exemplary embodiment of the present disclosure;
[0026] Figure 7 A flowchart of another diagram display method according to an exemplary embodiment of the present disclosure is shown;
[0027] Figure 8 A flowchart of another diagram display method according to an exemplary embodiment of the present disclosure is shown;
[0028] Fig. 9 A flowchart of another diagram display method according to an exemplary embodiment of the present disclosure is shown;
[0029] Fig.10 is a schematic diagram of the structure of a second conversion script provided by an exemplary embodiment of the present disclosure;
[0030] Fig.11 A schematic diagram showing a process of format conversion performed by a second conversion script provided by an exemplary embodiment of the present disclosure is shown;
[0031] Fig.12 It is a structural schematic diagram of a chart display device provided by an embodiment of the present disclosure;
[0032] Fig.13 A structural block diagram of an exemplary electronic device that can be used to implement the embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0033] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0034] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0035] The term "including" and its variations used in this document are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description. It should be noted that the concepts of "first", "second", etc. mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units. It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative and not restrictive. Those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more". The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are for illustrative purposes only, and are not used to limit the scope of these messages or information.
[0036] The solution of the present invention is described below with reference to the accompanying drawings, and the technical solution provided by the embodiment of the present invention is explained in detail through specific embodiments and their application scenarios.
[0037] In the related technology, in order to simplify the chart drawing process, researchers are accustomed to using the PlantUML tool to draw charts by writing codes. As Draw.io is a commonly used chart drawing, editing and display program, researchers often need to display charts in the Draw.io application. However, the charts written by the PlantUML tool are in the format of code text, which is a specific domain language and needs to rely on special parsing tools to be displayed normally. Therefore, the Draw.io application does not support direct display of charts drawn by the PlantUML tool. In other words, if researchers use the PlantUML tool to draw a chart, it cannot be displayed normally in the Draw.io application.
[0038] In order to solve the problems of the related art, the embodiments of the present disclosure provide a method for displaying a diagram drawn by PlantUML in the Draw.io application. Figure 1 , which shows a flowchart of a diagram display method according to an exemplary embodiment of the present disclosure. Figure 1 As shown, the method includes:
[0039] Step 101 , obtaining a first chart text in a first format that needs to be displayed in a target application, where the first chart text is generated by coding, and the target application does not support displaying the chart text in the first format.
[0040] The target application may be a Draw.io application; or the target application may be a program that can open an online webpage of the Draw.io application. For example, the target application may be a browser. By inputting the URL of the online webpage corresponding to the Draw.io application in the browser, the online interface of the Draw.io application may be opened. The following embodiments are only described by taking the Draw.io application as an example.
[0041] The purpose of the embodiment of the present disclosure is to realize the display of charts drawn by the PlantUML tool in the Draw.io application. Correspondingly, under the premise that the target application is the Draw.io application, the first chart text in the first format is a chart text drawn by the PlantUML tool, or the first chart text can also be called PlantUML chart text, which is generated by code writing, and the target application does not support the display of chart text in the first format.
[0042] Since the embodiment of the present disclosure provides a method for displaying a chart corresponding to a first chart text in a target application, after the R&D personnel use the PlantUML tool to write the first chart text, they can input or insert the first chart text in the user interface to obtain the first chart text in the first format that needs to be displayed in the target application.
[0043] Step 102: Perform format conversion processing on the first chart text by using a first conversion script to obtain a second chart text in a second format, where the second chart text is used to describe chart shape information.
[0044] In order to display the diagrams drawn by the PlantUML tool in the Draw.io application, two conversion scripts are configured to convert the diagram text drawn by the PlantUML tool into diagram text that can be opened using the Draw.io application, thereby indirectly achieving the purpose of displaying the diagrams drawn by the PlantUML tool in the Draw.io application.
[0045] Among them, the first conversion script is used to convert PlantUML chart text into SVG chart text, and the second conversion script is used to convert SVG chart text into DrawIO chart text, thereby realizing the conversion of PlantUML chart text to DrawIO chart text, and then opening the DrawIO chart text through the Draw.io application to achieve the purpose of displaying the chart drawn by the PlantUML tool in the Draw.io application.
[0046] When two conversion scripts are configured, if a chart drawn by the PlantUML tool needs to be displayed in the target application, the first conversion script is first called and run to perform format conversion processing on the first chart text through the first conversion script to obtain a second chart text in a second format, and the second chart text is used to describe the chart shape information.
[0047] Specifically, in the process of running the first conversion script, the first conversion script can call the Java library of PlantUML to convert the code description in the first diagram text into a code description in a second format (i.e., the code description in SVG format) to obtain a second diagram text in a second format (i.e., SVG diagram text in SVG format).
[0048] Step 103, performing format conversion processing on the second chart text by using a second conversion script to obtain a third chart text in a third format, and the target application supports displaying the chart text in the third format.
[0049] After obtaining the second chart text in the second format, the second conversion script is called and run to perform format conversion processing on the second chart text through the second conversion script to obtain a third chart text in the third format. The third chart text matches the chart format supported by the target application for opening, that is, the target application supports displaying chart text in the third format.
[0050] Step 104: In response to the display operation on the third chart text, display the target chart indicated by the first chart text in the target application.
[0051] After obtaining the third chart text adapted to the target application, the target application can be used to open the third chart text; the corresponding electronic device receives the display operation of the third chart text, and can display the target chart indicated by the first chart text in the target application. Through two format conversions, the purpose of displaying the chart drawn by the PlantUML tool in the Draw.io application is finally achieved.
[0052] Optionally, the format conversion capability provided by the embodiments of the present disclosure can be implemented as a partial function of the Draw.io application. When a user uses the Draw.io application to open a chart text in a first format, a first conversion script and a second conversion script are serially called in the background to convert a first chart text in the first format into a third chart text in a third format, and based on the third chart text in the third format, a final target chart is displayed in the user interface of the Draw.io application.
[0053] Optionally, the format conversion capability provided by the embodiments of the present disclosure may also be implemented as a separate application or a separate service. The user first inputs a first chart text in a first format in the user interface of the application or service to trigger the format conversion function. The background serially calls the first conversion script and the second conversion script to convert the first chart text in the first format into a third chart text in a third format, and returns the third chart text. The user then opens the third chart text through the Draw.io application.
[0054] Figure 2 FIG. 1 is a schematic diagram of the architecture of the chart format conversion service provided by the exemplary embodiment of the present disclosure. Figure 2 As shown, the PlantUML conversion service is called through the Node.js server to convert the PlantUML chart text into the SVG chart text through the PlantUML to SVG Python script (the first conversion script); and then the SVG conversion service is called to convert the SVG chart text into the DrawIO chart text through the SVG toDrawIO Python script (the second conversion script).
[0055] based on Figure 2 The architecture diagram shown in Figure 3As shown, it is a schematic diagram of a chart display process provided by an exemplary embodiment of the present disclosure. The user enters the PlantUML chart text (first chart text) in the user interface, and the corresponding Node.js server sends a POST request to the PlantUML conversion service to convert the PlantUML chart text into SVG data (second chart text) through the PlantUML to SVG Python script (first conversion script); then call the SVG conversion service to convert the SVG data into DrawIO data (third chart text) through the SVG to DrawIO Python script (second conversion script); and then display the target chart in the user interface based on the DrawIO data.
[0056] In summary, the embodiments of the present disclosure provide a method for displaying a chart: by serially calling a pre-configured first conversion script and a second conversion script, a first chart text in a first format is converted into a third chart text in a third format, and the target application supports the display of the third chart text; so that a chart text that does not support display can be converted into a chart text that supports display through multiple format conversions; when the target application is a Draw.io application and the first chart text in the first format is a PlantUML chart text, the purpose of displaying a chart drawn by the PlantUML tool in the Draw.io application can be achieved; the user can first use a simple PlantUML to draw the chart, and the drawn chart can also be displayed in a general Draw.io application, which simplifies the user's drawing process while taking into account the chart display function.
[0057] Please refer to Figure 4 , which shows a flowchart of another diagram display method according to an exemplary embodiment of the present disclosure. Figure 4 As shown, the method includes:
[0058] Step 401 , obtaining a first chart text in a first format that needs to be displayed in a target application, where the first chart text is generated by coding, and the target application does not support displaying the chart text in the first format.
[0059] The implementation of step 401 may refer to step 101 , and this embodiment will not be described in detail here.
[0060] Step 402: Perform format conversion processing on the first chart text by using a first conversion script to obtain a second chart text in a second format, where the second chart text is used to describe chart shape information.
[0061] In a possible implementation, the first conversion script calls the target code language library to convert the format of the first chart text to obtain a second chart text in a second format. Exemplarily, the target code language library is a Java library of PlantUML, and by calling the target code language library, the code description in the first chart text can be converted into a code description in a second format (i.e., a code description in SVG format) to obtain a second chart text in a second format (i.e., an SVG chart text in SVG format).
[0062] Since PlantUML can draw different types of charts, it is found that when the first conversion script converts the chart text corresponding to different types of charts, some conversion results lack the standard XML declaration corresponding to the SVG standard format, and the lack of standard XML declaration in the conversion result will affect the subsequent format conversion. After outputting the SVG conversion result, it is necessary to perform a format check on the converted text so as to determine the subsequent execution steps based on the format check result. Correspondingly, in an illustrative example, step 402 can also include steps 402A to 402C.
[0063] Step 402A: Perform format conversion processing on the first chart text by using the first conversion script to obtain a processed fifth chart text.
[0064] First, the first conversion script calls the PlantUML Java library to perform format conversion processing on the first chart text, and converts the code description in the first chart text into a code description in the second format (ie, the code description in the SVG format) to obtain a fifth chart text in the SVG format.
[0065] Step 402B, perform a standard format check on the fifth chart text to obtain a format check result.
[0066] The fifth chart text in SVG format is subjected to a standard format check, that is, whether the fifth chart text is missing a standard XML declaration, and a format check result is obtained. The format check result includes two types: a standard format and a non-standard format. The standard format indicates that the standard XML declaration is not missing, and the non-standard format indicates that the standard XML declaration is missing.
[0067] Step 402C: if the format checking result indicates that the fifth chart text complies with the standard text format corresponding to the second format, the fifth chart text is determined as the second chart text.
[0068] If the format check result indicates that the fifth chart text conforms to the standard text format corresponding to the second format (ie, SVG format), that is, the format check result is the standard format and the standard XML declaration is not missing, the converted fifth chart text can be directly determined as the second chart text.
[0069] Step 402C: if the format check result indicates that the fifth chart text does not conform to the standard text format corresponding to the second format, a standard declaration is added to the fifth chart text to obtain the second chart text.
[0070] On the contrary, if the format check result indicates that the fifth chart text does not conform to the standard text format corresponding to the second format, that is, the format check result is a non-standard format and lacks a standard XML declaration, then you first need to add a standard declaration for the fifth chart text, that is, add a standard XML declaration, and determine the fifth chart text with the standard declaration added as the converted second chart text.
[0071] Figure 5 FIG. 1 is a schematic diagram of a process of converting a PlantUML diagram text into an SVG diagram text provided by an exemplary embodiment of the present disclosure. Figure 5 As shown, during the running process of the first conversion script, it is first checked whether the PlantUML chart text (first chart text) exists. If not, it exits and displays an error message; if it exists, the PlantUML chart text is read, and the PlantUML Java library is called to convert the PlantUML chart text into an SVG chart text. If the conversion times out, a processing timeout error is displayed; if the conversion is successful, the SVG chart text format is checked. If it is a standard format, the converted SVG chart text is output; if it is a non-standard format, a standard XML declaration is added to the converted SVG chart text, and then the SVG chart text (i.e., the second chart text) is output.
[0072] Optionally, the first conversion script also has file reading and writing functions to read the first chart text and write the converted second chart text into a file system; in addition, the first conversion script also has an error handling function to capture potential timeout errors during the format conversion process.
[0073] Figure 6 Schematic diagram of the function of the first conversion script provided by the exemplary embodiment of the present disclosure. Figure 6 As shown, the first conversion script has format conversion function, read / write function and error handling function; under the format conversion function, the first conversion script calls the Java virtual machine and the PlantUML Java library to perform format conversion to output SVG chart text; under the read / write function, the first chart text to be converted is read from the file system, and the converted second chart text is written to the file system; under the error handling function, the timeout error is captured, and log information is output, etc.
[0074] Step 403: Process the identification symbol in the second chart text based on a preset symbol conversion rule to obtain a processed fourth chart text.
[0075] Since the code in the second chart text in SVG format describes the shape information of the chart, and the Draw.io application can display pictures or chart objects, that is, if the second chart text can be converted into a picture or chart object, and a chart object is created in the Draw.io application to carry the chart, it can be displayed in the Draw.io application. A first encoder is configured in the second conversion script to realize the encoding conversion of the description text of the shape information corresponding to the chart to the chart. Exemplarily, the first encoder is a Base64 encoder.
[0076] Before the second chart text in SVG format is encoded by the first encoder, some identifiers in the second chart text need to be replaced to make it more compatible with the Draw.io application and to facilitate the encoding by the first encoder. In a possible implementation, the identifiers in the second chart text can be processed based on a preset symbol conversion rule to obtain a processed fourth chart text.
[0077] Exemplarily, the preset symbol rules may include: replacing the & character in the second chart text with &; replacing the < character in the second chart text with <; replacing the > character in the second chart text with >; replacing the double quotation marks in the second chart text with "; replacing the single quotation marks in the second chart text with ' replacing the carriage return character \r\n in the second chart text with \n; replacing the line feed character \n in the second chart text with \n; replacing the carriage return character \r in the second chart text with \n; replacing the tab character \t in the second chart text with \t. The second chart text processed through the above steps is stored as escaped text (i.e., the fourth chart text).
[0078] Step 404: Encode the fourth chart text using the second conversion script to generate a target chart.
[0079] Furthermore, the fourth chart text is encoded by the first encoder (ie, Base64 encoder) in the second conversion script. Specifically, based on the graphic description text in the fourth chart text, a target chart in a picture format is analyzed and generated.
[0080] Step 405: Generate a third chart text in a third format based on the target chart.
[0081] Finally, the target chart and the fourth chart text may be merged into a third chart text in a third format.
[0082] Step 406: In response to the display operation on the third chart text, display the target chart indicated by the first chart text in the target application.
[0083] The implementation of step 406 may refer to step 104, and this embodiment will not be described in detail here.
[0084] In this embodiment, in the process of converting the first chart text into the second chart text, a format checking mechanism is also provided, and a standard declaration is added for the converted chart text that is found not to conform to the standard text format according to the format check, so as to avoid affecting the subsequent conversion from SVG format to DrawIO format and ensure the smooth execution of the subsequent format conversion; in addition, the first encoder is configured in the second conversion script so that the chart is obtained by encoding and analyzing by the first encoder, which is used for the subsequent generation of the DrawIO chart text in the third format.
[0085] Please refer to Figure 7 , which shows a flowchart of another diagram display method according to an exemplary embodiment of the present disclosure. Figure 7 As shown, the method includes:
[0086] Step 701 , obtaining a first chart text in a first format that needs to be displayed in a target application, where the first chart text is generated by coding, and the target application does not support displaying the chart text in the first format.
[0087] Step 702: Perform format conversion processing on the first chart text by using a first conversion script to obtain a second chart text in a second format, where the second chart text is used to describe chart shape information.
[0088] Step 703: Process the identification symbol in the second chart text based on a preset symbol conversion rule to obtain a processed fourth chart text.
[0089] Step 704: Encode the fourth chart text using the second conversion script to generate a target chart.
[0090] The implementation of steps 701 to 704 may refer to the above embodiment, and will not be described in detail in this embodiment.
[0091] Step 705: extracting target size information of the target chart from the fourth chart text by using the second conversion script.
[0092] Since the target chart needs to rely on the chart object created in the target application for display, in order to enable the encoded target chart to be correctly displayed in the target application, it is also necessary to clearly define the size of the created chart object; in addition to the first encoder, the corresponding second conversion script is also configured with a size extractor, so that in the process of running the second conversion script, the target size information of the target chart can be extracted from the fourth chart text through the size extractor in the second conversion script; the target size information may include the width and height information of the target chart.
[0093] Step 706: Generate a third chart text in a third format based on the target chart and the target size information.
[0094] Correspondingly, a third chart text in a third format may be generated based on the target chart, the target size information, and the fourth chart text.
[0095] Step 707: In response to the display operation on the third chart text, a chart object matching the target size information is created in the target application.
[0096] Step 708: Display the target chart indicated by the first chart text in the target application through a chart object.
[0097] In the case where the third chart text includes a target chart and target size information, when the third chart text is opened using a target application, the target size information is first obtained from the third chart text, and based on the target size information, a chart object matching the target size information is created in the target application, and then the target chart is placed in the chart object, thereby realizing the ability to display the target chart indicated by the first chart text in the target application.
[0098] In this embodiment, by configuring a size extractor in the second conversion script, during the execution of the second conversion script, the target size information is extracted from the fourth chart text by the size extractor in the second conversion script, thereby facilitating the subsequent creation of a chart object of adapted size to display the target chart.
[0099] Please refer to Figure 8 , which shows a flowchart of another diagram display method according to an exemplary embodiment of the present disclosure. Figure 8 As shown, the method includes:
[0100] Step 801, obtaining a first chart text in a first format that needs to be displayed in a target application, where the first chart text is generated by coding, and the target application does not support displaying the chart text in the first format.
[0101] Step 802: Perform format conversion processing on the first chart text through a first conversion script to obtain a second chart text in a second format, where the second chart text is used to describe chart shape information.
[0102] Step 803: Process the identification symbol in the second chart text based on a preset symbol conversion rule to obtain a processed fourth chart text.
[0103] Step 804: Encode the fourth chart text using the second conversion script to generate a target chart.
[0104] Step 805: extracting target size information of the target chart from the fourth chart text by using the second conversion script.
[0105] The implementation of steps 801 to 805 may refer to the above embodiments, and will not be described in detail in this embodiment.
[0106] Step 806: Encode the first chart text through the second conversion script to obtain target code data.
[0107] Considering that after displaying the target chart, the user may still have the need to edit the target chart, and since the target chart is generated by PlantUML tool coding, if the target chart needs to be edited, the corresponding code also needs to be modified. In order to enable editing of the target chart in the target application, the second conversion script also provides a second encoder, which encodes the first chart text (code form text) in the first format through the second encoder in the second conversion script and converts it into target code data that can be displayed in the target application, so as to implement the editing operation of the target chart by editing the target code data.
[0108] Exemplarily, the second encoder may use encoding methods such as XML / HTML / URL.
[0109] Step 807: Generate a third chart text in a third format based on the target code data, the target chart and the target size information.
[0110] Further, a third chart text in a third format may be generated based on the target code data, the target chart and the target size information.
[0111] Step 808: In response to the display operation on the third chart text, display the target chart indicated by the first chart text in the target application.
[0112] The implementation of step 808 may refer to the above embodiment, and will not be described in detail in this embodiment.
[0113] Step 809, in response to the editing operation on the target chart, display the target code data in the target application.
[0114] Step 810 , in response to an editing operation on the target code data, editing the target chart in the target application.
[0115] If the user needs to edit the target chart, the editing operation on the target chart can be triggered, and the target code data will be displayed in the target application accordingly; the user can modify the target code data according to the editing requirements, and correspondingly receive the editing operation on the target code data, and edit the target chart in the target application according to the edited target code data.
[0116] In this embodiment, by encoding the first chart text, target code data that can be compatible with display in the Draw.io application is obtained, and then by editing the target code data, the target chart displayed in the target application can be edited.
[0117] In other possible scenarios, when displaying the target chart, there is a need to view the chart modification date. In addition to the above information, there is also a need to display the chart modification date. Figure 8 On the basis of Fig. 9 As shown, the method further includes step 901 , and step 807 can be replaced by step 902 .
[0118] Step 901, extracting the chart modification date from the fourth chart text by using the second conversion script.
[0119] The second conversion script is also configured with a date setter, so that when the second conversion script is run, the chart modification date can be extracted from the fourth chart text through the date setter in the second conversion script.
[0120] Step 902: Generate a third chart text in a third format based on the target code data, the target chart, the target size information and the chart modification date.
[0121] Then, based on the target code data, the target chart, the target size information and the chart modification date, a third chart text in a third format is generated. Specifically, the above information is encoded by an XML data generator to generate the third chart text. When the target chart is subsequently displayed, the chart modification date information of the target chart can be displayed.
[0122] Fig.10 is a schematic diagram of the structure of a second conversion script provided by an exemplary embodiment of the present disclosure. Fig.10 As shown, the second conversion script includes a Base64 encoder (first encoder), an XML / HTML / URL encoder (second encoder), a size extractor, a date setter, and an XML data generator.
[0123] based on Fig.10 The script structure shown is as follows Fig.11As shown, it shows a schematic diagram of the process of format conversion of the second conversion script provided by the exemplary embodiment of the present disclosure. The conversion process is: read the SVG file (i.e., the second chart text), and determine whether the file exists. If not, an error is displayed; if it exists, convert the SVG (i.e., process the identification symbol in the second chart text according to the preset symbol rule to obtain the fourth chart text), and determine whether the conversion is successful; if the conversion is unsuccessful, a processing error is displayed; if the conversion is successful, encode the SVG (i.e., perform Base64 encoding on the fourth chart text to obtain the target chart), encode the PlantUML text (i.e., encode the first chart text to obtain the target code data), extract the size (i.e., extract the target size information from the fourth chart text), set the date (extract the chart modification date from the fourth chart text), generate XML data (i.e., perform XML format encoding based on the target code data, target size information, chart modification date, and target chart), and finally output the data (i.e., output the third chart text in the third format).
[0124] In this embodiment, by configuring a date setter in the second conversion script, during the running of the second conversion script, the chart modification date is extracted from the fourth chart text through the date setter in the second conversion script, so that when the target chart is subsequently displayed in the target application, the chart modification date of the target chart can also be viewed.
[0125] Please refer to Fig.12 , which is a structural schematic diagram of a chart display device provided by an embodiment of the present disclosure. For example, Fig.12 As shown, the device 1200 includes:
[0126] An acquisition module 1201 is used to acquire a first chart text in a first format that needs to be displayed in a target application, where the first chart text is generated by coding, and the target application does not support displaying the chart text in the first format;
[0127] A first conversion module 1202 is used to perform format conversion processing on the first chart text through a first conversion script to obtain a second chart text in a second format, where the second chart text is used to describe chart shape information;
[0128] The second conversion module 1203 is used to perform format conversion processing on the second chart text through a second conversion script to obtain a third chart text in a third format, and the target application supports displaying the chart text in the third format;
[0129] The display module 1204 is used to display the target chart indicated by the first chart text in the target application in response to the display operation on the third chart text.
[0130] Optionally, the second conversion module 1203 is further configured to:
[0131] Processing the identification symbol in the second chart text based on a preset symbol conversion rule to obtain a processed fourth chart text;
[0132] Performing encoding processing on the fourth chart text by using the second conversion script to generate the target chart;
[0133] Based on the target chart, the third chart text in the third format is generated.
[0134] Optionally, the second conversion module 1203 is further configured to:
[0135] extracting target size information of the target chart from the fourth chart text by using the second conversion script;
[0136] The second conversion module 1203 is further used to include:
[0137] The third chart text in the third format is generated based on the target chart and the target size information.
[0138] Optionally, the display module 1204 is further used to:
[0139] Creating a chart object matching the target size information in the target application;
[0140] The target chart indicated by the first chart text is displayed in the target application through the chart object.
[0141] Optionally, the device further comprises:
[0142] An encoding module, used for encoding the first chart text by using the second conversion script to obtain target code data;
[0143] The second conversion module 1203 is further configured to:
[0144] generating the third chart text in the third format based on the target code data, the target chart and the target size information;
[0145] After displaying the target chart indicated by the first chart text in the target application, the apparatus further comprises:
[0146] A display module, for displaying the target code data in the target application in response to an editing operation on the target chart;
[0147] The editing module is used for editing the target chart in the target application in response to an editing operation on the target code data.
[0148] Optionally, the second conversion module 1203 is further configured to:
[0149] extracting a chart modification date from the fourth chart text by means of the second conversion script;
[0150] The second conversion module 1203 is further configured to:
[0151] The third chart text in the third format is generated based on the target code data, the target chart, the target size information and the chart modification date.
[0152] Optionally, the first conversion module 1202 is further configured to:
[0153] The first conversion script calls the target code language library to perform format conversion processing on the first chart text to obtain the second chart text in the second format.
[0154] In summary, the embodiments of the present disclosure provide a method for displaying a chart: by serially calling a pre-configured first conversion script and a second conversion script, a first chart text in a first format is converted into a third chart text in a third format, and the target application supports the display of the third chart text; so that a chart text that does not support display can be converted into a chart text that supports display through multiple format conversions; when the target application is not a Draw.io application and the first chart text in the first format is a PlantUML chart text, the purpose of displaying a chart drawn by the PlantUML tool in the Draw.io application can be achieved; the user can first use a simple PlantUML to draw the chart, and the drawn chart can also be displayed in a general Draw.io application, simplifying the user's drawing process while taking into account the chart display function.
[0155] The exemplary embodiment of the present disclosure also provides an electronic device, comprising: at least one processor; and a memory connected to the at least one processor in communication. The memory stores a computer program that can be executed by the at least one processor, and the computer program is used to cause the electronic device to perform the method according to the embodiment of the present disclosure when executed by the at least one processor.
[0156] The exemplary embodiments of the present disclosure also provide a non-transitory computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor of a computer, is used to cause the computer to perform the method according to the embodiments of the present disclosure.
[0157] The exemplary embodiments of the present disclosure further provide a computer program product, including a computer program, wherein when the computer program is executed by a processor of a computer, the computer is used to enable the computer to perform the method according to the embodiments of the present disclosure.
[0158] refer to Fig.13 , a block diagram of an electronic device 1300 that can be used as a server or client of the present disclosure will now be described, which is an example of a hardware device that can be applied to various aspects of the present disclosure. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0159] like Fig.13 As shown, the electronic device 1300 includes a computing unit 1301, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1302 or a computer program loaded from a storage unit 1308 into a random access memory (RAM) 1303. In the RAM 1303, various programs and data required for the operation of the device 1300 can also be stored. The computing unit 1301, the ROM 1302, and the RAM 1303 are connected to each other via a bus 1304. An input / output (I / O) interface 1305 is also connected to the bus 1304.
[0160] Multiple components in the electronic device 1300 are connected to the I / O interface 1305, including: an input unit 1306, an output unit 1307, a storage unit 1308, and a communication unit 1309. The input unit 1306 can be any type of device that can input information to the electronic device 1300, and the input unit 1306 can receive input digital or character information, and generate key signal input related to user settings and / or function control of the electronic device. The output unit 1307 can be any type of device that can present information, and can include but is not limited to a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 1308 can include but is not limited to a disk, an optical disk. The communication unit 1309 allows the electronic device 1300 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks, and can include but is not limited to a modem, a network card, an infrared communication device, a wireless communication transceiver, and / or a chipset, such as a Bluetooth device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.
[0161] The computing unit 1301 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 1301 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 1301 performs the various methods and processes described above. For example, in some embodiments, Figure 1 , Figure 4 , Figure 5 , Figure 7 , Figure 8 and Fig. 9 The method shown may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as storage unit 1308. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 1300 via ROM 1302 and / or communication unit 1309. In some embodiments, computing unit 1301 may be configured to execute the computer program in any other suitable manner (e.g., by means of firmware). Figure 1 , Figure 4 , Figure 5 , Figure 7 , Figure 8 and Fig. 9 The method shown.
[0162] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0163] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, 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 foregoing.
[0164] As used in this disclosure, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and / or device (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.
[0165] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0166] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0167] A computer system may include clients and servers. Clients and servers are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other.
Claims
1. A method for displaying a chart, characterized in that: The method comprises: Acquire a first chart text in a first format that needs to be displayed in a target application, where the first chart text is generated by coding, and the target application does not support displaying the chart text in the first format; Performing format conversion processing on the first chart text by using a first conversion script to obtain a second chart text in a second format, wherein the second chart text is used to describe chart shape information; Performing format conversion processing on the second chart text by using a second conversion script to obtain a third chart text in a third format, wherein the target application supports displaying the chart text in the third format; In response to a display operation on the third chart text, a target chart indicated by the first chart text is displayed in the target application.
2. The method according to claim 1, characterized in that The step of performing format conversion processing on the second chart text by using a second conversion script to obtain a third chart text in a third format includes: Processing the identification symbol in the second chart text based on a preset symbol conversion rule to obtain a processed fourth chart text; Performing encoding processing on the fourth chart text by using the second conversion script to generate the target chart; Based on the target chart, the third chart text in the third format is generated.
3. The method according to claim 2, characterized in that The method of performing format conversion processing on the second chart text by using a second conversion script to obtain a third chart text in a third format further includes: extracting target size information of the target chart from the fourth chart text by using the second conversion script; The step of generating the third chart text in the third format based on the target chart includes: The third chart text in the third format is generated based on the target chart and the target size information.
4. The method according to claim 3, characterized in that The target chart indicated by the first chart text is displayed in the target application, comprising: Creating a chart object matching the target size information in the target application; The target chart indicated by the first chart text is displayed in the target application through the chart object.
5. The method according to claim 4, characterized in that The method further comprises: Encoding the first chart text by the second conversion script to obtain target code data; The step of generating the third chart text in the third format based on the target chart and the target size information includes: The third chart text in the third format is generated based on the target code data, the target chart and the target size information.
6. The method according to claim 5, characterized in that The method of performing format conversion processing on the second chart text by using a second conversion script to obtain a third chart text in a third format further includes: extracting a chart modification date from the second chart text by means of the second conversion script; The step of generating the third chart text in the third format based on the target code data, the target chart and the target size information comprises: The third chart text in the third format is generated based on the target code data, the target chart, the target size information and the chart modification date.
7. The method according to any one of claims 1 to 6, characterized in that: The step of performing format conversion processing on the first chart text by using a first conversion script to obtain a second chart text in a second format includes: The first conversion script calls the target code language library to perform format conversion processing on the first chart text to obtain the second chart text in the second format.
8. A chart display device, characterized in that: The device comprises: An acquisition module, used for acquiring a first chart text in a first format to be displayed in a target application, wherein the first chart text is generated by coding, and the target application does not support displaying the chart text in the first format; A first conversion module, configured to perform format conversion processing on the first chart text through a first conversion script to obtain a second chart text in a second format, wherein the second chart text is used to describe chart shape information; A second conversion module is used to perform format conversion processing on the second chart text through a second conversion script to obtain a third chart text in a third format, and the target application supports displaying the chart text in the third format; The display module is used for displaying the target chart indicated by the first chart text in the target application in response to the display operation on the third chart text.
9. An electronic device, comprising: processor; as well as Memory for storing programs, The program includes instructions, which, when executed by the processor, cause the processor to perform the method according to any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-7.