Label rendering method, device and equipment for horizontal axis of chart and medium

CN120259491APending Publication Date: 2025-07-04BEIJING YOUTEJIE INFORMATION TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510399823.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-01
Publication Date
2025-07-04

AI Technical Summary

Technical Problem

When faced with large data volume and complex application scenarios, the existing chart horizontal axis label rendering methods have poor adaptability, accuracy and readability of label rendering results, resulting in poor user experience.

Method used

By obtaining the original labels of the user's display requirements and the horizontal axis of the chart, calculating the target step size, and using the local curvature algorithm to identify key inflection points, performing label rendering to avoid label overlap and occlusion.

Benefits of technology

Improve the adaptability, accuracy and efficiency of label rendering results, improve the readability of the chart, and improve the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120259491A_ABST
    Figure CN120259491A_ABST
Patent Text Reader

Abstract

The invention discloses a tag rendering method, device and equipment for a chart horizontal axis and a medium. The method comprises the steps of obtaining a display demand of a user for a target chart and all original labels of a horizontal axis of the target chart; according to the display demand and each original label, calculating to obtain a target step length matched with the target chart; and processing the target chart based on a preset local curvature algorithm to obtain at least one target inflection point matched with the target chart, and performing label rendering on the horizontal axis of the target chart based on the target step length and each target inflection point. According to the technical scheme, label rendering of the horizontal axis of the chart under the multi-label condition can be achieved, the adaptability, accuracy and efficiency of a label rendering result are improved, the rendering effect is improved, the readability of the chart is improved, and then the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data display, and in particular, to a method, apparatus, device, and medium for rendering labels on the horizontal axis of a chart. Background Art

[0002] In the current era of digital information explosion, data visualization technology has developed vigorously. As an effective way to intuitively display data, charts are widely used in various fields, such as business data analysis, scientific research, financial statement presentation, etc. In many chart application scenarios, especially when dealing with time series data or categorical data, a large number of character labels are often required to be displayed on the horizontal axis of the chart to identify different data points. However, when the data volume is large, label overlap is likely to occur, causing each label to obscure the others and making it difficult to clearly distinguish; the crowded label distribution makes the entire chart visually chaotic; furthermore, some labels may exceed the display range of the chart, resulting in incomplete presentation of key information.

[0003] To address the above problems, traditional solutions mainly adopt fixed-step or simple interval sampling methods. The fixed-step method selects and displays labels at a pre-set fixed interval, but this method lacks flexibility and cannot adapt to scenarios with different rendering widths and label lengths. The simple interval sampling method extracts a label for display every certain number of data points. Although this method alleviates the label crowding problem to a certain extent, it is prone to missing important information. At the same time, traditional methods cannot intelligently identify key inflection points in the data. In many actual data, key inflection points often contain important information, such as sudden increases or decreases in sales performance. Due to the lack of this intelligent recognition ability, traditional algorithms may ignore this important data, causing users to miss key insights.

[0004] In summary, the existing methods for rendering labels on the horizontal axis of a chart have poor adaptability, accuracy, efficiency of the label rendering results and poor readability of the chart when facing large data volumes and complex application scenarios, which in turn leads to a poor user experience. Summary of the Invention

[0005] The present invention provides a method, apparatus, device, and medium for rendering labels on the horizontal axis of a chart, which can solve the problems of poor adaptability, accuracy, efficiency of the label rendering results and poor readability of the chart existing in the existing methods for rendering labels on the horizontal axis of a chart, which in turn leads to a poor user experience.

[0006] In a first aspect, an embodiment of the present invention provides a method for rendering labels on the horizontal axis of a chart, the method comprising:

[0007] Obtain the display requirements of the user for the target chart and all the original labels on the horizontal axis of the target chart;

[0008] Calculate a target step size that matches the target chart based on the display requirements and each original label.

[0009] Process the target chart based on a preset local curvature algorithm to obtain at least one target inflection point that matches the target chart, and perform label rendering on the horizontal axis of the target chart based on the target step size and each target inflection point.

[0010] In a second aspect, an embodiment of the present invention provides a device for label rendering of the horizontal axis of a chart. The device includes:

[0011] An information acquisition module, configured to acquire the display requirements of a user for a target chart and all original labels of the horizontal axis of the target chart.

[0012] A step size calculation module, configured to calculate a target step size that matches the target chart according to the display requirements and each original label.

[0013] An inflection point calculation module, configured to process the target chart based on a preset local curvature algorithm to obtain at least one target inflection point that matches the target chart, and perform label rendering on the horizontal axis of the target chart based on the target step size and each target inflection point.

[0014] In a third aspect, an embodiment of the present invention provides an electronic device. The electronic device includes:

[0015] At least one processor; and

[0016] A memory communicatively connected to the at least one processor; wherein,

[0017] The memory stores a computer program executable by the at least one processor. When the computer program is executed by the at least one processor, the at least one processor is enabled to execute a method for label rendering of the horizontal axis of a chart according to any embodiment of the present invention.

