Chart of the Week: Visualize the Transfer Spending and Earning among the Football League Clubs Using WPF Scatter Chart
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (182).NET Core  (27).NET MAUI  (233)Angular  (117)ASP.NET  (49)ASP.NET Core  (81)ASP.NET MVC  (87)Azure  (42)Black Friday Deal  (1)Blazor  (244)BoldSign  (15)DocIO  (24)Essential JS 2  (109)Essential Studio  (200)File Formats  (74)Flutter  (140)JavaScript  (227)Microsoft  (121)PDF  (86)Python  (1)React  (107)Streamlit  (1)Succinctly series  (131)Syncfusion  (991)TypeScript  (33)Uno Platform  (3)UWP  (3)Vue  (46)Webinar  (53)Windows Forms  (59)WinUI  (72)Word  (9)WPF  (165)Xamarin  (159)XlsIO  (38)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (11)Business intelligence  (55)Button  (4)C#  (164)Chart  (154)Chart of the week  (62)Cloud  (16)Company  (440)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (74)Development  (694)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (7)Essential Tools  (13)Excel  (43)Extensions  (31)File Manager  (8)Gantt  (23)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (530)Mobile MVC  (9)OLAP server  (2)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (48)Performance  (13)PHP  (2)PivotGrid  (5)Predictive Analytics  (6)Report Server  (3)Reporting  (8)Reporting / Back Office  (9)Rich Text Editor  (12)Road Map  (12)Scheduler  (54)Security  (5)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (32)Solution Services  (4)Spreadsheet  (11)SQL  (15)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (426)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (648)What's new  (354)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Chart of the Week Visualize the Spending and Earning among the Football League Clubs using WPF S

Chart of the Week: Visualize the Transfer Spending and Earning among the Football League Clubs Using WPF Scatter Chart

Welcome to our blog series, Chart of the Week!

Today, we will visualize the amount of money spent and earned on transfers by the five big European football league clubs since the summer of 2016. For this demonstration, we will use Syncfusion’s WPF scatter chart control.

The team with the highest positive balance in France was LOSC Lille (+€191M), having spent €252M and earned €443M. In England, Manchester City had the most negative balance (-€631M), having spent €1006M and earned €375M.

Refer to the following image.

Visualizing the transfer amount spent and earned among the European football league clubs using WPF scatter chart
Visualizing the transfer amount spent and earned among the European football league clubs using WPF scatter chart

Let’s start constructing a football (soccer) transfer earning and spending chart using the Syncfusion WPF scatter chart control.

Step 1: Collect data on football spending and earnings

Before creating a chart, let’s gather the data from the CIES Football Observatory site. We’re going to obtain the transfer spending and earning details for the big five football league clubs since the summer of 2016. You can also download the data as a separate JSON file.

Step 2: Preparing the data for the chart

Create the FootballMarket class to hold the transfer spent and earned amounts, net amount in millions of euros, club names, and league code information.

Refer to the following code example for assistance.

public class FootballMarket
{
    public double Club_tm { get; set; }
    public double Spent { get; set; }
    public string LeagueCode { get; set; }
    public string Club { get; set; }
    public double Earned { get; set; }
    public double Net { get; set; }
}

Next, generate a collection of net transfer spent and earned amounts using the FootballRevenue class and PremierLeague, Liga, Ligue1, Bundesliga, and SerieA properties.

public class FootballRevenue
{
   private List<FootballMarket> premierLeague;
   public List<FootballMarket> PremierLeague
   {
       get { return premierLeague; }
       set
       {
           premierLeague = value;
       }
   }

   public List<FootballMarket> FlagCollection { get; set; }

   private List<FootballMarket> liga;
   public List<FootballMarket> Liga
   {
      get { return liga; }
      set
      {
         liga = value;
      }
   }
   
   private List<FootballMarket> ligue1;
   public List<FootballMarket> Ligue1
   {
       get { return ligue1; }
       set
       {
           ligue1 = value;
       }
   }
   
   private List<FootballMarket> bundesliga;
   public List<FootballMarket> Bundesliga
   {
       get { return bundesliga; }
       set
       {
           bundesliga = value;
       }
   }
   
   private List<FootballMarket> serieA;
   public List<FootballMarket> SerieA
   {
      get { return serieA; }
      set
      {
         serieA = value;
      }
    }
}

