HTML5 pie chart (Statistical Chart)

Source: Internet
Author: User

HTML5 provides a powerful drawing API that allows us to easily draw various images using JavaScript. This article describes how to use HTML5 to draw a pie chart (Statistical Chart. First look at the pie chart effect:

This chart is dynamically generated. It dynamically draws a pie chart based on the input ratio parameter (array. The size of the pie chart is dynamically adjusted based on the <canvas> height.

AllCodeAs follows:

<! Doctype HTML> 

This function can be used directly. If you want to make it more beautiful, you can add some extra beautiful painting.

The maximum flexibility of this Code is to separate the drawing parameters from the drawing code. The pie chart size is automatically adjusted according to the canvas container height. The parameter passing method is as follows:

 
VaR data_arr = [0.05, 0.25, 0.6, 0.1]; // proportional data var color_arr = ["#00ff21", "# ffaa00", "#00 AABB ", "# ff4400"]; // color var text_arr = ["first quarter", "second quarter", "third quarter", "fourth quarter"]; // text // draw the pie chart drawcircle ("canvas_circle", data_arr, color_arr, text_arr );

If any error occurs, please correct it!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.