[0018] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium. The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to execute a method for label rendering of the horizontal axis of a chart according to any embodiment of the present invention when executed.

[0019] The technical solution of the embodiment of the present invention obtains the display requirements of the user for the target chart and all the original labels of the horizontal axis of the target chart, then calculates the target step length matching the target chart according to the display requirements and each original label, and finally processes the target chart based on the preset local curvature algorithm to obtain at least one target inflection point matching the target chart, and performs label rendering on the horizontal axis of the target chart based on the target step length and each target inflection point, solving the problem that the existing chart horizontal axis label rendering method has poor adaptability, accuracy, efficiency of the label rendering result and poor readability of the chart, which in turn leads to poor user experience, realizing the label rendering of the horizontal axis of the chart under the condition of multiple labels, improving the adaptability, accuracy and efficiency of the label rendering result, improving the rendering effect, enhancing the readability of the chart, and thus enhancing the user experience.

[0020] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present invention, nor is it used to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0022] Figure 1a is a flowchart of a method for rendering labels on the horizontal axis of a chart according to Embodiment 1 of the present invention;

[0023] Figure 1b is a schematic diagram of the text height of a label obtained by the method according to Embodiment 1 of the present invention;

[0024] Figure 1c is a schematic diagram of the label rendering result of the horizontal axis of a chart obtained according to Embodiment 1 of the present invention when the label rotation angle is not 0;

[0025] Figure 1d is a schematic diagram of the label rendering result of the horizontal axis of a chart obtained according to Embodiment 1 of the present invention when the label rotation angle is 0;

[0026] Figure 2 is a flowchart of a method for rendering labels on the horizontal axis of a chart according to Embodiment 2 of the present invention;

[0027] Figure 3It is a schematic structural diagram of a label rendering device for the horizontal axis of a chart according to Embodiment 3 of the present invention;

[0028] Figure 4 It is a schematic structural diagram of an electronic device for implementing a method for rendering labels on the horizontal axis of a chart according to an embodiment of the present invention. Detailed implementation manners

[0029] In order to enable those skilled in the art to better understand the solution of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0030] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above drawings are used to distinguish similar objects, and do not necessarily need to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" any variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.

[0031] Embodiment 1

[0032] FIG. 1 is a flowchart of a method for rendering labels on the horizontal axis of a chart according to Embodiment 1 of the present invention. This embodiment is applicable to the situation of rendering labels on the horizontal axis of a chart in the case of multiple labels. This method can be executed by a label rendering device for the horizontal axis of a chart, and the label rendering device for the horizontal axis of a chart can be implemented in the form of hardware and / or software. The label rendering device for the horizontal axis of a chart can be configured in a terminal or server with the function of rendering labels on the horizontal axis of a chart.

[0033] As shown in FIG. 1, the method includes:

[0034] S110. Obtain the display requirements of the user for the target chart and all the original labels of the horizontal axis of the target chart.

[0035] Among them, the display requirements include: the text height of the target chart, the label display interval, the rendering width, the label rotation angle, and the number of target inflection points.

[0036] Specifically, the target chart is a visual carrier for users to display data. It carries various data information and aims to present data characteristics and trends in an intuitive manner. For example, Figure 1c and Figure 1d shown is an example of a type of chart to which the method described in this embodiment can be applied.

[0037] Furthermore, the display requirements are a series of requirements put forward by users based on factors such as their own purposes of using the chart, display scenarios, and directions of key attention to data. Among them, the text height refers to the width of the last character in each label in the chart. Exemplarily, as Figure 1b shown, the text height can be the length of the black straight line above the last character '8' in the label "test_1739531876_1308", that is, the width of the last character '8'. Similarly, the text height can also be Figure 1c the width of the last character '4' in the label "test_1739531874_9194" in. It should be noted that relevant personnel in this field should understand that since the display conditions of all labels, such as font size and inclination, are the same when rendering the horizontal axis labels in the same chart, the widths of the last characters in each label in the chart in this embodiment are equal. That is, the widths of the last characters in each label in the target chart are equal to the text width in the display requirements, and can be set and adjusted manually according to the actual application scenario.

[0038] Furthermore, the label display interval can be used to set the distance between the rendered labels on the horizontal axis of the icon, and the rendering width refers to the horizontal space size occupied by the chart when displayed. Taking a bar chart displayed on a web page as an example, the width of the web page section where it is located is limited. The user sets the rendering width to 800 pixels according to the size of this section to ensure that the chart can be completely and adaptively displayed in the specified area, neither exceeding the display range due to excessive width nor causing incomplete data display due to insufficient width.

[0039] Furthermore, the label rotation angle is a parameter that controls the direction of the horizontal axis labels of the chart and is used to represent the included angle between the direction of the horizontal axis labels of the icon and the horizontal axis of the chart. In some cases, when the label content is long and the quantity is large, in order to make better use of space and avoid overlap between labels, users will choose to rotate the labels. For example, Figure 1c shown is a schematic diagram of the label rendering result of the horizontal axis of the chart obtained by the method described in this embodiment when the label rotation angle is 45 degrees. Figure 1d is a schematic diagram of the label rendering result of the horizontal axis of the chart obtained by the method described in this embodiment when the label rotation angle is 0 degrees.