To convert the JSON data to a collection, use the StreamReader and JsonConvert.DeserializeObject methods and the NewtonSoft.Json package. Then, store the converted data in the appropriate properties.

public class FootballRevenue
{
  public FootballRevenue()
  {
      Assembly executingAssembly = typeof(App).GetTypeInfo().Assembly;
      using (var stream = executingAssembly.GetManifestResourceStream("FootballSpentEarned.Resources.data.json"))
      using (TextReader textStream = new StreamReader(stream))
      {
          var data = textStream.ReadToEnd();
          data = data.Trim();
          Data = JsonConvert.DeserializeObject<List<FootballMarket>>(data);
          PremierLeague = Data.Where(d => d.LeagueCode == "ENG").ToList();
          Bundesliga = Data.Where(d => d.LeagueCode == "GER").ToList();
          Liga = Data.Where(d => d.LeagueCode == "ESP").ToList();
          Ligue1 = Data.Where(d => d.LeagueCode == "FRA").ToList();
          SerieA = Data.Where(d => d.LeagueCode == "ITA").ToList();
      }
  }
}

Step 3: Configure the Syncfusion WPF Charts control

Now, let’s configure the Syncfusion WPF Charts control using this documentation.

Refer to the following code example.

<chart:SfChart >
 <chart:SfChart.PrimaryAxis>
  <chart:NumericalAxis> 
  </chart:NumericalAxis>
 </chart:SfChart.PrimaryAxis>
 <chart:SfChart.SecondaryAxis>
  <chart:NumericalAxis>
  </chart:NumericalAxis>
 </chart:SfChart.SecondaryAxis>
</chart:SfChart>

Step 4: Bind football spending and earning data to the scatter chart

Bind the football league clubs’ spending and earning data using the FastScatterBitmapSeries class. This class will allow you to render a collection with a large number of data points.

<chart:SfChart.Series>
 <chart:FastScatterBitmapSeries XBindingPath="Spent" YBindingPath="Earned" ItemsSource="{Binding PremierLeague}" />
 <chart:FastScatterBitmapSeries XBindingPath="Spent" YBindingPath="Earned" ItemsSource="{Binding Liga}" />
 <chart:FastScatterBitmapSeries XBindingPath="Spent" YBindingPath="Earned" ItemsSource="{Binding Ligue1}"  />
 <chart:FastScatterBitmapSeries XBindingPath="Spent" YBindingPath="Earned" ItemsSource="{Binding Bundesliga}" />
 <chart:FastScatterBitmapSeries XBindingPath="Spent" YBindingPath="Earned" ItemsSource="{Binding SerieA}" />
</chart:SfChart.Series>

In this example, we’ve bound the scatter chart with the PremierLeague, Liga, Ligue1, Bundesliga, and SerieA properties, which contain the information of the football league clubs. Additionally, we’ve specified the XBindingPath and YBindingPath with the Spent and Earned properties, which inform the chart about the data points for the x- and y-axes.

Step 5: Customize the header of the WPF scatter chart

The WPF scatter chart allows us to customize its appearance based on our requirements.

Let’s see how to add a title to the chart using the Header property. Also, we’ll align the header using the HorizontalHeaderAlignment and VerticalHeaderAlignment properties.

<chart:SfChart x:Name="chart" Margin="10" HorizontalHeaderAlignment="Left">
 <chart:SfChart.Header>
  <Grid HorizontalAlignment="Left" Margin="5,0,0,10" VerticalAlignment="Center" >
   <Grid.ColumnDefinitions>
    <ColumnDefinition Width="13"/>
    <ColumnDefinition Width="*"/>
   </Grid.ColumnDefinitions>
   <StackPanel  Orientation="Vertical" Background="Green" Margin="0,10,0,0"  Grid.RowSpan="2"/>
   <StackPanel Margin="5,0,0,0" HorizontalAlignment="Left"  Orientation="Vertical" Grid.Column="1" >
    <TextBlock  Text="Football Transfer Spending" HorizontalAlignment="Left" TextWrapping="Wrap" FontSize="35" FontWeight="SemiBold" Foreground="Black"/>
    <TextBlock Text="Cumulative transfer spending and earning of clubs from European football since summer 2016" HorizontalAlignment="Left" FontSize="15" Foreground="Gray"/>
   </StackPanel>
  </Grid>
 </chart:SfChart.Header>
