0

如何在代码后面(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)

4

1 回答 1

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
于 2009-10-29T13:01:30.913 回答