[0040] Further, all the original labels on the horizontal axis of the target chart are important identification information of the chart data, and they usually come from actual data records. For example, in a chart for counting the population of different regions, the original labels on the horizontal axis may be the names of each region, such as "Beijing", "Shanghai", "Guangzhou", "Shenzhen", etc.; in a conditional sequence chart, the original labels may be strings in a specific format, such as Figure 1c "test_1739531876_1308", "test_1739531874_9194", etc. shown as above. These original labels completely record information such as the categories or time corresponding to the data, and are the basic elements for constructing the chart.

[0041] S120. Calculate a target step size that matches the target chart according to the display requirement and each original label.

[0042] S130. Process the target chart based on a preset local curvature algorithm to obtain at least one target inflection point that matches the target chart, and perform label rendering on the horizontal axis of the target chart based on the target step size and each target inflection point.

[0043] Among them, processing the target chart based on a preset local curvature algorithm to obtain at least one target inflection point that matches the target chart includes: obtaining the data sequence of the target chart, where the data sequence is composed of at least one data point and the original label matching the data point; for each data point in the data sequence, respectively calculate the curvature between the target data point and the data point immediately adjacent to the target data point in the data sequence through the preset local curvature algorithm; based on the curvatures of each data point, perform a descending sort on each data point in the data sequence to obtain a decreasing sequence of positions; obtain the number N of target inflection points in the display requirement, and obtain the first N data points in the decreasing sequence as each target inflection point.

[0044] In a specific implementation method of this embodiment, first, obtain the data sequence of the target chart, where the data sequence is composed of a series of data points and the original labels matched with them. For example, in a chart showing the quarterly sales changes of a certain company, the data points represent the sales values of each quarter, and the original labels are the corresponding quarter names, such as "First Quarter", "Second Quarter", etc. These data points and the original labels correspond one by one, completely recording the specific information of the data and its meaning. Suppose the company's sales in the first quarter are 1 million yuan and in the second quarter are 1.2 million yuan. Then the data sequence will include the data point "100" and its matched original label "First Quarter", as well as the data point "120" and the original label "Second Quarter", etc. Next, for each data point in the data sequence, it is necessary to calculate the curvature between the target data point and the data point immediately adjacent to it in the data sequence through a preset local curvature algorithm; among them, the local curvature algorithm is an algorithm for measuring the degree of curve bending based on the change trend between data points. Specifically, when calculating, it will consider the magnitude of the numerical change between data points and their positional relationship in the data sequence. For example, for the data sequence

[0045] [100, 120, 110, 150], when calculating the curvature of the data point 120, the numerical differences between 120 and the previous data point 100 and the next data point 110 will be analyzed. If the numerical change is relatively gentle, it means that the curve bending degree is small and the curvature is also small; on the contrary, if the numerical change is drastic, such as a large increase from 110 to 150, the curve bending degree is large and the curvature is large. In this way, the change situation of the curve at each data point can be quantified, providing a basis for subsequent screening of key inflection points. After obtaining the curvature of each data point, it is necessary to sort the data points in the data sequence in descending order according to the curvature size to obtain a decreasing point sequence. The purpose of sorting is to arrange the data points with larger curvature in the front and the data points with smaller curvature in the back, so as to clearly distinguish the regions where the data changes relatively smoothly and the regions where the data changes drastically. For example, after calculation and sorting, the original data sequence [100, 120, 110, 150] may correspond to the curvature sequence [0.2, 0.5, 0.3, 0.8]. After sorting, the data point sequence (i.e., the decreasing point sequence) becomes [150, 120, 110, 100], and the corresponding curvature sequence is also adjusted accordingly to

[0046] [0.8, 0.5, 0.3, 0.2]. Then, obtain the number of target inflection points N in the display requirement. This number is preset by the user according to the key points of concern for the data and the purpose of chart display. Finally, obtain the first N data points in the decreasing sequence as each target inflection point. Because in the decreasing sequence, the data points ranked in the front have relatively small curvatures, representing relatively stable data changes; while the data points ranked in the back have relatively large curvatures, meaning relatively drastic data changes and are more likely to be key inflection points. For example, if the number of target inflection points N is 3 and the decreasing sequence is [150, 120, 110, 100] (corresponding to the curvature sequence [0.8, 0.5, 0.3, 0.2]), then the first 3 data points 150, 120, and 110 are determined as the target inflection points.

[0047] Based on the above steps, perform label rendering on the horizontal axis of the target chart based on the target step size and each target inflection point, including: performing a screening operation on each original label based on the target step size to obtain at least one rendered label that matches the target step size; performing a rendering operation on each rendered label and the original labels of each target inflection point based on the display requirement; performing a collision test on each rendered label and the original labels of each target inflection point after the rendering operation to obtain a collision result, and performing an update display operation on each rendered label and the original labels of each target inflection point according to the collision result to obtain a rendering result.

