[DevExpress] ChartControl-pie chart percentage example, chartcontrol
Key code:
Using System; using System. data; using System. windows. forms; using DevExpress. xtraCharts; namespace DevExpressChart {public partial class winPieSeriesView: Form {public winPieSeriesView () {InitializeComponent ();} private DataTable CreateChartData () {DataTable table = new able ("Table1 "); table. columns. add ("Name", typeof (String); table. columns. add ("Value", typeof (Int32); table. rows. add (new object [] {"A", 10}); table. rows. add (new object [] {"B", 20}); table. rows. add (new object [] {"C", 40}); table. rows. add (new object [] {"D", 20}); table. rows. add (new object [] {"E", 30}); return table;} private void winPieSeriesView_Load (object sender, EventArgs e) {BuilderDevChart ();} private void BuilderDevChart () {Series _ pieSeries = new Series ("test", ViewType. pie); _ pieSeries. valueDataMembers [0] = "Value"; _ pieSeries. argumentDataMember = "Name"; _ pieSeries. dataSource = CreateChartData (); chartControl1.Series. add (_ pieSeries); // ------------------------------------------ _ pieSeries. legendPointOptions. pointView = PointView. argumentAndValues; _ pieSeries. setPiePercentage ();}}}
Bytes ---------------------------------------------------------------------------------------------
/// <Summary> // set the pie Series to percent display // </summary> /// <param name = "series"> Series </param> public static void SetPiePercentage (this Series) {if (series. view is PieSeriesView) {(PiePointOptions) series. pointOptions ). percentOptions. valueAsPercent = true; (PiePointOptions) series. pointOptions ). valueNumericOptions. format = NumericFormat. percent; (PiePointOptions) series. pointOptions ). valueNumericOptions. precision = 0 ;}}
Running effect:
Hope this is helpful! Thank you!
Devexpress chart control ChartControl
No. There are only three display modes:
Category name: Value
Value
Category name
How to Use WebChartControl of DevExpress
1. WebChartControl can be used to query statements similar to select * from table, and some grouping statistics can be achieved through configuration.
2. series is equivalent to the grouping field during grouping statistics. A series has several groups.
3. Statistical results are displayed on the square bar in the figure.
4. You can use the built-in wizard for configuration. Focus on series binding in Data items.
For example, to calculate a table that shows the monthly income of some people, the structure is as follows:
Name Revenue Unit month
The query statement is: select * from table
1. Collect the total income of each person:
Method 1: Set argument properties --- type in series 1 under series binding in the Data item to the default value, argument to the name, value properties --- type to numerical, and mode to function, function is SUM ([revenue]).
Method 2: In the preceding example, the mode is value, and the function is age.
Disadvantage: People with duplicate names are counted together.
2. count the number of times each person has received the income:
Set argument properties --- type in series 1 under series binding in Data item to default, argument to name, value properties --- type to numerical, mode to function, function to COUNT ().