using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
namespace Infragistics.Models
{
// TODO add data model
// TODO add data source
}
This topic provides sample data and data models for use with the XamDataChart™ control and its Category Series and Stacked Series.
This topic contains the following sections:
In C#:
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
namespace Infragistics.Models
{
// TODO add data model
// TODO add data source
}
In Visual Basic:
Imports System
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports System.ComponentModel
Imports System.Linq
Namespace Infragistics.Models
' TODO add data model
' TODO add data source
End Namespace
In C#:
public class EnergyProduction
{
public string Country { get; set; }
public string Region { get; set; }
public string Year { get; set; }
// Non-Renewable Energy Sources
public double Nuclear { get; set; }
public double Coal { get; set; }
public double Oil { get; set; }
public double Gas { get; set; }
// Renewable Energy Sources
public double Hydro { get; set; }
public double GeoThermal { get; set; }
public double Solar { get; set; }
public double Wind { get; set; }
public double Total { get { return Renewable + NonRenewable; } }
public double Renewable { get { return Hydro + GeoThermal + Wind + Solar; } }
public double NonRenewable { get { return Coal + Oil + Gas + Nuclear; } }
}
In Visual Basic:
Public Class EnergyProduction
Public Property Country As String
Public Property Region As Double
Public Property Year As Double
Public Property Nuclear As Double
Public Property Coal As Double
Public Property Oil As Double
Public Property Gas As Double
Public Property Hydro As Double
Public Property GeoThermal As Double
Public Property Solar As Double
Public Property Wind As Double
Public Property NonRenewable As Double Get Return Coal + Oil + Gas + Nuclear End Get End Property
Public Property Renewable As Double Get Return Hydro + GeoThermal + Wind + Solar End Get End Property
Public Property Total As Double Get Return Renewable + NonRenewable End Get End Property
End Class
In C#:
public class EnergyDataSource : List<EnergyProduction>
{
public EnergyDataSource()
{
this.Add(new EnergyProduction { Region = "America", Country = "CAN", Coal = 400, Oil = 100, Gas = 175, Nuclear = 225, Hydro = 350 });
this.Add(new EnergyProduction { Region = "Asia", Country = "CHN", Coal = 925, Oil = 200, Gas = 350, Nuclear = 400, Hydro = 625 });
this.Add(new EnergyProduction { Region = "Europe", Country = "RUS", Coal = 550, Oil = 200, Gas = 250, Nuclear = 475, Hydro = 425 });
this.Add(new EnergyProduction { Region = "Asia", Country = "AUS", Coal = 450, Oil = 100, Gas = 150, Nuclear = 175, Hydro = 350 });
this.Add(new EnergyProduction { Region = "America", Country = "USA", Coal = 800, Oil = 250, Gas = 475, Nuclear = 575, Hydro = 750 });
this.Add(new EnergyProduction { Region = "Europe", Country = "FRA", Coal = 375, Oil = 150, Gas = 350, Nuclear = 275, Hydro = 325 });
}
}
public class EnergyDataHistory : List<EnergyProduction>
{
public EnergyDataHistory()
{
this.Add(new EnergyProduction { Year = "2000", Country = "Canada", Coal = 400, Oil = 100, Gas = 175, Nuclear = 225, Hydro = 350 });
this.Add(new EnergyProduction { Year = "2010", Country = "Canada", Coal = 450, Oil = 150, Gas = 225, Nuclear = 255, Hydro = 400 });
this.Add(new EnergyProduction { Year = "2020", Country = "Canada", Coal = 300, Oil = 200, Gas = 275, Nuclear = 325, Hydro = 450 });
this.Add(new EnergyProduction { Year = "2000", Country = "China", Coal = 825, Oil = 200, Gas = 350, Nuclear = 400, Hydro = 625 });
this.Add(new EnergyProduction { Year = "2010", Country = "China", Coal = 925, Oil = 250, Gas = 400, Nuclear = 420, Hydro = 685 });
this.Add(new EnergyProduction { Year = "2020", Country = "China", Coal = 975, Oil = 300, Gas = 450, Nuclear = 450, Hydro = 725 });
this.Add(new EnergyProduction { Year = "2000", Country = "Russia", Coal = 550, Oil = 200, Gas = 250, Nuclear = 475, Hydro = 425 });
this.Add(new EnergyProduction { Year = "2010", Country = "Russia", Coal = 600, Oil = 220, Gas = 280, Nuclear = 525, Hydro = 485 });
this.Add(new EnergyProduction { Year = "2020", Country = "Russia", Coal = 650, Oil = 250, Gas = 350, Nuclear = 575, Hydro = 525 });
this.Add(new EnergyProduction { Year = "2000", Country = "Australia", Coal = 450, Oil = 100, Gas = 150, Nuclear = 175, Hydro = 350 });
this.Add(new EnergyProduction { Year = "2010", Country = "Australia", Coal = 480, Oil = 120, Gas = 250, Nuclear = 225, Hydro = 400 });
this.Add(new EnergyProduction { Year = "2020", Country = "Australia", Coal = 550, Oil = 180, Gas = 350, Nuclear = 275, Hydro = 450 });
this.Add(new EnergyProduction { Year = "2000", Country = "United States", Coal = 800, Oil = 250, Gas = 475, Nuclear = 575, Hydro = 750 });
this.Add(new EnergyProduction { Year = "2010", Country = "United States", Coal = 850, Oil = 300, Gas = 525, Nuclear = 625, Hydro = 800 });
this.Add(new EnergyProduction { Year = "2020", Country = "United States", Coal = 900, Oil = 350, Gas = 575, Nuclear = 675, Hydro = 850 });
this.Add(new EnergyProduction { Year = "2000", Country = "France", Coal = 375, Oil = 150, Gas = 350, Nuclear = 275, Hydro = 325 });
this.Add(new EnergyProduction { Year = "2010", Country = "France", Coal = 425, Oil = 200, Gas = 400, Nuclear = 325, Hydro = 385 });
this.Add(new EnergyProduction { Year = "2020", Country = "France", Coal = 455, Oil = 250, Gas = 450, Nuclear = 375, Hydro = 425 });
}
}
In Visual Basic:
Public Class EnergyDataSource Inherits List(Of EnergyProduction)
Public Sub New()
Me.Add(New EnergyProduction() With { .Region = "America", .Country = "Canada", .Coal = 400, .Oil = 100, .Gas = 175, .Nuclear = 225, .Hydro = 350 })
Me.Add(New EnergyProduction() With { .Region = "Asia", .Country = "China", .Coal = 925, .Oil = 200, .Gas = 350, .Nuclear = 400, .Hydro = 625 })
Me.Add(New EnergyProduction() With { .Region = "Europe", .Country = "Russia", .Coal = 550, .Oil = 200, .Gas = 250, .Nuclear = 475, .Hydro = 425 })
Me.Add(New EnergyProduction() With { .Region = "Asia", .Country = "Australia", .Coal = 450, .Oil = 100, .Gas = 150, .Nuclear = 175, .Hydro = 350 })
Me.Add(New EnergyProduction() With { .Region = "America", .Country = "United States", .Coal = 800, .Oil = 250, .Gas = 475, .Nuclear = 575, .Hydro = 750 })
Me.Add(New EnergyProduction() With { .Region = "Europe", .Country = "France", .Coal = 375, .Oil = 150, .Gas = 350, .Nuclear = 275, .Hydro = 325 })
End Sub
End Class
Public Class EnergyDataHistory Inherits List(Of EnergyProduction)
Public Sub New()
Me.Add(New EnergyProduction() With { .Year = "2000", .Country = "Canada", .Coal = 400, .Oil = 100, .Gas = 175, .Nuclear = 225, .Hydro = 350 })
Me.Add(New EnergyProduction() With { .Year = "2010", .Country = "Canada", .Coal = 450, .Oil = 150, .Gas = 225, .Nuclear = 255, .Hydro = 400 })
Me.Add(New EnergyProduction() With { .Year = "2020", .Country = "Canada", .Coal = 300, .Oil = 200, .Gas = 275, .Nuclear = 325, .Hydro = 450 })
Me.Add(New EnergyProduction() With { .Year = "2000", .Country = "China", .Coal = 825, .Oil = 200, .Gas = 350, .Nuclear = 400, .Hydro = 625 })
Me.Add(New EnergyProduction() With { .Year = "2010", .Country = "China", .Coal = 925, .Oil = 250, .Gas = 400, .Nuclear = 420, .Hydro = 685 })
Me.Add(New EnergyProduction() With { .Year = "2020", .Country = "China", .Coal = 975, .Oil = 300, .Gas = 450, .Nuclear = 450, .Hydro = 725 })
Me.Add(New EnergyProduction() With { .Year = "2000", .Country = "Russia", .Coal = 550, .Oil = 200, .Gas = 250, .Nuclear = 475, .Hydro = 425 })
Me.Add(New EnergyProduction() With { .Year = "2010", .Country = "Russia", .Coal = 600, .Oil = 220, .Gas = 280, .Nuclear = 525, .Hydro = 485 })
Me.Add(New EnergyProduction() With { .Year = "2020", .Country = "Russia", .Coal = 650, .Oil = 250, .Gas = 350, .Nuclear = 575, .Hydro = 525 })
Me.Add(New EnergyProduction() With { .Year = "2000", .Country = "Australia", .Coal = 450, .Oil = 100, .Gas = 150, .Nuclear = 175, .Hydro = 350 })
Me.Add(New EnergyProduction() With { .Year = "2010", .Country = "Australia", .Coal = 480, .Oil = 120, .Gas = 250, .Nuclear = 225, .Hydro = 400 })
Me.Add(New EnergyProduction() With { .Year = "2020", .Country = "Australia", .Coal = 550, .Oil = 180, .Gas = 350, .Nuclear = 275, .Hydro = 450 })
Me.Add(New EnergyProduction() With { .Year = "2000", .Country = "United States", .Coal = 800, .Oil = 250, .Gas = 475, .Nuclear = 575, .Hydro = 750 })
Me.Add(New EnergyProduction() With { .Year = "2010", .Country = "United States", .Coal = 850, .Oil = 300, .Gas = 525, .Nuclear = 625, .Hydro = 800 })
Me.Add(New EnergyProduction() With { .Year = "2020", .Country = "United States", .Coal = 900, .Oil = 350, .Gas = 575, .Nuclear = 675, .Hydro = 850 })
Me.Add(New EnergyProduction() With { .Year = "2000", .Country = "France", .Coal = 375, .Oil = 150, .Gas = 350, .Nuclear = 275, .Hydro = 325 })
Me.Add(New EnergyProduction() With { .Year = "2010", .Country = "France", .Coal = 425, .Oil = 200, .Gas = 400, .Nuclear = 325, .Hydro = 385 })
Me.Add(New EnergyProduction() With { .Year = "2020", .Country = "France", .Coal = 455, .Oil = 250, .Gas = 450, .Nuclear = 375, .Hydro = 425 })
End Sub
End Class
In C#:
public abstract class ObservableModel : INotifyPropertyChanged
{
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}
In Visual Basic:
Public MustInherit Class ObservableModel
Implements INotifyPropertyChanged
#Region "INotifyPropertyChanged"
Public Event PropertyChanged As PropertyChangedEventHandler
Protected Sub OnPropertyChanged(propertyName As String)
Dim handler As PropertyChangedEventHandler = Me.PropertyChanged
RaiseEvent handler(Me, New PropertyChangedEventArgs(propertyName))
End Sub
#Region "INotifyPropertyChanged"
Public Event PropertyChanged As PropertyChangedEventHandler
Protected Sub OnPropertyChanged(propertyName As String)
Dim handler As PropertyChangedEventHandler = Me.PropertyChanged
RaiseEvent handler(Me, New PropertyChangedEventArgs(propertyName))
End Sub
End Class