[0048] Specifically, after the rendering operation is completed, a collision test is performed on each rendered label and the original labels of each target inflection point to ensure that the labels do not overlap or obscure each other in the chart. The collision test is achieved by calculating the positions and sizes of the labels in the horizontal and vertical axes of the chart, and sequentially checking the spatial relationships between each label and other labels to determine whether they overlap within the display area. For example, in a bar chart, each label has its corresponding abscissa position and a certain width range. The method described in this embodiment will compare the abscissas and widths of adjacent labels to see if there is an overlapping part. If there is an overlap, it means a collision has occurred. The collision results will be recorded in detail, including information such as the names of the colliding labels, the collision positions, and the degree of overlap. According to the results of the collision test, an update display operation is performed on each rendered label and the original labels of each target inflection point to obtain the final accurate rendering result. If the collision results show that a rendered label collides with other labels and this label is not the original label of the target inflection point, the method described in this embodiment adopts a strategy of skipping the display of this label to give priority to ensuring that the original labels of the target inflection points can be clearly displayed. For example, in a chart showing the sales volume changes of different products, the rendered label "Product A" collides with the original label of the target inflection point "Product B" (the sales volume of Product B has a key change at a certain moment). Since Product B is the target inflection point, the method described in this embodiment will retain the display of the label "Product B" and hide the label "Product A" to ensure that the key data is not obscured. If the collision is between the original labels of two target inflection points, the collision problem will be solved according to the pre-set priority rules, or by trying to adjust the positions of the labels (such as fine-tuning the abscissa positions) or changing the display methods of the labels (such as using abbreviated forms) to ensure that all important label information can be clearly presented in the chart. Through such a series of rigorous operations, the final rendering result can accurately and intuitively display the data, helping users better understand and analyze the information expressed by the chart.

[0049] The technical solution of the embodiment of the present invention obtains the display requirements of the user for the target chart and all the original labels of the horizontal axis of the target chart, then calculates the target step size matching the target chart according to the display requirements and each original label, and finally processes the target chart based on the preset local curvature algorithm to obtain at least one target inflection point matching the target chart, and performs label rendering on the horizontal axis of the target chart based on the target step size and each target inflection point, which solves the problem that the existing chart horizontal axis label rendering method has poor adaptability, accuracy, efficiency of the label rendering result and poor readability of the chart, resulting in poor user experience, realizes the label rendering of the horizontal axis of the chart under the condition of multiple labels, improves the adaptability, accuracy and efficiency of the label rendering result, improves the rendering effect, enhances the readability of the chart, and further improves the user experience.

[0050] Embodiment 2

[0051] Figure 2 FIG. is a flowchart of a method for rendering labels on the horizontal axis of a chart provided in Embodiment 2 of the present invention. This embodiment is refined based on the above embodiment. Specifically, in this embodiment, the method for calculating the target step size matching the target chart according to the display requirements and each original label is refined.

[0052] As Figure 2 shown, the method includes:

[0053] S210. Obtain the display requirements of the user for the target chart and all the original labels of the horizontal axis of the target chart.

[0054] Wherein, the display requirements include: the text height of the target chart, the label display interval, the rendering width, the label rotation angle, and the number of target inflection points.

[0055] S220. Determine whether the label rendering angle in the display requirements is 0;

[0056] If so, execute S230;

[0057] If not, execute S240.

[0058] Exemplarily, as Figure 1c shown, it is a schematic diagram of the label rendering result of the horizontal axis of the chart obtained by the method of this embodiment when the label rotation angle is 45 degrees, Figure 1d and it is a schematic diagram of the label rendering result of the horizontal axis of the chart obtained by the method of this embodiment when the label rotation angle is 0 degrees.

[0059] S230. Calculate the target step length matching the target chart by the dichotomy method according to the rendering width in the display requirement and the label attributes of each original label, and execute S250.

[0060] Specifically, calculating the target step length matching the target chart by the dichotomy method according to the rendering width in the display requirement and the label attributes of each original label includes: obtaining the label lengths of each original label from the label attributes of each original label, and selecting the original label with the largest label length as the first label and the original label with the smallest label length as the second label; calculating the character width of the first label as the first character width according to the label length and the number of characters in the label attributes of the first label, and simultaneously calculating the character width of the second label as the second character width according to the label length and the number of characters in the label attributes of the second label; calculating the average value of the first character width and the second character width as the target character width; obtaining the number of characters of each original label from the label attributes of each original label, and adding up the number of characters of each original label to obtain the total number of characters; calculating the maximum width range matching the target chart based on the formula: maximum width range = number of characters × target character width, and calculating the target step length matching the target chart by the dichotomy method with the label length of the second label as the minimum value and the maximum width range as the maximum value.

