Skip to main content

Time Spent Donut Chart

Challenge: Data visualization. Create a Time Spent Donut Chart on the Art Canvas + Playground! The object of the activity is to use a list to store the Time Spent data of a student and code the VR Robot to draw lines on the donut shape, dividing it into sections based on the data. Then, use the VR Pen to fill each section with a color representing the corresponding routine to create the Donut Chart.

The Time Spent data of the student and the routine corresponding colors are as follows:

Routines

Sleep Sleep

School School

Sports Sports

Homework Homework

Reading Reading

Screen Time Screen Time

Other Other

Time spent

8 Hours

6 Hours

2 Hours

1Hour

1 hour

2 hours

4 Hours

  • Choose and Download the Time Spent Donut Chart activity image as a PNG file from this Google slideshow.
  • Select the Art Canvas+ Playground and upload the Time Spent Donut Chart activity image.
    • To learn more about uploading images to the Art Canvas+ Playground, see this article.
  • Declare a list to store the number of hours spent on each of the 7 routines.
  • Declare an index variable to represent the item’s position within the list, and set the initial values to 1. 
  • Code the VR Robot to create the Time Spent Donut Chart.
    • Use the index variable to retrieve an item in the list to calculate the Central Angle of the donut chart section corresponding to the item. Store the calculation results in an angle variable.
    • Use the angle variable to control the robot to turn in the desired direction.
    • Set the Pen color to the corresponding routine and code the VR Robot to draw a line on the donut shape to separate the routine section.
    • Use the VR Pen to fill the section with the color representing the corresponding routine.
    • Increase the index variable by 1 to point to the next item’s position in the list.
    • Use a loop to repeat the above steps for a set number of times to separate and fill each section with the color representing the corresponding routine to create the Donut Chart.
  • Collect the data on how you spend a school day to create your own Time Spent Donut Chart on the Art Canvas +. Share the chart with a friend.

Helpful Hints

  • The amount of time in a day is 24 hours and there are 360 degrees in one Full Rotation. Use the following formula to calculate the Central Angle of the routine section corresponding to the number of hours in a day.

 Central Angle of a routine = (The number of hours / 24)*360°

  • Use My Block from the My Blocks category to create a custom block to determine the VR Pen color and call it in the project. The My Block makes the project shorter and more easily readable. Define Routine Color
    • Matching Python command:Define Routine Color Python
  • For help with using My Blocks in the project, please select the “TUTORIALS” button in VEXcode VR and choose the My Blocks Tutorial. 

My Blocks Tutorial