Populating the Chart Control

Now we have to write code to show data in the Chart control. Imagine you want to get the total cost that customers paid to your company for orders, divided by year. To accomplish this, we first need a custom class for storing the year and the total amount per year. Add a new class to the project and name it CustomerData. The code for the new class is the following:

image

Then we can write the following LINQ query, which creates an IEnumerable(Of CustomerData) (the custom class that was defined at the beginning of this section) and that can be bound to the chart:

Notice how the Let keyword allows declaring a temporary variable ...

Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.