Creating a Pie Chart in Sketch the right way
What is the first thought that pops into your head when someone mentions a pie chart? I always think of the ugly pie charts from Microsoft Word back in the day, and I don’t know why. I must have hated graphs in high school.
While they are good at showing the relationship between parts as a whole, pie charts don’t convey information in the best way. Well, that is a topic for another time.
In this article, I’ll talk about a few ways you can create pie charts in Sketch app. Unfortunately, there is no out of the box method of creating a pie chart in Sketch app, so we’ll have to use some hacks and a plugin. First, we’re going to explore how to do one with the help of an angular gradient.
Angular Gradient Method
Let’s start by creating a circle with an Oval Tool (O). Hold Shift key when dragging an oval to make it a perfect circle and then change the fill to Angular Gradient (fourth from the left). If you have any border, turn it off by deselecting the checkmark in the border panel or right-clicking on the border color and selecting Remove.
You’ll immediately notice two different colors in the same position. Starting and ending colors divides each section which gives you a nice sharp edge between the slices.
Now to the splitting part. I’m going to make a pie chart with five equal slices. The easiest way to divide them is to click on the Plus symbol while hovering over the outer section of the oval. You can also double click on the gradient fill in the inspector panel.
Splitting pie chart into equal slices can be complicated, but luckily for us, there is a trick that makes splitting a lot easier. To put a color it in the middle of the other two, select the color you’d like to align and hit Equals Sign (=) on the keyboard. This is going to position a selected color perfectly in the middle of the other two in the gradient line.
The next step is to colorize to the slices. Add another color by clicking on the oval and make sure it is the same position as the dividers. Drag a color, so it displayed on top of the other color. This is how you’ll specify a starting and end color of the slice divider.
This is the hard part so don’t worry if you don’t succeed straight away. The inside color represents a starting color of the slice while the outer one represents an ending one. If you can’t get the right color for a particular slice, try to reposition the outside color a bit on the either side. Don’t forget to save this gradient to Document Gradients so you can re-use it later. Click on the plus icon (+) on the gradients fill panel to save it.
You can now convert this pie chart into a donut chart with almost no effort. To do that disable Fill on the current one and make a border with desired thickness. Now apply the Angular Gradient you just saved on the border and voilà!
Until recently the Angular Gradient method was the only one with the full control over a pie chart. Sketchy Pies plugin only allowed to insert equal slices based on the number of color values that were added. Aby now updated the plugin and made it possible to create pie charts with percentual slices.
Sketchy Pies Plugin Method
This plugin can turn any oval into a pie chart in a matter of seconds. There are two options that I’ve mentioned above. The first makes a pie chart with equal slices and the second one determines slice’s size by specifying the percentage of a slice.
To make a pie chart with equal slices create a perfect circle by selecting an Oval Tool (O) and holding down Shift while drawing the shape. Make sure the newly created shape is selected then go to Plugins > Sketchy Pies > Convert to Pie Chart. A new window will appear where you’ll enter the color values for the slices in the hexadecimal format. Enter the color values and hit Enter to create a pie chart. In my example, I’ve made a pie chart with three slices. The colors I’ve used are #D35400, #F1C40F, #E67E22.
There is a similar process to create a percentage based slices. This time select an Oval and go to Plugins > Sketch Pies > Convert to Pie Chart with Percentage Values. Additionally to the hex values you now have to specify the percentage of the slice. Next to the color value append a percentage value separated by a colon (e.g. #D35400:50%). You can also specify it by a decimal number (e.g. #D35400:0.5). I’ve created a pie chart with seven slices. The values I’ve used are #E74C3C:21%,#F39C12:33%,#F1C40F:12%,#16A085:4%,#1ABC9C:7%,#2980B9:17%,#8E44AD:6%.
This is a way faster way of making a pie chart compared to an Angular Gradient method, isn’t it? Sometimes you have to do things the wrong way first to see where you can improve and eventually learn how to do it the right way.
There you have it! I hope you’ve learned something new! Feel free to Tweet me for further assistance or any other questions you might have. :)
Originally published on http://sketchtricks.com