</chart:SfChart>

Step 6: Customize the axis elements

We can customize the chart axis’s header using the Header property. Refer to the following code example.

<chart:SfChart.PrimaryAxis>
 <chart:NumericalAxis >
  <chart:NumericalAxis.Header>
    <TextBlock Text="Spending" HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="Helvetica" FontSize="15" FontWeight="SemiBold" Foreground="Black"/>
  </chart:NumericalAxis.Header>
 </chart:NumericalAxis>
</chart:SfChart.PrimaryAxis>

<chart:SfChart.SecondaryAxis>
 <chart:NumericalAxis >
  <chart:NumericalAxis.Header>
   <TextBlock Text="Earning" FontWeight="SemiBold" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="15" Foreground="Black" FontFamily="Helvetica"/>
  </chart:NumericalAxis.Header>
 </chart:NumericalAxis>
</chart:SfChart.SecondaryAxis>

Then, let’s customize the axis line style, major tick line style, and axis label format and set the interval for the numerical axis using the AxisLineStyle, MajorTickLineStyle, LabelFormat, and Interval properties, respectively.

We can also configure the position of the edge labels using the EdgeLabelDrawingMode property and add padding to the y-axis by setting the Normal value to the RangePadding property.

<chart:SfChart.PrimaryAxis>
 <chart:NumericalAxis Interval="250" AxisLineStyle="{StaticResource lineStyle}" MajorTickLineStyle="{StaticResource lineStyle}" RangePadding="Normal" Foreground="Black" FontWeight="Normal" EdgeLabelsDrawingMode="Shift" LabelFormat="#,0'M€" >
 </chart:NumericalAxis>
</chart:SfChart.PrimaryAxis>

<chart:SfChart.SecondaryAxis>
 <chart:NumericalAxis Interval="250" AxisLineStyle="{StaticResource lineStyle}" MajorTickLineStyle="{StaticResource lineStyle}" FontWeight="Normal" Foreground="Black" LabelFormat="#,0'M€">
 </chart:NumericalAxis>
</chart:SfChart.SecondaryAxis>

Step 7: Customize the scatter points in the chart

Refer to the following code example to customize the chart’s scatter points using the ShapeType, Interior, ScatterHeight, ScatterWidth, and Label properties.

<chart:SfChart.Series>
 <chart:FastScatterBitmapSeries  XBindingPath="Spent" Interior="#d61111" Label="PremierLeague (England)"  ScatterWidth="10" ShapeType="Square" YBindingPath="Earned" ItemsSource="{Binding PremierLeague}"  ScatterHeight="10"/>      
 <chart:FastScatterBitmapSeries Interior="#e19620" Label="La Liga (Spain)" XBindingPath="Spent" ScatterHeight="10" ScatterWidth="10"  ShapeType="Square" YBindingPath="Earned" ItemsSource="{Binding Liga}" />
 <chart:FastScatterBitmapSeries Interior="#00008B" Label="Ligue 1 (France) XBindingPath="Spent" ScatterHeight="10" ScatterWidth="10" ShapeType="Square" YBindingPath="Earned" ItemsSource="{Binding Ligue1}" />
 <chart:FastScatterBitmapSeries Interior="#000000 Label="Bundesliga (Germany)" XBindingPath="Spent" ScatterHeight="10" ShapeType="Square" YBindingPath="Earned" ItemsSource="{Binding Bundesliga}"  ScatterWidth="10"/> 
 <chart:FastScatterBitmapSeries Interior="#49a349" Label="Serie A (Italy)" ScatterHeight="10" ScatterWidth="10" XBindingPath="Spent" ShapeType="Square" YBindingPath="Earned" ItemsSource="{Binding SerieA}" />
</chart:SfChart.Series>

Step 8: Customize the legends in the chart

Legends help us easily understand the different categories in the data set. You can customize the legend in the WPF scatter chart using the ItemTemplate property in the ChartLegend.

<Grid.Resources>
 <DataTemplate x:Key="legend">
  <StackPanel Orientation="Horizontal">
   <Image Source="{Binding Converter={StaticResource imageConverter}}" Margin="3,3,0,0" Height="12" VerticalAlignment="Center" Width="20" HorizontalAlignment="Left" />
   <TextBlock Text="{Binding Label}" Foreground="{Binding Interior}" FontSize="13" Margin="3" FontWeight="SemiBold"/>
  </StackPanel>
 </DataTemplate>
