Chart configuration automatic conversion method and system based on Echarts and G2

By adopting an automatic conversion method during the migration of Echarts and G2 chart library, using dynamic registration module and deep semantic analysis technology, the problems of low migration efficiency and poor compatibility are solved, and efficient, accurate and general chart library configuration conversion is achieved.

CN119883365APending Publication Date: 2025-04-25SHENZHEN SKIEER INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411979559.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

In the prior art, chart libraries have low migration efficiency, poor compatibility and insufficient scalability. Especially when migrating from Echarts to G2, developers need to invest a lot of time in the development of manual adjustment and hard-coded tools, and these tools are difficult to deal with complex configuration structures and compatibility between multiple chart libraries.

Method used

The automatic conversion method of chart configuration based on Echarts and G2 is adopted, and efficient automatic configuration conversion from Echarts to G2 is realized through the initialization of module registration, analysis stage, conversion stage and output generation stage. The method includes dynamic registration of parser and converter modules, deep semantic parsing and standardized configuration abstraction to ensure configuration accuracy and versatility.

Benefits of technology

It significantly improves the efficiency of chart library migration, ensures the accuracy and versatility of configuration transformations, supports compatibility and scalability between multiple chart libraries, and reduces maintenance costs and development workload.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883365A_ABST
    Figure CN119883365A_ABST
Patent Text Reader

Abstract

The invention discloses an automatic chart configuration conversion method and system based on Echarts and G2. Efficient automatic migration of configuration items is achieved through three stages of analysis, standardized configuration and conversion. The system adopts a modular dynamic registration design, supports flexible expansion of a resolver and a converter, solves the problems of large difference of configuration items and time consumption of migration among different chart libraries by abstracting Echarts configuration into intermediate standardized representation without chart library dependence, and has high efficiency and universality. In the analysis stage, deep semantic analysis is carried out on the configuration item, the configuration item is decomposed into a data module, a coordinate axis module, a graph module and the like according to functional modules, and the accuracy of data semantics and the correctness of a conversion result are ensured. In the conversion stage, standardized configuration is mapped into a format meeting the G2 requirement, manual adjustment is not needed, and the migration cost is greatly reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of front-end data visualization, and in particular to a method and system for automatically converting chart configurations based on Echarts and G2. Background Art

[0002] As two different chart libraries, Echarts and G2 have significant differences in their configuration item structures. Echarts' configuration usually adopts a static object structure, including directly defined configuration methods such as coordinate axes, data fields, and graphic styles, while G2 prefers dynamic programmable configuration, relying on functional data binding and chart generation models. Although their core working principles are both aimed at displaying data, they are completely different in configuration models, data structures, and semantic expressions. Therefore, when it is necessary to migrate a large number of historical projects based on Echarts to G2, developers face huge workloads and technical complexity. In the prior art, chart library migration usually relies on the following two methods:

[0003] 1. Manual migration: Developers analyze Echarts configurations item by item, manually adjust and refactor to the corresponding configurations of G2. Although this method is feasible, it is extremely inefficient and prone to configuration errors due to manual operations, especially when facing complex projects.

[0004] 2. Hard-coded tools: Some developers try to develop mapping tools between Echarts and G2, directly converting configuration items into target configurations through predefined rules. However, this method is usually only applicable to simple configuration structures and cannot handle complex semantic logic. In addition, the tool itself lacks flexibility and is difficult to adapt to changes in requirements.

[0005] The above methods have exposed the following shortcomings in actual use. For example, manual migration requires developers to spend a lot of time analyzing and adjusting configuration items one by one, which is long and costly. Hard-coded tools are usually only applicable to specific scenarios. When the configuration items contain complex nested logic or dynamic data binding, the conversion effect is poor or even completely ineffective. Hard-coded tools are difficult to extend to other chart libraries (such as D3.js, Highcharts, etc.). Once the requirements change, the tools need to be redeveloped, further increasing maintenance costs.

[0006] Therefore, how to improve the accuracy and versatility of configuration conversion while ensuring migration efficiency has become a technical problem to be solved by the present invention. Summary of the invention

[0007] The technical problem solved by the present invention is to provide a method and system for automatic conversion of chart configuration based on Echarts and G2 in response to the defects existing in the above-mentioned prior art, so as to solve the problems of low efficiency, poor compatibility and insufficient scalability in chart library migration proposed in the above-mentioned background technology.

