In the previous article, we described how to use the chart control provided by Silverlight Toolkit to draw a columnar chart (Column,bar), which will continue today
With the code created above, we can make the histogram appear to be pie, line, or scatter with little modification.
Well, start today's text.
First, we're going to create a new "Silverlight control" of a pie chart and name it: Piesample.xaml
Then we copy the corresponding code from the corresponding Columnsample.xaml,columnsample.xaml.cs to: Piesample.xaml and pie-.
Sample.xaml.cs file. Then we modify the dataserviceclient_getemployeelistcompleted in the PieSample.xaml.cs file.
method, the revised results are as follows:
void Dataserviceclient_getemployeelistcompleted (object sender, Getemployeelistcompletedeventargs e)
{
observablecollection<employeeinfo> employeelist = E.result;
Action<chart> chartmodifier = (Chart) =>
{
Axis Dateaxis = new Axis {orientation = axisorientation.horizontal, title = "Employee Name", FontStyle = Fontstyles.normal, FontS ize = 12f, Showgridlines = true};
EMPLOYEECHART.AXES.ADD (Dateaxis);
Axis Valueaxis = new Axis {orientation = axisorientation.vertical, Title = "Salary", Minimum = -1000, Maximum = 3000, SHOWGR Idlines = true};
EMPLOYEECHART.AXES.ADD (Valueaxis);
};
Chartmodifier (Employeechart);
Pieseries series = new Pieseries ();
Series. ItemsSource = EmployeeList;
Series. independentvaluebinding = new System.Windows.Data.Binding ("EmployeeName");
Series. dependentvaluebinding = new System.Windows.Data.Binding ("Salary");
Series. Animationsequence = Animationsequence.lasttofirst;
EMPLOYEECHART.SERIES.ADD (Series);
}