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

Chart Not Displaying Bars

1 Answer 38 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Tony asked on 15 Jun 2012, 02:13 PM
I am having a problem with a chart I am trying to implement where it will not show any bars going up the bar graph.  A pie chart will display all of the data, but all other chart types fail.  I have confirmed the data is being entered into the dt and my code below shows you how I am doing this.  I have also included a screenshot of what the output on the graph is as well as a screenshot of the data after the loop completes.  Any help would be greatly appreciated.  

Protected Sub CreateChart()
        Dim dt As New DataTable
        Dim dc As DataColumn
        Dim dr As DataRow
        Dim ctr As Integer = 0
        Dim usableMonths As String = Me.Invoice.Custom45.ToString()
        Dim usableData As String = Me.Invoice.Custom46.ToString()
        Dim months() As String = usableMonths.Split(New [Char]() {","c})
        Dim data() As String = usableData.Split(New [Char]() {","c})
        dc = New DataColumn("XValues", Type.GetType("System.Int32"))
        dc.AutoIncrement = True
        dc.AutoIncrementSeed = 300
        dc = New DataColumn("XDesc", Type.GetType("System.String"))
        dc = New DataColumn("YValues", Type.GetType("System.Double"))
        While ctr <= months.Length - 2
            dr = dt.NewRow
            If String.IsNullOrEmpty(months(ctr).ToString().Trim()) Then
                dr(1) = " "
                dr(1) = months(ctr)
            End If
            If String.IsNullOrEmpty(data(ctr).ToString().Trim()) Then
                dr(2) = 0
                dr(2) = Convert.ToDouble(data(ctr))
            End If
            ctr += 1
        End While
        Me.RadChart1.DataSource = dt
        Dim usage As New Telerik.Charting.ChartSeries("Usage", Telerik.Charting.ChartSeriesType.Bar)
        usage.DataXColumn = "XValues"
        usage.DataYColumn = "YValues"
        usage.Appearance.BarWidthPercent = 30
        usage.DefaultLabelValue = String.Empty
        usage.Visible = True
        Me.RadChart1.Width = Unit.Pixel(480)
        Me.RadChart1.Height = Unit.Pixel(200)
        Me.RadChart1.ChartTitle.Visible = False
        Me.RadChart1.Legend.Visible = False
        Me.RadChart1.PlotArea.XAxis.DataLabelsColumn = "XDesc"
        Me.RadChart1.PlotArea.XAxis.Appearance.TextAppearance.AutoTextWrap = Telerik.Charting.Styles.AutoTextWrap.True
        Me.RadChart1.PlotArea.XAxis.Appearance.MajorGridLines.Visible = False
        Me.RadChart1.PlotArea.XAxis.Appearance.MinorGridLines.Visible = False
        Me.RadChart1.PlotArea.YAxis.Appearance.MinorGridLines.Visible = False
        Me.RadChart1.PlotArea.Appearance.Dimensions.Margins.Top = Telerik.Charting.Styles.Unit.Pixel(20)
        Me.RadChart1.PlotArea.Appearance.Dimensions.Margins.Right = Telerik.Charting.Styles.Unit.Pixel(10)
        Me.RadChart1.PlotArea.Appearance.Dimensions.Margins.Bottom = Telerik.Charting.Styles.Unit.Pixel(40)
        Me.RadChart1.PlotArea.Appearance.Dimensions.Margins.Left = Telerik.Charting.Styles.Unit.Pixel(50)
        Me.RadChart1.Skin = "Classic"
    End Sub

1 Answer, 1 is accepted

Sort by
Top achievements
Rank 1
answered on 15 Jun 2012, 02:21 PM
We figured this out.  The dc.AutoIncrementSeed was set to 300 when it should have been 1
Chart (Obsolete)
Asked by
Top achievements
Rank 1
Answers by
Top achievements
Rank 1
Share this question