C#:如何在ASP.Net条形图中交叉阴影线 [英] C#: How To Crosshatch A Bar In An ASP.Net Bar Chart

查看:66
本文介绍了C#:如何在ASP.Net条形图中交叉阴影线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个asp.net条形图,我试图将交叉阴影线添加到其中一个条形图上.我不知道该怎么做.

I have an asp.net bar chart that I'm trying to add cross hatching to one of the bars. I cannot figure out how to do it.

我想对图表中的第4条(从左起)进行交叉阴影线绘制.我在下面尝试了以下代码,但无法正常工作.

I want to crosshatch the 4th bar (from the left) in the chart. I tried the following code below but it doesn't work.

Chart1.Series["Actual"].Points[3].Color = ColorTranslator.FromHtml("#ffffff");
Chart1.Series["Actual"].Points[3].BorderColor = ColorTranslator.FromHtml("#d0d0d0");
Chart1.Series["Actual"].Points[3].BackSecondaryColor = ColorTranslator.FromHtml("#d0d0d0");
Chart1.Series["Actual"].Points[3].BackHatchStyle = ChartHatchStyle.LightUpwardDiagonal;

你能告诉我怎么做吗?

安迪

推荐答案

使用隐藏代码:

    protected void Page_Load(object sender, EventArgs e)
    {
        for (int x = 1; x <= 5; x++)
            Chart1.Series[0].Points.AddXY(x, 10 * x);

        Chart1.Series[0].Points[3].BackHatchStyle = ChartHatchStyle.Cross;
        Chart1.Series[0].Points[3].Color = Color.Orange;
    }


BackHatchStyle应该这样做:


The BackHatchStyle should do it:

ASPX:

   <asp:Chart ID="Chart1" runat="server" Height="400px" Width="600px">
        <series>
            <asp:Series Name="Series1">
                <Points>
                    <asp:DataPoint XValue="1" YValues="10" />
                    <asp:DataPoint XValue="2" YValues="20" />
                    <asp:DataPoint XValue="3" YValues="30" />
                    <asp:DataPoint BackHatchStyle="WideUpwardDiagonal" Color="Red" XValue="4" YValues="40" />
                    <asp:DataPoint XValue="5" YValues="50" />
                </Points>
            </asp:Series>
        </series>
        <chartareas>
            <asp:ChartArea Name="ChartArea1">
            </asp:ChartArea>
        </chartareas>
    </asp:Chart>

这篇关于C#:如何在ASP.Net条形图中交叉阴影线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