Method for realizing radial gradual change of pie chart in visual chart

By defining the pie chart component and clipping path technology, calculating the angle of the fan area and cutting the gradient color elements, the problem of unsatisfactory pie chart gradient effect in the existing technology is solved, and the natural transition of the radial gradient effect is achieved and Visual aesthetics.

CN118918215APending Publication Date: 2024-11-08CHONGQING TIANZHIQI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410929866.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-11
Publication Date
2024-11-08

AI Technical Summary

Technical Problem

The existing open source chart library cannot effectively realize the radial gradient effect of pie charts, resulting in unsatisfactory gradient effect and it is difficult to control the consistency and visual aesthetics of the gradient effect.

Method used

By defining the pie chart component, calculating the angle of the sector area, defining the clipping path, cutting the gradient color element at the required angle, obtaining the visible part, and matching it with the display range, outputting the gradient color pie chart to ensure that the gradient transition is natural and smooth .

Benefits of technology

The radial gradient effect of the pie chart is realized, ensuring the natural transition of gradients, improving visual aesthetics and the accuracy of data expression, and meeting the data visualization needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118918215A_ABST
    Figure CN118918215A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of chart rendering, and discloses a method for realizing radial gradual change of a pie chart in a visual chart, which comprises the following steps of: 1, defining a pie chart component for loading input gradual change color elements; step 2, calculating a ratio of the input data to the overall data, calculating an angle of the input data in a corresponding fan-shaped region in the pie chart according to the ratio, and obtaining a display range of the input data; 3, defining a shearing path according to the angle of the fan-shaped region, and shearing the gradient color elements according to the angle of the fan-shaped region in the defined pie chart component to obtain a visible part; and 4, matching the visible part with the display range, and outputting the gradient pie chart of the input data part. According to the method, only one part of the element is displayed to achieve the effect of a radial gradually-changed pie chart, so that the visual effect is more distinct, and the method is simpler to use.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of chart rendering, and in particular to a method for realizing radial gradient of a pie chart in a visualization chart. Background Art

[0002] In today's data visualization field, JavaScript-based open source chart libraries have become the preferred tool for developers to build complex data display interfaces due to their flexibility, ease of use, and extensive community support. These chart libraries widely use Canvas or SVG as the underlying rendering technology, and efficiently realize the dynamic generation and interaction of various chart types including pie charts through data-driven views. As a classic chart type that intuitively displays the distribution of data proportions, the core of the pie chart design is to clearly distinguish and display the differences between various data items.

[0003] In traditional pie chart design, in order to improve the intuitiveness and aesthetics of data expression, different colors are usually assigned to different sectors to distinguish each data part. Conventional color display is well supported in most mainstream open source chart libraries. Developers can easily implement basic color configuration through preset color schemes or custom color values. However, when gradient colors are needed, due to the special structure of the pie chart, each sector area is rendered as an independent unit. Each sector area will use half of the radius of the pie chart as the starting point of its own circular gradient setting, and the gradient range is often limited by the actual size of the sector, resulting in unsatisfactory final presentation results. Summary of the invention

[0004] The present invention aims to provide a method for realizing radial gradient of pie charts in visual charts, so as to solve the problem that the existing open source chart library cannot realize radial gradient effect of pie charts.

[0005] To achieve the above purpose, the present invention adopts the following technical solution, which is used to visualize the method of realizing radial gradient of pie chart in the chart, by defining the pie chart component and defining the clipping path to obtain the visible part of the gradient image, so as to realize the radial gradient display of the pie chart. Specifically, it includes the following steps:

[0006] Step 1: Define a pie chart component to load the input gradient color element;

[0007] Step 2: Calculate the ratio of the input data to the overall data, and calculate the angle of the corresponding sector area of ​​the input data in the pie chart according to the ratio to obtain the display range of the input data;

[0008] Step 3, define a clipping path according to the angle of the sector area, which is used to clip the gradient color element according to the angle of the sector area in the defined pie chart component to obtain the visible part;

[0009] Step 4: Match the visible part with the display range and output a gradient color pie chart of the input data part.