[0061] In a specific implementation of this embodiment, exemplarily, first, the label length of each original label is extracted from the label attributes of the original labels. The label length reflects the space occupied by each original label in the horizontal axis direction of the chart. For example, in a chart showing different product names, the label length of "Smart Watch S1" may be 20 pixels, and the label length of "Wireless Headphones Pro" may reach 35 pixels. After obtaining the label lengths of all the original labels, the original label with the largest label length is selected as the first label, and the original label with the smallest label length is selected as the second label. Suppose in a group of original labels ["Laptop X", "Tablet M", "Smart Speaker A", "Wireless Headphones Pro", "Sports Bracelet B"], "Wireless Headphones Pro" has the largest label length and is elected as the first label; "Smart Speaker A" has the smallest label length and becomes the second label. Such a selection provides the basic data for comprehensively considering the label length variation range and calculating the average character width in the follow-up. Next, according to the label length and the number of characters in the label attributes of the first label, the character width of the first label is calculated and used as the first character width. For example, if the label length of "Wireless Headphones Pro" is 35 pixels and the number of characters is 5, then the first character width is 35÷5 = 7 pixels. At the same time, according to the label length and the number of characters in the label attributes of the second label, the character width of the second label is calculated and used as the second character width. Suppose the label length of "Smart Speaker A" is 15 pixels and the number of characters is 3, the second character width is 15÷3 = 5 pixels. Calculating the character widths of the longest and shortest labels respectively helps to understand the character width differences of labels with different lengths and lays the foundation for accurately calculating the average character width. Then, the average value of the first character width and the second character width is calculated and used as the target character width. In the above example, the target character width is (7 + 5)÷2 = 6 pixels. This target character width combines the character width situations of the longest and shortest labels and can more reasonably represent the average width of the characters in the chart. It is a key parameter for calculating the maximum width range in the follow-up. After that, the number of characters of each original label is obtained from the label attributes of the original labels, and the number of characters of all the original labels is added up to get the total number of characters. Suppose the number of characters of this group of original labels ["Laptop X", "Tablet M", "Smart Speaker A", "Wireless Headphones Pro", "Sports Bracelet B"] are 4, 3, 3, 5, 3 respectively, then the total number of characters is 4 + 3 + 3 + 5 + 3 = 18. Then, based on the formula "Maximum width range = Number of characters × Target character width", the maximum width range matching the target chart is calculated. In this example, the maximum width range is 18×6 = 108 pixels. This maximum width range represents the maximum space required on the horizontal axis of the chart if all the labels are tightly arranged according to the target character width.Next, taking the label length of the second label as the minimum value and the maximum width range as the maximum value, the target step size adapted to the target chart is calculated using the dichotomy method. In the calculation process of the dichotomy method here, the results obtained each time during the dichotomy are rounded to the nearest integer. The specific calculation process is as follows: First, set the initial interval. The minimum value is the label length of the second label (such as "Smart Speaker A"), which is 15 pixels, and the maximum value is the calculated maximum width range, which is 108 pixels. Then calculate the midpoint value of the interval. Assuming the current interval is [15, 108], the midpoint value is (15 + 108) ÷ 2 = 61.5 pixels, and after rounding to the nearest integer, it is 62 pixels. Next, based on this rounded midpoint value, simulate the arrangement of the labels in the chart, calculate the step size required at this time, and compare it with the rendering width. If the width required to arrange the labels according to this step size is greater than the rendering width, it indicates that the step size is too small and needs to be increased, so the search interval is adjusted to [62, 108]; if the width required to arrange the labels according to this step size is less than the rendering width, it means that the step size may still be reduced, and the search interval is adjusted to [15, 62]. This process is continuously repeated until a step size is found. Arranging the labels according to this step size can make full use of the rendering width without causing label overlap. This step size is the finally obtained target step size that matches the target chart. For example, after multiple dichotomy calculations and rounding to the nearest integer, the target step size is finally determined to be 4, that is, one label is displayed every 3 original labels, so as to ensure that the labels are reasonably arranged within the rendering width range, improving the readability and aesthetics of the chart.

[0062] S240. Calculate the actual width of each original label through trigonometric functions according to the label rendering angle, and calculate the target step size that matches the target chart according to the actual width and the rendering width in the display requirements, and execute S250.

[0063] Specifically, calculating the actual width of each original label through trigonometric functions according to the label rendering angle, and calculating the target step size that matches the target chart according to the actual width and the rendering width in the display requirements includes: obtaining the text height and label rotation angle in the display requirements, calculating the actual width that matches the target chart through trigonometric functions based on the text height and label rotation angle; obtaining the rendering width in the display requirements, and calculating the target step size that matches the target chart according to the formula target step size = rendering width / actual width.

