如何在代码隐藏(C#)中为ASP.NET 3.5图表控件系列设置自定义颜色作为边框颜色?我需要以下(在ASPX中)的代码隐藏实现
<ChartAreas>
<asp:ChartArea Name="ChartArea1" AlignmentOrientation="All">
<AxisX>
<MajorGrid LineColor="#EEEEEE" />
<MinorGrid LineColor="#EEEEEE" />
</AxisX>
<AxisY>
<MajorGrid LineColor="#EEEEEE" />
<MinorGrid LineColor="#EEEEEE" />
</AxisY>
</asp:ChartArea>
</ChartAreas>
我想将代码隐藏中的MajorGrid线颜色更改为RGB(125,135,111)
答案 0 :(得分:2)
确保为图表提供ID和runat =“server”...
<asp:Chart ID="ChartTest" runat="server" Width="800px" Height="300px">
</asp:Chart>
然后您可以直接访问LineColor属性:
ChartTest.ChartAreas[0].AxisY2.LineColor = Color.Black;
或使用自定义颜色(来自十六进制字符串):
Color customColour = System.Drawing.ColorTranslator.FromHtml("EEEEEE");
ChartTest.ChartAreas[0].AxisY2.LineColor = customColour