Public Class FoodRevenueData
Public Property USData() As Double
Public Property GermanData() As Double
Public Property KenyanData() As Double
Public Property FranceData() As Double
Public Property UKData() As Double
Public Property ChinaData() As Double
Public Property ItalyData() As Double
Public Property SwitzerLandData() As Double
Private Sub RevenueForm_Load(ByVal sender As Object, ByVal e As EventArgs)
'Set data to the class properties
Dim data As New FoodRevenueData() With {
.SwitzerLandData = 21133,
'map the property values of the class with its key(the country!)
Dim revenueByCountry As New Dictionary(Of String, Double)()
revenueByCountry.Add("United States of America", data.USData)
revenueByCountry.Add("German", data.GermanData)
revenueByCountry.Add("France", data.FranceData)
revenueByCountry.Add("China", data.ChinaData)
revenueByCountry.Add("Italy", data.ItalyData)
revenueByCountry.Add("SwitzerLand", data.SwitzerLandData)
revenueByCountry.Add("Kenya", data.KenyanData)
revenueByCountry.Add("United Kingdom", data.UKData)
' * sort data in the dictionary by value in a descending order and
' assign the data to the list
Dim y_AxisLabels As New List(Of String)()
Dim horizontalBarData As New List(Of Double)()
For Each countryData In revenueByCountry.OrderByDescending(Function(x) x.Value)
y_AxisLabels.Add(countryData.Key)
horizontalBarData.Add(countryData.Value)
bunifuChartCanvas1.Labels = y_AxisLabels.ToArray()
bunifuHorizontalBarChart1.Data = horizontalBarData