[0064] Exemplarily, first, after obtaining the text height and the label rotation angle in the display requirements, the actual width matching the target chart is calculated through trigonometric functions based on these two parameters; wherein, the trigonometric function calculation mainly determines the actual width according to the geometric relationship formed after the label is rotated. Taking the trigonometric function relationship of a common right triangle as an example, after obtaining the text height and the label rotation angle, the text height is regarded as the hypotenuse of a right triangle, and based on this, the actual width matching the target chart is calculated through trigonometric functions. Based on the geometric relationship formed by the label rotation, trigonometric functions are used to calculate the actual width. Suppose the label rotation angle is α and the text height is H. In the constructed right triangle, the actual width is solved according to the sine (sin) and cosine (cos) relationships of trigonometric functions. Taking the example where the label is rotated 30 degrees and the text height is 10 pixels, if calculating the actual width in the horizontal direction (assumed to be W), according to the sine function sinα = opposite side / hypotenuse, here the opposite side is the actual width in the horizontal direction we require, and the hypotenuse is the text height, so W = H×sinα = 10×sin30° = 10×0.5 = 5 pixels; if calculating the relevant length in the vertical direction (assumed to be V) for other layout calculations, according to the cosine function cosα = adjacent side / hypotenuse, V = H×cosα = 10×cos30° ≈ 10×0.866 = 8.66 pixels. Through such trigonometric function calculations, the actual occupied width after each original label is rotated can be accurately obtained, providing accurate data for the subsequent calculation of the target step size. Next, the rendering width in the display requirements is obtained. The rendering width refers to the space size occupied by the chart in the horizontal direction during display, and it is set according to the application scenario and display requirements of the chart. For example, in the data statistics section of a web page, due to the limitation of the page layout, the width of the area where the chart is located is limited. To ensure the complete display of the chart and not affect the overall layout of the web page, the user sets the rendering width to 600 pixels. Finally, according to the formula "target step size = rendering width / actual width", the target step size matching the target chart is calculated. For example, the rendering width is 600 pixels, and the calculated actual width of the original label is about 13 pixels, then the target step size

[0065] = 600 / 13 ≈ 46 (here the calculation result is usually appropriately rounded or adjusted according to the actual situation to meet the actual needs). The step size here has a clear meaning. If the step size is 2, it means that one label is displayed for every two labels; if the step size is 80, then one label is displayed for every 80 labels. In this example, the step size is about 46, that is, on the horizontal axis of the chart, one label is displayed for every 46 labels. Such a step size setting can ensure that the labels are reasonably distributed within the limited rendering width, avoid the phenomenon of label overlap, make the chart more clear and orderly, and facilitate users to quickly read and analyze data.

[0066] S250. Process the target chart based on a preset local curvature algorithm to obtain at least one target inflection point that matches the target chart, and perform label rendering on the horizontal axis of the target chart based on the target step size and the target inflection points.

[0067] In the technical solution of the embodiment of the present invention, by obtaining the display requirements of the user for the target chart and all the original labels on the horizontal axis of the target chart, and then determining whether the label rendering angle in the display requirements is 0. If so, the target step size that matches the target chart is calculated by the bisection method according to the rendering width in the display requirements and the label attributes of each original label. If not, the actual width of each original label is calculated by trigonometric functions according to the label rendering angle, and the target step size that matches the target chart is calculated according to the actual width and the rendering width in the display requirements. Finally, the target chart is processed based on a preset local curvature algorithm to obtain at least one target inflection point that matches the target chart, and label rendering is performed on the horizontal axis of the target chart based on the target step size and the target inflection points, which solves the problem that the adaptability, accuracy, efficiency of the label rendering result and the readability of the chart in the existing chart horizontal axis label rendering method are poor, resulting in a poor user experience. It realizes label rendering on the horizontal axis of the chart under multi-label conditions, improves the adaptability, accuracy and efficiency of the label rendering result, improves the rendering effect, enhances the readability of the chart, and thus enhances the user experience.

[0068] Embodiment III

[0069] Figure 3 It is a schematic structural diagram of a label rendering device for the horizontal axis of a chart provided in Embodiment III of the present invention. As Figure 3 shown, the device includes:

[0070] An information acquisition module 310, configured to acquire the display requirements of the user for the target chart and all the original labels on the horizontal axis of the target chart;

[0071] A step size calculation module 320, configured to calculate the target step size that matches the target chart according to the display requirements and each original label;

[0072] An inflection point calculation module 330, configured to process the target chart based on a preset local curvature algorithm to obtain at least one target inflection point that matches the target chart, and perform label rendering on the horizontal axis of the target chart based on the target step size and the target inflection points. Beneficial effects of the independent claim

[0073] The technical solution of the embodiment of the present invention obtains the display requirements of the user for the target chart and all the original labels of the horizontal axis of the target chart, then calculates the target step size matching the target chart according to the display requirements and each original label, and finally processes the target chart based on the preset local curvature algorithm to obtain at least one target inflection point matching the target chart, and performs label rendering on the horizontal axis of the target chart based on the target step size and each target inflection point, solving the problem that the existing chart horizontal axis label rendering method has poor adaptability, accuracy, efficiency of the label rendering result and poor readability of the chart, thereby resulting in poor user experience, realizing label rendering of the horizontal axis of the chart under multi-label conditions, improving the adaptability, accuracy and efficiency of the label rendering result, improving the rendering effect, enhancing the readability of the chart, and further enhancing the user experience.

[0074] Based on the above embodiment, the step size calculation module 320 includes:

[0075] An angle judgment unit for judging whether the label rendering angle in the display requirements is 0;