[0010] The principles and advantages of this solution are:

[0011] Due to the special structure of pie charts, each sector is rendered as an independent unit. When trying to apply radial gradient, existing chart libraries can only treat a single sector as a whole, and use half of the radius of the pie as its radial starting point, and gradient outward along the radial direction. This implementation method is not only difficult to control the consistency of the gradient effect of the entire chart, but may also cause the gradient edges between adjacent sector areas to be abrupt, affecting the visual beauty and the accuracy of data communication.

[0012] However, due to the maturity of basic rendering technology, we rely too much on the automatic rendering generation method of rendering software. Automatic generation needs to start rendering based on the starting point, but it is limited by the special structure of the fan and the uncertain fan range area. It is difficult to accurately determine the rendering starting point for the gradient rendering of the fan area, and it is difficult to solve the problem of unsatisfactory rendering effect of the fan area.

[0013] This solution breaks away from the inherent thinking mode of relying on automatic rendering, and breaks the problem of having to accurately locate the starting point of rendering. It adopts a custom pie chart component and defines the clipping path according to the calculated display range. The visible part is cut out from the complete pie chart image at the required angle, and the visible part is matched and combined with the display range to achieve a radial gradient display effect in the sector area, ensuring that the gradient transition between each sector area is natural and smooth, while maintaining the accuracy of data expression and the attractiveness of visual effects to meet the growing needs of data visualization. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] Figure 1 The present invention is a flow chart of a method for realizing radial gradient of a pie chart in a visualized chart. DETAILED DESCRIPTION

[0015] The following is further described in detail through specific implementation methods:

[0016] Embodiment 1

[0017] As attached Figure 1 As shown, the method for realizing radial gradient of pie chart in the visualization chart in this embodiment, the method customizes the pie chart component, automatically calculates the display range of the current data, and obtains the visible part of the picture corresponding to the display range by defining the clipping path, so as to realize radial gradient of the sector area and improve the display effect. In this embodiment, the following steps are specifically included:

[0018] S1, define a pie chart component through a data-driven view, then input a complete gradient color element into the pie chart component, and load the input gradient color element through the pie chart component. In this embodiment, the gradient color element includes gradient color circular images, chart data and other loadable gradient color elements. Among them, a complete gradient color image refers to an image whose color smoothly transitions from one or more colors to another color or multiple colors, forming a continuous color change effect. Specifically, it is a radial color change, which not only includes the gradient effect itself, but also the gradient is complete and coherent in the picture, without interruptions or sudden color changes.

[0019] The pie chart component is divided into 5 areas to ensure that a complete pie chart can be formed by fewer divided areas. In this embodiment, they are 0-45 degrees, 45-135 degrees, 135-225 degrees, 225-315 degrees, and 315-360 degrees, respectively, with the purpose of realizing that all the sector areas of a pie chart can be completely covered in the CSS trabsition attribute, while the area division is simpler and faster, ensuring the accuracy and completeness of the area division, and the components used to form a complete pie chart can better display the relationship or trend between data, and more accurately locate the clipping path of the component to ensure the rapid definition of the clipping path.

[0020] S2, calculates the ratio of the input data to the overall data, and through the defined pie chart component, automatically calculates the sector area angle of the input data in the pie chart according to the ratio, and obtains the display range of the input data in the pie chart.

[0021] S3, defining a clipping path according to the angle of the fan-shaped area to determine the visible portion of the element. In this embodiment, the clipping path is customized through the clip-path attribute in CSS, and the clip-path attribute can be used for various HTML elements, including images, texts, and backgrounds.

[0022] In the defined pie chart component, the gradient color image (gradient color element) is cut according to the angle of the sector area to obtain the visible part, so that only a part of the image is displayed according to the required display range, which not only ensures the effect of color gradient continuity, but also meets the gradient requirements of the sector area. In this embodiment, according to the divided pie chart area, the area where the clipping path is located can be quickly located according to the obtained angle, and an accurate clipping path can be quickly formed to improve the processing speed of the visible part.

