Page chart layout method, device and equipment and readable storage medium
By monitoring changes in the size of the chart container, adjusting the viewport size and baseline resolution, and optimizing the page chart layout method, the adaptability problem of traditional methods in different display scenarios is solved, and charts are displayed adaptively on multiple devices and viewports.
Patent Information
- Application Number
- CN202411119014.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-15
- Publication Date
- 2024-11-22
AI Technical Summary
Traditional page chart layout methods lack adaptability in different display scenarios, which may lead to display errors or poor results.
By monitoring changes in the size of the chart container, obtaining the current viewport size and preset baseline resolution, and adjusting the chart's rendering size and layout parameters, including skeleton configuration items and graphic configuration item attribute parameters, the chart is ensured to adapt to different devices and viewport sizes.
The chart layout has been improved to ensure that charts are displayed correctly and appropriately on different devices, resolutions, and viewport sizes, thus enhancing the user experience.
Smart Images

Figure CN119003076A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data visualization, and in particular to a page chart layout method, device, equipment and readable storage medium. Background Art
[0002] With the continuous advancement of technology and the expansion of application scenarios, data visualization has become an indispensable part of data science and analysis. Data visualization can help people quickly find important information in a large amount of data. By displaying data in the form of charts and graphs, trends and anomalies in the data can be more intuitively seen.
[0003] The traditional page chart layout method is that the electronic device layouts the configuration items of the chart according to the attribute information of the configuration items of the chart and the location information of the configuration items in the chart. However, it lacks adaptability to the visualization of charts in different display scenarios, and display errors or poor display effects may occur. Summary of the invention
[0004] Based on this, it is necessary to provide a method, device, computer equipment, computer-readable storage medium and computer program product capable of adaptive page chart layout in order to solve the above technical problems.
[0005] In a first aspect, the present application provides a page chart layout method, comprising:
[0006] Initialize the chart on the page and monitor the size changes of the chart container;
[0007] When a change in the size of the chart container is detected, the viewport size at the current time is obtained, and based on the viewport size and a preset reference resolution, the rendering size of the chart is adjusted to obtain a first chart;
[0008] Adjusting the layout parameters of the first chart to obtain a second chart, wherein the layout parameters include parameters of the skeleton configuration items;
[0009] Based on the viewport size, adjust the graphic configuration item property parameters of the second chart.
[0010] In one embodiment, the skeleton configuration items include: a grid, a legend, and a coordinate axis, and adjusting the parameters of the skeleton configuration items of the first chart includes:
[0011] Adjust the grid margins according to the preset display conversion relationship;
[0012] According to the preset display conversion relationship, adjust the attributes of the legend, wherein the attributes of the legend include the position and height of the legend;
[0013] If the coordinate system of the chart is a rectangular coordinate system, adjust the rectangular coordinate system margins based on the height of the legend and the margins of the grid;
[0014] If the coordinate system of the chart is a polar coordinate system, the radius of the polar coordinate system is determined according to the rendering size, and the center position of the polar coordinate system is adjusted according to the position of the legend.
[0015] In one embodiment, adjusting the attribute parameters of the graphic configuration item of the second chart based on the viewport size includes at least one of the following methods:
[0016] The first item adjusts the font size of the text in the chart according to the viewport size and the preset display conversion relationship;
[0017] The second item is to adjust the graphic size and graphic line width in the second chart according to the preset display conversion relationship;
[0018] The third item is, when the data amount of the second chart is greater than a preset data amount threshold, setting the display state of the graphic text label in the second chart to be invisible;
[0019] The attribute parameters of the graphic configuration item include the font size of the text, the graphic size, the graphic line width, and the display status of the graphic text label.
[0020] In one embodiment, after determining and adjusting the rendering size and the chart layout parameters of the chart based on the viewport size and the chart size, and before adjusting the attribute parameters of the graphic configuration item of the chart based on the viewport size, the method includes:
[0021] Performing data analysis on the chart to obtain data analysis results, wherein the data preprocessing includes at least one of data length analysis, value size analysis, and data duplication analysis;
[0022] Based on the data analysis results, preprocess the data of the chart;
[0023] Adjust the chart's graphical configuration property parameters based on the viewport size, including:
[0024] Adjust the graphics configuration property parameters of the preprocessed chart based on the viewport size.
[0025] In one embodiment, performing data length analysis on a chart includes:
[0026] Determine whether the maximum text length of the chart label exceeds the preset length threshold and obtain the data length analysis result;
[0027] Based on the data analysis results, the chart is preprocessed, including:
[0028] When the data length analysis result indicates that the maximum text length of the label in the chart exceeds the coordinate axis scale width and is less than the preset length threshold of the target label text, the target label text is displayed tilted;
[0029] When the data length analysis result indicates that the maximum text length of the label in the chart is greater than a preset length threshold, the label text greater than the preset length threshold is truncated and displayed.
[0030] In one embodiment, performing numerical value analysis on a chart includes:
[0031] Determine whether the maximum value of the data in the chart meets the preset unit conversion conditions and obtain the numerical value analysis results;
[0032] Based on the numerical analysis results, the chart is preprocessed, including:
[0033] When the maximum value of the data in the chart represented by the numerical value analysis result satisfies the preset unit conversion condition, the unit conversion is performed on the data in the chart according to the unit conversion condition.
[0034] In one embodiment, performing repeated data analysis on a chart includes:
[0035] Determine whether there is duplicate data in the chart and obtain the data duplication analysis results;
[0036] Based on the results of repeated data analysis, the charts are preprocessed, including:
[0037] When the data duplication analysis results indicate that there is duplicate data in the chart, the duplicate data is removed.
[0038] In a second aspect, the present application also provides a page chart layout device, comprising:
[0039] Automatic rendering module, used to initialize the chart on the page and monitor the size changes of the chart container;
[0040] A chart skeleton optimization module is used to obtain the viewport size at the current time when detecting that the size of the chart container has changed, and adjust the rendering size of the chart based on the viewport size and a preset reference resolution to obtain a first chart; adjust the layout parameters of the first chart to obtain a second chart, wherein the layout parameters include parameters of the skeleton configuration items;
[0041] The dynamic configuration item adjustment module is used to adjust the graphic configuration item attribute parameters of the second chart based on the viewport size.
[0042] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned page diagram layout method when executing the computer program.
[0043] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the above-mentioned page diagram layout method when executed by a processor.
[0044] In a fifth aspect, the present application also provides a computer program product, including a computer program, which implements the above-mentioned page diagram layout method when executed by a processor.
[0045] The above-mentioned page chart layout method, device, computer equipment, computer-readable storage medium and computer program product, by initializing the chart in the page, monitors the size change of the chart container, responds to the size change of the chart container, and obtains the viewport size at the current time when the size change of the chart container is monitored, adjusts the rendering size of the chart according to the viewport size and a preset reference resolution, obtains the adjusted first chart, adjusts the parameters of the skeleton configuration items of the first chart to ensure that the content and layout of the main frame of the chart can be correctly and appropriately displayed after the rendering size of the chart changes, and further enables the chart to adapt to the layout display under the current viewport; after obtaining the second chart, adjusts the attribute parameters of the graphic configuration items in the chart according to the viewport size at the current time, so as to achieve the display effect of dynamically adjusting the graphic configuration items following the change of the viewport size, further improving the adaptability of the chart layout, so that it can be suitable for chart layouts under different devices, different resolutions and different viewport sizes. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0047] FIG1 is an application environment diagram of a page chart layout method in one embodiment;
[0048] Figure 2 A schematic diagram of a flow chart of a page diagram layout method in one embodiment;
[0049] Figure 3 A schematic diagram of a flow chart of a page diagram layout method in another embodiment;
[0050] Figure 4A schematic diagram of a flow chart of a page chart layout method in another embodiment;
[0051] Figure 5 A schematic diagram of a flow chart of a page chart layout method in yet another embodiment;
[0052] Figure 6 A schematic diagram of a flow chart of a page chart method in a detailed embodiment;
[0053] Figure 7 A structural block diagram of a page chart layout device in one embodiment;
[0054] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0055] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0056] The page chart layout method provided in the embodiment of the present application can be applied to the application environment shown in FIG1. In which, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers.
[0057] Specifically, the operator may upload the initialization data of the chart to the server 104 through the terminal 102, and then send a chart layout message to the server 104 through the terminal. The server 104 initializes the chart in the page and monitors the size change of the chart container. Secondly, when the size change of the chart container is detected, the viewport size at the current time is obtained, and the rendering size of the chart is adjusted based on the viewport size and a preset reference resolution to obtain a first chart. The layout parameters of the first chart are adjusted to obtain a second chart, and the layout parameters include skeleton configuration item parameters. Finally, based on the viewport size, the graphic configuration item attribute parameters of the second chart are adjusted.
[0058] The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices, and portable wearable devices. The IoT devices may be smart speakers, smart TVs, smart air conditioners, smart car devices, projection devices, etc. Portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. Head-mounted devices may be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. The server 104 may be an independent physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides cloud computing services.
[0059] In an exemplary embodiment, Figure 2 As shown, a page chart layout method is provided, and the method is applied to the server 104 in FIG. 1 as an example for description, including the following steps S200 to S800. Among them:
[0060] S200, initializing a chart in the page, and monitoring size changes of a container of the chart.
[0061] Before initializing the chart in the page, you can create a DOM (Document Object Model) container for displaying the chart and set the width and height of the container. The chart container is used to carry the chart rendering data, and one chart container corresponds to one instance object. The size of the chart container includes the width and height of the chart container.
[0062] In actual applications, the initialization of a chart can be to first create a chart instance and bind it to a container, and then perform initial configuration of the chart. Specifically, the style, data, interactive behavior, and other aspects of the chart can be set through JavaScript objects or JSON format configuration items. The initial configuration of a chart can include setting the chart title, legend, data area scaling, grid lines, X / Y axis, and other configuration items, as well as setting parameters such as color, style, and animation for each data series in the chart. When the chart is initialized, an automatic rendering instance is created. The width change of the chart container size can be monitored by mounting a container size change listener for the chart instance. After the container size change event of the listener is triggered, the layout of the chart is adjusted accordingly.
[0063] S400 , when it is detected that the size of the chart container changes, the viewport size at the current time is obtained, and based on the viewport size and a preset reference resolution, the rendering size of the chart is adjusted to obtain a first chart.
[0064] The viewport refers to the visible area in the browser used to render web page content. When the browser is zoomed in or out, the viewport size will change. The viewport size includes the width and height of the viewport. In order to make the content displayed in the chart adaptive when the viewport size changes, the chart rendering size needs to follow the viewport size change. The chart rendering size includes the width and height of the chart.
[0065] The preset base resolution may refer to the pixels of the display screen in the horizontal direction. The preset base resolution may be used to adjust the container size, rendering size, and size of the configuration item components in the chart to suit the resolutions of different devices. The base resolution may be set according to the resolution specifications of the most commonly used displays. For example, 1080P (1920*1080) is the most common display resolution, and 1920px may be set as the base resolution. It is understandable that different devices have different resolutions, and the base resolution may also be adjusted according to the resolution of the device. For example, if the resolution of the current device is 640*680, the base resolution may be adjusted to 640px according to the horizontal pixels in the resolution.
[0066] In practical applications, after the width of the viewport changes, the size of the chart container can be automatically adjusted to follow the change of the width of the viewport. The size adjustment method of the chart container can be to obtain the width of the viewport at the current time, and obtain the size of the chart container according to the viewport width and the reference resolution. Specifically, the size adjustment method of the chart container can be: the width of the adjusted chart container = (the width of the chart container before adjustment / reference resolution) * the width of the viewport at the current time; the height of the adjusted chart container = (the height of the chart container before adjustment / reference resolution) * the height of the viewport at the current time. Exemplarily, before the width of the viewport changes, the height and width of the chart container are 300px and 400px respectively. Taking the reference resolution of 1920px as an example, the width of the viewport changes and is scaled to 1440px. The height of the chart container is automatically adjusted to (300 / 1920)*1440=225, and the width of the chart is automatically adjusted to (400 / 1920)*1440=300. After the size of the chart's container changes, a container size change event is triggered through a listener to obtain the width of the viewport at the current time. The size parameters of the chart can be modified based on the width of the viewport and the base resolution, thereby adjusting the rendered width and height of the chart to obtain a first chart whose rendering size is adapted to the viewport size at the current time.
[0067] S600: Adjust layout parameters of the first chart to obtain a second chart, where the layout parameters include parameters of skeleton configuration items.
[0068] The skeleton configuration items of a chart may include title, grid, axis, legend, toolbox, etc. Specifically, the parameters of the title may include parameters such as the top margin, bottom margin, left margin, right margin, title width, and title height; the parameters of the legend may include parameters such as the top margin, bottom margin, left margin, and right margin of the legend.
[0069] In actual applications, after adjusting the rendering size of the chart to obtain the first chart, the parameters of the skeleton configuration items of the chart may be converted and adjusted according to a certain ratio based on the viewport size at the current time and the parameters of the skeleton configuration items of the chart at the current time. Alternatively, the parameters of different skeleton configuration items of the chart may be adjusted according to a preset configuration table. The preset configuration table may include specific settings for the skeleton configuration item parameters that are not affected by changes in the chart size, and settings for the skeleton configuration item parameters that change with changes in the chart size. For example, a uniform value may be set for the margins in the axis parameters, such as margin=10px. For the height of the legend, it may be converted based on the viewport size at the current time and the display conversion relationship to change the layout of the first chart and obtain the second chart.
[0070] S800: Adjusting attribute parameters of the graphic configuration item of the second chart based on the viewport size.
[0071] The attribute parameters of the graphic configuration item include the font size of the text, the graphic size, the graphic line width, and the display status of the graphic text label, etc. Among them, the graphic refers to the graphic content drawn in the chart, such as the lines of a line chart, the column rectangle of a bar chart, etc.; the graphic line width refers to the outer contour of the graphic; the graphic text label refers to the data label corresponding to the graphic.
[0072] In actual applications, the attribute parameters of the graphic configuration items in the second chart can be adjusted according to the viewport width at the current time and the preset adjustment conditions. For example, for the adjustment method of the attribute parameters of the graphic configuration items such as the text font size, graphic size and graphic line width, a conversion ratio of the attribute parameters of the graphic configuration item can be determined according to the viewport width at the current time, and the font size, graphic size and graphic line width of the text can be converted and adjusted according to the conversion ratio; for the adjustment method of the display status of the graphic text label, the display status of the graphic text label can be adjusted according to the data volume of the chart. When the data volume is large, the display status of the graphic text label can be turned off to avoid text label overlap.
[0073] In the above-mentioned page chart layout method, by initializing the chart in the page, monitoring the size change of the chart container, responding to the size change of the chart container, and in the case of monitoring the size change of the chart container, obtaining the viewport size at the current time, adjusting the rendering size of the chart according to the viewport size and the preset reference resolution, obtaining the adjusted first chart, adjusting the parameters of the skeleton configuration items of the first chart to ensure that the content and layout of the main frame of the chart can be correctly and appropriately displayed after the rendering size of the chart changes, and further, the chart can be adapted to the layout display under the current viewport; after obtaining the second chart, adjusting the attribute parameters of the graphic configuration items in the chart according to the viewport size at the current time, so as to achieve the display effect of dynamically adjusting the graphic configuration items following the change of the viewport size, further improving the adaptability of the chart layout, so that it can be suitable for chart layouts under different devices, different resolutions, and different viewport sizes.
[0074] In an exemplary embodiment, Figure 3 As shown, S600 includes S602 to S608. Among them:
[0075] S602: Adjust the margin of the grid according to a preset display conversion relationship.
[0076] The display conversion relationship is used to monitor the change of the chart container size, so that the chart can adapt to the current viewport. The display conversion relationship can act on the size of the chart container, the rendering size of the chart, the attribute parameters of the chart's graphic configuration items, the parameters of the skeleton configuration items, etc. The preset display conversion relationship can be the adjusted size = (the size before adjustment / the base resolution) * the current viewport width, or the adjusted parameter = (the parameter before adjustment / the base resolution) * the current viewport width. The grid margin refers to the inner margin, and the grid margin includes the top margin, the bottom margin, the left margin, and the right margin. The grid is used to adjust the position of the chart.
[0077] In actual applications, the margin parameters of the adjusted grid are obtained according to the preset display conversion relationship, and the margin of the grid is adjusted according to the adjusted margin parameters. For example, the left margin of the grid before adjustment is 50 and the base resolution is 1920px. After the current viewport width is expanded to 1440px, according to the display conversion relationship, the left margin of the adjusted grid = (50 / 1920)*1440=37.5.
[0078] S604: Adjust the attributes of the legend according to a preset display conversion relationship, wherein the attributes of the legend include the position of the legend and the height of the legend.
[0079] The position of the legend includes the top margin, bottom margin, left margin and right margin. The display conversion relationship can be adjusted parameter = (parameter before adjustment / base resolution) * current viewport width. The grid margin refers to the inner margin, and the grid margin includes the top margin, bottom margin, left margin and right margin.
[0080] In practical applications, the adjusted position and height parameters of the legend are obtained according to the display conversion relationship, and the legend is adjusted according to the adjusted legend position and height parameters. For example, the height of the legend before adjustment is 20 and the base resolution is 1920px. After the current viewport size is scaled to 1440px, according to the display conversion relationship, the adjusted legend height = (20 / 1920) * 1440 = 15.
[0081] S606: If the coordinate system of the chart is a rectangular coordinate system, adjust the margins of the coordinate axes of the rectangular coordinate system based on the height of the legend and the margins of the grid.
[0082] In practical applications, the margins of the rectangular coordinate components in the chart are controlled by the grid margins. The outer margins of the rectangular coordinate components can be preset to set values, such as margin=10. The setting of the margins of the rectangular coordinate components, that is, the inner margins of the grid, can be adjusted according to the display conversion relationship, and then it can be determined whether the margins of the rectangular coordinate components need to be adjusted according to the legend position and legend height. For example, assuming that the position of the legend is above the rectangular coordinate component, it is determined whether the value of the top margin of the rectangular coordinate component can accommodate the outer margins and the legend. If the top margin of the grid is < the legend height + the outer margin, the top margin of the grid is adjusted. Specifically, the top margin of the grid = the legend height + the outer margin.
[0083] S608: If the coordinate system of the chart is a polar coordinate system, determine the radius of the polar coordinate system according to the rendering size, and adjust the center position of the polar coordinate system according to the position of the legend.
[0084] In practical applications, before adjusting the radius and center position of the polar coordinate system component of the chart, a preset position width can be reserved for the label and label guide line of the chart, for example, the preset position width is 5%. For the adjustment of the radius of the polar coordinate system, it can be that after the rendering size of the chart changes, according to the chart height, legend height in the rendering size of the chart and the radius of the polar coordinate system at the current time, it is determined whether to adjust the radius of the coordinate system. For example, if the radius + legend height > chart height, the radius needs to be adjusted, and the adjusted radius = (chart height - legend height) / chart height * 100 - the position width of the label and label guide line. Generally speaking, the center position of the polar coordinate system is globally centered. For the adjustment of the center position of the polar coordinate system, the offset ratio can be determined according to the position of the legend, and the center position of the polar coordinate system can be adjusted according to the offset ratio. For example, the center position of the polar coordinate system = [`50%`, 50 + offset ratio + `%`], and the offset ratio = legend height / chart height * 100 - the position width of the label and label guide line.
[0085] In some embodiments, the parameters of the title and toolbox in the skeleton configuration items can also be adjusted. The parameters of the title in the first chart can be adjusted by converting the top margin, bottom margin, left margin, right margin, title height and title width of the title according to a preset display conversion relationship to obtain the adjusted title parameters; the parameters of the toolbox in the first chart can be adjusted by converting the top margin, bottom margin, left margin and right margin of the toolbox according to a preset display conversion relationship to obtain the adjusted toolbox parameters.
[0086] In this embodiment, firstly, according to the display conversion relationship, the margins of the grid, the height of the legend and the position of the legend in the skeleton configuration items in the first chart are converted and adjusted. Secondly, according to the legend height and the margins of the grid, the margins of the rectangular coordinate system are adjusted, the radius of the polar coordinate system is determined according to the rendering size of the chart, and the center position of the polar coordinate system is adjusted according to the legend position. This ensures that the layout of the chart is adaptive to the size of the chart container, and automatically adjusts the layout of the main framework content of the chart after the rendering size changes, thereby improving the accuracy of the chart layout display under different viewport sizes, ensuring a suitable layout density, and providing a comfortable visual effect, thereby further improving the user's viewing experience.
[0087] In an exemplary embodiment, Figure 4 As shown, S800 also includes S802 to S806. Among them:
[0088] S802, the first item, adjusts the font size of the text in the chart according to the viewport size and the preset display conversion relationship.
[0089] S804, the second item, adjusting the graphic size and graphic line width in the second chart according to a preset display conversion relationship.
[0090] The display conversion relationship can be adjusted parameter = (parameter before adjustment / base resolution) * current viewport width. Graphics refers to the graphic content drawn in the chart, such as the lines of a line chart, the columnar rectangle of a bar chart, etc. Graphic lines refer to the outer contour of the graphic; graphic text labels refer to the data labels corresponding to the graphics.
[0091] In actual applications, according to the viewport size and the preset display conversion relationship, the font size of the text in the chart can be adjusted by converting the font size of the text through the display conversion relationship. Specifically, the font size of the adjusted text = (font size of the text before adjustment / benchmark resolution) * current viewport width; according to the preset display conversion relationship, the graphic size and graphic line width in the second chart can be adjusted by converting the graphic size and graphic line width through the display conversion relationship. Specifically, the adjusted graphic size = (graphic size before adjustment / benchmark resolution) * current viewport width, and the adjusted graphic line width = (graphic line width before adjustment / benchmark resolution) * current viewport width.
[0092] S806, the third item, when the data volume of the second chart is greater than a preset data volume threshold, setting the display status of the graphic text label in the second chart to invisible.
[0093] The text label of a graphic refers to the data label corresponding to the graphic.
[0094] In actual applications, the adjustment of the display status of the graphic text labels in the second chart can be determined according to the number of the second chart. Specifically, when the data volume is greater than a preset data volume threshold, for example, the data volume threshold is 50, in order to avoid overlapping of graphic text labels, the display status of the graphic text labels is set to a hidden state, that is, an invisible state.
[0095] In some embodiments, the display status of the graphic text labels can be adjusted by setting an interval value to display the text labels at intervals when the amount of data is large. For example, when the interval value is 2, the display status of each 2 text labels is set to visible. In some embodiments, the display status of the graphic text labels can be adjusted by identifying key data according to actual needs during data preprocessing and setting the display status of the text labels of the key data to visible.
[0096] In this embodiment, the text font size, graphic size and line width in the chart are adjusted according to the viewport size at the current time and the preset display conversion relationship, ensuring that the text, graphic size and line width in the chart adapt to the viewport size. When the amount of data in the chart is greater than the preset data volume threshold, the display status of the graphic text label in the second chart is set to invisible, which can avoid the overlapping of text labels due to excessive data volume, further improving the adaptive display of the chart in different viewports.
[0097] In an exemplary embodiment, Figure 5 As shown, after S600 and before S800, including S702 to S706. Among them:
[0098] S702, performing data analysis on the chart to obtain data analysis results, wherein data preprocessing includes at least one of data length analysis, value size analysis, and data duplication analysis.
[0099] S704: Based on the data analysis results, preprocess the data on the chart.
[0100] Data length analysis may refer to analyzing the length of data for display in a chart. For example, the displayed data may include scale label text. Data length analysis may be based on the length of the data in the chart and a preset length threshold to obtain data analysis results. Preprocessing the chart data based on the data analysis results may include displaying the scale label text in an inclined or truncated manner, etc.
[0101] Numerical size analysis may refer to processing the numerical data used for display in a chart. For example, the displayed numerical data may include the numerical data in the scale label text. Data size analysis may be based on the numerical data in the scale label text, determining whether unit conversion is required, obtaining data analysis results, and performing corresponding unit conversion based on the data analysis results.
[0102] Data duplication analysis can be performed by analyzing the data in a chart to determine whether there is duplicate data, obtaining data duplication analysis results, and performing data deduplication or elimination of similar data based on the data duplication analysis results.
[0103] In practical applications, at least one of data length analysis, value size analysis and data repetition analysis can be performed on the data in the chart to obtain corresponding data analysis results, and data preprocessing can be performed on the chart based on the corresponding data analysis results.
[0104] S706: Adjusting the attribute parameters of the graphic configuration items of the preprocessed chart based on the viewport size.
[0105] After preprocessing the data in the chart, the attribute parameters of the graphic configuration items of the chart may be adjusted according to the viewport size and the display conversion relationship.
[0106] In this embodiment, by performing at least one of data length analysis, numerical value size analysis, and data duplication analysis on the chart, an analysis result is obtained, and based on the analysis result, data preprocessing is performed on the chart. According to the viewport size, the attribute parameters of the graphic configuration items of the preprocessed chart are adjusted, which can improve the precision and accuracy of data display at different resolutions, and further improve the accuracy and adaptability of the chart display.
[0107] In an exemplary embodiment, S702 includes S722 to S744. Among them:
[0108] S722, determining whether the maximum text length of the chart label exceeds a preset length threshold, and obtaining a data length analysis result.
[0109] S742, when the data length analysis result indicates that there is a target label text in the chart whose maximum label text length exceeds the coordinate axis scale width and is less than a preset length threshold, the target label text is displayed tilted.
[0110] The data length analysis of the chart includes determining whether the maximum text length of the chart label exceeds a preset length threshold. Specifically, since the maximum text length attribute parameter of the chart label reflects the length of the scale label text of the coordinate axis, the data length analysis method of the scale label text of the coordinate axis can be to obtain the maximum text length of the label of each scale label, and compare the maximum text length of the label of each scale label with the preset length threshold. If there are scale label texts whose maximum text length is less than the preset length threshold but exceeds the coordinate axis scale width, these scale label texts are determined as target label texts, and the target label texts are displayed tilted, wherein the preset length threshold can be a set value, for example, the preset length threshold can be 15 characters, or a benchmark length threshold can be set. When the rendering size of the chart changes, the benchmark length threshold is converted according to the display conversion relationship to adapt to data length analysis in different display environments.
[0111] The method for determining the inclination angle of the target label text can be to determine the inclination angle of the target label text for inclination display according to the scale width, scale height, scale margin, and the maximum diagonal length of the label text of the target label text. Specifically, the inclination angle of the target label text = ((scale height + scale margin) / scale width) / (scale width / maximum diagonal length of the label text).
[0112] S744, when the data length analysis result indicates that the maximum text length of the label in the chart is greater than a preset length threshold, the label text greater than the preset length threshold is truncated and displayed.
[0113] In actual applications, the maximum text length of each scale label is compared with a preset length threshold. If there is a label text with a maximum text length greater than the preset length threshold, the label text of the preset length needs to be truncated and displayed. Specifically, the truncated display method can be achieved by presetting a truncation threshold, such as 5 characters, to truncate the text after the 5th character of the label text and use ellipsis instead of displaying it; or a semantic analysis algorithm can be used to identify keywords in the label text, and truncate and display it by displaying only the keywords.
[0114] In this embodiment, the data length analysis result is obtained by judging whether the maximum text length of the label of the chart exceeds the preset length threshold. When the data length analysis result indicates that the chart has a target label text with a maximum label text length exceeding the coordinate axis scale width and less than the preset length threshold, the target label text is displayed tilted. When the data length analysis result indicates that the chart has a label text with a maximum label text length greater than the preset length threshold, the label text greater than the preset length threshold is truncated and displayed. This can reduce the possibility of overlapping label texts due to changes in the size of the chart, ensure the display of scale labels within a limited space, improve the readability of the label text, and further improve the readability of the chart data in different display environments, thereby improving the adaptability of the chart.
[0115] In an exemplary embodiment, S702 also includes S724 to S746. Among them:
[0116] S724, determining whether the maximum value of the data in the chart meets the preset unit conversion condition, and obtaining the numerical value analysis result.
[0117] S746, when the maximum value of the data in the chart represented by the numerical value analysis result satisfies a preset unit conversion condition, the unit conversion is performed on the data in the chart according to the unit conversion condition.
[0118] In practical applications, the numerical data displayed in the chart can be analyzed for numerical value, and the numerical data displayed in the chart can be the numerical data in the scale label text. For example, the numerical data in the scale label text in the chart can be obtained first, and the maximum and minimum values therein can be taken out to determine whether the maximum or minimum value meets the preset unit conversion condition. Among them, the determination of the maximum value and the preset unit conversion condition can be: determine whether the maximum value is less than the preset percentage unit conversion threshold, if the maximum value is less than the preset percentage unit conversion threshold, all numerical data are converted and displayed in percentage units.
[0119] For example, the preset percentage unit conversion threshold may be 0.01. If the maximum value is less than 0.01, the converted data unit is "%", and the data is converted to data in "%" for display. The judgment of the minimum value and the preset unit conversion condition may be: judging whether the minimum value is within the preset thousandth unit conversion threshold range, all data is converted and displayed in thousandths. For example, if the minimum value is within the threshold range of 1000 to 10000, the converted data unit is "k", and the data is converted to data in "k" for display; judging whether the minimum value is within the preset ten-thousandth unit conversion threshold range, all data is converted and displayed in ten-thousandths. For example, if the minimum value is within the threshold range of 10000 to 10000000, the converted data unit is "w", and the data is converted to data in "w" for display.
[0120] In some embodiments, the analysis of the numerical value may also be to determine the difference between the maximum and minimum values of the numerical data, that is, the range. The larger the range, the greater the numerical difference in the data. When the numerical difference is large, the coordinate axis may be truncated to reduce the display difference of the data on the chart.
[0121] In this embodiment, the numerical value analysis result is obtained by judging whether the maximum value of the data in the chart meets the preset unit conversion condition. When the numerical value analysis result indicates that the maximum value of the data in the chart meets the preset unit conversion condition, the data in the chart is converted according to the unit conversion condition, which can improve the display accuracy and readability of the data, and further improve the readability of the chart.
[0122] In an exemplary embodiment, S702 further includes S726 to S748. Among them:
[0123] S726, determining whether there is duplicate data in the chart, and obtaining data duplication analysis results.
[0124] S748, when the data duplication analysis result indicates that there is duplicate data in the chart, remove the duplicate data.
[0125] In practical applications, data duplication analysis is to determine whether there is duplicate data in the chart and obtain the data duplication analysis results. If there is duplicate data, the duplicate data is removed.
[0126] In some application scenarios, in order to reduce the amount of information on the chart and improve data readability, for repeated analysis of large amounts of data, the method of removing data with similar values can be adopted. Specifically, a similarity threshold can be preset. If the difference between the current data and the previous data is less than the similarity threshold, the current data is removed. The preset similarity threshold can be 0.1.
[0127] In this embodiment, the data duplication analysis result is obtained by determining whether there is duplicate data in the chart. When the data duplication analysis result indicates that there is duplicate data in the chart, the duplicate data is removed to improve the accuracy and readability of the data, thereby further improving the accuracy and readability of the chart.
[0128] In order to make a clearer description of the page chart layout method provided by the present application, the following is a specific embodiment and the attached Figure 6 To illustrate, this specific embodiment includes the following steps:
[0129] S501, initializing a chart in the page, and monitoring size changes of a container of the chart.
[0130] S502 , when it is detected that the size of the chart container changes, the viewport size at the current time is obtained, and based on the viewport size and a preset reference resolution, the rendering size of the chart is adjusted to obtain a first chart.
[0131] S503, adjusting the margin of the grid according to a preset display conversion relationship; adjusting the attributes of the legend according to a preset display conversion relationship, wherein the attributes of the legend include the position of the legend and the height of the legend. If the coordinate system of the chart is a rectangular coordinate system, adjusting the margin of the rectangular coordinate system based on the height of the legend and the margin of the grid; if the coordinate system of the chart is a polar coordinate system, determining the radius of the polar coordinate system according to the rendering size, and adjusting the center position of the polar coordinate system according to the position of the legend, to obtain a second chart.
[0132] S504: Determine whether the maximum text length of the label of the second chart exceeds a preset length threshold, and obtain a data length analysis result.
[0133] S505, when the data length analysis result represents that the chart has a target label text with a maximum label text length exceeding the coordinate axis scale width and less than a preset length threshold, the target label text is displayed tilted; when the data length analysis result represents that the chart has a label text with a maximum label text length greater than a preset length threshold, the label text greater than the preset length threshold is displayed truncated.
[0134] S506, determining whether the maximum value of the data in the second chart meets the preset unit conversion condition, and obtaining a numerical value analysis result. When the numerical value analysis result indicates that the maximum value of the data in the chart meets the preset unit conversion condition, the data in the chart is converted in units according to the unit conversion condition.
[0135] S507, determining whether there is duplicate data in the second chart, obtaining a data duplication analysis result, and removing the duplicate data when the data duplication analysis result indicates that there is duplicate data in the chart.
[0136] S508, adjusting the font size of the text in the chart according to the viewport size and the preset display conversion relationship; adjusting the graphic size and graphic line width in the second chart according to the preset display conversion relationship; when the data volume of the second chart is greater than the preset data volume threshold, setting the display status of the graphic text label in the second chart to invisible.
[0137] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0138] In an exemplary embodiment, Figure 7 As shown, a page chart layout device 900 is provided, including: an automatic rendering module 910, a chart skeleton optimization module 920 and a dynamic configuration item adjustment module 940, wherein:
[0139] The automatic rendering module 910 is used to initialize the chart in the page and monitor the size change of the container of the chart.
[0140] The chart skeleton optimization module 920 is used to obtain the viewport size at the current time when it is monitored that the size of the chart container has changed, adjust the rendering size of the chart based on the viewport size and a preset benchmark resolution to obtain a first chart, adjust the layout parameters of the first chart to obtain a second chart, and the layout parameters include parameters of the skeleton configuration items.
[0141] The dynamic configuration item adjustment module 940 is used to adjust the attribute parameters of the graphic configuration items of the second chart based on the viewport size.
[0142] In an exemplary embodiment, the chart skeleton optimization module 920 is also used to adjust the margins of the grid according to a preset display conversion relationship; adjust the properties of the legend according to a preset display conversion relationship, wherein the properties of the legend include the position of the legend and the height of the legend; if the coordinate system of the chart is a rectangular coordinate system, the margins of the rectangular coordinate system are adjusted based on the height of the legend and the margins of the grid; if the coordinate system of the chart is a polar coordinate system, the radius of the polar coordinate system is determined according to the rendering size, and the center position of the polar coordinate system is adjusted according to the position of the legend; wherein the skeleton configuration items include: grid, legend and coordinate axis, and the parameters of the skeleton configuration items of the first chart are adjusted.
[0143] In an exemplary embodiment, the dynamic adjustment configuration item module 940 is also used to adjust the font size of the text in the chart according to the viewport size and the preset display conversion relationship, adjust the graphic size and graphic line width in the second chart according to the preset display conversion relationship, and when the data volume of the second chart is greater than the preset data volume threshold, set the display status of the graphic text label in the second chart to invisible, wherein the graphic configuration item attribute parameters include the font size of the text, the graphic size, the graphic line width and the display status of the graphic text label.
[0144] In an exemplary embodiment, the page chart layout device 900 also includes a data display optimization module 930, which is used to perform data analysis on the chart to obtain data analysis results after the chart skeleton optimization module 920 determines and adjusts the rendering size and chart layout parameters of the chart based on the viewport size and the chart size, and before the dynamic adjustment configuration item module 940 adjusts the graphic configuration item attribute parameters of the chart based on the viewport size. The data preprocessing includes at least one of data length analysis, numerical value analysis, and data duplication analysis. Based on the data analysis results, data preprocessing is performed on the chart.
[0145] In an exemplary embodiment, the data display optimization module 930 is also used to determine whether the maximum text length of the chart label exceeds a preset length threshold, and obtain a data length analysis result. When the data length analysis result indicates that the chart has a target label text with a maximum label text length that exceeds the coordinate axis scale width and is less than a preset length threshold, the target label text is displayed at an angle; when the data length analysis result indicates that the chart has a label text with a maximum label text length that is greater than a preset length threshold, the label text greater than the preset length threshold is displayed truncated.
[0146] In an exemplary embodiment, the data display optimization module 930 is also used to determine whether the maximum value of the data in the chart meets the preset unit conversion conditions, and obtain the numerical value analysis result. When the numerical value analysis result indicates that the maximum value of the data in the chart meets the preset unit conversion conditions, the data in the chart is converted according to the unit conversion conditions.
[0147] In an exemplary embodiment, the data display optimization module 930 is also used to determine whether there is duplicate data in the chart, obtain a data duplication analysis result, and remove the duplicate data when the data duplication analysis result indicates that there is duplicate data in the chart.
[0148] In an exemplary embodiment, the dynamic configuration item adjustment module 940 is further configured to adjust the graphic configuration item attribute parameters of the pre-processed chart based on the viewport size.
[0149] Each module in the above-mentioned page chart layout device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module.
[0150] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 8As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store chart initialization data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a page chart layout method is implemented.
[0151] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0152] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the steps in any one of the above-mentioned page graph layout method embodiments are implemented.
[0153] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in any one of the above-mentioned page graph layout method embodiments are implemented.
[0154] In one embodiment, a computer program product is provided, including a computer program, which implements the steps of any one of the above-mentioned page graph layout method embodiments when executed by a processor.
[0155] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0156] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0157] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0158] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A page chart layout method, characterized in that: The method comprises: Initialize a chart in the page and monitor the size change of the container of the chart; When a change in the size of the chart container is detected, obtaining the viewport size at the current time, and adjusting the rendering size of the chart based on the viewport size and a preset reference resolution to obtain a first chart; Adjusting layout parameters of the first chart to obtain a second chart, wherein the layout parameters include parameters of skeleton configuration items; Based on the viewport size, a graphic configuration item property parameter of the second chart is adjusted.
2. The method according to claim 1, characterized in that The skeleton configuration items include: a grid, a legend, and a coordinate axis. The parameters for adjusting the skeleton configuration items of the first chart include: Adjusting the margin of the grid according to a preset display conversion relationship; According to the preset display conversion relationship, adjusting the attributes of the legend, wherein the attributes of the legend include the position of the legend and the height of the legend; If the coordinate system of the chart is a rectangular coordinate system, adjusting the margin of the rectangular coordinate system based on the height of the legend and the margin of the grid; If the coordinate system of the chart is a polar coordinate system, the radius of the polar coordinate system is determined according to the rendering size, and the center position of the polar coordinate system is adjusted according to the position of the legend.
3. The method according to claim 1, characterized in that The adjusting the attribute parameters of the graphic configuration item of the second chart based on the viewport size includes at least one of the following methods: The first item is to adjust the font size of the text in the chart according to the viewport size and a preset display conversion relationship; The second item is to adjust the graphic size and graphic line width in the second chart according to the preset display conversion relationship; The third item is, when the data volume of the second chart is greater than a preset data volume threshold, setting the display state of the graphic text label in the second chart to be invisible; The attribute parameters of the graphic configuration item include the font size of the text, the size of the graphic, the width of the graphic line, and the display status of the text label of the graphic.
4. The method according to any one of claims 1 to 3, characterized in that: After determining and adjusting the rendering size and chart layout parameters of the chart based on the viewport size and the chart size, and before adjusting the attribute parameters of the graphic configuration items of the chart based on the viewport size, the method includes: Performing data analysis on the chart to obtain data analysis results, wherein the data preprocessing includes at least one of data length analysis, value size analysis, and data repetition analysis; Based on the data analysis result, performing data preprocessing on the chart; Adjusting the attribute parameters of the graphic configuration item of the chart based on the viewport size includes: Based on the viewport size, the attribute parameters of the preprocessed graphic configuration items of the chart are adjusted.
5. The method according to claim 4, characterized in that The data length analysis of the chart is performed, including: Determine whether the maximum text length of the label of the chart exceeds a preset length threshold, and obtain a data length analysis result; The step of performing data preprocessing on the chart based on the data analysis result includes: When the data length analysis result indicates that the chart has a target label text whose maximum label text length exceeds the coordinate axis scale width and is less than a preset length threshold, the target label text is displayed tilted; When the data length analysis result indicates that the maximum text length of the label text in the chart is greater than a preset length threshold, the label text greater than the preset length threshold is truncated and displayed.
6. The method according to claim 4, characterized in that The numerical analysis of the chart includes: Determine whether the maximum value of the data in the chart meets the preset unit conversion condition, and obtain the numerical value analysis result; The data preprocessing of the chart based on the numerical value analysis result includes: When the numerical value analysis result indicates that the maximum value of the data in the chart satisfies a preset unit conversion condition, the data in the chart is converted into units according to the unit conversion condition.
7. The method according to claim 4, characterized in that Repeated data analysis of the graphs included: Determine whether there is duplicate data in the chart, and obtain data duplication analysis results; The data preprocessing of the chart based on the repeated data analysis results includes: When the data duplication analysis result indicates that duplicate data exists in the chart, the duplicate data is removed.
8. A page chart layout device, characterized in that: The device comprises: An automatic rendering module, used for initializing a chart in a page and monitoring size changes of a container of the chart; A chart skeleton optimization module is used to obtain the viewport size at the current time when the size of the chart container is detected to have changed, and adjust the rendering size of the chart based on the viewport size and a preset reference resolution to obtain a first chart; and adjust the layout parameters of the first chart to obtain a second chart, wherein the layout parameters include parameters of the skeleton configuration items; The module for dynamically adjusting configuration items is used to adjust the layout parameters of the first chart to obtain the second chart, wherein the layout parameters include parameters of the skeleton configuration items.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Chart display method and device for machine data and storage medium
CN121901472A
A method and device for charting display of machine data and a storage medium
CN121901472B