[0076] A first step size calculation unit for, if so, calculating the target step size matching the target chart by the dichotomy method according to the rendering width in the display requirements and the label attributes of each original label;

[0077] A second step size calculation unit for, if not, calculating the actual width of each original label through trigonometric functions according to the label rendering angle, and calculating the target step size matching the target chart according to the actual width and the rendering width in the display requirements.

[0078] Based on the above embodiment, the first step size calculation unit includes:

[0079] A label selection unit for obtaining the label lengths of each original label in the label attributes of each original label, selecting the original label with the largest label length as the first label, and selecting the original label with the smallest label length as the second label;

[0080] A character width calculation unit for calculating the character width of the first label as the first character width according to the label length and the number of characters in the label attributes of the first label, and simultaneously calculating the character width of the second label as the second character width according to the label length and the number of characters in the label attributes of the second label;

[0081] A character average value calculation unit for calculating the average value of the first character width and the second character width as the target character width;

[0082] A character superposition unit, configured to obtain the number of characters of each original label from the label attributes of each original label, and superimpose the number of characters of each original label to obtain the total number of characters;

[0083] A dichotomy unit, configured to calculate, based on the formula: maximum width range = number of characters × target character width, a maximum width range matching the target chart, and calculate, by dichotomy, a target step length matching the target chart with the label length of the second label as the minimum value and the maximum width range as the maximum value.

[0084] Based on the above embodiments, the second step length calculation unit includes:

[0085] An actual width calculation unit, configured to obtain the text height and label rotation angle in the display requirement, and calculate, through trigonometric functions based on the text height and label rotation angle, an actual width matching the target chart;

[0086] A target step length calculation unit, configured to obtain the rendering width in the display requirement, and calculate, according to the formula target step length = rendering width / actual width, a target step length matching the target chart.

[0087] Based on the above embodiments, the inflection point calculation module 330 includes:

[0088] A data sequence acquisition unit, configured to acquire the data sequence of the target chart, where the data sequence is composed of at least one data point and an original label matching the data point;

[0089] A curvature calculation unit, configured to calculate, for each data point in the data sequence, the curvature between the target data point and the data point immediately adjacent to the target data point in the data sequence respectively through a preset local curvature algorithm;

[0090] A sorting unit, configured to sort the data points in the data sequence in a decreasing order based on the curvatures of the data points to obtain a decreasing point sequence;

[0091] A target inflection point acquisition unit, configured to obtain the number N of target inflection points in the display requirement, and acquire the first N data points in the decreasing sequence as the respective target inflection points.

[0092] Based on the above embodiments, the inflection point calculation module 330 includes:

[0093] A label screening unit, configured to perform a screening operation on each original label based on the target step length to obtain at least one rendering label matching the target step length;

[0094] A rendering unit, configured to perform a rendering operation on each rendering label and the original labels of each target inflection point based on the display requirement;

[0095] A collision test unit is configured to perform a collision test on each rendered label and the original label of each target inflection point after a rendering operation to obtain a collision result, and perform an update display operation on each rendered label and the original label of each target inflection point according to the collision result to obtain a rendering result.

[0096] The label rendering device for the chart horizontal axis provided by an embodiment of the present invention can execute the label rendering method for the chart horizontal axis provided by any embodiment of the present invention, and has function modules and beneficial effects corresponding to the execution of the method.

[0097] Embodiment Four

[0098] Figure 4 FIG. shows a schematic structural diagram of an electronic device 10 that can be used to implement the embodiments of the present invention. The electronic device is intended to represent various forms of digital computers, such as, for example, a laptop computer, a desktop computer, a workbench, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as, for example, a personal digital processor, a cellular phone, a smart phone, a wearable device (such as a helmet, glasses, a watch, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present invention described and / or claimed herein.

[0099] As Figure 4 shown, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc. Among them, the memory stores a computer program executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.

[0100] Multiple components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disc, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0101] The processor 11 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a method for rendering labels on the horizontal axis of a chart.

[0102] Correspondingly, the method includes:

[0103] Obtain the display requirements of the user for the target chart and all the original labels on the horizontal axis of the target chart;

[0104] Calculate a target step size that matches the target chart based on the display requirements and each original label;

[0105] Process the target chart based on a preset local curvature algorithm to obtain at least one target inflection point that matches the target chart, and render labels on the horizontal axis of the target chart based on the target step size and each target inflection point.

[0106] In some embodiments, a method for rendering labels on the horizontal axis of a chart can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the method for rendering labels on the horizontal axis of a chart described above can be executed. Alternatively, in other embodiments, the processor 11 can be configured to execute a method for rendering labels on the horizontal axis of a chart in any other suitable manner (e.g., by means of firmware).

[0107] The various embodiments of the systems and techniques described above in this specification can be implemented in digital electronic circuitry, integrated circuit systems, field programmable gate arrays (FPGA), application specific integrated circuits (ASIC), application specific standard products (ASSP), systems-on-chip (SOC), complex programmable logic devices (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which may be a special-purpose or general-purpose programmable processor that receives data and instructions from, and transmits data and instructions to, a storage system, at least one input device, and at least one output device.

[0108] The computer programs for implementing the methods of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions / operations specified in the flowchart and / or block diagram to be implemented. The computer programs may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.

[0109] In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, the computer-readable storage medium may be a machine-readable signal medium. More specific examples of the machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0110] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, speech input, or tactile input).