[0008] In order to solve the above technical problems, the technical solution adopted by the present invention is as follows:

[0009] A method for automatically converting chart configuration based on Echarts and G2, the method comprising the following steps:

[0010] Step 1, initialize module registration:

[0011] Register the parser module and load the parser used to parse the Echarts chart configuration into the system;

[0012] Register the converter module to load the converter used to generate the G2 chart configuration into the system;

[0013] Step 2: Receive configuration items entered by the user:

[0014] Receive input data containing Echarts chart configuration;

[0015] Specify the target chart library as G2 according to user needs;

[0016] Step 3, parsing phase:

[0017] Call the parser module to parse the input Echarts chart configuration, decompose the configuration items according to functional modules, and generate standardized configuration;

[0018] The functional modules include a data module, a coordinate axis module, a graphic module, a numerical label module and a prompt box module;

[0019] Step 4, conversion phase:

[0020] Calling the converter module to generate configuration items of the target chart library G2 according to the standardized configuration;

[0021] The conversion includes mapping the common data fields, coordinate axis styles, graphic types and parameters of the standardized configuration to the G2 configuration format;

[0022] Step 5, output generation phase:

[0023] Outputs complete configuration item values ​​that conform to the G2 configuration format and ensure compatibility with the target chart library.

[0024] As a further solution of the present invention, the generation of the standardized configuration includes:

[0025] Extract the data fields in the original Echarts configuration into a unified data structure;

[0026] Parse the axis module to extract axis type, bound data fields, scale information, and style;

[0027] Parse the graphics module to identify the chart type and its drawing parameters;

[0028] Parse the numerical label module to identify the display rules, formatting methods and styles of labels;

[0029] Extract the triggering method, formatting string, and display style of the prompt box module.

[0030] As a further solution of the present invention, the parser module adopts a dynamic registration method, and the dynamic registration of the parser includes:

[0031] Batch load parser code files;

[0032] Automatically register the parser module to the system according to the parser's configured name;

[0033] Provides a unified interface to call the specified parser and parse the input configuration items.

[0034] As a further solution of the present invention, the converter module adopts a dynamic registration method, and the dynamic registration of the converter includes:

[0035] Batch load converter code files;

[0036] Automatically register the converter module to the system according to the converter's configured name;

[0037] Provides a unified interface to call the specified converter and convert the standardized configuration to the configuration format of the target chart library.

[0038] As a further solution of the present invention, the step of generating the standardized configuration further includes:

[0039] Perform deep semantic analysis on the multi-dimensional data structure in Echarts configuration;

[0040] Automatically associate data fields with corresponding functional modules;

[0041] Eliminate the semantic differences between Echarts configuration and G2 configuration by abstracting the data format.

[0042] As a further solution of the present invention, the conversion stage includes:

[0043] According to the data module in the standardized configuration, map the data fields to the table fields of the G2 configuration;

[0044] According to the analysis results of the axis module, configure the axis type, style and binding field of G2;

[0045] According to the analysis results of the graphics module, set the graphics type and drawing parameters of G2;

[0046] According to the parsing results of the value label module, set the value label style and display position of G2;

[0047] Configure the prompt box style and interaction method of G2 according to the analysis results of the prompt box module.

[0048] As a further solution of the present invention, the output generation stage includes:

[0049] Output the configuration items of the target chart library in JSON format;

[0050] Verify the compatibility of the output configuration items with the target chart library;

[0051] Loads and renders the final chart in the target chart library.

[0052] A system constructed based on the automatic conversion method of Echarts and G2 chart configuration, the system comprising:

[0053] A parser module, used to perform the steps of the parsing stage in claim 1, parse the Echarts chart configuration and generate a standardized configuration;

[0054] A converter module, configured to perform the steps of the conversion phase in claim 1, mapping the standardized configuration into a configuration format of a target chart library G2;

[0055] A core scheduling module, used to call the parser module and the converter module according to the conversion requirements input by the user;

[0056] The output generation module is used to execute the steps of the output generation phase in claim 1, output the configuration items of the target chart library G2 and verify its compatibility.

[0057] Compared with the prior art, the present invention has the following beneficial effects:

[0058] 1. The method of realizing efficient and automated configuration conversion from Echarts to G2 through three stages of parsing, standardized configuration and conversion avoids the inefficiency of manually adjusting configuration items in traditional technologies. Through the parser and converter modules, the original Echarts configuration can be automatically converted to a configuration format that meets the requirements of G2, without the need for manual adjustment item by item, which greatly improves the efficiency of configuration migration.

[0059] 2. Introducing a standardized configuration abstraction method, by abstracting the original configuration into an intermediate representation that does not depend on the chart library, configuration conversion between different chart libraries becomes possible. This abstraction is not only applicable to the migration between Echarts and G2, but also supports expansion to other chart libraries (such as D3.js, Highcharts, etc.), providing a technical foundation for the coexistence or switching of multiple chart libraries in the future, with good versatility and extensibility.

[0060] 3. The system adopts a modular dynamic registration method, and supports dynamic expansion on demand by batch loading parser and converter code files. Both the parser module and the converter module can be connected to the new chart library or functional component through a simple registration mechanism, which ensures the flexibility and maintainability of the technical solution, and splits complex configuration items into functional units such as data module, coordinate axis module, graphic module, numerical label module and prompt box module. This process not only extracts the core semantic relationship in the configuration item, but also ensures the correctness of the configuration semantics during the conversion process through one-to-one mapping with the target chart library format. Especially for multi-dimensional data structures or complex configuration logic, deep semantic parsing technology ensures the accuracy of the conversion.

[0061] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0063] Figure 1 This is a technical flow chart of the automatic conversion method of the chart configuration based on Echarts and G2 of the present invention. DETAILED DESCRIPTION

[0064] The technical solutions in the embodiments of the present invention are described clearly and completely below. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0065] See also Figure 1 In an embodiment of the present invention, a method for automatically converting a chart configuration based on Echarts and G2 is provided, and the method comprises the following steps:

[0066] Step 1, initialize module registration:

[0067] Register the parser module and load the parser used to parse the Echarts chart configuration into the system;

[0068] Register the converter module to load the converter used to generate the G2 chart configuration into the system;

[0069] Step 2: Receive configuration items entered by the user:

[0070] Receive input data containing Echarts chart configuration;

[0071] Specify the target chart library as G2 according to user needs;

[0072] Step 3, parsing phase:

[0073] Call the parser module to parse the input Echarts chart configuration, decompose the configuration items according to functional modules, and generate standardized configuration;

[0074] The functional modules include a data module, a coordinate axis module, a graphic module, a numerical label module and a prompt box module;

[0075] Step 4, conversion phase:

[0076] Calling the converter module to generate configuration items of the target chart library G2 according to the standardized configuration;

[0077] The conversion includes mapping the common data fields, coordinate axis styles, graphic types and parameters of the standardized configuration to the G2 configuration format;

[0078] Step 5, output generation phase:

[0079] Outputs complete configuration item values ​​that conform to the G2 configuration format and ensure compatibility with the target chart library.

[0080] As a further solution of the present invention, the generation of the standardized configuration includes:

[0081] Extract the data fields in the original Echarts configuration into a unified data structure;

[0082] Parse the axis module to extract axis type, bound data fields, scale information, and style;

[0083] Parse the graphics module to identify the chart type and its drawing parameters;

[0084] Parse the numerical label module to identify the display rules, formatting methods and styles of labels;

[0085] Extract the triggering method, formatting string, and display style of the prompt box module.

[0086] As a further solution of the present invention, the parser module adopts a dynamic registration method, and the dynamic registration of the parser includes:

[0087] Batch load parser code files;

[0088] Automatically register the parser module to the system according to the parser's configured name;

[0089] Provides a unified interface to call the specified parser and parse the input configuration items.

[0090] As a further solution of the present invention, the converter module adopts a dynamic registration method, and the dynamic registration of the converter includes:

[0091] Batch load converter code files;

[0092] Automatically register the converter module to the system according to the converter's configured name;

[0093] Provides a unified interface to call the specified converter and convert the standardized configuration to the configuration format of the target chart library.

[0094] As a further solution of the present invention, the step of generating the standardized configuration further includes:

[0095] Perform deep semantic analysis on the multi-dimensional data structure in Echarts configuration;

[0096] Automatically associate data fields with corresponding functional modules;

[0097] Eliminate the semantic differences between Echarts configuration and G2 configuration by abstracting the data format.

[0098] As a further solution of the present invention, the conversion stage includes:

