Android table icon library production

A chart lib has been written before, but it is difficult to keep up with the pace of product demand changes due to the speed of development. Therefore, the original chart library is modified to support the integration of table under the chart to display the corresponding categories, replace broken lines with curves, support the display of multiple curves, increase the display animation, and add some customizable attributes, It supports the display of horizontal bar chart and superimposed bar chart, as well as multi curve chart and pie chart

1. Renderings

2. Usage of various charts 1. Pie chart is the same as the original use, but an animation is added. See the previous article, pie chart usage. 2. Horizontal multi histogram 2.1 XML layout

2.2 data setting

3. Overlay histogram 3.1 XML layout

3.2 data settings, as in 2.2. 3. Several key points implemented. 3.1 width needs to be rewritten. Onmeasure, because the width of the control is greater than the width of the screen. The width is composed of the displayed X-axis points and spacing, and the width distance occupied by the y-axis coordinate text.

3.2 plan a fixed area, which is not visible in the part beyond the area. This is implemented in the bitmap used before. It always feels awkward. When you read the official source code, you know the canvas clipRect method. When we draw this piece, we call the onDraw method.

3.3 we can basically use valueanimator to realize animation, such as pie chart: one of his drawings is the change of angle from 0 to 360, so we can

Then use mdrawangle to control the angle of each drawing, so that you can have the feeling of drawing from 0-360 degrees. The animation of the histogram is the same, so as to keep unchanged and adapt to changes.

3.4 algorithm of Bezier curve drawing

When drawing Bezier curves, I carefully checked the calculation rules of these control points and calculated two control points according to three points. However, the curve drawn in this way is very smooth within the three points, but it doesn't feel very good when the next fourth point is connected, so I still used the above calculation method to calculate the control points, and I posted the algorithm, The parameters are the X and Y coordinates and bending coefficient of 1, 2 and 3, respectively

3. Library import method

GitHub address

The above is the whole content of this small compilation. Thank you for your support for programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>