[0111] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer having a graphical user interface or a web browser through which the user can interact with an implementation of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected to each other by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local area network (LAN), wide area network (WAN), blockchain network, and the Internet.

[0112] A computing system can include a client and a server. The client and the server are generally remote from each other and typically interact through a communication network. The client-server relationship is created by computer programs that run on respective computers and have a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system, and solves the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS services.

[0113] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps recited in the present invention can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved, and no limitation is imposed herein.

Claims

1. A method for rendering labels on the horizontal axis of a chart, characterized in that, Including: Obtaining the display requirements of the user for the target chart and all the original labels of the horizontal axis of the target chart; Calculating a target step size that matches the target chart according to the display requirements and each original label; Processing the target chart based on a preset local curvature algorithm to obtain at least one target inflection point that matches the target chart, and performing label rendering on the horizontal axis of the target chart based on the target step size and each target inflection point.

2. The method according to claim 1, wherein The display requirements include: the text height of the target chart, the label display interval, the rendering width, the label rotation angle, and the number of target inflection points.

3. The method according to any one of claims 1-2, characterized in that Calculating a target step size that matches the target chart according to the display requirements and each original label includes: Determining whether the label rendering angle in the display requirements is 0; If so, calculating the target step size that matches the target chart by the dichotomy method according to the rendering width in the display requirements and the label attributes of each original label; If not, calculating the actual width of each original label by trigonometric functions according to the label rendering angle, and calculating the target step size that matches the target chart according to the actual width and the rendering width in the display requirements.

4. The method according to any one of claims 2-3, characterized in that Calculating the target step size that matches the target chart by the dichotomy method according to the rendering width in the display requirements and the label attributes of each original label includes: Obtaining the label lengths of each original label from the label attributes of each original label, and selecting the original label with the largest label length as the first label and the original label with the smallest label length as the second label; Calculating the character width of the first label as the first character width according to the label length and the number of characters in the label attributes of the first label, and simultaneously calculating the character width of the second label as the second character width according to the label length and the number of characters in the label attributes of the second label; Calculating the average value of the first character width and the second character width as the target character width; Obtaining the number of characters of each original label from the label attributes of each original label, and adding up the number of characters of each original label to obtain the total number of characters; Calculating the maximum width range that matches the target chart based on the formula: maximum width range = number of characters × target character width, and calculating the target step size that matches the target chart by the dichotomy method with the label length of the second label as the minimum value and the maximum width range as the maximum value.

5. The method according to any one of claims 2-3, characterized in that Calculating the actual width of each original label by trigonometric functions according to the label rendering angle, and calculating the target step size that matches the target chart according to the actual width and the rendering width in the display requirements includes: Obtaining the text height and the label rotation angle in the display requirements, and calculating the actual width that matches the target chart by trigonometric functions based on the text height and the label rotation angle; Obtaining the rendering width in the display requirements, and calculating the target step size that matches the target chart according to the formula target step size = rendering width / actual width.

6. The method according to any one of claims 1-2, characterized in that, Processing the target chart based on a preset local curvature algorithm to obtain at least one target inflection point that matches the target chart includes: Obtain the data series of the target chart, where the data series consists of at least one data point and the original label matching the data point; For each data point in the data series, calculate the curvature between the target data point and the data point immediately adjacent to the target data point in the data series respectively through a preset local curvature algorithm; Based on the curvatures of the data points, sort the data points in the data series in descending order to obtain a point position descending sequence; Obtain the target inflection point number N in the display requirement, and obtain the first N data points in the descending sequence as each target inflection point.

7. The method according to claim 1, characterized in that Based on the target step size and the target inflection points, perform label rendering on the horizontal axis of the target chart, including: Perform a screening operation on each original label based on the target step size to obtain at least one rendering label matching the target step size; Perform a rendering operation on each rendering label and the original label of each target inflection point based on the display requirement; Perform a collision test on each rendering label and the original label of each target inflection point after the rendering operation to obtain a collision result, and update the display operation on each rendering label and the original label of each target inflection point according to the collision result to obtain a rendering result.

8. A label rendering device for the horizontal axis of a chart, characterized in that, including: An information acquisition module for acquiring the display requirement of the user for the target chart and all the original labels of the horizontal axis of the target chart; A step size calculation module for calculating a target step size matching the target chart according to the display requirement and each original label; An inflection point calculation module for processing the target chart based on a preset local curvature algorithm to obtain at least one target inflection point matching the target chart, and performing label rendering on the horizontal axis of the target chart based on the target step size and the target inflection points.

9. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute a method for label rendering of the horizontal axis of a chart according to any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a processor to implement a method for label rendering of the horizontal axis of a chart according to any one of claims 1-7 when executed.