[0099] According to the data module in the standardized configuration, map the data fields to the table fields of the G2 configuration;

[0100] According to the analysis results of the axis module, configure the axis type, style and binding field of G2;

[0101] According to the analysis results of the graphics module, set the graphics type and drawing parameters of G2;

[0102] According to the parsing results of the value label module, set the value label style and display position of G2;

[0103] Configure the prompt box style and interaction method of G2 according to the analysis results of the prompt box module.

[0104] As a further solution of the present invention, the output generation stage includes:

[0105] Output the configuration items of the target chart library in JSON format;

[0106] Verify the compatibility of the output configuration items with the target chart library;

[0107] Loads and renders the final chart in the target chart library.

[0108] A system constructed based on the automatic conversion method of Echarts and G2 chart configuration, the system comprising:

[0109] A parser module, used to perform the steps of the parsing stage in claim 1, parse the Echarts chart configuration and generate a standardized configuration;

[0110] A converter module, configured to perform the steps of the conversion phase in claim 1, mapping the standardized configuration into a configuration format of a target chart library G2;

[0111] A core scheduling module, used to call the parser module and the converter module according to the conversion requirements input by the user;

[0112] The output generation module is used to execute the steps of the output generation phase in claim 1, output the configuration items of the target chart library G2 and verify its compatibility.

[0113] See also Figure 1 , shows a technical flow chart of an automatic conversion method for chart configuration based on Echarts and G2. The whole process starts with the initialization module registration and is mainly divided into the parsing stage and the conversion stage. The system first registers parsers (such as Echarts parsers) and converters (such as G2 converters) in batches to form a dynamically scalable modular architecture. The Echarts configuration items entered by the user are parsed into standardized configurations by the parser module, and then the configuration items of the target chart library (such as G2) are generated by the converter module.

[0114] In the initial stage, the system provides support for subsequent configuration parsing and conversion by batch registering parser and converter modules. For example, the Echarts parser is responsible for parsing the original Echarts configuration, and the G2 converter is used to map the standardized configuration to the G2 format. The registration mechanism supports dynamic loading, which is convenient for subsequent expansion of other chart libraries. The user provides the Echarts configuration items that need to be converted, and specifies the required parser (such as the Echarts parser) and the target converter (such as the G2 converter). The system will determine whether the corresponding parser and converter exist, and prompt an error if they do not exist. If the specified parser exists, the system executes the Echarts parser, decomposes the input Echarts configuration according to the functional module, and generates a standardized configuration. Specifically, the following steps are included: Extract the configuration of "analyze data" to generate a common data structure. Extract the configuration of "coordinate axis" to parse the type and binding field of the x-axis and y-axis. Extract the configuration of "value label" to identify the data points on the chart. Extract the configuration of "tooltip" for the prompt box interaction logic. Extract other attribute configurations related to the chart.

[0115] The system passes the parsed standardized configuration to the specified G2 converter and performs the following steps: Generate the corresponding coordinate axis (such as linear axis, category axis). Generate value labels (such as the value mark displayed at the top). Generate chart graphics (such as line charts, bar charts). Generate the interactive style configuration of "tooltip". Generate other personalized settings related to the chart library. After the conversion is completed, the system outputs the configuration items that conform to the G2 format, and the user can directly load it into the target chart library for rendering.

[0116] Parsers and converters are flexibly extended through a registration mechanism, which not only supports the conversion from Echarts to G2, but also facilitates expansion to other chart libraries such as D3.js or Highcharts. The intermediate representation generated during the parsing phase ensures the consistency of data semantics and provides technical support for efficient and accurate conversion. Users only need to provide input configuration and target requirements, and the entire conversion process is fully automated, significantly improving migration efficiency.

[0117] Embodiment 1:

[0118] This embodiment takes a typical usage scenario of realizing automatic conversion between Echarts and G2 chart configuration as an example to illustrate in detail the specific implementation method and technical effect of the present invention.

[0119] The present invention realizes efficient and automatic conversion from Echarts configuration to G2 configuration through three stages: input parsing, core processing and output generation. The following code implementation details are combined to explain how to convert Echarts configuration to G2 configuration, showing the specific functions of each functional module of the system.

