本帖最后由 奋斗丶小Z 于 2015-12-2 22:47 编辑
开发环境vs2010 webform,自带chart(工具箱----数据----Chart)
饼图,效果图如下
前台代码:
[C#] 纯文本查看 复制代码 <asp:Chart ID="Chart3" runat="server" Width="900px">
<Legends>
<asp:Legend BackColor="Transparent" Alignment="Center" Font="Trebuchet MS, 8.25pt, style=Bold"
IsTextAutoFit="False" Name="Default" LegendStyle="Column">
</asp:Legend>
</Legends>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
<Area3DStyle Rotation="0" />
<AxisY LineColor="64, 64, 64, 64">
<LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" />
<MajorGrid LineColor="64, 64, 64, 64" />
</AxisY>
<AxisX LineColor="64, 64, 64, 64">
<LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" />
<MajorGrid LineColor="64, 64, 64, 64" />
</AxisX>
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
后台代码
[C#] 纯文本查看 复制代码 Chart3.BackColor = Color.Moccasin;
Chart3.BackGradientStyle = GradientStyle.DiagonalRight;
Chart3.BorderlineDashStyle = ChartDashStyle.Solid;
Chart3.BorderlineColor = Color.Gray;
Chart3.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
// forma the chart area
Chart3.ChartAreas[0].BackColor = Color.Wheat;
// add and format the title
Chart3.Titles.Add("个人成绩质量分布图表");
Chart3.Titles[0].Font = new Font("Utopia", 14, FontStyle.Bold);
Chart3.Series.Add(new Series("Pie")
{
ChartType = SeriesChartType.Pie,
ShadowOffset = 2
});
Chart3.Series[0].Label = "#VALX \n\n #PERCENT{P}";//显示百分比和说明
Chart3.Series[0].LegendText = "#VALX";
double[] yValues = { 23, 12, 26, 39, };
string[] xValues = { "优秀", "不及格", "良好", "及格" };
//饼状图的标签方位
Chart3.Series[0]["PieLabelStyle"] = "Outside";
Chart3.Series[0]["PieLineColor"] = "Black";
Chart3.Series[0].Points.DataBindXY(xValues, yValues);
//每个部分开花
foreach (DataPoint point in Chart3.Series[0].Points)
{
point["Exploded"] = "true";
}
|