Using Silverlight Toolkit to draw a chart (top)--Columnar chart

Source: Internet
Author: User
Tags silverlight

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;
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.