[0120] Initialize module registration. When the system starts, first batch register the parser and converter modules to provide support for subsequent automated processing: Echarts parser registration: The system dynamically loads all parser modules by traversing the file directory and automatically registers the parser to the system. The parser is responsible for parsing Echarts configuration items and generating standardized representations.

[0121]

[0122] G2 converter registration: Similar to parser registration, converter modules are also registered in batches through dynamic loading to map standardized representations to G2 configuration format.

[0123]

[0124] Receive user conversion requirements. Users pass the Echarts configuration items that need to be converted through the interface and specify the parser and converter. For example:

[0125]

[0126]

[0127] In the parsing phase, the system calls the specified Echarts parser to decompose the input Echarts configuration into a standardized configuration representation, including the following steps:

[0128] Data module: extracts xAxis.data and series.data and generates common data structures.

[0129]

[0130] Axis module: parse axis types and binding fields.

[0131]

[0132] Graphics module: Identify chart types and their parameters, such as style configuration for bar charts.

[0133] Numeric Label Module: Identifies the logic of the numeric labels above the data points.

[0134] The final standardized configuration structure is as follows:

[0135]

[0136]

[0137] Graphics module: Identify chart types and their parameters, such as style configuration for bar charts.

[0138] Numeric Label Module: Identifies the logic of the numeric labels above the data points.

[0139] The final standardized configuration structure is as follows:

[0140]

[0141] In the execution conversion phase, the standardized configuration is passed to the G2 converter, and the system calls each functional module in the converter in turn to map the standardized configuration to the G2 format. The converter generates:

[0142] Axes: Define the type, title, and style of the x-axis and y-axis.

[0143] Chart Graphics: Defines the drawing style of the bar chart.

[0144] Tooltip: Configure the data prompt behavior when the mouse hovers.

[0145] Other G2 supported personalization settings.

[0146] The converted G2 configuration is as follows:

[0147]

[0148]

[0149] Users apply the converted G2 configuration directly to the G2 chart instance without additional adjustments:

[0150] const chart=new Chart({container:"container"});

[0151] chart.options(g2Options);

[0152] chart.render();

[0153] Through the above process, this embodiment demonstrates the automated parsing and conversion process of the present invention, which significantly improves the efficiency of configuration migration; standardized configuration abstraction eliminates semantic differences between chart libraries and ensures the accuracy of conversion; modular design provides flexibility for subsequent support of other chart libraries to meet the needs of multiple scenarios.

[0154] Embodiment 2:

[0155] This embodiment takes the actual application scenario of an enterprise migrating from Echarts to G2 in a front-end project as an example to illustrate in detail the specific implementation methods of the present invention and its significant effects.

[0156] For example, an enterprise has long used Echarts as its core tool for data visualization and has accumulated a large number of configuration items based on Echarts. These configurations are widely used in various charts, such as bar charts, line charts, scatter charts, etc., to display financial data, user behavior analysis and operational indicators. However, with the continuous development of the enterprise's business and the need for performance optimization, the enterprise decided to adopt the G2 chart library with higher flexibility and better performance. However, due to the differences in structure, semantics and implementation between Echarts and G2 configuration items, the migration process has the following challenges: Echarts configuration items are statically defined, while G2 relies more on dynamic programming mode. Direct migration requires manual parsing of the semantic logic of each configuration item and reconstruction one by one, which is time-consuming and error-prone; the enterprise's existing Echarts configuration items are highly complex, and some charts contain multidimensional data structures, dynamically bound fields and complex interactive logic. Traditional point-to-point mapping tools cannot meet the needs; the enterprise hopes to be able to flexibly switch chart libraries in the future, so the migration tool is required to be universal, rather than just supporting a single conversion from Echarts to G2.

[0157] In order to solve the above problems, the present invention provides a method and system for automatic conversion of chart configuration based on Echarts and G2, which realizes the automatic migration from Echarts configuration to G2 configuration through three stages of parsing, standardized configuration and conversion. The specific steps are as follows:

[0158] First, before the migration begins, the system initializes the parser and converter modules through a modular dynamic registration mechanism. The parser module is used to extract the semantic information of the Echarts configuration, and the converter module is used to map the standardized configuration to the G2 format. The registration mechanism supports on-demand expansion. For example, if you need to migrate to other chart libraries later, you only need to add the corresponding converter module without reconstructing the core logic.

[0159] During the migration process, the system receives the Echarts configuration items provided by the user as input, such as the following bar chart configuration:

[0160]

[0161]

[0162] The system first calls the parser module to perform semantic analysis on the configuration item. The parser decomposes the configuration item according to the functional module, for example:

[0163] The data module extracts data fields and abstracts the values ​​in xAxis.data and series.data into a standardized format:

[0164]

[0165] The axis module parses axis types, binding fields and styles:

[0166]

[0167] The graphics module parses the chart type and drawing parameters, identifies it as a bar chart type and extracts the relevant style configuration.

[0168] After parsing is completed, the system generates a standardized configuration as an intermediate representation without relying on Echarts or G2 itself.

[0169] The system then calls the converter module to map the standardized configuration into the format required by G2:

[0170]

[0171]

[0172] Finally, the system generates the G2 configuration as output for users to load directly into the G2 framework without additional adjustments. This process is completed automatically without manual intervention, thus significantly improving the migration efficiency.

[0173] This embodiment achieves the following effects in the following ways: through the introduction of standardized configuration, the system can accurately parse complex Echarts configuration items and abstract common data structures, solving the problem of configuration logic complexity; through the modular dynamic registration mechanism, the parser and converter modules can be expanded on demand, so that the system not only supports the conversion between Echarts and G2, but can also be extended to other chart libraries, showing good versatility and flexibility; the parsing stage deeply parses semantic information such as data fields, coordinate axes, and graphic parameters, ensuring the semantic consistency and logical correctness of complex configuration items after migration, and avoiding the common problems of function loss or data errors in traditional methods. As a result, the present invention not only significantly reduces the migration cost and development workload, but also provides a universal technical foundation for future multi-chart library switching.

[0174] Embodiment 3:

[0175] This embodiment takes a visual report scenario of cross-departmental team collaboration as an example to illustrate the specific application of the present invention and its significant technical effects.

[0176] The marketing department and the finance department of a large enterprise have long used different chart tools for data display. The marketing department mainly develops visualization reports based on Echarts, while the finance department uses G2 to build its internal data analysis dashboard. Due to the different chart libraries of the two departments, there are significant differences in data formats and semantic structures of configuration items, which leads to the following problems:

[0177] Whenever it is necessary to merge the visualization reports of the two departments to generate a unified corporate annual report, dedicated developers are required to manually reconstruct the Echarts configuration provided by the marketing department into the G2 configuration, which is time-consuming and error-prone.

[0178] Due to the complex structure of the Echarts configuration items of the marketing department, including nested multi-dimensional arrays, dynamic data fields and complex interaction logic, traditional point-to-point mapping tools cannot effectively handle these configuration items, and data loss or functional abnormalities often occur after migration.

[0179] Both departments hope to unify data visualization tools in the future, but during the transition period, they need to support the coexistence of two chart libraries, so the migration tool is required to have good versatility and scalability.

[0180] In order to solve the above problems, the present invention is based on the automatic conversion method of Echarts and G2 chart configuration. Through the three stages of parsing, standardized configuration and conversion, the Echarts configuration of the marketing department is quickly migrated to the G2 format used by the finance department. The specific implementation method is as follows:

[0181] First, the system receives the Echarts configuration items provided by the marketing department. The following is a sample configuration showing the marketing quarterly revenue:

[0182]

[0183]

[0184] The system first calls the parser module to parse the semantic logic of the Echarts configuration and decompose it into standardized configurations:

[0185] The data module extracts the revenue data and its associated time fields and converts them into a standardized data structure:

[0186]

[0187] The axis module parses the type and style of the x-axis and y-axis:

[0188]

[0189] The graphics module identifies the chart type and its parameters, marks the line chart as a smoothing type and records the relevant configuration.

[0190] After parsing, the system generates a standardized configuration representation as the semantic middle layer between Echarts and G2. Then, the system calls the converter module to generate the target G2 configuration based on the standardized configuration:

[0191]

[0192]

[0193] After receiving the generated G2 configuration, the Finance Department can directly load and render it in its internal dashboard to display marketing and financial data in a unified format, without the need to manually adjust configuration items.

[0194] This embodiment automatically completes configuration migration through parsing and conversion modules, avoiding the inefficiency and potential errors caused by manual adjustment; deep semantic parsing technology ensures that dynamic fields, interaction logic and styles in complex configuration items are completely retained, solving the problems of data loss and functional abnormalities in traditional tools. At the same time, since the system adopts a modular dynamic registration design, if other chart libraries (such as D3.js or Highcharts) need to be supported in the future, it only needs to add corresponding parser and converter modules without changing the core logic.

