开发者

MSCharts : How to change Border color in series in codebehind

开发者 https://www.devze.com 2022-12-09 15:09 出处:网络
How can iset a custom color asborder color for the ASP.NET 3.5 chart control series in code behind(C#) ? I need a codebehind implementation of the following (which is in ASPX)

How can i set a custom color as border color for the ASP.NET 3.5 chart control series in code behind(C#) ? I need a codebehind implementation of the following (which is in ASPX)

  <ChartAreas>
        <asp:ChartArea Name="ChartArea1开发者_Go百科" AlignmentOrientation="All"> 
        <AxisX>
        <MajorGrid LineColor="#EEEEEE" />
        <MinorGrid LineColor="#EEEEEE" />
        </AxisX>
        <AxisY>
        <MajorGrid LineColor="#EEEEEE" />
        <MinorGrid LineColor="#EEEEEE" />
        </AxisY>
        </asp:ChartArea>
    </ChartAreas>

I want to change the MajorGrid line color in my codebehind as RGB(125,135,111)


Make sure you give your Charts an ID and runat="server"...

<asp:Chart ID="ChartTest" runat="server" Width="800px" Height="300px">
</asp:Chart>

Then you can directly access the LineColor properties:

ChartTest.ChartAreas[0].AxisY2.LineColor = Color.Black;

Or using a custom colour (from a Hex string):

Color customColour = System.Drawing.ColorTranslator.FromHtml("EEEEEE");
ChartTest.ChartAreas[0].AxisY2.LineColor = customColour
0

精彩评论

暂无评论...
验证码 换一张
取 消