62,046
社区成员
发帖
与我相关
我的任务
分享
Chart chart = new Chart();
// Add series to the chart
Series series = chart.Series.Add("My series");
// Set series visual attributes
series.ChartType = SeriesChartType.Pie;
series.ShadowOffset = 4;
series.Font = new Font("Times New Format", 7f);
series.BorderColor = Color.DarkGray;
//series.CustomAttributes = "LabelStyle=Outside";
series.ToolTip = "#LEGENDTEXT: #VAL{C} million";
series.LegendToolTip = "#PERCENT";
series.PostBackValue = "#INDEX";
series.LegendPostBackValue = "#INDEX";
chart.Titles.Add("test");
chart.Titles[0].Text = "早餐前(空腹)";
// Populate series data
double[] yValues = { 7, 2, 5, 11};
string[] xValues = { "理想", "较好", "差(高血糖)", "差(低血糖)"};
series.Points.DataBindY(yValues);
for (int pointIndex = 0; pointIndex < series.Points.Count; pointIndex++)
{
series.Points[pointIndex].LegendText = xValues[pointIndex];
}
if (!this.IsPostBack)
{
series.Points[0].CustomProperties += "Exploded=true";
}
Controls.Add(chart);
Chart chart = new Chart();
// Add chartArea to the chart
ChartArea chartArea = new ChartArea("myChartArea");
// Add series to the chart
Series series = new Series("My series");
//..........
//.........
chart.ChartAreas.Add(chartArea);
chart.Series.Add(series);
Controls.Add(chart);
Legend legend = new Legend("my Legend");
chart.Legends.Add(legend);