3

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.

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;

Can you tell me how to do this please?

Andy

jsanalytics
  • 13,058
  • 4
  • 22
  • 43
Andy
  • 383
  • 1
  • 6
  • 23

1 Answers1

1

EDIT:

Using code-behind:

enter image description here

    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;
    }

The BackHatchStyle should do it:

enter image description here

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>
jsanalytics
  • 13,058
  • 4
  • 22
  • 43