This is a migrated thread and some comments may be shown as answers.

Bar Chart question

1 Answer 44 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 10 Jun 2009, 01:50 PM
I have a bar chart that I want the Labels on the x axis to display a name not a count. Currently the x axis labels are just a count of 1,2,3,4. Here is the markup and the code behind :

<asp:SqlDataSource ID="SqlDataSource1" runat="server"  
                            ConnectionString="<%$ ConnectionStrings:tp %>"  
                            SelectCommand="tsp_PortalChart_Get"  
                    SelectCommandType="StoredProcedure"
                    <SelectParameters> 
                        <asp:CookieParameter CookieName="PortalAccountNumber" DefaultValue=""  
                                    Name="AccountNumber" Type="Int32" /> 
                    </SelectParameters> 
                </asp:SqlDataSource> 
<telerik:RadChart ID="RadChart1" runat="server"  
    Title="Account Summary" OnItemDataBound="RadChart1_ItemDataBound"  
    DataSourceID="SqlDataSource1"  
    ChartTitle-TextBlock-Appearance-TextProperties-Font="Verdana, 10pt"  
    Width="370px" Height="254px"
 
    <Appearance> 
        <Border Visible="False" /> 
    </Appearance> 
 
<ChartTitle> 
<TextBlock Text="Account Summary"
<Appearance TextProperties-Font="Verdana, 10pt"></Appearance> 
</TextBlock> 
</ChartTitle> 
 
                    <Legend Appearance-ItemTextAppearance-TextProperties-Font="Verdana, 8pt"
<Appearance> 
<ItemTextAppearance TextProperties-Font="Verdana, 8pt"></ItemTextAppearance> 
</Appearance> 
                    </Legend> 
                   <Series> 
                    <cc1:ChartSeries Name="Series 1" Type="Bar" DataYColumn="Count"
                    <Appearance LegendDisplayMode="ItemLabels" ></Appearance
                    </cc1:ChartSeries> 
                    </Series> 
                     </telerik:RadChart> 

Code Behind
Partial Class UserControls_AccountSummaryChart 
    Inherits System.Web.UI.UserControl 
 
    Protected Sub RadChart1_ItemDataBound(ByVal sender As ObjectByVal e As ChartItemDataBoundEventArgs) 
        e.SeriesItem.Name = CType(e.DataItem, DataRowView)("Name").ToString() 
    End Sub 
 
    Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load 
 
        RadChart1.Skin = Application("TelerikTheme"
        RadChart1.ChartTitle.TextBlock.Text = Application("CompanyName").ToString 
        RadChart1.Chart.Appearance.FillStyle.MainColor = Color.Transparent 
        If Not IsPostBack Then 
 
            RadChart1.DataSourceID = "SqlDataSource1" 
            RadChart1.DataBind() 
            RadChart1.Series(0).Name = "Type" 
 
            Dim barColors As Color() = New Color(4) {Color.Purple, Color.SteelBlue, Color.Green, Color.Yellow, Color.Crimson} 
            Dim i As Integer = 0 
            For Each item As ChartSeriesItem In RadChart1.Series(0).Items 
                item.Appearance.FillStyle.MainColor = barColors(System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)) 
            Next 
        End If 
 
 
 
 
 
    End Sub 
End Class 


Thanks!
Sam



1 Answer, 1 is accepted

Sort by
0
Sam
Top achievements
Rank 1
answered on 10 Jun 2009, 03:04 PM
Nevermind I figured it out.

<PlotArea> 
                    <XAxis DataLabelsColumn="Name"></XAxis> 
                    </PlotArea> 


Thanks!
Sam




Tags
Chart (Obsolete)
Asked by
Sam
Top achievements
Rank 1
Answers by
Sam
Top achievements
Rank 1
Share this question
or