Window1.xaml.cs |
using System;
using System.Data;
using System.Windows;
namespace ManhattanBar3DChart {
public partial class Window1 : Window {
public Window1() {
InitializeComponent();
}
}
public class DevAVSalesByYear {
public DataTable Data {
get { return GetData(); }
}
public DataTable Series1Source {
get {
return GetData().AsEnumerable()
.Where(r => r.Field<int>("Year") == DateTime.Now.Year - 1)
.CopyToDataTable();
}
}
public DataTable Series2Source {
get {
return GetData().AsEnumerable()
.Where(r => r.Field<int>("Year") == DateTime.Now.Year - 2)
.CopyToDataTable();
}
}
public DataTable Series3Source {
get {
return GetData().AsEnumerable()
.Where(r => r.Field<int>("Year") == DateTime.Now.Year - 3)
.CopyToDataTable();
}
}
public string Series1DisplayName {
get { return (DateTime.Now.Year - 1).ToString(); }
}
public string Series2DisplayName {
get { return (DateTime.Now.Year - 2).ToString(); }
}
public string Series3DisplayName {
get { return (DateTime.Now.Year - 3).ToString(); }
}
public DataTable GetData() {
int lastYear = DateTime.Now.Year - 1;
DataTable table = new DataTable();
table.Columns.AddRange(new DataColumn[] {
new DataColumn("Year", typeof(int)),
new DataColumn("Region", typeof(string)),
new DataColumn("Sales", typeof(decimal))
});
table.Rows.Add(lastYear - 2, "Asia", 4.23M);
table.Rows.Add(lastYear - 2, "North America", 3.485M);
table.Rows.Add(lastYear - 2, "Europe", 3.088M);
table.Rows.Add(lastYear - 2, "Australia", 1.78M);
table.Rows.Add(lastYear - 2, "South America", 1.602M);
table.Rows.Add(lastYear - 1, "Asia", 4.768M);
table.Rows.Add(lastYear - 1, "North America", 3.747M);
table.Rows.Add(lastYear - 1, "Europe", 3.357M);
table.Rows.Add(lastYear - 1, "Australia", 1.957M);
table.Rows.Add(lastYear - 1, "South America", 1.823M);
table.Rows.Add(lastYear, "Asia", 5.289M);
table.Rows.Add(lastYear, "North America", 4.182M);
table.Rows.Add(lastYear, "Europe", 3.725M);
table.Rows.Add(lastYear, "Australia", 2.272M);
table.Rows.Add(lastYear, "South America", 2.117M);
return table;
}
}
}
|
Window1.xaml.vb |
Imports System
Imports System.Data
Imports System.Windows
Namespace ManhattanBar3DChart
Partial Public Class Window1
Inherits Window
Public Sub New()
InitializeComponent()
End Sub
End Class
Public Class DevAVSalesByYear
Public ReadOnly Property Data() As DataTable
Get
Return GetData()
End Get
End Property
Public ReadOnly Property Series1Source() As DataTable
Get
Return GetData().AsEnumerable().Where(Function(r) r.Field(Of Integer)("Year") = Date.Now.Year - 1).CopyToDataTable()
End Get
End Property
Public ReadOnly Property Series2Source() As DataTable
Get
Return GetData().AsEnumerable().Where(Function(r) r.Field(Of Integer)("Year") = Date.Now.Year - 2).CopyToDataTable()
End Get
End Property
Public ReadOnly Property Series3Source() As DataTable
Get
Return GetData().AsEnumerable().Where(Function(r) r.Field(Of Integer)("Year") = Date.Now.Year - 3).CopyToDataTable()
End Get
End Property
Public ReadOnly Property Series1DisplayName() As String
Get
Return (Date.Now.Year - 1).ToString()
End Get
End Property
Public ReadOnly Property Series2DisplayName() As String
Get
Return (Date.Now.Year - 2).ToString()
End Get
End Property
Public ReadOnly Property Series3DisplayName() As String
Get
Return (Date.Now.Year - 3).ToString()
End Get
End Property
Public Function GetData() As DataTable
Dim lastYear As Integer = Date.Now.Year - 1
Dim table As New DataTable()
table.Columns.AddRange(New DataColumn() { _
New DataColumn("Year", GetType(Integer)), _
New DataColumn("Region", GetType(String)), _
New DataColumn("Sales", GetType(Decimal)) _
})
table.Rows.Add(lastYear - 2, "Asia", 4.23D)
table.Rows.Add(lastYear - 2, "North America", 3.485D)
table.Rows.Add(lastYear - 2, "Europe", 3.088D)
table.Rows.Add(lastYear - 2, "Australia", 1.78D)
table.Rows.Add(lastYear - 2, "South America", 1.602D)
table.Rows.Add(lastYear - 1, "Asia", 4.768D)
table.Rows.Add(lastYear - 1, "North America", 3.747D)
table.Rows.Add(lastYear - 1, "Europe", 3.357D)
table.Rows.Add(lastYear - 1, "Australia", 1.957D)
table.Rows.Add(lastYear - 1, "South America", 1.823D)
table.Rows.Add(lastYear, "Asia", 5.289D)
table.Rows.Add(lastYear, "North America", 4.182D)
table.Rows.Add(lastYear, "Europe", 3.725D)
table.Rows.Add(lastYear, "Australia", 2.272D)
table.Rows.Add(lastYear, "South America", 2.117D)
Return table
End Function
End Class
End Namespace
|