[0195] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above and that the present invention can be implemented in other specific forms without departing from the spirit or essential features of the present invention. Therefore, the embodiments should be considered exemplary and non-restrictive in all respects, and the scope of the present invention is defined by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims be included in the present invention.

Claims

1. A method for automatic conversion of chart configuration based on Echarts and G2, characterized in that: The method comprises the following steps: Step 1, initialize module registration: Register the parser module and load the parser used to parse the Echarts chart configuration into the system; Register the converter module to load the converter used to generate the G2 chart configuration into the system; Step 2: Receive configuration items entered by the user: Receive input data containing Echarts chart configuration; Specify the target chart library as G2 according to user needs; Step 3, parsing phase: Call the parser module to parse the input Echarts chart configuration, decompose the configuration items according to functional modules, and generate standardized configuration; The functional modules include a data module, a coordinate axis module, a graphic module, a numerical label module and a prompt box module; Step 4, conversion phase: Calling the converter module to generate configuration items of the target chart library G2 according to the standardized configuration; The conversion includes mapping the common data fields, coordinate axis styles, graphic types and parameters of the standardized configuration to the G2 configuration format; Step 5, output generation phase: Outputs complete configuration item values ​​that conform to the G2 configuration format and ensure compatibility with the target chart library.

2. The method for automatically converting chart configuration based on Echarts and G2 according to claim 1, characterized in that: The generation of the standardized configuration includes: Extract the data fields in the original Echarts configuration into a unified data structure; Parse the axis module to extract axis type, bound data fields, scale information, and style; Parse the graphics module to identify the chart type and its drawing parameters; Parse the numerical label module to identify the display rules, formatting methods and styles of labels; Extract the triggering method, formatting string, and display style of the prompt box module.

3. The method for automatically converting chart configuration based on Echarts and G2 according to claim 1, characterized in that: The parser module adopts a dynamic registration method, and the dynamic registration of the parser includes: Batch load parser code files; Automatically register the parser module to the system according to the parser's configured name; Provides a unified interface to call the specified parser and parse the input configuration items.

4. The method for automatically converting chart configuration based on Echarts and G2 according to claim 1, characterized in that: The converter module adopts a dynamic registration method, and the dynamic registration of the converter includes: Batch load converter code files; Automatically register the converter module to the system according to the converter's configured name; Provides a unified interface to call the specified converter and convert the standardized configuration to the configuration format of the target chart library.

5. The method for automatically converting chart configuration based on Echarts and G2 according to claim 1, characterized in that: The step of generating the standardized configuration further comprises: Perform deep semantic analysis on the multi-dimensional data structure in Echarts configuration; Automatically associate data fields with corresponding functional modules; Eliminate the semantic differences between Echarts configuration and G2 configuration by abstracting the data format.

6. The method for automatically converting chart configuration based on Echarts and G2 according to claim 1, characterized in that: The conversion phase includes: According to the data module in the standardized configuration, map the data fields to the table fields of the G2 configuration; According to the analysis results of the axis module, configure the axis type, style and binding field of G2; According to the analysis results of the graphics module, set the graphics type and drawing parameters of G2; According to the parsing results of the value label module, set the value label style and display position of G2; Configure the prompt box style and interaction method of G2 according to the analysis results of the prompt box module.

7. The method for automatically converting chart configuration based on Echarts and G2 according to claim 1, characterized in that: The output generation phase includes: Output the configuration items of the target chart library in JSON format; Verify the compatibility of the output configuration items with the target chart library; Loads and renders the final chart in the target chart library.

8. The system constructed based on the automatic conversion method of chart configuration between Echarts and G2 according to claim 1, characterized in that: The system comprises: A parser module, used to perform the steps of the parsing stage in claim 1, parse the Echarts chart configuration and generate a standardized configuration; A converter module, configured to perform the steps of the conversion phase in claim 1, mapping the standardized configuration into a configuration format of a target chart library G2; A core scheduling module, used to call the parser module and the converter module according to the conversion requirements input by the user; The output generation module is used to execute the steps of the output generation phase in claim 1, output the configuration items of the target chart library G2 and verify its compatibility.