{"id":6674,"date":"2025-09-30T14:56:47","date_gmt":"2025-09-30T14:56:47","guid":{"rendered":"https:\/\/obsidiansofteducation.com\/?page_id=6674"},"modified":"2025-09-30T14:56:47","modified_gmt":"2025-09-30T14:56:47","slug":"mit-app-inventor-pie-chart-tutorial","status":"publish","type":"page","link":"https:\/\/obsidiansofteducation.com\/index.php\/mit-app-inventor-pie-chart-tutorial\/","title":{"rendered":"MIT App Inventor Pie Chart Tutorial &#8211; Expense App in App Inventor"},"content":{"rendered":"\n<p class=\"has-medium-font-size wp-block-paragraph\">Hello friends,<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Welcome to Obsidian Soft.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Today, I will teach you how to use the built-in charts component in MIT App Inventor to draw a pie chart.&nbsp;<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/snake-game-11-1024x576.jpg\" alt=\"\" class=\"wp-image-6677\" style=\"width:732px;height:auto\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/snake-game-11-1024x576.jpg 1024w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/snake-game-11-300x169.jpg 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/snake-game-11-768x432.jpg 768w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/snake-game-11-800x450.jpg 800w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/snake-game-11.jpg 1280w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">We will make a simple budget app in this tutorial with expense amounts and their categories, and these expenses will be graphically displayed in a pie chart.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">So, let\u2019s begin.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Open up MIT App Inventor. Start a new project and call it BudgetApp.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Drag and drop a textbox from the user interface palette onto the viewer.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Rename to amountTextbox. Make font bold, font size 18, and change hint to \u201c<strong>Enter Expense Amount\u201d<\/strong>.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Drag and drop a listpicker from the user interface below the textbox. Rename to categoryPicker. Make font bold, font size 18, change text to \u201c<strong>Choose Expense Type\u201d, <\/strong>and in elements from string, type: Food, Travel, Bills, Other.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Add a label for space below this listpicker. Remove all text from it.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Add a button below this space. Rename to saveBtn. Make font bold, font size 18, and change text to \u201cSave\u201d.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Now, drag and drop a Chart component from the Charts palette below the save button.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Rename to PieChart. Make height 50% and width 70%. It is very important that you check the legendEnabled checkbox and change the type to Pie.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Now, here comes another important thing. Drag and drop a ChartData2D component from the Charts palette inside this PieChart.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Lastly, add a tinyDB component from storage to the viewer and also a notifier for error handling from the user interface.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Our screen design is done, so let\u2019s go to the blocks section.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Make a global variable for our list of expenses:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"794\" height=\"54\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-53.png\" alt=\"\" class=\"wp-image-6676\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-53.png 794w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-53-300x20.png 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-53-768x52.png 768w\" sizes=\"auto, (max-width: 794px) 100vw, 794px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">And a global variable for our DB Tag:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"794\" height=\"54\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-53.png\" alt=\"\" class=\"wp-image-6675\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-53.png 794w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-53-300x20.png 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-53-768x52.png 768w\" sizes=\"auto, (max-width: 794px) 100vw, 794px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Make an empty procedure of the first type that doesn\u2019t return a result by getting the relevant block from the Procedures section and name it updateChart.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"302\" height=\"122\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-54.png\" alt=\"\" class=\"wp-image-6678\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-54.png 302w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-54-300x121.png 300w\" sizes=\"auto, (max-width: 302px) 100vw, 302px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Then, get the save button click event.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">First, we are going to check that the user has entered an amount, and if not, then we will go inside the else condition and show an alert message using the notifier.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"980\" height=\"350\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-55.png\" alt=\"\" class=\"wp-image-6679\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-55.png 980w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-55-300x107.png 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-55-768x274.png 768w\" sizes=\"auto, (max-width: 980px) 100vw, 980px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Error handling handled \ud83d\ude09<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">So, we need to add the data to the expenses list, where each item is a small list too, with 2 items:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li class=\"has-medium-font-size\">Amount<\/li>\n\n\n\n<li class=\"has-medium-font-size\">Category<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"376\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-56-1024x376.png\" alt=\"\" class=\"wp-image-6680\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-56-1024x376.png 1024w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-56-300x110.png 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-56-768x282.png 768w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-56.png 1276w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Next, we need to store this expensesList in TinyDB against our DBTag. We will also empty our amountTexbox to prepare for future entries and call our updateChart procedure(empty at the moment)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"584\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-57-1024x584.png\" alt=\"\" class=\"wp-image-6681\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-57-1024x584.png 1024w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-57-300x171.png 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-57-768x438.png 768w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-57.png 1276w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Next, what happens when the screen is initialized? We need to load our previously saved expenses list from the tinyDB against our DB tag into our global expenses list and construct the pie chart for it by calling updateChart procedure.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"234\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-60-1024x234.png\" alt=\"\" class=\"wp-image-6684\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-60-1024x234.png 1024w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-60-300x69.png 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-60-768x176.png 768w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-60.png 1258w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Lastly, let\u2019s work on our updateChart procedure.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">First, we are going to clear our previously drawn pie chart by calling the Clear procedure for our ChartData2D component.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"508\" height=\"132\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-58.png\" alt=\"\" class=\"wp-image-6682\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-58.png 508w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-58-300x78.png 300w\" sizes=\"auto, (max-width: 508px) 100vw, 508px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Next, we are going to initialize some local total variables for our expense categories to 0.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"604\" height=\"410\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-59.png\" alt=\"\" class=\"wp-image-6683\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-59.png 604w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-59-300x204.png 300w\" sizes=\"auto, (max-width: 604px) 100vw, 604px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Now we\u2019ll loop through our expenses list. Remember that each expense is itself a small list where the first item is the amount and the second item is the category. For every expense, we check the category, and based on whether it\u2019s Food, Travel, Other, or Bills, we add the amount to the matching total variable. This way, by the end of the loop, each category variable holds the sum of all its expenses.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"891\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-62-1024x891.png\" alt=\"\" class=\"wp-image-6686\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-62-1024x891.png 1024w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-62-300x261.png 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-62-768x668.png 768w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-62-1536x1336.png 1536w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-62.png 1596w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">After the for loop ends, we need to specify colors for our pie chart:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"890\" height=\"218\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-61.png\" alt=\"\" class=\"wp-image-6685\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-61.png 890w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-61-300x73.png 300w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-61-768x188.png 768w\" sizes=\"auto, (max-width: 890px) 100vw, 890px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">And at the very end, we are going to provide our total variables to chartData2D as entries.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"469\" height=\"361\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-63.png\" alt=\"\" class=\"wp-image-6687\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-63.png 469w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-63-300x231.png 300w\" sizes=\"auto, (max-width: 469px) 100vw, 469px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">So the final updateChart procedure looks like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"735\" height=\"1024\" src=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-64-735x1024.png\" alt=\"\" class=\"wp-image-6688\" srcset=\"https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-64-735x1024.png 735w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-64-215x300.png 215w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-64-768x1069.png 768w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-64-1103x1536.png 1103w, https:\/\/obsidiansofteducation.com\/wp-content\/uploads\/2025\/09\/image-64.png 1149w\" sizes=\"auto, (max-width: 735px) 100vw, 735px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">And this is done. I hope you liked this tutorial for making a pie chart in MIT App Inventor using <strong>no extensions<\/strong>. You can also have a look at the video tutorial for this project on my channel.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<p class=\"responsive-video-wrap clr\"><iframe loading=\"lazy\" title=\"MIT App Inventor Chart - Build an Expense App with Pie Chart - Graph MIT App Inventor\" width=\"1200\" height=\"675\" src=\"https:\/\/www.youtube.com\/embed\/6JGf5wXL5XM?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<\/div><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Please like my tutorials and share it with your friends and family. Also, subscribe to my channel and press the bell icon so you don\u2019t miss any of the great projects I have planned for you.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\"><a href=\"https:\/\/www.youtube.com\/c\/obsidiansofteducation\" target=\"_blank\" rel=\"noopener\">https:\/\/www.youtube.com\/c\/obsidiansofteducation<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Please like my Facebook page and Instagram page for more educational resources and tips.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\"><strong>Facebook:<\/strong><a href=\"https:\/\/www.blogger.com\/blog\/page\/edit\/4947000819484484884\/7140650632339107612#\" target=\"_blank\" rel=\"noopener\">&nbsp;https:\/\/www.facebook.com\/ObsidianSoft\/<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\"><strong>Instagram:<\/strong><a href=\"https:\/\/www.blogger.com\/blog\/page\/edit\/4947000819484484884\/7140650632339107612#\" target=\"_blank\" rel=\"noopener\">&nbsp;https:\/\/www.instagram.com\/obsidiansoftapps\/<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\"><strong>Pinterest:<\/strong>&nbsp;<a href=\"https:\/\/www.pinterest.com\/obsidiansoft\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.pinterest.com\/obsidiansoft\/<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">For links to free educational&nbsp;<a href=\"https:\/\/obsidiansofteducation.com\/index.php\/flappy-bird-game-mit-app-inventor\/#\">&nbsp;apps<\/a>, have a look at the&nbsp;<a href=\"https:\/\/obsidiansofteducation.com\/index.php\/mobile-apps\/\">educational apps page<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello friends, Welcome to Obsidian Soft. Today, I will teach you how to use the built-in charts component in MIT App Inventor to draw a pie chart.&nbsp; We will make a simple budget app in this tutorial with expense amounts and their categories, and these expenses will be graphically displayed in a pie chart. So, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-6674","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages\/6674","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/comments?post=6674"}],"version-history":[{"count":1,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages\/6674\/revisions"}],"predecessor-version":[{"id":6689,"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/pages\/6674\/revisions\/6689"}],"wp:attachment":[{"href":"https:\/\/obsidiansofteducation.com\/index.php\/wp-json\/wp\/v2\/media?parent=6674"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}