Silverlight Toolkit provides controls such as drawing a histogram (Column,bar), Pie (PIE), line chart (lines), scatter chart (scatter).
We can easily bind the existing data source to the corresponding graphics control, set up the corresponding X,y axis display style and data fields are finished, and it also supports the timing of the load refresh graphics, graphics dynamic loading animation effect. Let's take a histogram as an example today and briefly summarize how to use the control to display our data.
First, we need to create a Silverlight project named: DataVisualization.
Then we use WCF to publish the data source information, where we create a "Silverlight-enabled WCF" and name it:
Dataservice.svc
The following code is then copied to the class file:
public class EmployeeInfo
{
public int EmployeeID {set; get;}
public string EmployeeName {set;
public int Salary {set; get;}
Public int[] Cost {get; set;}
public string City {set;
}
[ServiceContract (Namespace = "")]
[Aspnetcompatibilityrequirements (Requirementsmode = aspnetcompatibilityrequirementsmode.allowed)]
public class DataService
{
[OperationContract]
Public list<employeeinfo> getemployeelist ()
{
list<employeeinfo> employeelist = new list<employeeinfo> ();
Employeelist.add (new EmployeeInfo {EmployeeID = 1, EmployeeName = "John", Salary = 1000, city = "Hefei"});
Employeelist.add (new EmployeeInfo {EmployeeID = 2, EmployeeName = "Dick", Salary = 1500, city = "Tianjin"});
Employeelist.add (new EmployeeInfo {EmployeeID = 3, EmployeeName = "Harry", Salary =, city = "Shanghai"});
Employeelist.add (new EmployeeInfo {EmployeeID = 4, EmployeeName = "Zhao Liu", Salary = -800, CITY = "Beijing"});
Employeelist.add (new EmployeeInfo {EmployeeID = 5, EmployeeName = "Especially seven", Salary = 2100, city = "Wuhan"});
Employeelist.add (new EmployeeInfo {EmployeeID = 6, EmployeeName = "Horse Eight", Salary = 2300, city = "Haikou"});
return employeelist;
}
}