</Grid.Resources>
<chart:SfChart.Legend>
 <chart:ChartLegend ItemTemplate="{StaticResource legend}" ItemMargin="50,50,0,0" DockPosition="Right" />
</chart:SfChart.Legend>

Step 9: Add tooltip interaction

Refer to the following code example to enable and customize the default appearance of the tooltip in the WPF scatter chart.

<Grid.Resources>
 <local:Converter x:Key="imageConverter" />
 <local:ImageConverter x:Key="toolTipConverter" />
 <local:ColorConverter x:Key="color" />
 <DataTemplate x:Key="toolTip1">
  <StackPanel>
   <StackPanel Orientation="Horizontal">
    <Image Source="{Binding Item.Club,Converter={StaticResource toolTipConverter}}" Height="30" Width="30" />
    <Label Content="{Binding Item.Club}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Black" FontWeight="Bold" FontFamily="Helvetica" Margin="0,2,0,2" FontSize="12" Grid.Row="0"/>
   </StackPanel>
   <Rectangle Fill="Gray" Height="1" Width="100" />
   <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal" >
    <Rectangle  Stroke="Black" StrokeThickness="1" Height="10" Width="10" Fill="{Binding Item,Converter={StaticResource color}}" />
    <Label Content="{Binding Item.LeagueCode}"  HorizontalAlignment="Center"  HorizontalContentAlignment="Left" Foreground="Black" FontWeight="Bold" FontFamily="Helvetica" FontSize="12" Margin="3,0,3,0" />
    <TextBlock Text=" : " FontWeight="Bold" VerticalAlignment="Center" Foreground="Black" FontFamily="Helvetica" Margin="0,0,3,0" FontSize="12" />
    <TextBlock Text="{Binding Item.Net, StringFormat='{}{0}M€'}" FontWeight="Bold" VerticalAlignment="Center" Foreground="Black" FontFamily="Helvetica" Margin="0,0,3,0" FontSize="12" />
   </StackPanel>
  </StackPanel>
 </DataTemplate>
</Grid.Resources>

Finally, configure the tooltip behavior using the following code example.

<Grid.Resources>
 <Style TargetType="Path" x:Key="style">
  <Setter Property="Stroke" Value="Black"/>
  <Setter Property="Fill" Value="White"/>
  <Setter Property="StrokeThickness" Value="1"/>
 </Style>
</Grid.Resources>

<chart:SfChart.Behaviors>
 <chart:ChartTooltipBehavior ShowDuration="2500" Style="{StaticResource style}"/>
</chart:SfChart.Behaviors>

<chart:SfChart.Series>
 <chart:FastScatterBitmapSeries ShowTooltip="True" TooltipTemplate="{StaticResource toolTip1}" />
 <chart:FastScatterBitmapSeries TooltipTemplate="{StaticResource toolTip1}" ShowTooltip="True" />
 <chart:FastScatterBitmapSeries TooltipTemplate="{StaticResource toolTip1}" ShowTooltip="True" />
 <chart:FastScatterBitmapSeries TooltipTemplate="{StaticResource toolTip1}" ShowTooltip="True" />
 <chart:FastScatterBitmapSeries TooltipTemplate="{StaticResource toolTip1}" ShowTooltip="True" />
</chart:SfChart.Series>

After executing these code examples, we will get output like in the following image.

Visualizing Money Spent and Earned by Football League Clubs Using WPF Scatter Chart
Visualizing Money Spent and Earned by Football League Clubs Using WPF Scatter Chart

GitHub reference

For more details, refer to the project on GitHub.

Conclusion

Thanks for reading! In this blog, we have seen how to visualize football league clubs’ transfer spending and earning data using the Syncfusion WPF scatter chart. We encourage you to try these steps and share your thoughts in the comments below.

You can also explore our WPF Charts examples to learn more about the supported chart types and how easy it is to configure them for stunning visual effects.

The latest version of the WPF Charts control is available for current customers from the License and Downloads page. If you are not a Syncfusion customer, try our 30-day free trial to check it out.

For questions, you can contact us through our support forums, support portal, or feedback portal. We are always happy to assist you!

Related blogs

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed