Creating a pie chart
When visualizing proportions or percentages as a whole, we usually use pie charts. Pie charts are simple enough to draw on our own; however, to get more flexibility and aesthetically pleasing results, we're going to use the Flot charting library with its pie plugin.
Flot's pie plugin can show a pie with or without a legend, and has extensive options for controlling the position of the labels. It's also capable of rendering tilted pies and donuts. Support for interactive pies is also included.
In this recipe, we're going to make a pie chart of our visitor's browsers.
Getting ready
We'll need to download Flot from the official website at http://www.flotcharts.org/ and extract the contents to a separate folder named flot
.
How to do it...
Let's write the HTML and JavaScript code.
Create the following HTML page in
index.html
:<!DOCTYPE HTML> <html> <head> <title>Chart example</title> </head> <body> <div id=...