Mschart控件制作的柱状图如何为同一序列的不同Column设置不同颜色
我使用c#和asp.net书写了如下代码:
Chart5.DataSource = dt;
Chart5.DataBind();
Chart5.Series["Series1"].XValueMember="ym";
Chart5.Series["Series1"].YValueMembers = "QTY";
Random rand = new Random();
int red;
int green;
int blue;
foreach (DataPoint dp in Chart5.Series["Series1"].Points)
{
red = rand.Next(0, 255);
green = rand.Next(0, 255);
blue = rand.Next(0, 255);
dp.Color = System.Drawing.Color.FromArgb(rand.Next(255), rand.Next(255), rand.Next(255));
}
// Show data points labels
Chart5.Series["Series1"].IsValueShownAsLabel = true;
// Set data points label style
Chart5.Series["Series1"]["BarLabelStyle"] = "Center";
// Show as 3D
Chart5.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
Chart5.ChartAreas["ChartArea1"].BackColor = System.Drawing.Color.White;
Chart5.ChartAreas["ChartArea1"].AxisX.Interval = 1;
// Draw as 3D Cylinder
Chart5.Series["Series1"]["DrawingStyle"] = "Cylinder";