Business structure chart display method and device
By using elastic layout and parent-child relationship to generate connection lines on the display page of the business structure diagram, the problem of low efficiency in the drawing of business structure diagram in the existing technology is solved, and efficient adaptive display is achieved.
Patent Information
- Application Number
- CN202411384749.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2024-11-05
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the prior art, the drawing efficiency of business structure diagrams is low, and the location of project nodes and connection lines is required to frequently calculate the locations of project nodes and connection lines, resulting in complexity and inefficiency.
By drawing business project nodes according to project groups on the target display page and adding elastic layout attributes to each project group, using elastic layout adaptive layout, generating connection lines based on parent-child relationships, avoiding complex position calculations.
It improves the drawing efficiency of the business structure diagram, realizes adaptive display of project nodes and connection lines, and simplifies the drawing process.
Smart Images

Figure CN118897692A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the computer field, and in particular, to a method and device for displaying a business structure diagram. Background Art
[0002] As an important tool for displaying the development direction and progress of business projects, business structure diagrams are very important throughout the entire life cycle of a business. Methods that can conveniently and quickly draw business structure diagrams are also attracting more and more attention. Currently, the drawing of business structure diagrams requires redrawing all business projects and their corresponding project connection lines according to the situation of the page where the business structure diagram is drawn each time the business structure diagram is displayed. The drawing process requires constantly calculating the position of the business project nodes in the display page and the position of the connection lines. The drawing process is relatively complicated and the efficiency of drawing business structure diagrams is poor. Summary of the invention
[0003] The embodiments of the present application provide a method and device for displaying a business structure diagram, so as to at least solve the problem of poor efficiency in drawing a business structure diagram in the related art.
[0004] According to an embodiment of the present application, a method for displaying a business structure diagram is provided, comprising: receiving a display request, wherein the display request is used to request displaying a business structure diagram of a target business on a target display page according to a target direction; in response to the display request, drawing project nodes corresponding to business items included in the target business on the target display page according to project groups in the target direction, and adding target elastic layout attributes matching the target direction in the target display page in a cascading style sheet of project nodes in each project group, to obtain an initial business structure diagram of the target business, wherein the project nodes included in each project group are divided according to the parent-child relationship between the business items included in the target business; generating connecting lines between project nodes on the initial business structure diagram according to the parent-child relationship between the business items included in the target business, to obtain a target business structure diagram of the target business.
[0005] As an optional implementation, the project nodes corresponding to the business items included in the target business are drawn in the target direction according to the project grouping on the target display page, and the target elastic layout attributes matching the target direction in the target display page are added in the cascading style sheet of the project nodes in each project group, including: adding the cascading style sheet style corresponding to the elastic layout of the target direction to the target display page; drawing the project nodes of each business item using the project grouping of the business items included in the target business as the layout content of the target display page in the elastic layout of the target direction, and adding the target elastic layout attributes in the elastic layout of the target display page to each project node.
[0006] As an optional implementation, adding the cascading style sheet style corresponding to the elastic layout of the target direction to the target display page includes: creating a page element corresponding to the target display page; adding the elastic layout attributes of the target direction and the alignment attributes in a reference direction to the page element corresponding to the target display page, wherein the reference direction is perpendicular to the target direction, and the alignment attributes are used to indicate the alignment of the display content in the page element in the reference direction.
[0007] As an optional implementation, the method of adding the elastic layout attributes of the target direction and the alignment attributes in the reference direction to the page elements corresponding to the target display page includes: when the target direction is a horizontal direction, adding the elastic layout attributes of the page elements corresponding to the target display page as an elastic layout, and adding the alignment attributes of the page elements corresponding to the target display page as a vertical center alignment, wherein the default direction of the elastic layout of the page elements is a horizontal direction; when the target direction is a vertical direction, adding the elastic layout attributes of the page elements corresponding to the target display page as an elastic layout, adding the direction of the elastic layout as a vertical direction, and adding the alignment attributes of the page elements corresponding to the target display page as a horizontal center alignment.
[0008] As an optional implementation, the project grouping of the business items included in the target business as the layout content of the target display page in the elastic layout in the target direction, drawing the project nodes of each business item, and adding the target elastic layout attributes in the elastic layout of the target display page for each project node, includes: traversing each business item in order from parent to child according to the parent-child relationship between the business items included in the target business; creating a page element corresponding to the currently traversed business item, and drawing the project node of the currently traversed business item in the page element corresponding to the currently traversed business item, and adding the target elastic layout attributes to the page element of the currently traversed business item; in the currently traversed In the case where the business item currently traversed has child business items, the page element corresponding to the business item currently traversed is taken as the parent element, and the page element corresponding to the child business item of the business item currently traversed is created as the child element, and the elastic layout attribute of the reference direction is added to the page element corresponding to the child business item of the business item currently traversed, wherein the page element corresponding to the child business item is used to draw the project node of the child business item of the business item currently traversed, the parent element and the child element are a project group, and the reference direction is perpendicular to the target direction; in the case where the business item currently traversed does not have a child business item, the page element corresponding to the business item currently traversed is determined as a project group.
[0009] As an optional implementation, adding the target elastic layout attributes to the page elements of the currently traversed business item includes: adding margin attributes to the page elements of the currently traversed business item; adding elastic layout attributes of a reference direction to the page elements corresponding to the sub-business items of the currently traversed business item includes: when the target direction is a horizontal direction, adding the elastic layout attributes of the page elements corresponding to the sub-business items of the currently traversed business item as an elastic layout, and adding the direction of the elastic layout as a vertical direction; when the target direction is a vertical direction, adding the elastic layout attributes of the page elements corresponding to the sub-business items of the currently traversed business item as an elastic layout, wherein the default direction of the elastic layout of the page elements is a horizontal direction.
[0010] As an optional implementation, the connection lines between project nodes are generated on the initial business structure diagram according to the parent-child relationship between the business projects included in the target business, including: drawing a first connection line along the target direction from the first border of the project node serving as the parent node according to the node distance between the parent node and the child node along the target direction, wherein the first border is the border of the project node serving as the parent node at the end of the target direction; drawing a second connection line in the opposite direction of the target direction from the second border of the project node serving as the child node according to the node distance between the parent node and the child node along the target direction, wherein the second border is the border of the project node serving as the child node at the beginning of the target direction, and the sum of the lengths of the second connection line and the first connection line is the node distance; and drawing a third connection line connecting the end of the first connection line and the end of the second connection line.
[0011] As an optional implementation, drawing a first connection line along the target direction from the first border of the project node serving as the parent node according to the node distance between the parent node and the child node along the target direction comprises: creating a connection line element of the parent node in the page element corresponding to the parent node; drawing the first connection line along the target direction from the first border of the project node serving as the parent node according to the node distance between the parent node and the child node along the target direction in the connection line element of the parent node, and adding an absolute positioning attribute to the connection line element of the parent node; drawing a second connection line in the opposite direction of the target direction from the second border of the project node serving as the child node according to the node distance between the parent node and the child node along the target direction comprises: creating a connection line element of the child node in the page element corresponding to the child node; drawing a second connection line in the opposite direction of the target direction from the second border of the project node serving as the child node according to the node distance between the parent node and the child node along the target direction in the connection line element of the child node, and adding an absolute positioning attribute to the connection line element of the child node.
[0012] As an optional implementation, drawing a third connecting line connecting the end of the first connecting line and the end of the second connecting line includes: creating a line connecting line element in a connecting line element of a parent node or a connecting line element of a child node; drawing the third connecting line connecting the end of the first connecting line and the end of the second connecting line in the line connecting line element; and adding an absolute positioning attribute to the line connecting line element.
[0013] As an optional implementation, after drawing each project node, the method further includes: matching the first node information of the currently drawn project node with the second node information recorded in the default selected node attribute; when the first node information matches the second node information successfully, adding a selection node style attribute to the cascading style sheet of the currently drawn project node, wherein the selection node style attribute is used to display the currently drawn project node as a selected display style.
[0014] As an optional implementation, after generating connecting lines between project nodes on the initial business structure diagram according to the parent-child relationship between business projects included in the target business to obtain the target business structure diagram of the target business, the method also includes: detecting the node operation triggered on each project node; when it is detected that the target node operation is triggered on the target project node, searching for the target operation response corresponding to the target project node under the target node operation from the project nodes, node operations and operation responses with corresponding relationships; and controlling the target business structure diagram to execute the target operation response.
[0015] According to another embodiment of the present application, a display device for a business structure diagram is provided, comprising: a receiving module, for receiving a display request, wherein the display request is used to request to display a business structure diagram of a target business on a target display page according to a target direction; a drawing module, for responding to the display request, drawing project nodes corresponding to business items included in the target business on the target display page according to project groups in the target direction, and adding a target elastic layout attribute matching the target direction in the target display page to a cascading style sheet of project nodes in each project group, to obtain an initial business structure diagram of the target business, wherein the project nodes included in each project group are divided according to the parent-child relationship between the business items included in the target business; and a generating module, for generating connecting lines between project nodes on the initial business structure diagram according to the parent-child relationship between the business items included in the target business, to obtain a target business structure diagram of the target business.
[0016] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.
[0017] According to another embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0018] According to another embodiment of the present application, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0019] Through the present application, when a display request is received and a display request is responded to, the project nodes corresponding to the business items included in the target business will be drawn in the target direction according to the project grouping on the target display page, and the target elastic layout attributes matching the target direction in the target display page will be added to the cascading style sheet of the project nodes in each project group. The elastic layout can adapt to the flexible layout of the target display page within the target display page, so that the project nodes corresponding to the business items included in the target business can be adaptively displayed on the target display page, avoiding the complex operation of calculating different project node positions according to different display pages, and then generating connection lines between the project nodes on the initial business structure diagram according to the parent-child relationship between the business items included in the target business. The positions of the connection lines are also generated based on the adaptive parent-child relationship between the business items, avoiding the complex operation of calculating the connection line positions according to different project node positions under different display pages. Therefore, the problem of poor drawing efficiency of the business structure diagram can be solved, thereby achieving the effect of improving the drawing efficiency of the business structure diagram. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 It is a hardware structure block diagram of a server device of a method for displaying a business structure diagram in an embodiment of the present application;
[0021] Figure 2 is a flowchart of a method for displaying a business structure diagram according to an embodiment of the present application;
[0022] Figure 3 This is a schematic diagram of the effect of the elastic layout according to the embodiment of the present application. Figure 1 ;
[0023] Figure 4 This is a schematic diagram of the effect of the elastic layout according to the embodiment of the present application. Figure 2 ;
[0024] Figure 5 This is a schematic diagram of the effect of the elastic layout according to the embodiment of the present application. Figure 3 ;
[0025] Figure 6 is a schematic diagram of a node grouping logic according to an embodiment of the present application;
[0026] Figure 7 The business structure according to the embodiment of the present application Figure 1 ;
[0027] Figure 8 The business structure according to the embodiment of the present application Figure 2 ;
[0028] Fig. 9 The business structure according to the embodiment of the present application Figure 3 ;
[0029] Fig.10 The business structure according to the embodiment of the present application Figure 4 ;
[0030] Fig.11 It is a structural block diagram of a device for displaying a business structure diagram according to an embodiment of the present application. DETAILED DESCRIPTION
[0031] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0033] The method embodiments provided in the embodiments of the present application can be executed in a server device or a similar computing device. Taking running on a server device as an example, Figure 1 1 is a hardware structure block diagram of a server device of a method for displaying a business structure diagram according to an embodiment of the present application. Figure 1 As shown, the server device may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the above-mentioned server device may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above server device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0034] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the display method of the business structure diagram in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the server device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0035] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the server device. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0036] In this embodiment, a method for displaying a business structure diagram is provided. Figure 2 is a flow chart of a method for displaying a business structure diagram according to an embodiment of the present application, such as Figure 2 As shown, the process includes the following steps:
[0037] Step S202, receiving a display request, wherein the display request is used to request displaying a business structure diagram of a target business on a target display page according to a target direction;
[0038] Step S204, in response to the display request, drawing project nodes corresponding to the business items included in the target business in the target direction according to the project grouping on the target display page, and adding a target elastic layout attribute matching the target direction in the target display page to the cascading style sheet of the project nodes in each project grouping, to obtain an initial business structure diagram of the target business, wherein the project nodes included in each project grouping are divided according to the parent-child relationship between the business items included in the target business;
[0039] Step S206: generating connection lines between project nodes on the initial business structure diagram according to the parent-child relationship between the business projects included in the target business, so as to obtain a target business structure diagram of the target business.
[0040] Through the above steps, in the case of receiving a display request and responding to the display request, the project nodes corresponding to the business items included in the target business will be drawn in the target direction according to the project grouping on the target display page, and the target elastic layout attributes matching the target direction in the target display page will be added to the cascading style sheet of the project nodes in each project group. The elastic layout can adapt to the flexible layout of the target display page, so that the project nodes corresponding to the business items included in the target business can be adaptively displayed on the target display page, avoiding the complex operation of calculating different project node positions according to different display pages, and then generating connection lines between the project nodes on the initial business structure diagram according to the parent-child relationship between the business items included in the target business. The positions of the connection lines are also generated based on the adaptive parent-child relationship between the business items, avoiding the complex operation of calculating the connection line positions according to different project node positions under different display pages. Therefore, the problem of poor drawing efficiency of the business structure diagram can be solved, and the effect of improving the drawing efficiency of the business structure diagram can be achieved.
[0041] In the embodiment provided in step S202, the business that requires a business structure diagram includes but is not limited to software business or hardware business. For example, the evolution process of the algorithm version is displayed in the form of a business structure diagram. Different versions are generally created for the same algorithm. When continuing to develop other versions of the algorithm, it is necessary to understand the version development status of the algorithm and the parent-child relationship between different versions.
[0042] In the embodiment provided in step S204, the target direction may include but is not limited to a horizontal direction and a vertical direction. The target direction may also include a horizontal direction from left to right, or a horizontal direction from right to left, or a vertical direction from top to bottom, or a vertical direction from bottom to top, which can be flexibly selected according to display requirements.
[0043] Optionally, in an embodiment of the present application, Cascading Style Sheets (CSS) is a computer language used to express file styles such as HTML (HyperText Markup Language, an application of standard general purpose markup language) or XML (eXtensible Markup Language, a subset of standard general purpose markup language). CSS can not only modify web pages statically, but also dynamically format various elements of web pages in conjunction with various scripting languages. CSS can precisely control the layout of element positions in web pages at the pixel level, supports almost all font sizes and styles, and has the ability to edit web page objects and model styles. The full name of HTML is Hypertext Markup Language, which is a markup language. It includes a series of tags, through which the document format on the network can be unified, so that scattered network resources can be connected into a logical whole. HTML text is a descriptive text composed of HTML commands, which can describe text, graphics, animations, sounds, tables, connections, etc.
[0044] Optionally, in an embodiment of the present application, flexbox is a CSS module for web page layout, which allows sub-elements in a container to be automatically arranged and resized according to certain rules. The flexbox controls the arrangement and size of sub-elements by setting the properties of the container, and can achieve flexible web page layout. Figure 3 This is a schematic diagram of the effect of the elastic layout according to the embodiment of the present application. Figure 1 ,like Figure 3 As shown in the figure, adding the display: flex property to a container will set the container to a flexible layout (Flexbox), thereby changing the layout of the sub-elements (items) inside the container, where the Y-axis alignment is: align-item. Specifically, a container with the display: flex property will become a flexible container, and its internal sub-elements will be arranged and positioned according to the rules of the flexible layout. The following are the effects of using display: flex:
[0045] 1. Main axis and cross axis: The container determines the direction of the main axis (horizontal or vertical) according to the flex-direction property (row by default), and controls the alignment of child elements on the main axis and cross axis according to the justify-content and align-items properties respectively.
[0046] 2. Flexible items: Child elements become flexible items, and their expansion ratio in the flexible container can be controlled according to the flex attribute, thereby achieving flexible layout effects.
[0047] 3. Automatically adjust the order of items: Use the order property to adjust the order of items so that the position of the items in the parent box changes.
[0048] 4. Adaptive layout: Flexible layout can automatically adjust the size and position of child elements according to the size of the parent box to adapt to different screen sizes and devices.
[0049] 5. Space allocation: You can use the flex-grow, flex-shrink, and flex-basis properties to control the space allocation of child elements within a flexible container to achieve flexible layout adjustments.
[0050] Figure 4 This is a schematic diagram of the effect of the elastic layout according to the embodiment of the present application. Figure 2 ,like Figure 4 As shown, after setting the Y-axis alignment to align-item: center, the child elements are centered on the vertical axis. Figure 5 This is a schematic diagram of the effect of the elastic layout according to the embodiment of the present application. Figure 3 ,like Figure 5 As shown, the default main axis alignment of the flexible layout is row, that is, horizontal alignment. When the main axis alignment is set to the reverse direction: flex-direction: column, that is, the main axis alignment is set to vertical alignment, the child elements are arranged vertically in the container.
[0051] Optionally, in an embodiment of the present application, project nodes corresponding to the business items included in the target business are drawn in the target direction according to project grouping on the target display page, and target elastic layout attributes matching the target direction in the target display page are added to the cascading style sheet of the project nodes in each project group, including but not limited to drawing project nodes corresponding to the business items included in the target business in the target direction according to the project grouping on the target display page; when the project nodes corresponding to the business items included in the target business have been drawn, target elastic layout attributes matching the target direction are added to the page elements where the business items and combinations of business items are located according to the project grouping of the business items.
[0052] In the embodiment provided in step S206, generating connection lines between project nodes on the initial business structure diagram according to the parent-child relationship between the business items included in the target business includes but is not limited to obtaining a first node distance between the parent node and the child node along the target direction and a second node distance between the parent node and the child node along the reference direction, wherein the reference direction is perpendicular to the target direction; calculating a third node distance and an offset angle between the parent node and the child node according to the first node distance and the second node distance, wherein the third node distance is the straight-line distance between the parent node and the child node, and the offset angle is the angle between the direction of the parent node pointing to the child node and the target direction; in the page element corresponding to the parent node or the child node Create a direct connection line element in , draw a fourth connection line from the first border of the project node as the parent node in the direction from the parent node to the child node according to the third node distance and the offset angle in the direct connection line element, or draw a fifth connection line from the second border of the project node as the child node in the direction from the child node to the parent node according to the third node distance and the offset angle in the direct connection line element, and add an absolute positioning attribute to the direct connection line element, wherein the first border is the border at the end of the target direction in the border of the project node as the parent node, the second border is the border at the beginning of the target direction in the border of the project node as the child node, and the length of the fourth and fifth connection lines is the third node distance. Through the above steps, direct connection lines between project nodes are generated, which more intuitively displays the parent-child relationship between nodes from another perspective.
[0053] Optionally, in an embodiment of the present application, when the target direction is horizontal, but not limited to, the connecting line is composed of a horizontal line with a width of half the horizontal distance between the parent and child elements drawn on the right side of the parent element with the center point of the right side of the parent element as the starting point and half the horizontal distance between the parent and child elements as the end point, a horizontal line with a width of half the horizontal distance between the parent and child elements drawn on the left side of the child element with the center point of the right side of the child element as the starting point and half the horizontal distance between the parent and child elements as the end point, and a vertical line with a height equal to the height between the vertical center points of the parent and child elements generated according to the height of the vertical center points of the parent and child elements.
[0054] Optionally, in an embodiment of the present application, it is possible but not limited to the case where the target direction is the vertical direction, the connecting line is composed of a vertical line with a height of half the parent-child element drawn at the bottom of the parent element with the center point of the bottom side of the parent element as the starting point and half the height of the parent-child element as the end point, a vertical line with a height of half the parent-child element drawn at the top of the child element with a starting point of half the height of the parent-child element and the center point of the top of the child element as the end point, and a horizontal line with a width equal to the distance between the horizontal center points of the parent and child elements generated according to the width of the horizontal center points of the parent and child elements.
[0055] As an optional implementation manner, drawing the project nodes corresponding to the business items included in the target business in the target direction according to the project grouping on the target display page, and adding the target elastic layout attributes matching the target direction in the target display page to the cascading style sheet of the project nodes in each project group, includes:
[0056] Adding a cascading style sheet style corresponding to the elastic layout of the target direction to the target display page;
[0057] The project groups of the business projects included in the target business are used as the layout content of the target display page in the elastic layout of the target direction to draw the project nodes of each business project, and the target elastic layout attributes in the elastic layout of the target display page are added to each project node.
[0058] Through the above steps, after adding the cascading style sheet style corresponding to the elastic layout of the target direction to the target display page, the project grouping of the business projects is used as the layout content of the target display page in the elastic layout of the target direction to draw the project nodes of each business project and add the target elastic layout attributes to each project node, thereby ensuring the uniform distribution of the project nodes on the display page as needed and improving the display effect of the drawn business structure diagram.
[0059] As an optional implementation manner, adding a cascading style sheet style corresponding to the elastic layout of the target direction to the target display page includes:
[0060] Creating a page element corresponding to the target display page;
[0061] Add the elastic layout attribute of the target direction and the alignment attribute of the reference direction to the page element corresponding to the target display page, wherein the reference direction is perpendicular to the target direction, and the alignment attribute is used to indicate the alignment of the display content in the page element in the reference direction.
[0062] Optionally, in an embodiment of the present application, the target direction may be but is not limited to a horizontal direction. When the target direction is a horizontal direction, the corresponding reference direction is a vertical direction; or the target direction may be but is not limited to a vertical direction. When the target direction is a vertical direction, the corresponding reference direction is a horizontal direction.
[0063] As an optional implementation manner, adding the elastic layout attribute in the target direction and the alignment attribute in the reference direction to the page element corresponding to the target display page includes:
[0064] When the target direction is horizontal, the elastic layout attribute of the page element corresponding to the target display page is added as elastic layout, and the alignment attribute of the page element corresponding to the target display page is added as vertical center alignment, wherein the default direction of the elastic layout of the page element is horizontal;
[0065] When the target direction is a vertical direction, the elastic layout attribute of the page element corresponding to the target display page is added as an elastic layout, the direction of the elastic layout is added as a vertical direction, and the alignment attribute of the page element corresponding to the target display page is added as a horizontal center alignment.
[0066] Optionally, in an embodiment of the present application, the direction of the elastic layout defaults to the horizontal direction. Therefore, when the target direction is the horizontal direction, it is only necessary to add the elastic layout attributes of the page element corresponding to the target display page as the elastic layout.
[0067] Optionally, in an embodiment of the present application, the elastic layout attributes of the page element corresponding to the target display page are added as elastic layout, including but not limited to defining the page element as an elastic layout: display:flex, and the alignment attributes of the page element corresponding to the target display page are added as vertical center alignment, including but not limited to setting the vertical center alignment of the item nodes in the page element in the vertical direction: align-items:center; the elastic layout attributes of the page element corresponding to the target display page are added as elastic layout, and the direction of the elastic layout is added as a vertical direction, including but not limited to defining the page element as an elastic layout: display:flex, and defining the arrangement direction of the item nodes in the page element on the main axis as a vertical direction: flex-direction:column, and the alignment attributes of the page element corresponding to the target display page are added as horizontal center alignment, including but not limited to setting the item nodes in the page element in the horizontal direction: align-items:center.
[0068] Through the above steps, the project nodes can be placed in a flexible layout vertically or horizontally centered as required under the constraints of page element attributes, which simplifies the drawing complexity of the project nodes and improves the display effect of the business structure diagram.
[0069] As an optional implementation manner, the item grouping of the business items included in the target business as the layout content of the target display page in the elastic layout in the target direction to draw the item nodes of each business item, and adding the target elastic layout attribute in the elastic layout of the target display page to each item node, includes:
[0070] Traverse each business item in order from parent to child according to the parent-child relationship between the business items included in the target business;
[0071] Creating a page element corresponding to the currently traversed business item, drawing the project node of the currently traversed business item in the page element corresponding to the currently traversed business item, and adding the target elastic layout attribute to the page element of the currently traversed business item;
[0072] In the case where the currently traversed business item has a sub-business item, the page element corresponding to the currently traversed business item is used as a parent element, and the page element corresponding to the sub-business item of the currently traversed business item is created as a child element, and a flexible layout attribute of a reference direction is added to the page element corresponding to the sub-business item of the currently traversed business item, wherein the page element corresponding to the sub-business item is used to draw the project node of the sub-business item of the currently traversed business item, the parent element and the child element are a project group, and the reference direction is perpendicular to the target direction;
[0073] In the case that the currently traversed business item has no child business items, the page elements corresponding to the currently traversed business item are determined as an item group.
[0074] Optionally, in an embodiment of the present application, including but not limited to traversing each business project in order from parent to child according to the parent-child relationship between the business projects included in the target business, creating a page element as a child element for the sub-business project when the traversed business project has a sub-business project, and then continuing to draw the project node of the sub-business project in the sub-element, and continuing to traverse the business projects included in the target business including the sub-business project, until all business projects no longer have sub-business projects, and the business structure diagram of the business is completed.
[0075] Optionally, in an embodiment of the present application, when the currently traversed business item has child business items, the page element corresponding to the currently traversed business item is used as the parent element, and the page element corresponding to the child business item of the currently traversed business item is created as a child element, including but not limited to adding the page element corresponding to the child business item of the currently traversed business item to the page element corresponding to the currently traversed business item through appendChild(). appendChild() is a method for operating DOM (Document Object Model), which allows a new node to be added to the end of the list of child nodes of a specified element. Specifically, appendChild() adds a new child node after the last child node of the specified element. If the new node passed in already exists elsewhere in the document, using appendChild() will remove the node from its original position and add it to the new position, because a DOM node cannot appear in multiple positions of a document at the same time.
[0076] As an optional implementation, the adding the target elastic layout attribute to the page element of the currently traversed business item includes: adding a margin attribute to the page element of the currently traversed business item;
[0077] The method of adding elastic layout attributes of a reference direction to page elements corresponding to sub-business items of the currently traversed business item includes: when the target direction is a horizontal direction, adding the elastic layout attributes of page elements corresponding to sub-business items of the currently traversed business item as elastic layout, and adding the direction of the elastic layout as a vertical direction; when the target direction is a vertical direction, adding the elastic layout attributes of page elements corresponding to sub-business items of the currently traversed business item as elastic layout, wherein the default direction of the elastic layout of the page elements is a horizontal direction.
[0078] Optionally, in an embodiment of the present application, margin attributes include but are not limited to CSS margin attributes, which define the space around an element. Margin can change the top, bottom, left, and right margins of an element individually, or all attributes can be changed at once. For example: maigin:10px means that the top, bottom, left, and right margins are all 10 pixels. maigin:10px, 5px means that the top and bottom margins are 10 pixels each, and the left and right margins are 5 pixels each. maigin:9px, 8px, 7px, 6px means that the top margin is 9 pixels, the right margin is 8 pixels, the bottom margin is 7 pixels, and the left margin is 6 pixels.
[0079] Optionally, in an embodiment of the present application, when the target direction is horizontal, the elastic layout attributes of the page elements corresponding to the sub-business items of the currently traversed business item are added as elastic layout, and the direction of the elastic layout is added as a vertical direction, including but not limited to setting display:flex and flex-direction:column; when the target direction is vertical, the elastic layout attributes of the page elements corresponding to the sub-business items of the currently traversed business item are added as elastic layout, including but not limited to setting display:flex.
[0080] Through the above steps, by adding margin attributes to the page elements of the currently traversed business project, it is convenient to draw the connection lines between the parent and child nodes later, and also improves the aesthetics of the drawn business structure diagram.
[0081] As an optional implementation, Figure 6 is a schematic diagram of a node grouping logic according to an embodiment of the present application, such as Figure 6 As shown, the part surrounded by the same marked box is an item group. It can be seen that an item group includes two parts, the left part is the parent element, and the right part includes all the child elements of the current parent element. When there are multiple child elements, the child elements are at the same level, and each child element has the potential to become a parent element.
[0082] As an optional implementation manner, generating connection lines between project nodes on the initial business structure diagram according to the parent-child relationship between business projects included in the target business includes:
[0083] Draw a first connection line along the target direction from a first border of the project node serving as the parent node according to the node distance between the parent node and the child node along the target direction, wherein the first border is a border at an end of the border of the project node serving as the parent node in the target direction;
[0084] Draw a second connection line in the opposite direction of the target direction from the second border of the project node as the child node according to the node distance between the parent node and the child node along the target direction, wherein the second border is the border of the project node as the child node at the beginning of the target direction, and the sum of the lengths of the second connection line and the first connection line is the node distance;
[0085] A third connecting line is drawn connecting an end of the first connecting line and an end of the second connecting line.
[0086] Optionally, in the embodiment of the present application, the line width and color of the connecting line can be customized but are not limited to.
[0087] Optionally, in the embodiment of the present application, including but not limited to adding a unique identifier and a parent identifier to the business item, the unique identifier of each business item is different. When traversing the business items, if the currently traversed business item has a child business item, the unique identifier of the current business item is passed to the child business item of the current business item as the parent identifier of the child business item, so that the business items with the same parent identifier are direct child business items of the same business item. If the parent identifier of one business item is the same as the unique identifier of another business item, the previous business item is a child business item of the next business item.
[0088] Through the above steps, the first connection line, the second connection line and the third connection line are combined to form a connection line between the parent and child nodes, replacing the solution of directly connecting the parent and child nodes through a straight line, reducing the possibility of the connection lines between multiple pairs of parent and child nodes crossing each other, and also improving the aesthetics of the business structure diagram.
[0089] As an optional implementation, drawing a first connection line along the target direction from a first border of the project node as the parent node according to the node distance between the parent node and the child node along the target direction includes:
[0090] Create a connecting line element of the parent node in the page element corresponding to the parent node;
[0091] In the connection line element of the parent node, a first connection line is drawn along the target direction from the first border of the project node as the parent node according to the node distance between the parent node and the child node along the target direction, and an absolute positioning attribute is added to the connection line element of the parent node;
[0092] Drawing a second connection line in the opposite direction of the target direction from the second border of the item node as the child node according to the node distance between the parent node and the child node along the target direction includes:
[0093] Create a connecting line element for the subnode in the page element corresponding to the subnode;
[0094] In the connecting line element of the child node, a second connecting line is drawn from the second border of the project node as the child node along the opposite direction of the target direction according to the node distance between the parent node and the child node along the target direction, and an absolute positioning attribute is added to the connecting line element of the child node.
[0095] Optionally, in an embodiment of the present application, the absolute positioning attribute is a concept relative to the relative positioning attribute, and can be, but is not limited to, specifying the positioning type of an element and specifying the positioning method of an element in a document (display page) by defining the position attribute, wherein the attributes used are: relative, relative positioning, absolute, absolute positioning.
[0096] 1. Relative positioning: position : relative;
[0097] In relative positioning, the positioned element is positioned according to its original position. Relative positioning will not deviate from the document flow and will not affect other elements in the document flow. The offset is based on the given value and can be negative.
[0098] The larger the top value is, the lower it is, that is, the difference between the top and the original position;
[0099] The larger the bottom value is, the higher it goes, that is, the difference between the bottom and the original position;
[0100] The larger the left value is, the more to the right it is, that is, the difference between the left and the original position;
[0101] right The larger the value, the more to the left, that is, the difference between the right side and the original position;
[0102] 2. Absolute positioning: position:absolute;
[0103] In absolute positioning, the positioning is based on the parent of the positioned element. Absolutely positioned elements will be out of the document flow. The width and height can be set within the line. Block elements do not occupy a single line, and the width and height are extended by the content.
[0104] The larger the top value, the lower it is, that is, the difference between the top and the top of the positioned parent;
[0105] The larger the bottom value, the higher it goes, that is, the difference between the bottom and the bottom of the positioned parent;
[0106] The larger the left value, the further to the right it is, that is, the difference between the left side and the left side of the positioned parent;
[0107] The larger the right value, the further to the left, that is, the difference between the right side and the right side of the positioned parent.
[0108] Since the default positioning attribute is relative positioning: position: relative, when the positioning attributes of the page elements and child elements corresponding to the project node are relative positioning and the positioning attribute of the connecting line element is absolute positioning: position: absolute, the connecting line can be fixed in position.
[0109] As an optional implementation manner, drawing a third connection line connecting an end of the first connection line and an end of the second connection line includes:
[0110] Create a line connector element in a parent node's connector element or a child node's connector element;
[0111] A third connecting line connecting an end of the first connecting line and an end of the second connecting line is drawn in a connecting line element of the line, and an absolute positioning attribute is added to the connecting line element of the line.
[0112] As an optional implementation, after drawing each project node, the method further includes:
[0113] Match the first node information of the currently drawn project node with the second node information recorded in the default selected node attribute;
[0114] When the first node information matches the second node information successfully, a selection node style attribute is added to the cascading style sheet of the currently drawn project node, wherein the selection node style attribute is used to display the currently drawn project node as a selected display style.
[0115] Optionally, in an embodiment of the present application, the second node information may be pre-set information related to the node information of the project node, or operation information of an operation on the business structure diagram, such as clicking on the project node.
[0116] Optionally, in an embodiment of the present application, the node style attributes may be, but are not limited to, bolding the border of the project node or displaying a special color for the border of the project node, etc., which can display a project node that matches the second node information with different style attributes from other project nodes.
[0117] Through the above steps, the project nodes that need more attention can be intuitively displayed in the business structure diagram through the free setting of the second node information, thereby further improving the display effect of the business structure diagram.
[0118] As an optional implementation manner, after generating connecting lines between project nodes on the initial business structure diagram according to the parent-child relationship between business projects included in the target business to obtain the target business structure diagram of the target business, the method further includes:
[0119] Detect the node operations triggered on each project node;
[0120] When it is detected that a target node operation is triggered on a target project node, searching for a target operation response corresponding to the target project node under the target node operation from project nodes, node operations and operation responses having a corresponding relationship;
[0121] The target business structure diagram is controlled to execute the target operation response.
[0122] Optionally, in an embodiment of the present application, including but not limited to setting up clicking on project node A, project node A will display more node information in the node box of node A.
[0123] Through the above steps, by setting the correspondence between project nodes, node operations and operation responses, and executing operation responses after the project nodes have been operated, the usage functions of the business structure diagram can be expanded and the usage effect of the business structure diagram can be improved.
[0124] As an optional implementation, the present application also provides a method for dynamically creating a tree structure that supports diversified customization. According to the data required to generate a tree structure diagram (i.e., a business structure diagram), a tree structure with clear parent-child relationships and diversified customization can be dynamically generated. The tree structure supports customized content such as display template customization, event customization, and rendering direction customization. The tree structure is generated by grouping nodes and using the properties of the elastic layout of the browser CSS to achieve automatic positioning of nodes without manually calculating the position of each node. This greatly improves performance. The method includes the following steps:
[0125] Step S1, defining an array for storing data, which is used as a data source for displaying the tree structure;
[0126] Step S2, initializing the content that supports customization:
[0127] El: The container that the tree structure needs to mount (i.e. the target display page);
[0128] Data: data for rendering the tree structure (i.e., the project data of the target business that requests to display the business structure diagram);
[0129] Direction: The direction of rendering the tree structure (i.e., the target direction). It supports horizontal and vertical directions, and the default direction is horizontal.
[0130] LineWidth: The width of the line between two nodes (i.e. the width of the connecting line);
[0131] LineColor: The color of the connecting line between two nodes (i.e. the color of the connecting line);
[0132] NodeTemplate: node template, the rendering template of each node in the tree structure (that is, the template of the content displayed by the project node);
[0133] ItemClick: customize the click method of each node, which can be extended to a single node, such as setting a lazy loading tree and clicking to load the next level of tree structure;
[0134] ActiveTree: The node selected by default, which can be used in a variety of scenarios. For example, if a multi-level tree is loaded, the node at the second level is selected by default.
[0135] ActiveClass: The style of the default selected node, which distinguishes the visual effects of selected nodes from unselected nodes.
[0136] Step S3, define a method to create a page element createEl, create an element through document.createElement(), and need to accept two values: tag: the html element tag of the created element and domStyle: the style CSS table used to create the element.
[0137] Step S4, define a variable nodenum, the initial variable value is 0, this variable is used to record the unique identifier of the node (ie, business item).
[0138] Step S5, defining an initialization method init, in which it is determined whether the initialization parameter Direction is horizontal or vertical, and different values call different node drawing methods and the method drawLine for drawing the connection line between nodes.
[0139] Step S6, define a creation class TreeMap. In this class, all customized contents will be received. In this class, nodenum is set to 0 and the initialization method init is called.
[0140] Step S7, define a method createNode to create a single node. In this method, createEl is used to create a page element, and the NodeTemplate passed by initialization is used to create a custom single node.
[0141] Step S8, defining two node drawing methods, one for drawing nodes in a horizontal direction, and one for drawing nodes in a vertical direction.
[0142] Step S8.1, draw the node render_h in the horizontal direction, which requires three parameters: the data to be rendered Data, the rendering container El and the unique identifier nodenum.
[0143] Step S8.1.1, create a page element parentNode through createEl. All future nodes will be inside this page element. Add CSS styles to parentNode: (1): define the element as a flexible layout: display:flex, (2): set the items in the container to be vertically centered: align-items:center. By setting this style, each parent element can be horizontally aligned with its child elements when there are multiple child elements. This step is to start grouping nodes.
[0144] Step S8.1.2, create a node currentNode representing the current element through createNode. It is necessary to add a unique identifier (data_id) to the current node. The value of data_id is equal to nodenum plus 1 each time (to ensure that nodenum is different). And add an attribute (represented by f_id). The value of this attribute is the unique identifier passed by render_h. When the node is a child node, this value is the data_id of the parent node. This attribute is used to draw connecting lines. Add CSS style to currentNode: (1): Add relative positioning: position:relative. After adding this attribute, when drawing connecting lines in the future, the connecting lines can be fixed in position after using absolute positioning for the connecting lines. (2): Add margin attribute: margin (customizable width). Setting this attribute can generate a certain distance between parent and child nodes, leaving space for drawing connecting lines, and generating a certain distance between nodes up and down, which has a better visual effect.
[0145] Step S8.1.3, determine if there are child nodes (childrenList) that need to be rendered in the current data. If there are child nodes that need to be rendered, create a page element (childrenNodes) through createEl, and all child nodes of the current element are in this page element. Add currentNode and childrenNodes to the parentNode node through appendChild(). It is also necessary to obtain the data_id of the current node, loop through all the child node lists childreList, call the render_h method in the loop, and pass the child node data, childrenNodes, and the data_id of the current node as rendering data. If there are no child nodes that need to be rendered, the currentNode node will be added after the last child node of the parentNode node to complete the grouping of nodes.
[0146] Step S8.1.4, determine whether the unique identifier of the current data is equal to the unique identifier of ActiveTree. If it is equal to the unique identifier of ActiveTree, add ActiveClass style to the current node, indicating that the current tree node is in the selected state.
[0147] Step S8.1.5, the currentNode click event executes the itemclick event and passes the current data to itemclick.
[0148] Step S8.1.6, add parentNode to El through appendChild().
[0149] Step S8.2, draw the node render_v in the vertical direction, create a page element parentNode through createEl, and all future nodes are in this page element. Unlike the horizontal direction, three CSS style attributes need to be set for this element: (1): define the element as a flexible layout: display:flex, (2): define the arrangement direction of the child items on the main axis as the vertical direction: flex-direction:column, (3): set the items in the container to be vertically centered in the vertical direction: align-items:center. Because child nodes need to be horizontally aligned, these three attributes also need to be set when creating the element childrenNodes that contains the child nodes, and the flex-direction value is row. The other steps are the same as drawing nodes in the horizontal direction.
[0150] Step S9, define two methods of connecting nodes, divided into horizontal direction (drawLine_h) and vertical direction (drawLine_v).
[0151] Step S9.1, connect two nodes horizontally, and pass the parent node and child node to be connected.
[0152] Step S9.1.1, get the position of the parent element:
[0153] parentHeight: The height of the parent element (the space it occupies in the vertical direction).
[0154] parentWidth: The width of the parent element (the horizontal space the element takes up).
[0155] parentLeft: The distance in pixels from the left outer border of an element to the left inner border of the containing element.
[0156] parentTop: The pixel distance from the top outer border of an element to the top inner border of the containing element.
[0157] The coordinates of the center point on the right side of the parent node, the horizontal coordinate parentRightCenterX = parentLeft +parentWidth, the vertical coordinate parentRightCenterY = parentTop + (parentHeight / 2).
[0158] Step S9.1.2, get the position of the child node:
[0159] childrenHeight: The height of child elements.
[0160] childrenLeft: The distance in pixels from the left outer border of an element to the left inner border of the containing element.
[0161] childrenTop: The pixel distance from the top outer border of an element to the top inner border of the containing element.
[0162] The coordinates of the center point on the left side of the child node, the horizontal coordinate childrenLeftCenterX = childrenLeft, the vertical coordinate childrenLeftCenterY = childrenTop + (childrenHeight / 2).
[0163] The relative position width of the center point of the parent and child nodes is half centerWidthHalf: (childrenLeftCenterX- parentRightCenterX) / 2.
[0164] The relative height of the center point of the parent and child nodes: centerHeight: childrenLeftCenterY–parentRightCenterY.
[0165] Step S9.1.3, draw the connection lines:
[0166] The horizontal line line1 on the right side of the parent node: Create an element through createEl. The width of the element is centerWidthHalf, the height is LineWidth, the background color is LineColor, the positioning attribute is position:absolute, the distance between the top edge and the top edge is parentHeight / 2, and the distance between the right edge and the right edge of the parent element is: -centerWidthHalf.
[0167] The horizontal line line2 on the left side of the child node: Create an element through createEl. The width of the horizontal line is centerWidthHalf, the height is LineWidth, the background color is LineColor, the positioning attribute is position:absolute, the distance from the top edge to the top edge is childrenHeight / 2, and the distance from the left edge to the right edge is: -centerWidthHalf.
[0168] The vertical line line3 connecting the two horizontal lines: Create an element through createEl, the width of the horizontal line is LineWidth, the height is centerHeight, and the background color is LineColor. The positioning attribute is position:absolute. If parentRightCenterY > childrenLeftCenterY, the distance between the top edge of line3 and the top edge is 0, and the distance between the left edge is: 0, line3 is mounted to the line2 element through appendChild(). If parentRightCenterY < childrenLeftCenterY, the distance between the bottom edge of line3 and the top edge is 0, and the distance between the left edge and the right edge is: 0, line3 is mounted to the line2 element through appendChild(). If parentRightCenterY = childrenLeftCenterY, the height of the horizontal line is LineWidth, the distance between the top edge and the top edge is 0, and the distance between the right edge and the right edge of the parent element is: 0. Line3 is mounted to the line1 element through appendChild().
[0169] Finally, line1 is mounted on the parent node through appendChild(), and line2 is mounted on the child node through appendChild().
[0170] Step S9.2, connect two nodes vertically, and pass the parent node and child node to be connected.
[0171] Step S9.2.1, get the position of the parent element:
[0172] parentHeight: The height of the parent element (the space it occupies in the vertical direction).
[0173] parentWidth: The width of the element (the horizontal space the element takes up).
[0174] parentLeft: The distance in pixels from the left outer border of an element to the left inner border of the containing element.
[0175] parentTop: The pixel distance from the top outer border of an element to the top inner border of the containing element.
[0176] The coordinates of the center point at the bottom of the parent node, the horizontal coordinate parentBottomCenterX = parentLeft + (parentWidth / 2), the vertical coordinate parentBottomCentery = parentTop + parentHeight.
[0177] Step S9.2.2, get the position of the child node:
[0178] childrenWidth: the width of child elements.
[0179] childrenLeft: The distance in pixels from the left outer border of an element to the left inner border of the containing element.
[0180] childrenTop: The pixel distance from the top outer border of an element to the top inner border of the containing element.
[0181] The coordinates of the center point at the top of the child node, the horizontal coordinate childrenTopCenterX = childrenLeft + (childrenWidth / 2), the vertical coordinate childrenTopCenterY = childrenTop.
[0182] The relative position width of the center point of the parent and child nodes is centerWidth: (parentBottomCenterX -childrenTopCenterX).
[0183] Half of the relative height of the center point of the parent and child nodes: centerHeightHalf:(childrenTopCenterY–parentBottomCentery) / 2.
[0184] Step S9.2.3, draw the connection lines:
[0185] Vertical line line1 at the bottom of the parent node: Create an element through createEl, the width of the element is LineWidth, the height is centerHeightHalf, the background color is LineColor, the positioning attribute is position:absolute, the distance from the bottom edge to the top edge is -centerHeightHalf, and the distance from the left edge to the right edge is: parentWidth / 2.
[0186] Vertical line line2 at the top of the child node: Create an element through createEl, the width of the element is LineWidth, the height is centerHeightHalf, the background color is LineColor, the positioning attribute is position:absolute, the distance from the top edge to the top edge is -centerHeightHalf, and the distance from the left edge to the right edge is: childrenWidth / 2.
[0187] Line3, the horizontal line connecting the two vertical lines: Create an element through createEl, the width of the element is centerWidth, the height is LineWidth, and the background color is LineColor. The positioning attribute is position:absolute. If parentBottomCenterX > childrenTopCenterX, the distance from the top edge to the top edge is 0, and the distance from the left edge to the right edge is: 0. If parentBottomCenterX < childrenTopCenterX, the distance from the top edge to the top edge is 0, and the distance from the right edge to the right edge of the parent element is: 0. Line3 is mounted to the line2 element through appendChild(). If parentBottomCenterX = childrenTopCenterX, the width is LineWidth, the distance from the top edge to the top edge is 0, and the distance from the left edge to the right edge is: 0. Line3 is mounted to the line1 element through appendChild().
[0188] Finally, line1 is mounted on the parent node through appendChild(), and line2 is mounted on the child node through appendChild().
[0189] Step S10, define a public redrawing method: in this method, all nodes are removed and the variable nodenum is set to 0. In this method, the usage scenarios that need to be redrawn can be expanded.
[0190] Step S11, define a public method to represent a node click event (represented by ItemClick). In this method, the passed data is accepted and ActiveTree is set to the passed data. This method can expand the usage scenario of a single node.
[0191] Step S12, define a common method for drawing node connection lines: obtain all node elements in the page, loop all node elements, define a parameter in the loop method to obtain the parent element, if there is a parent element when data_id is equal to the f_id value of another element, it means that there is a parent element, if there is a parent element, determine the direction to be drawn, call different methods to connect two nodes, and draw a connection line.
[0192] Step S13, when in use, call new TreeMap() and pass the customized content.
[0193] Through the above steps, you can draw a project structure diagram of the business project in the horizontal or vertical direction based on the needs. Figure 7 The business structure according to the embodiment of the present application Figure 1 , Figure 8 The business structure according to the embodiment of the present application Figure 2 , Fig. 9 The business structure according to the embodiment of the present application Figure 3 , Fig.10 The business structure according to the embodiment of the present application Figure 4 ,like Figure 7 and Fig. 9 The business structure diagram is drawn horizontally. Figure 8 and Fig.10 The following is a business structure diagram drawn in the vertical direction. Figure 7 and Figure 8 The following is a business structure diagram that only draws one parent-child relationship, such as Fig. 9 and Fig.10 The following is the effect of clicking on the tree node lazy loading multiple times, showing the parent-child relationship of multiple nodes, such as Fig. 9 and Fig.10 The bold border in the box indicates the selection effect.
[0194] Through the above steps, instead of calculating the position of each node through code, the nodes are grouped and the drawing is handed over to the browser's CSS style. Nodes are automatically positioned through CSS, without calculating the node position. The drawing performance is greatly improved. If the connection line of the node is drawn directly from the parent element to the child element, when there are many levels or child elements, the more lines are drawn, the performance will be affected. By splicing horizontal and vertical lines, the lines of the parent element are reused, and the vertical lines are also reused. Fewer elements are drawn, and the rendering speed will be faster. And there is no need to recalculate the node position as the height or width of the external canvas changes, and it can be adapted according to the browser. You can design and add a variety of custom solutions to make the tree structure highly scalable and usable.
[0195] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0196] In this embodiment, a display device for a business structure diagram is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0197] Fig.11 is a structural block diagram of a display device for a business structure diagram according to an embodiment of the present application, such as Fig.11 As shown, the device comprises:
[0198] The receiving module 1102 is used to receive a display request, wherein the display request is used to request to display a business structure diagram of a target business in a target direction on a target display page;
[0199] A drawing module 1104 is used to respond to the display request, draw the project nodes corresponding to the business items included in the target business in the target direction according to the project grouping on the target display page, and add the target elastic layout attributes matching the target direction in the target display page to the cascading style sheet of the project nodes in each project group, so as to obtain an initial business structure diagram of the target business, wherein the project nodes included in each project grouping are divided according to the parent-child relationship between the business items included in the target business;
[0200] The generating module 1106 is used to generate connecting lines between project nodes on the initial business structure diagram according to the parent-child relationship between the business projects included in the target business, so as to obtain a target business structure diagram of the target business.
[0201] Through the above steps, in the case of receiving a display request and responding to the display request, the project nodes corresponding to the business items included in the target business will be drawn in the target direction according to the project grouping on the target display page, and the target elastic layout attributes matching the target direction in the target display page will be added to the cascading style sheet of the project nodes in each project group. The elastic layout will adapt to the flexible layout of the target display page, so that the project nodes corresponding to the business items included in the target business can be adaptively displayed on the target display page, avoiding the complex operation of calculating different project node positions according to different display pages, and then generating connection lines between the project nodes on the initial business structure diagram according to the parent-child relationship between the business items included in the target business. The position of the connection line is also generated based on the adaptive parent-child relationship between the business items, avoiding the complex operation of calculating the connection line position according to different project node positions under different display pages. Therefore, the problem of poor drawing efficiency of the business structure diagram can be solved, and the effect of improving the drawing efficiency of the business structure diagram can be achieved.
[0202] As an optional implementation, the drawing module includes: an adding unit, used to add a cascading style sheet style corresponding to the elastic layout of the target direction to the target display page; a first drawing unit, used to draw the project nodes of each business project by grouping the project items of the business items included in the target business as the layout content of the target display page in the elastic layout of the target direction, and add the target elastic layout attributes in the elastic layout of the target display page to each project node.
[0203] As an optional implementation, the adding unit is further used to: create a page element corresponding to the target display page; add elastic layout attributes of the target direction and alignment attributes in a reference direction to the page element corresponding to the target display page, wherein the reference direction is perpendicular to the target direction, and the alignment attributes are used to indicate the alignment of the display content in the page element in the reference direction.
[0204] As an optional implementation, the adding unit is further used to: when the target direction is a horizontal direction, add the elastic layout attributes of the page elements corresponding to the target display page as an elastic layout, and add the alignment attributes of the page elements corresponding to the target display page as a vertical center alignment, wherein the default direction of the elastic layout of the page elements is a horizontal direction; when the target direction is a vertical direction, add the elastic layout attributes of the page elements corresponding to the target display page as an elastic layout, add the direction of the elastic layout as a vertical direction, and add the alignment attributes of the page elements corresponding to the target display page as a horizontal center alignment.
[0205] As an optional implementation, the first drawing unit is further used to: traverse each business item in order from parent to child according to the parent-child relationship between the business items included in the target business; create a page element corresponding to the currently traversed business item, and draw the project node of the currently traversed business item in the page element corresponding to the currently traversed business item, and add the target elastic layout attribute to the page element of the currently traversed business item; when the currently traversed business item has a child business item, use the page element corresponding to the currently traversed business item as the parent element, create the page element corresponding to the child business item of the currently traversed business item as the child element, and add the elastic layout attribute of the reference direction to the page element corresponding to the child business item of the currently traversed business item, wherein the page element corresponding to the child business item is used to draw the project node of the child business item of the currently traversed business item, the parent element and the child element are a project group, and the reference direction is perpendicular to the target direction; when the currently traversed business item does not have a child business item, determine the page element corresponding to the currently traversed business item as a project group.
[0206] As an optional implementation, the first drawing unit is also used to: add margin attributes to the page elements of the currently traversed business item; when the target direction is a horizontal direction, add the elastic layout attributes of the page elements corresponding to the sub-business items of the currently traversed business item as elastic layout, and add the direction of the elastic layout as a vertical direction; when the target direction is a vertical direction, add the elastic layout attributes of the page elements corresponding to the sub-business items of the currently traversed business item as elastic layout, wherein the default direction of the elastic layout of the page elements is a horizontal direction.
[0207] As an optional implementation, the generation module further includes: a second drawing unit, used to draw a first connecting line along the target direction from the first border of the project node serving as the parent node according to the node distance between the parent node and the child node along the target direction, wherein the first border is the border at the end of the border of the project node serving as the parent node in the target direction; a third drawing unit, used to draw a second connecting line in the opposite direction of the target direction from the second border of the project node serving as the child node according to the node distance between the parent node and the child node along the target direction, wherein the second border is the border at the beginning of the border of the project node serving as the child node in the target direction, and the sum of the lengths of the second connecting line and the first connecting line is the node distance; a fourth drawing unit, used to draw a third connecting line connecting the end of the first connecting line and the end of the second connecting line.
[0208] As an optional implementation, the second drawing unit is further used to: create a connecting line element of the parent node in the page element corresponding to the parent node; draw a first connecting line along the target direction from the first border of the project node serving as the parent node in the connecting line element of the parent node according to the node distance between the parent node and the child node along the target direction, and add an absolute positioning attribute to the connecting line element of the parent node; as an optional implementation, the third drawing unit is further used to: create a connecting line element of the child node in the page element corresponding to the child node; draw a second connecting line in the opposite direction of the target direction from the second border of the project node serving as the child node in the connecting line element of the child node according to the node distance between the parent node and the child node along the target direction, and add an absolute positioning attribute to the connecting line element of the child node.
[0209] As an optional implementation, the fourth drawing unit is also used to: create a line connection line element in the connection line element of the parent node or the connection line element of the child node; draw a third connection line connecting the end of the first connection line and the end of the second connection line in the line connection line element; and add an absolute positioning attribute to the line connection line element.
[0210] As an optional implementation, the device also includes: a matching module, used to match the first node information of the currently drawn project node with the second node information recorded in the default selected node attribute; an adding module, used to add a selection node style attribute to the cascading style sheet of the currently drawn project node when the first node information matches the second node information successfully, wherein the selection node style attribute is used to display the currently drawn project node as a selected display style.
[0211] As an optional implementation, the device also includes: a detection module, which is used to detect the node operation triggered on each project node; a search module, which is used to search for the target operation response corresponding to the target project node under the target node operation from the project nodes, node operations and operation responses with corresponding relationships when it is detected that the target node operation is triggered on the target project node; and a control module, which is used to control the target business structure diagram to execute the target operation response.
[0212] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0213] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0214] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0215] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0216] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0217] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.
[0218] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0219] An embodiment of the present application also provides a computer program, which includes computer instructions, which are 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 performs the steps in any one of the above method embodiments.
[0220] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0221] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0222] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for displaying a business structure diagram, characterized in that: include: receiving a display request, wherein the display request is used to request displaying a business structure diagram of a target business on a target display page according to a target direction; In response to the display request, drawing the project nodes corresponding to the business items included in the target business in the target direction according to the project groups on the target display page, and adding the target elastic layout attributes matching the target direction in the target display page to the cascading style sheet of the project nodes in each project group, so as to obtain an initial business structure diagram of the target business, wherein the project nodes included in each project group are divided according to the parent-child relationship between the business items included in the target business; Connecting lines between project nodes are generated on the initial business structure diagram according to the parent-child relationship between business projects included in the target business, so as to obtain a target business structure diagram of the target business.
2. The method according to claim 1, characterized in that The step of drawing the project nodes corresponding to the business projects included in the target business in the target direction according to the project groups on the target display page, and adding the target elastic layout attributes matching the target direction in the target display page to the cascading style sheet of the project nodes in each project group, includes: Adding a cascading style sheet style corresponding to the elastic layout of the target direction to the target display page; The project groups of the business projects included in the target business are used as the layout content of the target display page in the elastic layout of the target direction to draw the project nodes of each business project, and the target elastic layout attributes in the elastic layout of the target display page are added to each project node.
3. The method according to claim 2, characterized in that The adding of the cascading style sheet style corresponding to the elastic layout of the target direction to the target display page includes: Creating a page element corresponding to the target display page; Add the elastic layout attribute of the target direction and the alignment attribute of the reference direction to the page element corresponding to the target display page, wherein the reference direction is perpendicular to the target direction, and the alignment attribute is used to indicate the alignment of the display content in the page element in the reference direction.
4. The method according to claim 3, characterized in that The adding the elastic layout attribute in the target direction and the alignment attribute in the reference direction to the page element corresponding to the target display page includes: When the target direction is horizontal, the elastic layout attribute of the page element corresponding to the target display page is added as elastic layout, and the alignment attribute of the page element corresponding to the target display page is added as vertical center alignment, wherein the default direction of the elastic layout of the page element is horizontal; When the target direction is a vertical direction, the elastic layout attribute of the page element corresponding to the target display page is added as an elastic layout, the direction of the elastic layout is added as a vertical direction, and the alignment attribute of the page element corresponding to the target display page is added as a horizontal center alignment.
5. The method according to claim 2, characterized in that: The step of grouping the items of the target business items as the layout content of the target display page in the elastic layout in the target direction, drawing the item nodes of each business item, and adding the target elastic layout attribute in the elastic layout of the target display page to each item node includes: Traverse each business item in order from parent to child according to the parent-child relationship between the business items included in the target business; Creating a page element corresponding to the currently traversed business item, drawing the project node of the currently traversed business item in the page element corresponding to the currently traversed business item, and adding the target elastic layout attribute to the page element of the currently traversed business item; In the case where the currently traversed business item has a sub-business item, the page element corresponding to the currently traversed business item is used as a parent element, and the page element corresponding to the sub-business item of the currently traversed business item is created as a child element, and a flexible layout attribute of a reference direction is added to the page element corresponding to the sub-business item of the currently traversed business item, wherein the page element corresponding to the sub-business item is used to draw the project node of the sub-business item of the currently traversed business item, the parent element and the child element are a project group, and the reference direction is perpendicular to the target direction; In the case that the currently traversed business item has no child business items, the page elements corresponding to the currently traversed business item are determined as an item group.
6. The method according to claim 5, characterized in that The adding the target elastic layout attribute to the page element of the currently traversed business item includes: adding a margin attribute to the page element of the currently traversed business item; The method of adding elastic layout attributes of a reference direction to page elements corresponding to sub-business items of the currently traversed business item includes: when the target direction is a horizontal direction, adding the elastic layout attributes of page elements corresponding to sub-business items of the currently traversed business item as elastic layout, and adding the direction of the elastic layout as a vertical direction; when the target direction is a vertical direction, adding the elastic layout attributes of page elements corresponding to sub-business items of the currently traversed business item as elastic layout, wherein the default direction of the elastic layout of the page elements is a horizontal direction.
7. The method according to claim 1, characterized in that The generating connection lines between project nodes on the initial business structure diagram according to the parent-child relationship between the business projects included in the target business includes: Draw a first connection line along the target direction from a first border of the project node serving as the parent node according to the node distance between the parent node and the child node along the target direction, wherein the first border is a border at an end of the border of the project node serving as the parent node in the target direction; Draw a second connection line in the opposite direction of the target direction from the second border of the project node as the child node according to the node distance between the parent node and the child node along the target direction, wherein the second border is the border of the project node as the child node at the beginning of the target direction, and the sum of the lengths of the second connection line and the first connection line is the node distance; A third connecting line is drawn connecting an end of the first connecting line and an end of the second connecting line.
8. The method according to claim 7, characterized in that The step of drawing a first connection line along the target direction from a first border of the project node as the parent node according to the node distance between the parent node and the child node along the target direction comprises: Create a connecting line element of the parent node in the page element corresponding to the parent node; In the connection line element of the parent node, a first connection line is drawn along the target direction from the first border of the project node as the parent node according to the node distance between the parent node and the child node along the target direction, and an absolute positioning attribute is added to the connection line element of the parent node; Drawing a second connection line in the opposite direction of the target direction from the second border of the item node as the child node according to the node distance between the parent node and the child node along the target direction includes: Create a connecting line element for the subnode in the page element corresponding to the subnode; In the connecting line element of the child node, a second connecting line is drawn from the second border of the project node as the child node along the opposite direction of the target direction according to the node distance between the parent node and the child node along the target direction, and an absolute positioning attribute is added to the connecting line element of the child node.
9. The method according to claim 8, characterized in that The step of drawing a third connecting line connecting an end of the first connecting line and an end of the second connecting line includes: Create a line connector element in a parent node's connector element or a child node's connector element; A third connecting line connecting an end of the first connecting line and an end of the second connecting line is drawn in a connecting line element of the line, and an absolute positioning attribute is added to the connecting line element of the line.
10. The method according to claim 1, characterized in that After drawing each project node, the method further includes: Match the first node information of the currently drawn project node with the second node information recorded in the default selected node attribute; When the first node information matches the second node information successfully, a selection node style attribute is added to the cascading style sheet of the currently drawn project node, wherein the selection node style attribute is used to display the currently drawn project node as a selected display style.
11. The method according to claim 1, characterized in that: After generating connecting lines between project nodes on the initial business structure diagram according to the parent-child relationship between the business projects included in the target business to obtain the target business structure diagram of the target business, the method further includes: Detect the node operations triggered on each project node; When it is detected that a target node operation is triggered on a target project node, searching for a target operation response corresponding to the target project node under the target node operation from project nodes, node operations and operation responses having a corresponding relationship; The target business structure diagram is controlled to execute the target operation response.
12. A display device for a business structure diagram, characterized in that: include: A receiving module, configured to receive a display request, wherein the display request is used to request displaying a business structure diagram of a target business on a target display page in a target direction; A drawing module, used for responding to the display request, drawing the project nodes corresponding to the business items included in the target business in the target direction according to the project grouping on the target display page, and adding the target elastic layout attributes matching the target direction in the target display page in the cascading style sheet of the project nodes in each project grouping, so as to obtain an initial business structure diagram of the target business, wherein the project nodes included in each project grouping are divided according to the parent-child relationship between the business items included in the target business; A generating module is used to generate connecting lines between project nodes on the initial business structure diagram according to the parent-child relationship between business projects included in the target business, so as to obtain a target business structure diagram of the target business.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 11 when executed by a processor.
14. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method described in any one of claims 1 to 11 are implemented.
15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 11 are implemented.
Citation Information
Patent Citations
Data processing method and device, equipment and storage medium
CN113127689A
Webpage layout method and device for browser automatic adaptation
CN118672579A
