大家好!!!我正在从数据库表中设计一个柱形图..现在我需要图表的每一列(条形)具有不同的颜色,以便我们可以有不同的图例,但我无法实现它。这是我的 c# 代码...... .
string conn = "Server=localhost;Port=3306;Database=dma;UID=root;Pwd=techsoft;pooling=false";
MySqlDataAdapter adp = new MySqlDataAdapter("select ConfID,NoOfCalls from chart1", conn);
DataSet ds = new DataSet();
adp.Fill(ds);
//2.Set the style/Settings for X and Y axis
Chart1.Font.Size = FontUnit.Medium;
Chart1.Series["Series1"].XValueType = ChartValueType.Int32;
Chart1.Series["Series1"].YValueType = ChartValueType.Int32;
Chart1.ChartAreas[0].AxisY.Title = "No. Of calls";
Chart1.ChartAreas[0].AxisX.Title = "ConferenceId";
//3.Define the chart type
Chart1.Series["Series1"].ChartType = SeriesChartType.Column;
//4.Add the actual values from the dataset to X & Y co-ordinates
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
Chart1.Series["Series1"].Points.AddXY(ds.Tables[0].Rows[i]["ConfID"], ds.Tables[0].Rows[i]["NoOfCalls"]);
}
这是我的图表的aspx页面代码...
<asp:Chart id="Chart1" runat="server" Width="572px" Height="339px"
BorderDashStyle="Solid" BorderWidth="2px" BorderColor="#B54001"
onload="Chart1_Load1">
<Legends>
<asp:Legend Name="Legend1">
</asp:Legend>
</Legends>
<BorderSkin SkinStyle="None" BackGradientStyle="None" BackSecondaryColor="SeaShell" BorderColor="#6198dc" BorderDashStyle="Solid" BorderWidth="1" BackColor="White"></BorderSkin>
<Series>
<asp:Series MarkerSize="3" BackGradientStyle="HorizontalCenter" BorderWidth="1"
Name="Series1" MarkerStyle="Circle" BorderColor="180, 26, 59, 105"
Color="220, 65, 140, 240" ShadowOffset="0" Legend="Legend1"></asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1" BorderWidth="0" BackColor="White" ShadowColor="Transparent">
<AxisY LineColor="64, 220, 64, 64" LineDashStyle="Solid" LineWidth="2">
<LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" />
<MajorGrid LineColor="64, 220, 64, 64" />
</AxisY>
<AxisX LineColor="64, 220, 64, 64" LineDashStyle="Solid" LineWidth="2">
<LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" />
<MajorGrid LineColor="64, 220, 64, 64" />
</AxisX>
</asp:ChartArea>
</ChartAreas>
请大家帮帮我。提前谢谢..