Change background color of each Bar

1 posts, 0 answers
  1. Charles
    Charles avatar
    11 posts
    Member since:
    Sep 2013

    Posted 19 Jan Link to this post

    I am trying to change the background colors of individual bars to red and green

    TryCast(RadHtmlChart1.PlotArea.Series(0), BarSeries).SeriesItems(0).BackgroundColor = System.Drawing.Color.Red.

    Chart works great and I am binding to a datatable

    RadHtmlChart1.DataSource = DifferenceDT
    RadHtmlChart1.DataBind()

     

    The error is on SeriesItems (Out of Range) and count is 0 when I inspect. 

    Am I  doing something wrong?

    Here is my .aspx code

    <telerik:RadHtmlChart ID="RadHtmlChart1" runat="server" Style="width: 100%; height: 98%;">
        <PlotArea>
            <Series>
                <telerik:BarSeries DataFieldY="Count" Name="Count" >
                    <LabelsAppearance>
                        <TextStyle Color="White" />
                    </LabelsAppearance>
                </telerik:BarSeries>
            </Series>
            <XAxis DataLabelsField="Name"  >
                <LabelsAppearance>
                    <TextStyle Color="White" />
                </LabelsAppearance>
                <MinorGridLines Visible="false" />
            </XAxis>
            <YAxis AxisCrossingValue="0" Step="1"  >
                <MinorGridLines Visible="false" />
                <LabelsAppearance>
                    <TextStyle Color="Blue" />
                </LabelsAppearance>
            </YAxis>
        </PlotArea>
    </telerik:RadHtmlChart>
Back to Top