[0023] S4, matches the visible part with the calculated display range, and finally outputs a gradient color pie chart of the input data part to achieve a gradient color effect presentation of the sector-shaped area.

[0024] In this embodiment, after matching, the edge area of ​​the cut visible part is set with a color transition according to the matching splicing color. Specifically, the transition is set by the transition attribute of CSS to ensure the coordination and continuity of the colors of the visible part and the connecting part, reduce abruptness, and improve aesthetics.

[0025] In this embodiment, the display range of the current data, that is, the angular range of the sector area, is automatically calculated by inputting the proportion of the data, and the corresponding display range is obtained. The clipping path is defined according to the set pie chart component to determine the visible part of the element, and then the transition is set by the CSS trabsition attribute. By displaying only a part of the image, the effect of a radial gradient pie chart can be achieved.

[0026] In this embodiment, since the existing rendering method is too dependent on the automatic rendering generation method of the rendering software, and the automatic generation needs to start rendering based on the starting point, but is limited by the special structure of the sector and the uncertain sector range area, it is difficult to accurately determine the rendering starting point for the gradient rendering of the sector area, and it is difficult to solve the problem of unsatisfactory rendering effect of the sector area. This solution breaks out of the inherent thinking mode of relying on automatic rendering, breaks the problem of accurately locating the rendering starting point, and achieves the radial gradient display effect of the sector area by cutting the complete picture to match the display range, improving the visual effect of the gradient display of the pie chart.

[0027] The above is only an embodiment of the present invention, and the common knowledge such as the known specific technical solutions and / or characteristics in the solution is not described in detail here. It should be pointed out that for those skilled in the art, without departing from the technical solution of the present invention, several modifications and improvements can be made, which should also be regarded as the protection scope of the present invention, and these will not affect the effect of the implementation of the present invention and the practicality of the patent. The scope of protection required by this application shall be based on the content of its claims, and the specific implementation methods and other records in the specification can be used to interpret the content of the claims.

Claims

1. A method for realizing radial gradient of a pie chart in a visualization chart, characterized in that: The following steps are involved: Step 1: Define a pie chart component to load the input gradient color element; Step 2: Calculate the ratio of the input data to the overall data, and calculate the angle of the corresponding sector area of ​​the input data in the pie chart according to the ratio to obtain the display range of the input data; Step 3, define a clipping path according to the angle of the sector area, which is used to clip the gradient color element according to the angle of the sector area in the defined pie chart component to obtain the visible part; Step 4: Match the visible part with the display range and output a gradient color pie chart of the input data part.

2. The method for realizing radial gradient of pie chart in a visualized chart according to claim 1, characterized in that: The method also includes setting a color transition for the edge area of ​​the cut-out visible part according to the splicing color after matching.

3. The method for realizing radial gradient of pie chart in a visualized chart according to claim 1, characterized in that: In step one, the pie chart component is also divided into five areas so as to form a complete pie chart.

4. The method for realizing radial gradient of pie chart in a visualized chart according to claim 3, characterized in that: The five areas include 0-45 degrees, 45-135 degrees, 135-225 degrees, 225-315 degrees, and 315-360 degrees.

5. The method for realizing radial gradient of pie chart in a visualized chart according to claim 1, characterized in that: The pie chart component is customized through a data driven view.

6. The method for realizing radial gradient of pie chart in a visualization chart according to claim 1, characterized in that: The clipping path is customized through the clip-path property in CSS, and the clip-path property is used for various HTML elements.

7. The method for realizing radial gradient of pie chart in a visualized chart according to claim 6, characterized in that: The HTML elements include images, texts and backgrounds.

8. The method for realizing radial gradient of pie chart in a visualization chart according to claim 1, characterized in that: The input gradient color element is a circular image containing a complete gradient color.

9. The method for realizing radial gradient of pie chart in a visualized chart according to claim 2, characterized in that: The color transition of the visible part is set by the CSS transition property.

10. The method for realizing radial gradient of pie chart in a visualization chart according to claim 1, characterized in that: The gradient color element also includes chart data.