DevExpress 通过WebChartControl 制作饼图的代码
前台代码:
<dxchartsui:WebChartControl ID="wccBrowserStatistics" runat="server" Width="600px"
ClientInstanceName="chart" Height="368px" >
</dxchartsui:WebChartControl>
后台代码:
wccBrowserStatistics.Series.Clear();
DataTable dt = analytics.GetBrowserCount();
wccBrowserStatistics.DataSource = dt;
wccBrowserStatistics.DataBind();
Series series1 = new Series("浏览器统计", ViewType.Pie);
wccBrowserStatistics.Series.Add(series1);
series1.ArgumentScaleType = ScaleType.Qualitative;
series1.ValueScaleType = ScaleType.Numerical;
for (int i = 0; i < dt.Rows.Count; i++)
{
string name = dt.Rows[i]["IEType"].ToString();
double browser = Convert.ToDouble(dt.Rows[i]["browser"].ToString());
series1.Points.Add(new SeriesPoint(IEType, new double[] { browser }));
}
SeriesPointFilter filter = new SeriesPointFilter(SeriesPointKey.Value_1,
DataFilterCondition.LessThanOrEqual, 10);
//普通饼图
((PieSeriesView)series1.View).ExplodedPointsFilters.Add(filter);
((PieSeriesView)series1.View).ExplodeMode = PieExplodeMode.UseFilters;
series1.SeriesPointsSorting = SortingMode.Ascending;
series1.SeriesPointsSortingKey = SeriesPointKey.Value_1;
((PieSeriesView)series1.View).Rotation = 90;
((PieSeriesLabel)series1.Label).Position = PieSeriesLabelPosition.Radial;
((PieSeriesLabel)series1.Label).Font = new Font("Tahoma", 8);
((PiePointOptions)series1.PointOptions).PointView = PointView.ArgumentAndValues;
//定义chart标题
ChartTitle CT1 = new ChartTitle();
CT1.Text = "浏览器统计";
wccBrowserStatistics.Titles.Add(CT1);