Adding Chart – One Punch Man Training App
After filling our Progress object with the data we gathered from our xml file. We will now try to display it in our chart.
Adding Chart to a Form
Let’s put the chart in our SubjectForm.
- While in form design view open the Toolbox
- in the Data category, select Chart
- and drag the chart control to the design area
Configure your chart properties like what the image below show.
Note: We will not discuss how we made our chart looks like that. As you can easily configure your chart’s properties in the Visual Studio designer. Just be sure to take note on the names I used in the code that will be adding later.
All charts data will come from our Progress property named GetExercises. Remember that this only supplies list of exercises name and repetitions (e.g: PushUps, 100). In the chart above, we want to show a hero like stats with different hero attributes in percentage.
Our approach :
- get each exercises record in the Progress propery,
- Sum every repetitions,
- convert each total to percentage
- and add it to its designated position in the chart
Note: We made things simpler by just designating one exercise to one attributes only.
e.g: Jog = Stamina
You can combine exercises that you think best fits an attribute. But in this tutorial we will leave it like that and continue to the next article.